more font size tweaks.
[citadel.git] / webcit / tiny_mce / plugins / advhr / editor_plugin_src.js
index 634f777c061810050e34b031f490d20fea869c68..0c652d3303e8bf9a6136dbc7ff1811baaf3e4e44 100644 (file)
@@ -1,74 +1,57 @@
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('advhr', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br,nl');
-
-function TinyMCE_advhr_getInfo() {
-       return {
-               longname : 'Advanced HR',
-               author : 'Moxiecode Systems',
-               authorurl : 'http://tinymce.moxiecode.com',
-               infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_advhr.html',
-               version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
-       };
-};
-
-function TinyMCE_advhr_getControlHTML(control_name) {
-    switch (control_name) {
-        case "advhr":
-            return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceAdvancedHr\');" onmousedown="return false;"><img id="{$editor_id}_advhr" src="{$pluginurl}/images/advhr.gif" title="{$lang_insert_advhr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
-    }
-
-    return "";
-}
-
-/**
- * Executes the mceAdvanceHr command.
- */
-function TinyMCE_advhr_execCommand(editor_id, element, command, user_interface, value) {
-    // Handle commands
-    switch (command) {
-        case "mceAdvancedHr":
-            var template = new Array();
-
-            template['file']   = '../../plugins/advhr/rule.htm'; // Relative to theme
-            template['width']  = 270;
-            template['height'] = 180;
-
-                       template['width']  += tinyMCE.getLang('lang_advhr_delta_width', 0);
-                       template['height'] += tinyMCE.getLang('lang_advhr_delta_height', 0);
-
-            var size = "", width = "", noshade = "";
-            if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "hr"){
-                tinyMCE.hrElement = tinyMCE.selectedElement;
-                if (tinyMCE.hrElement) {
-                    size    = tinyMCE.hrElement.getAttribute('size') ? tinyMCE.hrElement.getAttribute('size') : "";
-                    width   = tinyMCE.hrElement.getAttribute('width') ? tinyMCE.hrElement.getAttribute('width') : "";
-                    noshade = tinyMCE.hrElement.getAttribute('noshade') ? tinyMCE.hrElement.getAttribute('noshade') : "";
-                }
-                tinyMCE.openWindow(template, {editor_id : editor_id, size : size, width : width, noshade : noshade, mceDo : 'update'});
-            } else {
-                if (tinyMCE.isMSIE) {
-                    tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false,'<hr />');
-                } else {
-                    tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", size : size, width : width, noshade : noshade, mceDo : 'insert'});
-                }
-            }
-                    
-       return true;
-   }
-   // Pass to next handler in chain
-   return false;
-}
-
-function TinyMCE_advhr_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
-       tinyMCE.switchClassSticky(editor_id + '_advhr', 'mceButtonNormal');
-
-       if (node == null)
-               return;
-
-       do {
-               if (node.nodeName.toLowerCase() == "hr")
-                       tinyMCE.switchClassSticky(editor_id + '_advhr', 'mceButtonSelected');
-       } while ((node = node.parentNode));
-
-       return true;
-}
\ No newline at end of file
+/**\r
+ * editor_plugin_src.js\r
+ *\r
+ * Copyright 2009, Moxiecode Systems AB\r
+ * Released under LGPL License.\r
+ *\r
+ * License: http://tinymce.moxiecode.com/license\r
+ * Contributing: http://tinymce.moxiecode.com/contributing\r
+ */\r
+\r
+(function() {\r
+       tinymce.create('tinymce.plugins.AdvancedHRPlugin', {\r
+               init : function(ed, url) {\r
+                       // Register commands\r
+                       ed.addCommand('mceAdvancedHr', function() {\r
+                               ed.windowManager.open({\r
+                                       file : url + '/rule.htm',\r
+                                       width : 250 + parseInt(ed.getLang('advhr.delta_width', 0)),\r
+                                       height : 160 + parseInt(ed.getLang('advhr.delta_height', 0)),\r
+                                       inline : 1\r
+                               }, {\r
+                                       plugin_url : url\r
+                               });\r
+                       });\r
+\r
+                       // Register buttons\r
+                       ed.addButton('advhr', {\r
+                               title : 'advhr.advhr_desc',\r
+                               cmd : 'mceAdvancedHr'\r
+                       });\r
+\r
+                       ed.onNodeChange.add(function(ed, cm, n) {\r
+                               cm.setActive('advhr', n.nodeName == 'HR');\r
+                       });\r
+\r
+                       ed.onClick.add(function(ed, e) {\r
+                               e = e.target;\r
+\r
+                               if (e.nodeName === 'HR')\r
+                                       ed.selection.select(e);\r
+                       });\r
+               },\r
+\r
+               getInfo : function() {\r
+                       return {\r
+                               longname : 'Advanced HR',\r
+                               author : 'Moxiecode Systems AB',\r
+                               authorurl : 'http://tinymce.moxiecode.com',\r
+                               infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',\r
+                               version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+                       };\r
+               }\r
+       });\r
+\r
+       // Register plugin\r
+       tinymce.PluginManager.add('advhr', tinymce.plugins.AdvancedHRPlugin);\r
+})();
\ No newline at end of file