| 1 |
(function() { |
| 2 |
tinymce.create('tinymce.plugins.wp_ultimate_post_grid', { |
| 3 |
/** |
| 4 |
* Initializes the plugin, this will be executed after the plugin has been created. |
| 5 |
* This call is done before the editor instance has finished it's initialization so use the onInit event |
| 6 |
* of the editor instance to intercept that event. |
| 7 |
* |
| 8 |
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. |
| 9 |
* @param {string} url Absolute URL to where the plugin is located. |
| 10 |
*/ |
| 11 |
init : function(ed, url) { |
| 12 |
ed.addButton('wp_ultimate_post_grid', { |
| 13 |
title : 'WP Ultimate Post Grid', |
| 14 |
cmd : 'wp_ultimate_post_grid', |
| 15 |
image : url.slice(0, -9) + '/icons/wp-ultimate-post-grid.svg' |
| 16 |
}); |
| 17 |
|
| 18 |
ed.addCommand('wp_ultimate_post_grid', function() { |
| 19 |
WPUPG_Modal.open( 'menu', { |
| 20 |
insertCallback: ( shortcode ) => WPUPG_Modal.addTextToEditor( shortcode, ed.id ), |
| 21 |
} ); |
| 22 |
}); |
| 23 |
}, |
| 24 |
|
| 25 |
/** |
| 26 |
* Creates control instances based in the incomming name. This method is normally not |
| 27 |
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons |
| 28 |
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this |
| 29 |
* method can be used to create those. |
| 30 |
* |
| 31 |
* @param {String} n Name of the control to create. |
| 32 |
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. |
| 33 |
* @return {tinymce.ui.Control} New control instance or null if no control was created. |
| 34 |
*/ |
| 35 |
createControl : function(n, cm) { |
| 36 |
return null; |
| 37 |
}, |
| 38 |
|
| 39 |
/** |
| 40 |
* Returns information about the plugin as a name/value array. |
| 41 |
* The current keys are longname, author, authorurl, infourl and version. |
| 42 |
* |
| 43 |
* @return {Object} Name/value array containing information about the plugin. |
| 44 |
*/ |
| 45 |
getInfo : function() { |
| 46 |
return { |
| 47 |
longname : 'WP Ultimate Post Grid', |
| 48 |
author : 'Bootstrapped Ventures', |
| 49 |
authorurl : 'https://bootstrapped.ventures', |
| 50 |
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/example', |
| 51 |
version : "0.1" |
| 52 |
}; |
| 53 |
} |
| 54 |
}); |
| 55 |
|
| 56 |
// Register plugin |
| 57 |
tinymce.PluginManager.add( 'wp_ultimate_post_grid', tinymce.plugins.wp_ultimate_post_grid ); |
| 58 |
})(); |