diff --git a/core/misc/create/create-editonly.js b/core/misc/create/create-editonly.js index 4279a1b905837a205bef9df8ae5231b3da2a9b23..aed84a4ffcddc04e78f9e37b68b7e278793efe87 100644 --- a/core/misc/create/create-editonly.js +++ b/core/misc/create/create-editonly.js @@ -334,7 +334,6 @@ element: this.element, instance: this.options.model }; - var propertyParams = (predicate) ? { predicate: predicate, propertyEditor: this.options.propertyEditors[predicate], @@ -517,11 +516,11 @@ disable: function () { _.each(this.options.propertyEditors, function (editable) { - this.disableEditor({ + this.disablePropertyEditor({ widget: this, editable: editable, entity: this.options.model, - element: jQuery(editable) + element: editable.element }); }, this); this.options.propertyEditors = {}; @@ -592,7 +591,7 @@ return; } var widgetType = propertyElement.data('createWidgetName'); - this.options.propertyEditors[predicate] = propertyElement.data(widgetType); + this.options.propertyEditors[predicate] = propertyElement.data('Midgard-' + widgetType); // Deprecated. this.options.editables.push(propertyElement); @@ -673,18 +672,13 @@ }, disablePropertyEditor: function (data) { - var widgetName = jQuery(data.element).data('createWidgetName'); - - data.disabled = true; - - if (widgetName) { - // only if there has been an editing widget registered - jQuery(data.element)[widgetName](data); - jQuery(data.element).removeClass('ui-state-disabled'); + data.element[data.editable.widgetName]({ + disabled: true + }); + jQuery(data.element).removeClass('ui-state-disabled'); - if (data.element.is(':focus')) { - data.element.blur(); - } + if (data.element.is(':focus')) { + data.element.blur(); } }, @@ -755,7 +749,7 @@ // jQuery.widget('Namespace.MyWidget', jQuery.Create.editWidget, { // // override any properties // }); - jQuery.widget('Create.editWidget', { + jQuery.widget('Midgard.editWidget', { options: { disabled: false, vie: null @@ -849,7 +843,7 @@ // // Due to licensing incompatibilities, Aloha Editor needs to be installed // and configured separately. - jQuery.widget('Create.alohaWidget', jQuery.Create.editWidget, { + jQuery.widget('Midgard.alohaWidget', jQuery.Midgard.editWidget, { _initialize: function () {}, enable: function () { var options = this.options; @@ -912,7 +906,7 @@ // // This widget allows editing textual content areas with the // [CKEditor](http://ckeditor.com/) rich text editor. - jQuery.widget('Create.ckeditorWidget', jQuery.Create.editWidget, { + jQuery.widget('Midgard.ckeditorWidget', jQuery.Midgard.editWidget, { enable: function () { this.element.attr('contentEditable', 'true'); this.editor = CKEDITOR.inline(this.element.get(0)); @@ -924,6 +918,7 @@ }); this.editor.on('blur', function () { widget.options.activated(); + widget.options.changed(widget.editor.getData()); }); this.editor.on('key', function () { widget.options.changed(widget.editor.getData()); @@ -934,6 +929,11 @@ this.editor.on('afterCommandExec', function () { widget.options.changed(widget.editor.getData()); }); + this.editor.on('configLoaded', function() { + jQuery.each(widget.options.editorOptions, function(optionName, option) { + widget.editor.config[optionName] = option; + }); + }); }, disable: function () { @@ -964,7 +964,7 @@ // // This widget allows editing textual content areas with the // [Hallo](http://hallojs.org) rich text editor. - jQuery.widget('Create.halloWidget', jQuery.Create.editWidget, { + jQuery.widget('Midgard.halloWidget', jQuery.Midgard.editWidget, { options: { editorOptions: {}, disabled: true, @@ -1006,6 +1006,10 @@ return; } self.options.toolbarState = data.display; + if (!self.element.data('IKS-hallo')) { + // Hallo not yet instantiated + return; + } var newOptions = self.getHalloOptions(); self.element.hallo('changeToolbar', newOptions.parentElement, newOptions.toolbar, true); }); @@ -1061,7 +1065,7 @@ // // This widget allows editing textual content areas with the // [Redactor](http://redactorjs.com/) rich text editor. - jQuery.widget('Create.redactorWidget', jQuery.Create.editWidget, { + jQuery.widget('Midgard.redactorWidget', jQuery.Midgard.editWidget, { editor: null, options: { diff --git a/core/modules/edit/js/app.js b/core/modules/edit/js/app.js index 07f006f5e432b090d8e45375e94eeb1e8bad8e04..14d76a087f52d4e99b4c970a07eb13b34fdea2c2 100644 --- a/core/modules/edit/js/app.js +++ b/core/modules/edit/js/app.js @@ -317,7 +317,7 @@ // Discarded if it transitions from a changed state to 'candidate'. if (from === 'changed' || from === 'invalid') { // Retrieve the storage widget from DOM. - var createStorageWidget = this.$el.data('createStorage'); + var createStorageWidget = this.$el.data('DrupalCreateStorage'); // Revert changes in the model, this will trigger the direct editable // content to be reset and redrawn. createStorageWidget.revertChanges(editor.options.entity); diff --git a/core/modules/edit/js/createjs/editingWidgets/drupalcontenteditablewidget.js b/core/modules/edit/js/createjs/editingWidgets/drupalcontenteditablewidget.js index bc86a04a828d906aa59f8a55ebbf216de6e8c11b..cde6163730a0dace7cc4d4eaffeaa228d094d1ff 100644 --- a/core/modules/edit/js/createjs/editingWidgets/drupalcontenteditablewidget.js +++ b/core/modules/edit/js/createjs/editingWidgets/drupalcontenteditablewidget.js @@ -8,7 +8,7 @@ // @todo D8: use jQuery UI Widget bridging. // @see http://drupal.org/node/1874934#comment-7124904 - jQuery.widget('DrupalEditEditor.direct', jQuery.Create.editWidget, { + jQuery.widget('Midgard.direct', jQuery.Midgard.editWidget, { /** * Implements getEditUISettings() method. diff --git a/core/modules/edit/js/createjs/editingWidgets/formwidget.js b/core/modules/edit/js/createjs/editingWidgets/formwidget.js index 8824a5d00f496aca6cf7d5bd7641845102f33828..aa2dd0abda8b35a07d64fc4543ef61e57db5ecb9 100644 --- a/core/modules/edit/js/createjs/editingWidgets/formwidget.js +++ b/core/modules/edit/js/createjs/editingWidgets/formwidget.js @@ -8,7 +8,7 @@ // @todo D8: change the name to "form" + use jQuery UI Widget bridging. // @see http://drupal.org/node/1874934#comment-7124904 - $.widget('DrupalEditEditor.formEditEditor', $.Create.editWidget, { + $.widget('Midgard.formEditEditor', $.Midgard.editWidget, { id: null, $formContainer: null, diff --git a/core/modules/editor/js/editor.createjs.js b/core/modules/editor/js/editor.createjs.js index c4bfae6c443ecdd99bf3b435482393c53d31607c..de15c7796c0083dc81343ee03eeb657f59c5327c 100644 --- a/core/modules/editor/js/editor.createjs.js +++ b/core/modules/editor/js/editor.createjs.js @@ -18,7 +18,7 @@ // @todo D8: use jQuery UI Widget bridging. // @see http://drupal.org/node/1874934#comment-7124904 -jQuery.widget('DrupalEditEditor.editor', jQuery.DrupalEditEditor.direct, { +jQuery.widget('Midgard.editor', jQuery.Midgard.direct, { textFormat: null, textFormatHasTransformations: null,