123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- (function($) {
- Drupal.wysiwyg.editor.init.tinymce = function(settings) {
-
-
-
- tinyMCE.baseURL = settings.global.editorBasePath;
- tinyMCE.srcMode = (settings.global.execMode == 'src' ? '_src' : '');
- tinyMCE.gzipMode = (settings.global.execMode == 'gzip');
-
- for (var format in settings) {
- if (format == 'global') {
- continue;
- }
- tinyMCE.init(settings[format]);
- if (Drupal.settings.wysiwyg.plugins[format]) {
-
-
- for (var plugin in Drupal.settings.wysiwyg.plugins[format]['native']) {
- tinyMCE.loadPlugin(plugin, Drupal.settings.wysiwyg.plugins[format]['native'][plugin]);
- }
-
- for (var plugin in Drupal.settings.wysiwyg.plugins[format].drupal) {
- Drupal.wysiwyg.editor.instance.tinymce.addPlugin(plugin, Drupal.settings.wysiwyg.plugins[format].drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin]);
- }
- }
- }
- };
- Drupal.wysiwyg.editor.attach.tinymce = function(context, params, settings) {
-
- for (var setting in settings) {
- tinyMCE.settings[setting] = settings[setting];
- }
-
-
-
-
-
-
-
- $field = $('#' + params.field);
- $field.val($field.val().replace(/(<.+?\s+class=['"][\w\s]*?)\bmceItem\b([\w\s]*?['"].*?>)/ig, '$1$2'));
-
- tinyMCE.execCommand('mceAddControl', true, params.field);
- };
- Drupal.wysiwyg.editor.detach.tinymce = function(context, params) {
- if (typeof params != 'undefined') {
- tinyMCE.removeMCEControl(tinyMCE.getEditorId(params.field));
- $('#' + params.field).removeAttr('style');
- }
- };
- Drupal.wysiwyg.editor.instance.tinymce = {
- addPlugin: function(plugin, settings, pluginSettings) {
- if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
- return;
- }
- tinyMCE.addPlugin(plugin, {
-
- execCommand: function(editor_id, element, command, user_interface, value) {
- switch (command) {
- case plugin:
- if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') {
- var ed = tinyMCE.getInstanceById(editor_id);
- var data = { format: 'html', node: ed.getFocusElement(), content: ed.getFocusElement() };
- Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, ed.formTargetElementId);
- return true;
- }
- }
-
- return false;
- },
-
- getControlHTML: function(control_name) {
- switch (control_name) {
- case plugin:
- return tinyMCE.getButtonHTML(control_name, settings.iconTitle, settings.icon, plugin);
- }
- return '';
- },
-
- initInstance: function(ed) {
- if (settings.css) {
- tinyMCE.importCSS(ed.getDoc(), settings.css);
- }
- },
- cleanup: function(type, content) {
- switch (type) {
- case 'insert_to_editor':
-
- if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
- content = Drupal.wysiwyg.plugins[plugin].attach(content, pluginSettings, tinyMCE.selectedInstance.editorId);
- content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(content);
- }
- break;
- case 'get_from_editor':
-
- if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
- content = Drupal.wysiwyg.plugins[plugin].detach(content, pluginSettings, tinyMCE.selectedInstance.editorId);
- }
- break;
- }
-
- return content;
- },
-
-
- handleNodeChange: function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
- if (node === null) {
- return;
- }
- if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
- if (Drupal.wysiwyg.plugins[plugin].isNode(node)) {
- tinyMCE.switchClass(editor_id + '_' + plugin, 'mceButtonSelected');
- return true;
- }
- }
- tinyMCE.switchClass(editor_id + '_' + plugin, 'mceButtonNormal');
- return true;
- },
-
- getInfo: function() {
- return {
- longname: settings.title
- };
- }
- });
- },
- openDialog: function(dialog, params) {
- var editor = tinyMCE.getInstanceById(this.field);
- tinyMCE.openWindow({
- file: dialog.url + '/' + this.field,
- width: dialog.width,
- height: dialog.height,
- inline: 1
- }, params);
- },
- closeDialog: function(dialog) {
- var editor = tinyMCE.getInstanceById(this.field);
- tinyMCEPopup.close();
- },
- prepareContent: function(content) {
-
-
-
- var specialProperties = {
- img: { 'name': 'mce_drupal' }
- };
- var $content = $('<div>' + content + '</div>');
- jQuery.each(specialProperties, function(element, properties) {
- $content.find(element).each(function() {
- for (var property in properties) {
- if (property == 'class') {
- $(this).addClass(properties[property]);
- }
- else {
- $(this).attr(property, properties[property]);
- }
- }
- });
- });
- return $content.html();
- },
- insert: function(content) {
- content = this.prepareContent(content);
- var editor = tinyMCE.getInstanceById(this.field);
- editor.execCommand('mceInsertContent', false, content);
- editor.repaint();
- }
- };
- })(jQuery);
|