Commit a895095c authored by Henrik Danielsson's avatar Henrik Danielsson
Browse files

- #526280 by TwoD, klausi: Fixed change detection when editors are disabled.

parent 1d80af1a
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -57,15 +57,6 @@ Drupal.wysiwyg.editor.detach.none = function (context, params, trigger) {
  if (trigger != 'serialize') {
    // This will be called before any editor instances exist.
    var $field = $('#' + params.field, context);
    // Store the unaltered content so it can be restored if no changes
    // intentionally made by the user were detected, such as those caused by
    // WYSIWYG editors when initially parsing and loading content.
    $field.attr('data-wysiwyg-value-original', $field.val()).attr('data-wysiwyg-value-is-changed', 'false');
    // Switch to using any pre-filtered content if it exists.
    if ($field.attr('data-wysiwyg-value-filtered')) {
      // Pre-filtered content is only valid once.
      $field.val($field.attr('data-wysiwyg-value-filtered')).removeAttr('data-wysiwyg-value-filtered');
    }
    $field.removeClass('textarea-processed').removeClass('resizable');
    var $div = $field.parents('div.resizable-textarea');
    $div.before($field);
+6 −3
Original line number Diff line number Diff line
@@ -397,7 +397,10 @@ function WysiwygInternalInstance(params) {
 * Notify Wysiwyg that the editor contents for this instance have changed.
 */
WysiwygInternalInstance.prototype.contentsChanged = function () {
  this.$field.attr('data-wysiwyg-value-is-changed', (this.status ? 'true' : 'false'));
  // Only need to flip changed status once.
  if (this.$field.attr('data-wysiwyg-value-is-changed') === 'false') {
    this.$field.attr('data-wysiwyg-value-is-changed', 'true');
  }
  this.$field.trigger('drupal-wysiwyg-changed', this.publicInstance);
};

@@ -648,7 +651,7 @@ function detachFromField(mainFieldId, context, trigger) {
    Drupal.wysiwyg.editor.detach[editor].call(_internalInstances[fieldId], context, stateParams, trigger);
  }
  // Restore the original value of the user didn't make any changes yet.
  if ($field.attr('data-wysiwyg-value-is-changed') === 'false') {
  if (enabled && $field.attr('data-wysiwyg-value-is-changed') === 'false') {
    $field.val($field.attr('data-wysiwyg-value-original'));
  }
  if (trigger == 'unload' && _internalInstances[fieldId]) {
+10 −0
Original line number Diff line number Diff line
@@ -217,6 +217,16 @@ function wysiwyg_process_form(&$form) {
              wysiwyg_add_editor_settings($profile, $theme);
            }
          }

          // Store the unaltered content so it can be restored if no changes
          // intentionally made by the user were detected, such as those caused by
          // WYSIWYG editors when initially parsing and loading content.
          if (!empty($field['#value'])) {
            $original = $field['#value'];
            $field['#attributes']['data-wysiwyg-value-original'] = $original;
            $field['#attributes']['data-wysiwyg-value-is-changed'] = 'false';
          }

          // Tag this field to make it easier to find on the client.
          if (empty($field['#attributes']['class'])) {
            $field['#attributes']['class'] = 'wysiwyg';