(function() { tinymce.create('tinymce.plugins.animate_button', { /** * Initializes the plugin, this will be executed after the plugin has been created. * This call is done before the editor instance has finished it's initialization so use the onInit event * of the editor instance to intercept that event. * * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. * @param {string} url Absolute URL to where the plugin is located. */ init : function(ed, url) { ed.addButton('animate_button', { title : 'Animate Shortcode', cmd : 'animate_button', image : url + '/animate_button.png' }); ed.addCommand('animate_button', function() { tb_show( 'Animate Content Options', '#TB_inline?height=600&inlineId=animate_content_form' ); }); }, /** * Creates control instances based in the incomming name. This method is normally not * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons * but you sometimes need to create more complex controls like listboxes, split buttons etc then this * method can be used to create those. * * @param {String} n Name of the control to create. * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control. * @return {tinymce.ui.Control} New control instance or null if no control was created. */ createControl : function(n, cm) { return null; }, /** * Returns information about the plugin as a name/value array. * The current keys are longname, author, authorurl, infourl and version. * * @return {Object} Name/value array containing information about the plugin. */ getInfo : function() { return { longname : 'Animate Content Shortcode', author : 'Nicolas Grillet', authorurl : 'http://www.erreurs404.net', infourl : 'http://www.devictio.fr', version : "1.0.0" }; } }); // Register plugin tinymce.PluginManager.add( 'animate_button', tinymce.plugins.animate_button ); })(); // executes this when the DOM is ready jQuery(function(){ // creates a form to be displayed everytime the button is clicked // you should achieve this using AJAX instead of direct html code like this var form = jQuery('
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

\ Select the effect you want for this element.
\
\ Set the effect duration.
\
\ Set the effect duration.
\
\ Set the effect offset (distance to the element when triggering the animation).
\
\ Set the effect duration.
\

\ \

\
'); var table = form.find('table'); form.appendTo('body').hide(); // handles the click event of the submit button form.find('#animate_content_submit').click(function(){ selected = tinyMCE.activeEditor.selection.getContent(); var options = { 'effect' : 'bounce', 'iteration' : '0', 'delay' : '5s', 'duration' : '2s', 'offset' : '0' }; var shortcode = '[animate_content'; for( var index in options) { var value = table.find('#ac_' + index).val(); shortcode += ' ' + index + '="' + value + '"'; } shortcode += ']'+selected+'[/animate_content]'; // inserts the shortcode into the active editor tinyMCE.activeEditor.execCommand('mceInsertContent', false, shortcode); // closes Thickbox tb_remove(); }); });