summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt1
-rw-r--r--editors/js/whizzywig-56.js46
-rw-r--r--editors/js/whizzywig.js42
3 files changed, 57 insertions, 32 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 84bf241..13b0309 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -6,6 +6,7 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-3.x, xxxx-xx-xx
---------------------------
+#922520 by TwoD: Fixed Whizzywig is not detached properly.
#907186 by TwoD: Fixed Whizzywig v60+ compatibility.
#765292 by TwoD: Added TinyMCE WordCount plugin.
#768726 by TwoD: Added TinyMCE AutoResize plugin.
diff --git a/editors/js/whizzywig-56.js b/editors/js/whizzywig-56.js
index ba3bdb5..2d88842 100644
--- a/editors/js/whizzywig-56.js
+++ b/editors/js/whizzywig-56.js
@@ -72,7 +72,10 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
wysiwygWhizzywig.fields[wysiwygWhizzywig.currentField] = '';
// Whizzywig needs to have the width set 'inline'.
$field = $('#' + params.field);
- Drupal.wysiwyg.instances[params.field].originalWidth = $field.css('width');
+ var originalValues = Drupal.wysiwyg.instances[params.field];
+ originalValues.originalWidth = $field.css('width');
+ originalValues.originalColor = $field.css('color');
+ originalValues.originalZindex = $field.css('zIndex');
$field.css('width', $field.width() + 'px');
// Attach editor.
@@ -80,7 +83,7 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
// Whizzywig fails to detect and set initial textarea contents.
var instance = $('#whizzy' + params.field).get(0);
if (instance) {
- instance.contentWindow.document.body.innerHTML = $('#' + params.field).val();
+ instance.contentWindow.document.body.innerHTML = tidyD($field.val());
}
};
@@ -88,34 +91,43 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
* Detach a single or all editors.
*/
Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
- var detach = function (id) {
- var instance = $('#whizzy' + whizzies[id]).get(0);
+ var detach = function (index) {
+ var id = whizzies[index];
+ var instance = $('#whizzy' + id).get(0);
if (!instance) {
return;
}
- var body = instance.contentWindow.document.body;
- var $field = $('#' + whizzies[id]);
- body.innerHTML = tidyH(instance.contentWindow.document);
+ var editingArea = instance.contentWindow.document;
+ var $field = $('#' + id);
+ // Whizzywig shows the original textarea in source mode.
+ if ($field.css('display') == 'block') {
+ editingArea.body.innerHTML = $field.val();
+ }
// Save contents of editor back into textarea.
- $field.val(window.get_xhtml ? get_xhtml(body) : body.innerHTML);
- $field.val($field.val().replace(location.href + '#', '#'));
+ $field.val(tidyH(editingArea));
// Remove editor instance.
- $('#' + whizzies[id] + '-whizzywig').remove();
- whizzies.splice(id, 1);
- $field.css('width', Drupal.wysiwyg.instances[$field.attr('id')].originalWidth);
+ $('#' + id + '-whizzywig').remove();
+ whizzies.splice(index, 1);
+
+ // Restore original textarea styling.
+ var originalValues = Drupal.wysiwyg.instances[id];
+ $field.css('width', originalValues.originalWidth);
+ $field.css('color', originalValues.originalColor);
+ $field.css('zIndex', originalValues.originalZindex);
};
if (typeof params != 'undefined') {
- for (var id in whizzies) {
- if (whizzies[id] == params.field) {
- detach(id);
+ for (var i = 0; i < whizzies.length; i++) {
+ if (whizzies[i] == params.field) {
+ detach(i);
+ break;
}
}
}
else {
- for (var id in whizzies) {
- detach(id);
+ while (whizzies.length > 0) {
+ detach(0);
}
}
};
diff --git a/editors/js/whizzywig.js b/editors/js/whizzywig.js
index e10814a..3ca1e53 100644
--- a/editors/js/whizzywig.js
+++ b/editors/js/whizzywig.js
@@ -63,9 +63,10 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
wysiwygWhizzywig.fields[wysiwygWhizzywig.currentField] = '';
// Whizzywig needs to have the width set 'inline'.
$field = $('#' + params.field);
- this.instances = this.instances || {};
- this.instances[params.field] = this.instances[params.field] || {};
- this.instances[params.field].originalWidth = $field.css('width');
+ var originalValues = Drupal.wysiwyg.instances[params.field];
+ originalValues.originalWidth = $field.css('width');
+ originalValues.originalColor = $field.css('color');
+ originalValues.originalZindex = $field.css('zIndex');
$field.css('width', $field.width() + 'px');
// Attach editor.
@@ -73,7 +74,7 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
// Whizzywig fails to detect and set initial textarea contents.
var instance = $('#whizzy' + params.field).get(0);
if (instance) {
- instance.contentWindow.document.body.innerHTML = $('#' + params.field).val();
+ instance.contentWindow.document.body.innerHTML = tidyD($field.val());
}
};
@@ -81,34 +82,45 @@ Drupal.wysiwyg.editor.attach.whizzywig = function(context, params, settings) {
* Detach a single or all editors.
*/
Drupal.wysiwyg.editor.detach.whizzywig = function(context, params) {
- var detach = function (id) {
- var instance = $('#whizzy' + whizzies[id]).get(0);
+ var detach = function (index) {
+ var id = whizzies[index];
+ var instance = $('#whizzy' + id).get(0);
if (!instance) {
return;
}
var body = instance.contentWindow.document.body;
- var $field = $('#' + whizzies[id]);
+ var $field = $('#' + id);
+ // Whizzywig shows the original textarea in source mode.
+ if ($field.css('display') == 'block') {
+ body.innerHTML = $field.val();
+ }
body.innerHTML = tidyH(body.innerHTML);
// Save contents of editor back into textarea.
$field.val(window.get_xhtml ? get_xhtml(body) : body.innerHTML);
$field.val($field.val().replace(location.href + '#', '#'));
// Remove editor instance.
- $('#' + whizzies[id] + '-whizzywig').remove();
- whizzies.splice(id, 1);
- $field.css('width', Drupal.wysiwyg.instances[$field.attr('id')].originalWidth);
+ $('#' + id + '-whizzywig').remove();
+ whizzies.splice(index, 1);
+
+ // Restore original textarea styling.
+ var originalValues = Drupal.wysiwyg.instances[id];
+ $field.css('width', originalValues.originalWidth);
+ $field.css('color', originalValues.originalColor);
+ $field.css('zIndex', originalValues.originalZindex);
};
if (typeof params != 'undefined') {
- for (var id in whizzies) {
- if (whizzies[id] == params.field) {
- detach(id);
+ for (var i = 0; i < whizzies.length; i++) {
+ if (whizzies[i] == params.field) {
+ detach(i);
+ break;
}
}
}
else {
- for (var id in whizzies) {
- detach(id);
+ while (whizzies.length > 0) {
+ detach(0);
}
}
};