summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsun2008-10-11 19:54:24 (GMT)
committer sun2008-10-11 19:54:24 (GMT)
commitfb9108a1d92fc147943d65f48168696ec717484f (patch)
tree70dc87e7c05f19b5dd0e5a907080b95de99e2be9
parent6bf6d580189966966a0002fa0865346aa9f55b2a (diff)
#319363 by sun: Changed JavaScript namespaces and centralized namespace initialization.
-rw-r--r--CHANGELOG.txt2
-rw-r--r--editors/js/fckeditor-2.6.js14
-rw-r--r--editors/js/none.js12
-rw-r--r--editors/js/tinymce-2.js19
-rw-r--r--editors/js/tinymce-3.js18
-rw-r--r--editors/tinymce.inc1
-rw-r--r--wysiwyg.init.js8
-rw-r--r--wysiwyg_editor.js17
-rw-r--r--wysiwyg_editor.module10
9 files changed, 54 insertions, 47 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 0321b6d..ca1e3ce 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -6,6 +6,8 @@ Wysiwyg x.x-x.x, xxxx-xx-xx
Wysiwyg 6.x-x.x, xxxx-xx-xx
---------------------------
+#319363 by sun: Changed JavaScript namespaces and centralized namespace
+ initialization.
#270780 by sun: Fixed TinyMCE 3 support for external plugins.
#309832 by sun: Fixed README.txt.
#253600 by sun: Changed editor integration so that client-side editors attach to
diff --git a/editors/js/fckeditor-2.6.js b/editors/js/fckeditor-2.6.js
index 5d1e3c2..8f243b3 100644
--- a/editors/js/fckeditor-2.6.js
+++ b/editors/js/fckeditor-2.6.js
@@ -1,13 +1,11 @@
// $Id$
-Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
-
/**
* Attach this editor to a target element.
*
- * See Drupal.wysiwyg.attach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.attach.fckeditor = function(context, params, settings) {
+Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) {
// @todo Convert string into variable name w/o overwriting string?
// workaround: build object via editors[this.id] = new ...
var FCKinstance = new FCKeditor(params.field);
@@ -20,14 +18,14 @@ Drupal.wysiwyg.attach.fckeditor = function(context, params, settings) {
if (Drupal.settings.wysiwygEditor.status) {
FCKinstance.ReplaceTextarea();
}
-}
+};
/**
* Detach a single or all editors.
*
- * See Drupal.wysiwyg.detach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.detach.fckeditor = function(context, params) {
+Drupal.wysiwyg.editor.detach.fckeditor = function(context, params) {
if (typeof params != 'undefined') {
var editor = FCKeditorAPI.GetInstance(params.field);
if (editor) {
@@ -41,5 +39,5 @@ Drupal.wysiwyg.detach.fckeditor = function(context, params) {
// tinyMCE.triggerSave();
// tinyMCE.remove();
// }
-}
+};
diff --git a/editors/js/none.js b/editors/js/none.js
index cef6f68..39c1722 100644
--- a/editors/js/none.js
+++ b/editors/js/none.js
@@ -1,7 +1,5 @@
// $Id$
-Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
-
/**
* Attach this editor to a target element.
*
@@ -15,17 +13,17 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
* @param settings
* An object containing editor settings for all enabled editor themes.
*/
-Drupal.wysiwyg.attach.none = function(context, params, settings) {
+Drupal.wysiwyg.editor.attach.none = function(context, params, settings) {
if (params.resizable) {
$('#' + params.field).addClass('resizable');
Drupal.behaviors.textarea();
}
-}
+};
/**
* Detach a single or all editors.
*
- * See Drupal.wysiwyg.attach.none() for a full desciption of arguments.
+ * See Drupal.wysiwyg.editor.attach.none() for a full desciption of arguments.
*
* @param context
* A DOM element, supplied by Drupal.attachBehaviors().
@@ -35,12 +33,12 @@ Drupal.wysiwyg.attach.none = function(context, params, settings) {
* all editors should be detached and saved, so they can be submitted in
* AJAX/AHAH applications.
*/
-Drupal.wysiwyg.detach.none = function(context, params) {
+Drupal.wysiwyg.editor.detach.none = function(context, params) {
if (typeof params != 'undefined') {
var $textarea = $('#' + params.field, context).removeClass('textarea-processed');
var $div = $textarea.parents('div.resizable-textarea');
$div.before($textarea);
$div.remove();
}
-}
+};
diff --git a/editors/js/tinymce-2.js b/editors/js/tinymce-2.js
index ec660e0..c04ea3a 100644
--- a/editors/js/tinymce-2.js
+++ b/editors/js/tinymce-2.js
@@ -1,7 +1,5 @@
// $Id$
-Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
-
/**
* Initialize editor instances.
*
@@ -11,7 +9,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
* @param editorSettings
* An object containing editor settings for each enabled editor theme.
*/
-Drupal.wysiwyg.init.tinymce = function(editorSettings) {
+Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
// If JS compression is enabled, TinyMCE is unable to find its own base path
// and exec mode, hence we need to define it manually.
// @todo Move global library settings somewhere else.
@@ -20,6 +18,7 @@ Drupal.wysiwyg.init.tinymce = function(editorSettings) {
tinyMCE.gzipMode = (Drupal.settings.wysiwygEditor.execMode == 'gzip');
for (var theme in editorSettings) {
+ // @todo Remove; moved into wysiwygEditor.js.
// Clone, so original settings are not overwritten.
var config = Drupal.wysiwyg.clone(editorSettings[theme]);
tinyMCE.init(config);
@@ -28,14 +27,14 @@ Drupal.wysiwyg.init.tinymce = function(editorSettings) {
for (var plugin in Drupal.settings.wysiwygEditor.plugins.tinymce) {
tinyMCE.loadPlugin(plugin, Drupal.settings.wysiwygEditor.plugins.tinymce[plugin]);
}
-}
+};
/**
* Attach this editor to a target element.
*
- * See Drupal.wysiwyg.attach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) {
+Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) {
// Configure settings for this theme.
for (var setting in editorSettings[params.theme]) {
tinyMCE.settings[setting] = editorSettings[params.theme][setting];
@@ -44,14 +43,14 @@ Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) {
if (Drupal.settings.wysiwygEditor.status) {
tinyMCE.execCommand('mceAddControl', true, params.field);
}
-}
+};
/**
* Detach a single or all editors.
*
- * See Drupal.wysiwyg.detach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.detach.tinymce = function(context, params) {
+Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
if (typeof params != 'undefined') {
tinyMCE.removeMCEControl(tinyMCE.getEditorId(params.field));
$('#' + params.field).removeAttr('style');
@@ -60,5 +59,5 @@ Drupal.wysiwyg.detach.tinymce = function(context, params) {
// tinyMCE.triggerSave();
// tinyMCE.activeEditor.remove();
// }
-}
+};
diff --git a/editors/js/tinymce-3.js b/editors/js/tinymce-3.js
index 3370634..f86ea85 100644
--- a/editors/js/tinymce-3.js
+++ b/editors/js/tinymce-3.js
@@ -1,7 +1,5 @@
// $Id$
-Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
-
/**
* Initialize editor instances.
*
@@ -12,7 +10,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
* @param editorSettings
* An object containing editor settings for each enabled editor theme.
*/
-Drupal.wysiwyg.init.tinymce = function(editorSettings) {
+Drupal.wysiwyg.editor.init.tinymce = function(editorSettings) {
// If JS compression is enabled, TinyMCE is unable to find its own base path
// and exec mode, hence we need to define it manually.
// @todo Move global library settings somewhere else.
@@ -29,14 +27,14 @@ Drupal.wysiwyg.init.tinymce = function(editorSettings) {
for (var plugin in Drupal.settings.wysiwygEditor.plugins.tinymce) {
tinymce.PluginManager.load(plugin, Drupal.settings.wysiwygEditor.plugins.tinymce[plugin] + '/editor_plugin.js');
}
-}
+};
/**
* Attach this editor to a target element.
*
- * See Drupal.wysiwyg.attach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.attach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) {
+Drupal.wysiwyg.editor.attach.tinymce = function(context, params, editorSettings) {
// Configure settings for this theme.
for (var setting in editorSettings[params.theme]) {
tinyMCE.settings[setting] = editorSettings[params.theme][setting];
@@ -45,14 +43,14 @@ Drupal.wysiwyg.attach.tinymce = function(context, params, editorSettings) {
if (Drupal.settings.wysiwygEditor.status) {
tinyMCE.execCommand('mceAddControl', true, params.field);
}
-}
+};
/**
* Detach a single or all editors.
*
- * See Drupal.wysiwyg.detach.none() for a full desciption of this hook.
+ * See Drupal.wysiwyg.editor.detach.none() for a full desciption of this hook.
*/
-Drupal.wysiwyg.detach.tinymce = function(context, params) {
+Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
if (typeof params != 'undefined') {
var editor = tinyMCE.get(params.field);
if (editor) {
@@ -64,5 +62,5 @@ Drupal.wysiwyg.detach.tinymce = function(context, params) {
tinyMCE.triggerSave();
tinyMCE.activeEditor.remove();
}
-}
+};
diff --git a/editors/tinymce.inc b/editors/tinymce.inc
index 8d21deb..e81e87e 100644
--- a/editors/tinymce.inc
+++ b/editors/tinymce.inc
@@ -37,6 +37,7 @@ function wysiwyg_tinymce_editor() {
'2.1' => array(
// 'include files' => array('tinymce-2.inc'),
'js files' => array('tinymce-2.js'),
+ 'download url' => 'http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430&release_id=557383',
),
'3.2' => array(
// 'include files' => array('tinymce-3.inc'),
diff --git a/wysiwyg.init.js b/wysiwyg.init.js
new file mode 100644
index 0000000..f4d3fe7
--- /dev/null
+++ b/wysiwyg.init.js
@@ -0,0 +1,8 @@
+// $Id$
+
+Drupal.wysiwyg = Drupal.wysiwyg || {};
+
+Drupal.wysiwyg.editor = Drupal.wysiwyg.editor || { 'init': {}, 'attach': {}, 'detach': {} };
+
+Drupal.wysiwyg.plugins = Drupal.wysiwyg.plugins || {};
+
diff --git a/wysiwyg_editor.js b/wysiwyg_editor.js
index b66a244..f5530e1 100644
--- a/wysiwyg_editor.js
+++ b/wysiwyg_editor.js
@@ -1,7 +1,5 @@
// $Id$
-Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
-
/**
* Initialize editor libraries.
*
@@ -9,7 +7,7 @@ Drupal.wysiwyg = Drupal.wysiwyg || { 'init': {}, 'attach': {}, 'detach': {} };
* init hook gives them a chance to do so.
*/
Drupal.wysiwygInit = function() {
- jQuery.each(Drupal.wysiwyg.init, function(editor) {
+ jQuery.each(Drupal.wysiwyg.editor.init, function(editor) {
this(Drupal.settings.wysiwygEditor.configs[editor]);
});
}
@@ -80,10 +78,13 @@ Drupal.behaviors.attachWysiwyg = function(context) {
* An object containing input format parameters.
*/
Drupal.wysiwygAttach = function(context, params) {
- if (typeof Drupal.wysiwyg.attach[params.editor] == 'function') {
- Drupal.wysiwyg.attach[params.editor](context, params, Drupal.wysiwyg.clone(Drupal.settings.wysiwygEditor.configs[params.editor]));
+ if (typeof Drupal.wysiwyg.editor.attach[params.editor] == 'function') {
+ // Attach editor.
+ Drupal.wysiwyg.editor.attach[params.editor](context, params, Drupal.wysiwyg.clone(Drupal.settings.wysiwygEditor.configs[params.editor]));
+ // Display toggle link.
$('#wysiwyg-toggle-' + params.field).show();
}
+ // Hide toggle link in case no editor is attached.
if (params.editor == 'none') {
$('#wysiwyg-toggle-' + params.field).hide();
}
@@ -102,7 +103,7 @@ Drupal.wysiwygAttach = function(context, params) {
* An object containing input format parameters.
*/
Drupal.wysiwygDetach = function(context, params) {
- jQuery.each(Drupal.wysiwyg.detach, function(editor) {
+ jQuery.each(Drupal.wysiwyg.editor.detach, function(editor) {
this(context, params);
});
}
@@ -123,11 +124,11 @@ Drupal.wysiwygEditorAttachToggleLink = function(context, params) {
Drupal.wysiwygDetach(context, params);
$('#wysiwyg-toggle-' + params.field).html(Drupal.settings.wysiwygEditor.enable).blur();
// After disabling the editor, re-attach default behaviors.
- Drupal.wysiwyg.attach.none(context, params);
+ Drupal.wysiwyg.editor.attach.none(context, params);
},
function() {
// Before enabling the editor, detach default behaviors.
- Drupal.wysiwyg.detach.none(context, params);
+ Drupal.wysiwyg.editor.detach.none(context, params);
Drupal.wysiwygAttach(context, params);
$('#wysiwyg-toggle-' + params.field).html(Drupal.settings.wysiwygEditor.disable).blur();
})
diff --git a/wysiwyg_editor.module b/wysiwyg_editor.module
index ee6cdc5..34c16b0 100644
--- a/wysiwyg_editor.module
+++ b/wysiwyg_editor.module
@@ -290,7 +290,7 @@ function wysiwyg_editor_load_editor($profile) {
}
}
- // Add basic Wysiwyg settings.
+ // Add basic Wysiwyg settings if any editor has been added.
if (!isset($settings_added) && $loaded[$name]) {
drupal_add_js(array('wysiwygEditor' => array(
'configs' => array(),
@@ -298,6 +298,10 @@ function wysiwyg_editor_load_editor($profile) {
'enable' => t('Enable rich-text'),
)), 'setting');
+ // Initialize our namespaces in the *header* to do not force editor
+ // integration scripts to check and define Drupal.wysiwyg on its own.
+ drupal_add_js(wysiwyg_get_path('wysiwyg.init.js'));
+
// The 'none' editor is a special editor implementation, allowing us to
// attach and detach regular Drupal behaviors just like any other editor.
drupal_add_js(wysiwyg_get_path('editors/js/none.js'), 'module', 'footer');
@@ -308,12 +312,10 @@ function wysiwyg_editor_load_editor($profile) {
// Drupal.wysiwygEditorInit() must be executed AFTER editors registered
// their callbacks, and BEFORE Drupal.behaviors are applied, this must come
// last.
- // @todo Separate into wysiwyg.init.js and wysiwyg.editor?.js, to ensure
- // this logic/ordering, and do not force editor integration scripts to
- // check and define Drupal.wysiwyg on its own.
drupal_add_js(wysiwyg_get_path('wysiwyg_editor.js'), 'module', 'footer');
// Add our stylesheet to stack editor buttons into one row.
+ // @todo This is TinyMCE specific at the moment.
drupal_add_css(wysiwyg_get_path('wysiwyg_editor.css'));
$settings_added = TRUE;