From ca117d1e5b28129b5304742ec33d07c76bf94c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Fri, 12 Apr 2013 14:35:30 +0200 Subject: [PATCH] MDL-34674 add CTRL+right click hint to tinymce context menus --- .../ctrlhelp/lang/en/tinymce_ctrlhelp.php | 28 +++++++++++++++ lib/editor/tinymce/plugins/ctrlhelp/lib.php | 35 +++++++++++++++++++ .../plugins/ctrlhelp/tinymce/editor_plugin.js | 23 ++++++++++++ .../tinymce/plugins/ctrlhelp/version.php | 29 +++++++++++++++ lib/pluginlib.php | 2 +- 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 lib/editor/tinymce/plugins/ctrlhelp/lang/en/tinymce_ctrlhelp.php create mode 100644 lib/editor/tinymce/plugins/ctrlhelp/lib.php create mode 100644 lib/editor/tinymce/plugins/ctrlhelp/tinymce/editor_plugin.js create mode 100644 lib/editor/tinymce/plugins/ctrlhelp/version.php diff --git a/lib/editor/tinymce/plugins/ctrlhelp/lang/en/tinymce_ctrlhelp.php b/lib/editor/tinymce/plugins/ctrlhelp/lang/en/tinymce_ctrlhelp.php new file mode 100644 index 00000000000..8c346445bb0 --- /dev/null +++ b/lib/editor/tinymce/plugins/ctrlhelp/lang/en/tinymce_ctrlhelp.php @@ -0,0 +1,28 @@ +. + +/** + * Strings for CTRL+Right click helper. + * + * @package tinymce_ctrlhelp + * @copyright 2013 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'CTRL+right click helper'; + +/* All lang strings used from TinyMCE JavaScript code must be named 'pluginname:stringname', no need to create langs/en_dlg.js */ +$string['ctrlhelp:desc'] = 'CTRL + right click for more options'; diff --git a/lib/editor/tinymce/plugins/ctrlhelp/lib.php b/lib/editor/tinymce/plugins/ctrlhelp/lib.php new file mode 100644 index 00000000000..97fc7116fae --- /dev/null +++ b/lib/editor/tinymce/plugins/ctrlhelp/lib.php @@ -0,0 +1,35 @@ +. + +defined('MOODLE_INTERNAL') || die(); + +/** + * CTRL + right click helper + * + * @package tinymce_ctrlhelp + * @copyright 2013 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class tinymce_ctrlhelp extends editor_tinymce_plugin { + protected function update_init_params(array &$params, context $context, array $options = null) { + $this->add_js_plugin($params); + } + + protected function get_sort_order() { + // We want this plugin to register as the last one in the context menu. + return 66666; + } +} diff --git a/lib/editor/tinymce/plugins/ctrlhelp/tinymce/editor_plugin.js b/lib/editor/tinymce/plugins/ctrlhelp/tinymce/editor_plugin.js new file mode 100644 index 00000000000..9a2e5ec4169 --- /dev/null +++ b/lib/editor/tinymce/plugins/ctrlhelp/tinymce/editor_plugin.js @@ -0,0 +1,23 @@ +(function() { + tinymce.create('tinymce.plugins.CtrlHelpPlugin', { + + init : function(ed, url) { + ed.onContextMenu.add(function(ed, e) { + var m = ed.plugins.contextmenu._menu; + m.add({title : 'ctrlhelp.desc', icon : '', cmd : ''}); + }); + }, + + getInfo : function() { + return { + longname : 'Moodle CTRL + right click helper plugin', + author : 'Petr Skoda', + authorurl : 'http://skodak.org/', + infourl : 'http://moodle.org', + version : '1.0' + }; + } + }); + + tinymce.PluginManager.add('ctrlhelp', tinymce.plugins.CtrlHelpPlugin); +})(); diff --git a/lib/editor/tinymce/plugins/ctrlhelp/version.php b/lib/editor/tinymce/plugins/ctrlhelp/version.php new file mode 100644 index 00000000000..e4d582bcb4f --- /dev/null +++ b/lib/editor/tinymce/plugins/ctrlhelp/version.php @@ -0,0 +1,29 @@ +. + +/** + * CTRL + right click helper. + * + * @package tinymce_ctrlhelp + * @copyright 2013 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2013041200; +$plugin->requires = 2013041100; +$plugin->component = 'tinymce_ctrlhelp'; diff --git a/lib/pluginlib.php b/lib/pluginlib.php index de23503162f..d1aabf7328f 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -597,7 +597,7 @@ class plugin_manager { ), 'tinymce' => array( - 'dragmath', 'moodleemoticon', 'moodleimage', 'moodlemedia', 'moodlenolink', 'spellchecker', + 'ctrlhelp', 'dragmath', 'moodleemoticon', 'moodleimage', 'moodlemedia', 'moodlenolink', 'spellchecker', ), 'theme' => array(