annotate media/js/tiny_mce/plugins/example/editor_plugin_src.js @ 45:a5b4c5ce0658

Breaking down and controlling all media files, including javascript libraries.
author Brian Neal <bgneal@gmail.com>
date Fri, 19 Jun 2009 03:16:03 +0000
parents
children 149c3567fec1
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
bgneal@45 3 *
bgneal@45 4 * @author Moxiecode
bgneal@45 5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 6 */
bgneal@45 7
bgneal@45 8 (function() {
bgneal@45 9 // Load plugin specific language pack
bgneal@45 10 tinymce.PluginManager.requireLangPack('example');
bgneal@45 11
bgneal@45 12 tinymce.create('tinymce.plugins.ExamplePlugin', {
bgneal@45 13 /**
bgneal@45 14 * Initializes the plugin, this will be executed after the plugin has been created.
bgneal@45 15 * This call is done before the editor instance has finished it's initialization so use the onInit event
bgneal@45 16 * of the editor instance to intercept that event.
bgneal@45 17 *
bgneal@45 18 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
bgneal@45 19 * @param {string} url Absolute URL to where the plugin is located.
bgneal@45 20 */
bgneal@45 21 init : function(ed, url) {
bgneal@45 22 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
bgneal@45 23 ed.addCommand('mceExample', function() {
bgneal@45 24 ed.windowManager.open({
bgneal@45 25 file : url + '/dialog.htm',
bgneal@45 26 width : 320 + parseInt(ed.getLang('example.delta_width', 0)),
bgneal@45 27 height : 120 + parseInt(ed.getLang('example.delta_height', 0)),
bgneal@45 28 inline : 1
bgneal@45 29 }, {
bgneal@45 30 plugin_url : url, // Plugin absolute URL
bgneal@45 31 some_custom_arg : 'custom arg' // Custom argument
bgneal@45 32 });
bgneal@45 33 });
bgneal@45 34
bgneal@45 35 // Register example button
bgneal@45 36 ed.addButton('example', {
bgneal@45 37 title : 'example.desc',
bgneal@45 38 cmd : 'mceExample',
bgneal@45 39 image : url + '/img/example.gif'
bgneal@45 40 });
bgneal@45 41
bgneal@45 42 // Add a node change handler, selects the button in the UI when a image is selected
bgneal@45 43 ed.onNodeChange.add(function(ed, cm, n) {
bgneal@45 44 cm.setActive('example', n.nodeName == 'IMG');
bgneal@45 45 });
bgneal@45 46 },
bgneal@45 47
bgneal@45 48 /**
bgneal@45 49 * Creates control instances based in the incomming name. This method is normally not
bgneal@45 50 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
bgneal@45 51 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
bgneal@45 52 * method can be used to create those.
bgneal@45 53 *
bgneal@45 54 * @param {String} n Name of the control to create.
bgneal@45 55 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
bgneal@45 56 * @return {tinymce.ui.Control} New control instance or null if no control was created.
bgneal@45 57 */
bgneal@45 58 createControl : function(n, cm) {
bgneal@45 59 return null;
bgneal@45 60 },
bgneal@45 61
bgneal@45 62 /**
bgneal@45 63 * Returns information about the plugin as a name/value array.
bgneal@45 64 * The current keys are longname, author, authorurl, infourl and version.
bgneal@45 65 *
bgneal@45 66 * @return {Object} Name/value array containing information about the plugin.
bgneal@45 67 */
bgneal@45 68 getInfo : function() {
bgneal@45 69 return {
bgneal@45 70 longname : 'Example plugin',
bgneal@45 71 author : 'Some author',
bgneal@45 72 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 73 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example',
bgneal@45 74 version : "1.0"
bgneal@45 75 };
bgneal@45 76 }
bgneal@45 77 });
bgneal@45 78
bgneal@45 79 // Register plugin
bgneal@45 80 tinymce.PluginManager.add('example', tinymce.plugins.ExamplePlugin);
bgneal@45 81 })();