bgneal@312: /** bgneal@312: * editor_plugin_src.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: (function() { bgneal@312: // Load plugin specific language pack bgneal@312: tinymce.PluginManager.requireLangPack('example'); bgneal@312: bgneal@312: tinymce.create('tinymce.plugins.ExamplePlugin', { bgneal@312: /** bgneal@312: * Initializes the plugin, this will be executed after the plugin has been created. bgneal@312: * This call is done before the editor instance has finished it's initialization so use the onInit event bgneal@312: * of the editor instance to intercept that event. bgneal@312: * bgneal@312: * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. bgneal@312: * @param {string} url Absolute URL to where the plugin is located. bgneal@312: */ bgneal@312: init : function(ed, url) { bgneal@312: // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); bgneal@312: ed.addCommand('mceExample', function() { bgneal@312: ed.windowManager.open({ bgneal@312: file : url + '/dialog.htm', bgneal@312: width : 320 + parseInt(ed.getLang('example.delta_width', 0)), bgneal@312: height : 120 + parseInt(ed.getLang('example.delta_height', 0)), bgneal@312: inline : 1 bgneal@312: }, { bgneal@312: plugin_url : url, // Plugin absolute URL bgneal@312: some_custom_arg : 'custom arg' // Custom argument bgneal@312: }); bgneal@312: }); bgneal@312: bgneal@312: // Register example button bgneal@312: ed.addButton('example', { bgneal@312: title : 'example.desc', bgneal@312: cmd : 'mceExample', bgneal@312: image : url + '/img/example.gif' bgneal@312: }); bgneal@312: bgneal@312: // Add a node change handler, selects the button in the UI when a image is selected bgneal@312: ed.onNodeChange.add(function(ed, cm, n) { bgneal@312: cm.setActive('example', n.nodeName == 'IMG'); bgneal@312: }); bgneal@312: }, bgneal@312: bgneal@312: /** bgneal@312: * Creates control instances based in the incomming name. This method is normally not bgneal@312: * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons bgneal@312: * but you sometimes need to create more complex controls like listboxes, split buttons etc then this bgneal@312: * method can be used to create those. bgneal@312: * bgneal@312: * @param {String} n Name of the control to create. bgneal@312: * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. bgneal@312: * @return {tinymce.ui.Control} New control instance or null if no control was created. bgneal@312: */ bgneal@312: createControl : function(n, cm) { bgneal@312: return null; bgneal@312: }, bgneal@312: bgneal@312: /** bgneal@312: * Returns information about the plugin as a name/value array. bgneal@312: * The current keys are longname, author, authorurl, infourl and version. bgneal@312: * bgneal@312: * @return {Object} Name/value array containing information about the plugin. bgneal@312: */ bgneal@312: getInfo : function() { bgneal@312: return { bgneal@312: longname : 'Example plugin', bgneal@312: author : 'Some author', bgneal@312: authorurl : 'http://tinymce.moxiecode.com', bgneal@312: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example', bgneal@312: version : "1.0" bgneal@312: }; bgneal@312: } bgneal@312: }); bgneal@312: bgneal@312: // Register plugin bgneal@312: tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin); bgneal@312: })();