includes/clientside/tinymce/plugins/advhr/editor_plugin_src.js
changeset 335 67bd3121a12e
parent 1 fe660c52c48f
child 395 fa4c5ecb7c9a
--- a/includes/clientside/tinymce/plugins/advhr/editor_plugin_src.js	Wed Dec 26 00:37:26 2007 -0500
+++ b/includes/clientside/tinymce/plugins/advhr/editor_plugin_src.js	Thu Dec 27 22:09:33 2007 -0500
@@ -1,90 +1,54 @@
 /**
- * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ * $Id: editor_plugin_src.js 372 2007-11-11 18:38:50Z spocke $
  *
  * @author Moxiecode
  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
  */
 
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('advhr');
-
-var TinyMCE_AdvancedHRPlugin = {
-	getInfo : function() {
-		return {
-			longname : 'Advanced HR',
-			author : 'Moxiecode Systems AB',
-			authorurl : 'http://tinymce.moxiecode.com',
-			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
-			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
-		}
-	},
+(function() {
+	tinymce.create('tinymce.plugins.AdvancedHRPlugin', {
+		init : function(ed, url) {
+			// Register commands
+			ed.addCommand('mceAdvancedHr', function() {
+				ed.windowManager.open({
+					file : url + '/rule.htm',
+					width : 250 + ed.getLang('advhr.delta_width', 0),
+					height : 160 + ed.getLang('advhr.delta_height', 0),
+					inline : 1
+				}, {
+					plugin_url : url
+				});
+			});
 
-	getControlHTML : function(cn) {
-		switch (cn) {
-			case "advhr":
-				return tinyMCE.getButtonHTML(cn, 'lang_insert_advhr_desc', '{$pluginurl}/images/advhr.gif', 'mceAdvancedHr');
-		}
-
-		return "";
-	},
-
-	/**
-	 * Executes the mceAdvanceHr command.
-	 */
-	execCommand : function(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']  = 250;
-				template['height'] = 160;
-
-				template['width']  += tinyMCE.getLang('lang_advhr_delta_width', 0);
-				template['height'] += tinyMCE.getLang('lang_advhr_delta_height', 0);
+			// Register buttons
+			ed.addButton('advhr', {
+				title : 'advhr.advhr_desc',
+				cmd : 'mceAdvancedHr'
+			});
 
-				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') : "";
-					}
+			ed.onNodeChange.add(function(ed, cm, n) {
+				cm.setActive('advhr', n.nodeName == 'HR');
+			});
 
-					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'});
-					}
-				}
+			ed.onClick.add(function(ed, e) {
+				e = e.target;
 
-				return true;
-		}
+				if (e.nodeName === 'HR')
+					ed.selection.select(e);
+			});
+		},
 
-		// Pass to next handler in chain
-		return false;
-	},
-
-	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
-		if (node == null)
-			return;
+		getInfo : function() {
+			return {
+				longname : 'Advanced HR',
+				author : 'Moxiecode Systems AB',
+				authorurl : 'http://tinymce.moxiecode.com',
+				infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
+				version : tinymce.majorVersion + "." + tinymce.minorVersion
+			};
+		}
+	});
 
-		do {
-			if (node.nodeName == "HR") {
-				tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonSelected');
-				return true;
-			}
-		} while ((node = node.parentNode));
-
-		tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonNormal');
-
-		return true;
-	}
-};
-
-tinyMCE.addPlugin("advhr", TinyMCE_AdvancedHRPlugin);
+	// Register plugin
+	tinymce.PluginManager.add('advhr', tinymce.plugins.AdvancedHRPlugin);
+})();
\ No newline at end of file