annotate sites/all/modules/wysiwyg/editors/js/fckeditor-2.6.js @ 13:134d4b2e75f6

updated quicktabs and google analytics modules
author danieleb <danielebarchiesi@me.com>
date Tue, 29 Oct 2013 13:48:59 +0000
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1 (function($) {
danielebarchiesi@0 2
danielebarchiesi@0 3 /**
danielebarchiesi@0 4 * Attach this editor to a target element.
danielebarchiesi@0 5 */
danielebarchiesi@0 6 Drupal.wysiwyg.editor.attach.fckeditor = function(context, params, settings) {
danielebarchiesi@0 7 var FCKinstance = new FCKeditor(params.field, settings.Width, settings.Height, settings.ToolbarSet);
danielebarchiesi@0 8 // Apply editor instance settings.
danielebarchiesi@0 9 FCKinstance.BasePath = settings.EditorPath;
danielebarchiesi@0 10 FCKinstance.Config.wysiwygFormat = params.format;
danielebarchiesi@0 11 FCKinstance.Config.CustomConfigurationsPath = settings.CustomConfigurationsPath;
danielebarchiesi@0 12
danielebarchiesi@0 13 // Load Drupal plugins and apply format specific settings.
danielebarchiesi@0 14 // @see fckeditor.config.js
danielebarchiesi@0 15 // @see Drupal.wysiwyg.editor.instance.fckeditor.init()
danielebarchiesi@0 16
danielebarchiesi@0 17 // Attach editor.
danielebarchiesi@0 18 FCKinstance.ReplaceTextarea();
danielebarchiesi@0 19 };
danielebarchiesi@0 20
danielebarchiesi@0 21 /**
danielebarchiesi@0 22 * Detach a single or all editors.
danielebarchiesi@0 23 */
danielebarchiesi@0 24 Drupal.wysiwyg.editor.detach.fckeditor = function (context, params, trigger) {
danielebarchiesi@0 25 var instances = [];
danielebarchiesi@0 26 if (typeof params != 'undefined' && typeof FCKeditorAPI != 'undefined') {
danielebarchiesi@0 27 var instance = FCKeditorAPI.GetInstance(params.field);
danielebarchiesi@0 28 if (instance) {
danielebarchiesi@0 29 instances[params.field] = instance;
danielebarchiesi@0 30 }
danielebarchiesi@0 31 }
danielebarchiesi@0 32 else {
danielebarchiesi@0 33 instances = FCKeditorAPI.__Instances;
danielebarchiesi@0 34 }
danielebarchiesi@0 35
danielebarchiesi@0 36 for (var instanceName in instances) {
danielebarchiesi@0 37 var instance = instances[instanceName];
danielebarchiesi@0 38 instance.UpdateLinkedField();
danielebarchiesi@0 39 if (trigger == 'serialize') {
danielebarchiesi@0 40 // The editor is not being removed from the DOM, so updating the linked
danielebarchiesi@0 41 // field is the only action necessary.
danielebarchiesi@0 42 continue;
danielebarchiesi@0 43 }
danielebarchiesi@0 44 // Since we already detach the editor and update the textarea, the submit
danielebarchiesi@0 45 // event handler needs to be removed to prevent data loss (in IE).
danielebarchiesi@0 46 // FCKeditor uses 2 nested iFrames; instance.EditingArea.Window is the
danielebarchiesi@0 47 // deepest. Its parent is the iFrame containing the editor.
danielebarchiesi@0 48 var instanceScope = instance.EditingArea.Window.parent;
danielebarchiesi@0 49 instanceScope.FCKTools.RemoveEventListener(instance.GetParentForm(), 'submit', instance.UpdateLinkedField);
danielebarchiesi@0 50 // Run cleanups before forcing an unload of the iFrames or IE crashes.
danielebarchiesi@0 51 // This also deletes the instance from the FCKeditorAPI.__Instances array.
danielebarchiesi@0 52 instanceScope.FCKTools.RemoveEventListener(instanceScope, 'unload', instanceScope.FCKeditorAPI_Cleanup);
danielebarchiesi@0 53 instanceScope.FCKTools.RemoveEventListener(instanceScope, 'beforeunload', instanceScope.FCKeditorAPI_ConfirmCleanup);
danielebarchiesi@0 54 if (jQuery.isFunction(instanceScope.FCKIECleanup_Cleanup)) {
danielebarchiesi@0 55 instanceScope.FCKIECleanup_Cleanup();
danielebarchiesi@0 56 }
danielebarchiesi@0 57 instanceScope.FCKeditorAPI_ConfirmCleanup();
danielebarchiesi@0 58 instanceScope.FCKeditorAPI_Cleanup();
danielebarchiesi@0 59 // Remove the editor elements.
danielebarchiesi@0 60 $('#' + instanceName + '___Config').remove();
danielebarchiesi@0 61 $('#' + instanceName + '___Frame').remove();
danielebarchiesi@0 62 $('#' + instanceName).show();
danielebarchiesi@0 63 }
danielebarchiesi@0 64 };
danielebarchiesi@0 65
danielebarchiesi@0 66 Drupal.wysiwyg.editor.instance.fckeditor = {
danielebarchiesi@0 67 init: function(instance) {
danielebarchiesi@0 68 // Track which editor instance is active.
danielebarchiesi@0 69 instance.FCK.Events.AttachEvent('OnFocus', function(editorInstance) {
danielebarchiesi@0 70 Drupal.wysiwyg.activeId = editorInstance.Name;
danielebarchiesi@0 71 });
danielebarchiesi@0 72
danielebarchiesi@0 73 // Create a custom data processor to wrap the default one and allow Drupal
danielebarchiesi@0 74 // plugins modify the editor contents.
danielebarchiesi@0 75 var wysiwygDataProcessor = function() {};
danielebarchiesi@0 76 wysiwygDataProcessor.prototype = new instance.FCKDataProcessor();
danielebarchiesi@0 77 // Attach: Convert text into HTML.
danielebarchiesi@0 78 wysiwygDataProcessor.prototype.ConvertToHtml = function(data) {
danielebarchiesi@0 79 // Called from SetData() with stripped comments/scripts, revert those
danielebarchiesi@0 80 // manipulations and attach Drupal plugins.
danielebarchiesi@0 81 var data = instance.FCKConfig.ProtectedSource.Revert(data);
danielebarchiesi@0 82 if (Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat] && Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
danielebarchiesi@0 83 for (var plugin in Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
danielebarchiesi@0 84 if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
danielebarchiesi@0 85 data = Drupal.wysiwyg.plugins[plugin].attach(data, Drupal.settings.wysiwyg.plugins.drupal[plugin], instance.FCK.Name);
danielebarchiesi@0 86 data = Drupal.wysiwyg.editor.instance.fckeditor.prepareContent(data);
danielebarchiesi@0 87 }
danielebarchiesi@0 88 }
danielebarchiesi@0 89 }
danielebarchiesi@0 90 // Re-protect the source and use the original data processor to convert it
danielebarchiesi@0 91 // into XHTML.
danielebarchiesi@0 92 data = instance.FCKConfig.ProtectedSource.Protect(data);
danielebarchiesi@0 93 return instance.FCKDataProcessor.prototype.ConvertToHtml.call(this, data);
danielebarchiesi@0 94 };
danielebarchiesi@0 95 // Detach: Convert HTML into text.
danielebarchiesi@0 96 wysiwygDataProcessor.prototype.ConvertToDataFormat = function(rootNode, excludeRoot, ignoreIfEmptyParagraph, format) {
danielebarchiesi@0 97 // Called from GetData(), convert the content's DOM into a XHTML string
danielebarchiesi@0 98 // using the original data processor and detach Drupal plugins.
danielebarchiesi@0 99 var data = instance.FCKDataProcessor.prototype.ConvertToDataFormat.call(this, rootNode, excludeRoot, ignoreIfEmptyParagraph, format);
danielebarchiesi@0 100 if (Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat] && Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
danielebarchiesi@0 101 for (var plugin in Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
danielebarchiesi@0 102 if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
danielebarchiesi@0 103 data = Drupal.wysiwyg.plugins[plugin].detach(data, Drupal.settings.wysiwyg.plugins.drupal[plugin], instance.FCK.Name);
danielebarchiesi@0 104 }
danielebarchiesi@0 105 }
danielebarchiesi@0 106 }
danielebarchiesi@0 107 return data;
danielebarchiesi@0 108 };
danielebarchiesi@0 109 instance.FCK.DataProcessor = new wysiwygDataProcessor();
danielebarchiesi@0 110 },
danielebarchiesi@0 111
danielebarchiesi@0 112 addPlugin: function(plugin, settings, pluginSettings, instance) {
danielebarchiesi@0 113 if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
danielebarchiesi@0 114 return;
danielebarchiesi@0 115 }
danielebarchiesi@0 116
danielebarchiesi@0 117 if (Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal[plugin].css) {
danielebarchiesi@0 118 instance.FCKConfig.EditorAreaCSS += ',' + Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal[plugin].css;
danielebarchiesi@0 119 }
danielebarchiesi@0 120
danielebarchiesi@0 121 // @see fckcommands.js, fck_othercommands.js, fckpastewordcommand.js
danielebarchiesi@0 122 instance.FCKCommands.RegisterCommand(plugin, {
danielebarchiesi@0 123 // Invoke the plugin's button.
danielebarchiesi@0 124 Execute: function () {
danielebarchiesi@0 125 if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') {
danielebarchiesi@0 126 var data = { format: 'html', node: instance.FCKSelection.GetParentElement() };
danielebarchiesi@0 127 // @todo This is NOT the same as data.node.
danielebarchiesi@0 128 data.content = data.node.innerHTML;
danielebarchiesi@0 129 Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, instance.FCK.Name);
danielebarchiesi@0 130 }
danielebarchiesi@0 131 },
danielebarchiesi@0 132
danielebarchiesi@0 133 // isNode: Return whether the plugin button should be enabled for the
danielebarchiesi@0 134 // current selection.
danielebarchiesi@0 135 // @see FCKUnlinkCommand.prototype.GetState()
danielebarchiesi@0 136 GetState: function () {
danielebarchiesi@0 137 // Always disabled if not in WYSIWYG mode.
danielebarchiesi@0 138 if (instance.FCK.EditMode != FCK_EDITMODE_WYSIWYG) {
danielebarchiesi@0 139 return FCK_TRISTATE_DISABLED;
danielebarchiesi@0 140 }
danielebarchiesi@0 141 var state = instance.FCK.GetNamedCommandState(this.Name);
danielebarchiesi@0 142 // FCKeditor sets the wrong state in WebKit browsers.
danielebarchiesi@0 143 if (!$.support.queryCommandEnabled && state == FCK_TRISTATE_DISABLED) {
danielebarchiesi@0 144 state = FCK_TRISTATE_OFF;
danielebarchiesi@0 145 }
danielebarchiesi@0 146 if (state == FCK_TRISTATE_OFF && instance.FCK.EditMode == FCK_EDITMODE_WYSIWYG) {
danielebarchiesi@0 147 if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
danielebarchiesi@0 148 var node = instance.FCKSelection.GetSelectedElement();
danielebarchiesi@0 149 state = Drupal.wysiwyg.plugins[plugin].isNode(node) ? FCK_TRISTATE_ON : FCK_TRISTATE_OFF;
danielebarchiesi@0 150 }
danielebarchiesi@0 151 }
danielebarchiesi@0 152 return state;
danielebarchiesi@0 153 },
danielebarchiesi@0 154
danielebarchiesi@0 155 /**
danielebarchiesi@0 156 * Return information about the plugin as a name/value array.
danielebarchiesi@0 157 */
danielebarchiesi@0 158 Name: plugin
danielebarchiesi@0 159 });
danielebarchiesi@0 160
danielebarchiesi@0 161 // Register the plugin button.
danielebarchiesi@0 162 // Arguments: commandName, label, tooltip, style, sourceView, contextSensitive, icon.
danielebarchiesi@0 163 instance.FCKToolbarItems.RegisterItem(plugin, new instance.FCKToolbarButton(plugin, settings.iconTitle, settings.iconTitle, null, false, true, settings.icon));
danielebarchiesi@0 164 },
danielebarchiesi@0 165
danielebarchiesi@0 166 openDialog: function(dialog, params) {
danielebarchiesi@0 167 // @todo Implement open dialog.
danielebarchiesi@0 168 },
danielebarchiesi@0 169
danielebarchiesi@0 170 closeDialog: function(dialog) {
danielebarchiesi@0 171 // @todo Implement close dialog.
danielebarchiesi@0 172 },
danielebarchiesi@0 173
danielebarchiesi@0 174 prepareContent: function(content) {
danielebarchiesi@0 175 // @todo Not needed for FCKeditor?
danielebarchiesi@0 176 return content;
danielebarchiesi@0 177 },
danielebarchiesi@0 178
danielebarchiesi@0 179 insert: function(content) {
danielebarchiesi@0 180 var instance = FCKeditorAPI.GetInstance(this.field);
danielebarchiesi@0 181 // @see FCK.InsertHtml(), FCK.InsertElement()
danielebarchiesi@0 182 instance.InsertHtml(content);
danielebarchiesi@0 183 },
danielebarchiesi@0 184
danielebarchiesi@0 185 getContent: function () {
danielebarchiesi@0 186 var instance = FCKeditorAPI.GetInstance(this.field);
danielebarchiesi@0 187 return instance.GetData();
danielebarchiesi@0 188 },
danielebarchiesi@0 189
danielebarchiesi@0 190 setContent: function (content) {
danielebarchiesi@0 191 var instance = FCKeditorAPI.GetInstance(this.field);
danielebarchiesi@0 192 instance.SetHTML(content);
danielebarchiesi@0 193 }
danielebarchiesi@0 194 };
danielebarchiesi@0 195
danielebarchiesi@0 196 })(jQuery);