From f283ceae873753c3d5297e989f0075149f2dde29 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 22 Jan 2008 06:23:46 +0000 Subject: [PATCH] Port wphelp plugin to tinyMCE 3.0. Props azaozz. see #5703 git-svn-id: http://svn.automattic.com/wordpress/trunk@6641 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/autosave/langs/en.js | 5 - .../js/tinymce/plugins/wordpress/langs/en.js | 2 +- .../tinymce/plugins/wphelp/editor_plugin.js | 95 +++++++++---------- .../js/tinymce/plugins/wphelp/langs/en.js | 5 - wp-includes/js/tinymce/tiny_mce_config.php | 2 +- wp-includes/js/tinymce/wp-mce-help.php | 42 +++++--- 6 files changed, 77 insertions(+), 74 deletions(-) delete mode 100644 wp-includes/js/tinymce/plugins/autosave/langs/en.js delete mode 100644 wp-includes/js/tinymce/plugins/wphelp/langs/en.js diff --git a/wp-includes/js/tinymce/plugins/autosave/langs/en.js b/wp-includes/js/tinymce/plugins/autosave/langs/en.js deleted file mode 100644 index a1849339c..000000000 --- a/wp-includes/js/tinymce/plugins/autosave/langs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -// EN lang variables - -tinyMCE.addToLang('',{ -autosave_unload_msg : 'The changes you made will be lost if you navigate away from this page.' -}); diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js index 32a5ba576..8002252a6 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js +++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js @@ -12,7 +12,7 @@ else { var metaKey = 'Alt'; } -tinyMCE.addToLang('',{ +tinyMCE.addI18n('',{ wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)', wordpress_page_button : 'Split post with Page tag', wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+v)', diff --git a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js index da29521cc..9eac78d2a 100644 --- a/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wphelp/editor_plugin.js @@ -1,57 +1,50 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('wphelp', ''); +/* WordPress Help plugin for TinyMCE 3.x */ -function TinyMCE_wphelp_getControlHTML(control_name) { - switch (control_name) { - case "wphelp": - var titleHelp = tinyMCE.getLang('lang_help_button_title'); - var buttons = ''; - var hiddenControls = '
' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '
'; - return buttons+hiddenControls; - } +(function() { - return ""; -} +// tinymce.PluginManager.requireLangPack('wphelp'); + + tinymce.create('tinymce.plugins.WP_Help', { + + init : function(ed, url) { + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); + ed.addCommand('wpHelp', function() { + ed.windowManager.open({ + file : tinymce.baseURL + '/wp-mce-help.php', + width : 450, + height : 420, + inline : 1 + }, { + plugin_url : url, // Plugin absolute URL + resizable : 'yes', + scrollbars : 'yes' + }); + }); -function TinyMCE_wphelp_execCommand(editor_id, element, command, user_interface, value) { + // Register example button + ed.addButton('wphelp', { + title : ed.getLang('advanced.help_desc'), + cmd : 'wpHelp', + image : url + '/images/help.gif' + }); - // Handle commands - switch (command) { - case "mceWordPressHelp": - var template = new Array(); - - template['file'] = tinyMCE.baseURL + '/wp-mce-help.php'; - template['width'] = 480; - template['height'] = 380; - - args = { - resizable : 'yes', - scrollbars : 'yes' + // Add a node change handler, selects the button in the UI when a image is selected + ed.onNodeChange.add(function(ed, cm, n) { + cm.setActive('wphelp', n.nodeName == 'IMG'); + }); + }, + + getInfo : function() { + return { + longname : 'WordPress Help plugin', + author : 'WordPress', + authorurl : 'http://wordpress.org', + infourl : 'http://wordpress.org', + version : "3.0" }; + } + }); - tinyMCE.openWindow(template, args); - return true; - } - - // Pass to next handler in chain - return false; -} + // Register plugin + tinymce.PluginManager.add('wphelp', tinymce.plugins.WP_Help); +})(); diff --git a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js b/wp-includes/js/tinymce/plugins/wphelp/langs/en.js deleted file mode 100644 index 8c5b35ad8..000000000 --- a/wp-includes/js/tinymce/plugins/wphelp/langs/en.js +++ /dev/null @@ -1,5 +0,0 @@ -// EN lang variables - -tinyMCE.addToLang('',{ -help_button_title : 'Help (Alt+h)' -}); diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php index 9ad49f3ee..9b6e02729 100644 --- a/wp-includes/js/tinymce/tiny_mce_config.php +++ b/wp-includes/js/tinymce/tiny_mce_config.php @@ -27,7 +27,7 @@ $invalid_elements = apply_filters('mce_invalid_elements', ''); - $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media' ); + $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'wphelp', 'media' ); $plugins = apply_filters('mce_plugins', $plugins); $plugins = implode($plugins, ','); diff --git a/wp-includes/js/tinymce/wp-mce-help.php b/wp-includes/js/tinymce/wp-mce-help.php index 9bcdc5c8f..adf9b1fcd 100644 --- a/wp-includes/js/tinymce/wp-mce-help.php +++ b/wp-includes/js/tinymce/wp-mce-help.php @@ -6,22 +6,22 @@ header('Content-Type: text/html; charset=' . get_bloginfo('charset')); <?php _e('Rich Editor Help') ?> +