]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741: created a 'nolink' plugin for tinymce.
authorscyrma <scyrma>
Thu, 24 Jul 2008 07:46:28 +0000 (07:46 +0000)
committerscyrma <scyrma>
Thu, 24 Jul 2008 07:46:28 +0000 (07:46 +0000)
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin.js [new file with mode: 0644]
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin_src.js [new file with mode: 0644]
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/img/ed_nolink.gif [new file with mode: 0644]
lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/langs/en.js [new file with mode: 0644]

diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin.js b/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin.js
new file mode 100644 (file)
index 0000000..601ed4e
--- /dev/null
@@ -0,0 +1 @@
+(function(){tinymce.PluginManager.requireLangPack('moodlenolink');tinymce.create('tinymce.plugins.moodlenolinkPlugin',{init:function(ed,url){ed.addCommand('mcemoodlenolink',function(){var n,p;n=ed.selection.getNode();p=ed.dom.getParent(n,function(t){return ed.dom.getAttrib(t,'class')=='nolink'});if(p){ed.dom.remove(p,true)}else{ed.selection.setContent('<span class="nolink">'+ed.selection.getContent()+'</span>')}});ed.addButton('moodlenolink',{title:'moodlenolink.desc',cmd:'mcemoodlenolink',image:url+'/img/ed_nolink.gif'});ed.onNodeChange.add(function(ed,cm,n){var p,c;c=cm.get('moodlenolink');p=ed.dom.getParent(n,'SPAN');c.setActive(p&&ed.dom.hasClass(p,'nolink'));if(p&&ed.dom.hasClass(p,'nolink')||ed.selection.getContent()){c.setDisabled(false)}else{c.setDisabled(true)}})},getInfo:function(){return{longname:'moodlenolink plugin',author:'Some author',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/moodlenolink',version:"1.0"}}});tinymce.PluginManager.add('moodlenolink',tinymce.plugins.moodlenolinkPlugin)})();
\ No newline at end of file
diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin_src.js b/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/editor_plugin_src.js
new file mode 100644 (file)
index 0000000..2a40c6f
--- /dev/null
@@ -0,0 +1,78 @@
+/**\r
+ * $Id$\r
+ */\r
+\r
+(function() {\r
+       // Load plugin specific language pack\r
+       tinymce.PluginManager.requireLangPack('moodlenolink');\r
+\r
+       tinymce.create('tinymce.plugins.moodlenolinkPlugin', {\r
+               /**\r
+                * Initializes the plugin, this will be executed after the plugin has been created.\r
+                * This call is done before the editor instance has finished it's initialization so use the onInit event\r
+                * of the editor instance to intercept that event.\r
+                *\r
+                * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.\r
+                * @param {string} url Absolute URL to where the plugin is located.\r
+                */\r
+               init : function(ed, url) {\r
+                       // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mcemoodlenolink');\r
+                       ed.addCommand('mcemoodlenolink', function() {\r
+                var n, p;\r
+               \r
+                n = ed.selection.getNode();\r
+                p = ed.dom.getParent(n, function(t) { \r
+                    return ed.dom.getAttrib(t, 'class') == 'nolink';\r
+                });\r
+\r
+                if (p) {\r
+                    ed.dom.remove(p, true);\r
+                } else {\r
+                    ed.selection.setContent('<span class="nolink">' + ed.selection.getContent() + '</span>');\r
+                }\r
+\r
+                       });\r
+\r
+                       // Register moodlenolink button\r
+                       ed.addButton('moodlenolink', {\r
+                               title : 'moodlenolink.desc',\r
+                               cmd : 'mcemoodlenolink',\r
+                               image : url + '/img/ed_nolink.gif'\r
+                       });\r
+\r
+                       // Add a node change handler, selects the button in the UI when a image is selected\r
+                       ed.onNodeChange.add(function(ed, cm, n) {\r
+                var p, c;\r
+                c = cm.get('moodlenolink');\r
+                p = ed.dom.getParent(n, 'SPAN');\r
+\r
+                c.setActive(p && ed.dom.hasClass(p, 'nolink'));\r
+\r
+                if (p && ed.dom.hasClass(p, 'nolink') || ed.selection.getContent()) {\r
+                    c.setDisabled(false);\r
+                } else {\r
+                    c.setDisabled(true);\r
+                }\r
+                       });\r
+               },\r
+\r
+               /**\r
+                * Returns information about the plugin as a name/value array.\r
+                * The current keys are longname, author, authorurl, infourl and version.\r
+                *\r
+                * @return {Object} Name/value array containing information about the plugin.\r
+                */\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'moodlenolink plugin',\r
+                               author : 'Some author',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/moodlenolink',\r
+                               version : "1.0"\r
+                       };\r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('moodlenolink', tinymce.plugins.moodlenolinkPlugin);\r
+})();\r
diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/img/ed_nolink.gif b/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/img/ed_nolink.gif
new file mode 100644 (file)
index 0000000..c9b8069
Binary files /dev/null and b/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/img/ed_nolink.gif differ
diff --git a/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/langs/en.js b/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlenolink/langs/en.js
new file mode 100644 (file)
index 0000000..dd2167e
--- /dev/null
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('en.moodlenolink',{\r
+       desc : 'Prevent automatic linking'\r
+});\r