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