Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apostrophe-schema-widgets

Package Overview
Dependencies
Maintainers
10
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apostrophe-schema-widgets - npm Package Compare versions

Comparing version 0.5.8 to 0.5.9

public/css/editor.less

1

index.js

@@ -34,2 +34,3 @@ var _ = require('lodash');

self.pushAsset('script', 'editor', { when: 'user' });
self.pushAsset('stylesheet', 'editor', { when: 'user' });

@@ -36,0 +37,0 @@ _.each(options.widgets, function(options) {

2

package.json
{
"name": "apostrophe-schema-widgets",
"version": "0.5.8",
"version": "0.5.9",
"description": "An easy form widget builder for the Apostrophe content management system",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,3 +16,7 @@ // @class Editor for all schema widgets

// Block the standard A2 widget preview, which would cause
// false negatives for the "required" fields and try too hard
// to be continuously updated. We'll implement our own
self.prePreview = function(callback) {
return callback();
// The preview call at startup just causes false negatives for

@@ -29,2 +33,28 @@ // the "required" fields, and we don't do preview in the

self.afterCreatingEl = function(callback) {
self.$editButton = self.$el.find('[data-tab-button="edit"]');
self.$previewButton = self.$el.find('[data-tab-button="preview"]');
self.$editTab = self.$el.find('[data-tab="edit"]');
self.$previewTab = self.$el.find('[data-tab="preview"]');
self.$editButton.addClass('apos-active');
self.$editTab.addClass('apos-active');
self.$el.on('click', '[data-tab-button]', function() {
var $button = $(this);
var tab = $(this).attr('data-tab-button');
if (tab === 'preview') {
self.refreshPreview(after);
} else {
after();
}
function after() {
self.$el.find('[data-tab-button]').removeClass('apos-active');
self.$el.find('[data-tab]').removeClass('apos-active');
$button.addClass('apos-active');
var $tab = self.$el.find('[data-tab="' + tab + '"]');
$tab.addClass('apos-active');
}
return false;
});
self.$fields = aposSchemas.findSafe(self.$el, '[data-fields]');

@@ -34,2 +64,36 @@ return aposSchemas.populateFields(self.$fields, info.schema, self.data, callback);

self.refreshPreview = function(callback) {
// Validate first, then pass that data to the server
// to get a nice rendering of it
return self.debrief(function() {
return $.jsonCall(
'/apos/render-widget',
{ dataType: 'html' },
self.data,
function(html) {
// Work around fussy jquery HTML parsing behavior a little
var $previewWidget = $($.parseHTML($.trim(html)));
self.$previewTab.html('');
self.$previewTab.append($previewWidget);
// Schema widgets are often menus with links to various
// pages. If we follow these in the preview, we lose
// our work, and become sad. Disable links that don't
// look javascripty in the preview.
self.$previewTab.on('click', function(e) {
var $target = $(e.target);
var href = $target.attr('href');
if (href && (!href.match(/^#/))) {
e.preventDefault();
e.stopPropagation();
}
});
apos.enablePlayers(self.$previewTab);
return callback && callback();
}
);
});
};
self.debrief = function(callback) {

@@ -36,0 +100,0 @@ self.exists = false;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc