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

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

parent eb040a02
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -60,15 +60,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');
    }
    var $wrapper = $field.parents('.form-textarea-wrapper:first');
    $wrapper.removeOnce('textarea').removeClass('.resizable-textarea').removeClass('resizable')
      .find('.grippie').remove();
+6 −3
Original line number Diff line number Diff line
@@ -437,7 +437,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);
};

@@ -712,7 +715,7 @@ function detachFromField(mainFieldId, context, trigger, params) {
    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]) {
+15 −0
Original line number Diff line number Diff line
@@ -292,6 +292,21 @@ function wysiwyg_pre_render_text_format($element) {
      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($element['value']['#value'])) {
    $original = $element['value']['#value'];
    $element['value']['#attributes']['data-wysiwyg-value-original'] = $original;
    $element['value']['#attributes']['data-wysiwyg-value-is-changed'] = 'false';
  }
  if (!empty($element['summary']['#value']) && $element['summary']['#type'] === 'textarea') {
    $original = $element['summary']['#value'];
    $element['summary']['#attributes']['data-wysiwyg-value-original'] = $original;
    $element['summary']['#attributes']['data-wysiwyg-value-is-changed'] = 'false';
  }

  $element['value']['#attributes']['class'][] = 'wysiwyg';
  $element['#attached']['js'][] = array(
    'data' => array(