/** * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ (function() { window.mcImageManager = { settings : { document_base_url : '', relative_urls : false, remove_script_host : false, use_url_path : true, remember_last_path : 'auto', target_elements : '', target_form : '', handle : 'image,media' }, setup : function() { var t = this, o, d = document, cp = []; // Find document_base_url o = d.location.href; if (o.indexOf('?') != -1) o = o.substring(0, o.indexOf('?')); o = o.substring(0, o.lastIndexOf('/') + 1); t.settings.default_base_url = unescape(o); // Find script base URL function get(nl) { var i, n; for (i=0; i'), o.focusedFile, { urlencode : function(v) { return escape(v); }, xmlEncode : function(v) { return tinymce.DOM.encode(v); } } )); } }, v)); }); }, getInfo : function() { return mcImageManagerPlugin.getInfo(); }, createControl: function(n, cm) { var t = this, c, ed = t.editor, v; switch (n) { case 'insertimage': v = ed.getParam('imagemanager_insert_template'); if (v instanceof Array) { c = cm.createMenuButton('insertimage', { title : 'imagemanager_insertimage_desc', image : t.url + '/pages/im/img/insertimage.gif', icons : false }); c.onRenderMenu.add(function(c, m) { tinymce.each(v, function(v) { m.add({title : v.title, onclick : function() { ed.execCommand('mceInsertImage', false, v); }}); }); }); } else { c = cm.createButton('insertimage', { title : 'imagemanager_insertimage_desc', image : t.url + '/pages/im/img/insertimage.gif', onclick : function() { ed.execCommand('mceInsertImage', false, {template : v}); } }); } return c; } return null; } }); tinymce.PluginManager.add('imagemanager', tinymce.plugins.ImageManagerPlugin); tinymce.ScriptLoader.load((tinymce.PluginManager.urls['imagemanager'] || tinymce.baseURL + '/plugins/imagemanager')+ '/language/index.php?type=im&format=tinymce_3_x&group=tinymce&prefix=imagemanager_'); } // Setup TinyMCE 2.x plugin if (window.TinyMCE_Engine) { var TinyMCE_ImageManagerPlugin = { setup : function() { var b = (window.realTinyMCE || tinyMCE).baseURL; mcImageManager.baseURL = b + '/plugins/imagemanager/js'; document.write(''); }, initInstance : function(ed) { ed.settings.file_browser_callback = 'mcImageManager.filebrowserCallBack'; mcImageManager.settings.handle = tinyMCE.getParam('imagemanager_handle', mcImageManager.settings.handle); }, getControlHTML : function(cn) { switch (cn) { case "insertimage": return tinyMCE.getButtonHTML(cn, 'lang_imagemanager_insertimage_desc', '{$pluginurl}/pages/im/img/insertimage.gif', 'mceInsertImage', false); } return ""; }, getInfo : function() { return mcImageManagerPlugin.getInfo(); }, execCommand : function(id, el, cmd, ui, v) { var ed = tinyMCE.getInstanceById(id); if (cmd == 'mceInsertImage') { mcImageManager.browse(tinyMCE.extend({ path : tinyMCE.getParam("imagemanager_path"), rootpath : tinyMCE.getParam("imagemanager_rootpath"), remember_last_path : tinyMCE.getParam("imagemanager_remember_last_path"), custom_data : tinyMCE.getParam("imagemanager_custom_data"), insert_filter : tinyMCE.getParam("imagemanager_insert_filter"), oninsert : function(o) { var ci = o.focusedFile.custom; if (!ci.thumbnail_url) { ci.thumbnail_url = url; ci.twidth = ci.width; ci.theight = ci.height; } ed.execCommand('mceInsertContent', false, mcImageManagerPlugin.replace( tinyMCE.getParam('imagemanager_insert_template', ''), o.focusedFile, { urlencode : function(v) { return escape(v); }, xmlEncode : function(v) { return tinyMCE.xmlEncode(v); } } )); } }, v)); return true; } return false; } }; TinyMCE_ImageManagerPlugin.setup(); tinyMCE.addPlugin('imagemanager', TinyMCE_ImageManagerPlugin); } })();