| 1 |
/** |
| 2 |
* editor_plugin_src.js |
| 3 |
* |
| 4 |
* Copyright 2009, Moxiecode Systems AB |
| 5 |
* Released under LGPL License. |
| 6 |
* |
| 7 |
* License: http://tinymce.moxiecode.com/license |
| 8 |
* Contributing: http://tinymce.moxiecode.com/contributing |
| 9 |
*/ |
| 10 |
|
| 11 |
(function() { |
| 12 |
// Load plugin specific language pack |
| 13 |
tinymce.PluginManager.requireLangPack('timed_content'); |
| 14 |
|
| 15 |
tinymce.create('tinymce.plugins.TimedContentPlugin', { |
| 16 |
/** |
| 17 |
* Initializes the plugin, this will be executed after the plugin has been created. |
| 18 |
* This call is done before the editor instance has finished it's initialization so use the onInit event |
| 19 |
* of the editor instance to intercept that event. |
| 20 |
* |
| 21 |
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. |
| 22 |
* @param {string} url Absolute URL to where the plugin is located. |
| 23 |
*/ |
| 24 |
init : function(ed, url) { |
| 25 |
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); |
| 26 |
ed.addCommand('mceTimedContent', function() { |
| 27 |
ed.windowManager.open({ |
| 28 |
file : url + '/dialog.php', |
| 29 |
width : 640 + parseInt(ed.getLang('timed_content.delta_width', 0)), |
| 30 |
height : 480 + parseInt(ed.getLang('timed_content.delta_height', 0)), |
| 31 |
inline : 1 |
| 32 |
}, { |
| 33 |
plugin_url : url, // Plugin absolute URL |
| 34 |
}); |
| 35 |
}); |
| 36 |
|
| 37 |
// Register example button |
| 38 |
ed.addButton('timed_content', { |
| 39 |
title : 'timed_content.desc', |
| 40 |
cmd : 'mceTimedContent', |
| 41 |
image : url + '/img/clock.gif' |
| 42 |
}); |
| 43 |
|
| 44 |
// Add a node change handler, selects the button in the UI when a image is selected |
| 45 |
ed.onNodeChange.add(function(ed, cm, n) { |
| 46 |
cm.setActive('timed_content', n.nodeName == 'IMG'); |
| 47 |
}); |
| 48 |
}, |
| 49 |
|
| 50 |
/** |
| 51 |
* Creates control instances based in the incomming name. This method is normally not |
| 52 |
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons |
| 53 |
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this |
| 54 |
* method can be used to create those. |
| 55 |
* |
| 56 |
* @param {String} n Name of the control to create. |
| 57 |
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. |
| 58 |
* @return {tinymce.ui.Control} New control instance or null if no control was created. |
| 59 |
*/ |
| 60 |
createControl : function(n, cm) { |
| 61 |
return null; |
| 62 |
}, |
| 63 |
|
| 64 |
/** |
| 65 |
* Returns information about the plugin as a name/value array. |
| 66 |
* The current keys are longname, author, authorurl, infourl and version. |
| 67 |
* |
| 68 |
* @return {Object} Name/value array containing information about the plugin. |
| 69 |
*/ |
| 70 |
getInfo : function() { |
| 71 |
return { |
| 72 |
longname : 'Timed Content shortcodes plugin', |
| 73 |
author : 'K. Tough', |
| 74 |
authorurl : 'http://tinymce.moxiecode.com', |
| 75 |
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example', |
| 76 |
version : "1.0" |
| 77 |
}; |
| 78 |
} |
| 79 |
}); |
| 80 |
|
| 81 |
// Register plugin |
| 82 |
tinymce.PluginManager.add('timed_content', tinymce.plugins.TimedContentPlugin); |
| 83 |
})(); |