Index: drupalimage/editor_plugin.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/img_assist/drupalimage/editor_plugin.js,v retrieving revision 1.3 diff -u -p -r1.3 editor_plugin.js --- drupalimage/editor_plugin.js 6 Apr 2008 16:43:19 -0000 1.3 +++ drupalimage/editor_plugin.js 4 Jun 2008 02:02:44 -0000 @@ -1,8 +1,8 @@ // $Id: editor_plugin.js,v 1.3 2008/04/06 16:43:19 sun Exp $ /* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('drupalimage', 'en'); +//tinyMCE.importPluginLanguagePack('drupalimage', 'en'); -var TinyMCE_DrupalImagePlugin = { +(function() {tinymce.create('tinymce.plugins.DrupalImagePlugin', { getInfo : function() { return { longname : 'DrupalImage', @@ -18,64 +18,25 @@ var TinyMCE_DrupalImagePlugin = { tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + '/plugins/drupalimage/drupalimage.css'); }, - getControlHTML : function(cn) { - switch (cn) { - case 'drupalimage': - return tinyMCE.getButtonHTML(cn, 'lang_drupalimage_desc', '{$pluginurl}/images/drupalimage.gif', 'mceDrupalImage'); - } - - return ''; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - // Handle commands - switch (command) { - case 'mceDrupalImage': - var name = ''; - var nid = '', alt = '', captionTitle = '', captionDesc = '', link = '', url = '', align = '', width = '', height = ''; - var action = 'insert'; - var template = new Array(); - var inst = tinyMCE.getInstanceById(editor_id); - var focusElm = inst.getFocusElement(); - - template['file'] = BASE_URL + 'index.php?q=img_assist/load/tinymce'; - template['width'] = 600; - template['height'] = 350; - template['html'] = false; - - // Is selection a image - if (focusElm != null && focusElm.nodeName.toLowerCase() == 'img') { - name = tinyMCE.getAttrib(focusElm, 'class'); - - if (name.indexOf('mceItemDrupalImage') == -1) - // Not a DrupalImage - return true; - - // Get the rest of the DrupalImage attributes - align = tinyMCE.getAttrib(focusElm, 'align'); - width = tinyMCE.getAttrib(focusElm, 'width'); - height = tinyMCE.getAttrib(focusElm, 'height'); - // using 'title' because this doesn't seem to work with 'alt' - alt = decodeURIComponent(tinyMCE.getAttrib(focusElm, 'title')); - // parse the deliminated attributes in the alt tag - var miscAttribs = TinyMCE_DrupalImagePlugin._parsePipeAttributes(alt); - nid = miscAttribs['nid']; - captionTitle = miscAttribs['title']; - captionDesc = miscAttribs['desc']; - link = miscAttribs['link']; - if(typeof miscAttribs['url'] != 'undefined') { - url = miscAttribs['url']; - } - - action = 'update'; - } - - tinyMCE.openWindow(template, {editor_id: editor_id, nid: nid, captionTitle: captionTitle, captionDesc: captionDesc, link: link, url: url, align: align, width: width, height: height, action: action}); - return true; - } - - // Pass to next handler in chain - return false; + init : function(ed, url) { + // Register commands + ed.addCommand('mceDrupalImage', function() { + ed.windowManager.open({ + file : BASE_URL + 'index.php?q=img_assist/load/tinymce', + width : 600 + parseInt(ed.getLang('advhr.delta_width', 0)), + height : 350 + parseInt(ed.getLang('advhr.delta_height', 0)), + inline : 1 + }, { + plugin_url : url + }); + }); + + // Register buttons + ed.addButton('drupalimage', { + title : 'drupalimage.drupalimage_desc', + image: '{$pluginurl}/images/drupalimage.gif', + cmd : 'mceDrupalImage' + }); }, cleanup : function(type, content) { @@ -254,7 +215,8 @@ var TinyMCE_DrupalImagePlugin = { } return attributes; } -}; - -tinyMCE.addPlugin("drupalimage", TinyMCE_DrupalImagePlugin); +}); +// Register plugin +tinymce.PluginManager.add('drupalimage', tinymce.plugins.DrupalImagePlugin); +})();