includes/clientside/tinymce/plugins/advimage/editor_plugin_src.js
changeset 335 67bd3121a12e
parent 1 fe660c52c48f
child 395 fa4c5ecb7c9a
--- a/includes/clientside/tinymce/plugins/advimage/editor_plugin_src.js	Wed Dec 26 00:37:26 2007 -0500
+++ b/includes/clientside/tinymce/plugins/advimage/editor_plugin_src.js	Thu Dec 27 22:09:33 2007 -0500
@@ -1,148 +1,49 @@
 /**
- * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ * $Id: editor_plugin_src.js 373 2007-11-12 17:57:47Z spocke $
  *
  * @author Moxiecode
  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
  */
 
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('advimage');
-
-var TinyMCE_AdvancedImagePlugin = {
-	getInfo : function() {
-		return {
-			longname : 'Advanced image',
-			author : 'Moxiecode Systems AB',
-			authorurl : 'http://tinymce.moxiecode.com',
-			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
-			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
-		};
-	},
-
-	getControlHTML : function(cn) {
-		switch (cn) {
-			case "image":
-				return tinyMCE.getButtonHTML(cn, 'lang_image_desc', '{$themeurl}/images/image.gif', 'mceAdvImage');
-		}
-
-		return "";
-	},
-
-	execCommand : function(editor_id, element, command, user_interface, value) {
-		switch (command) {
-			case "mceAdvImage":
-				var template = new Array();
-
-				template['file']   = '../../plugins/advimage/image.htm';
-				template['width']  = 480;
-				template['height'] = 380;
+(function() {
+	tinymce.create('tinymce.plugins.AdvancedImagePlugin', {
+		init : function(ed, url) {
+			// Register commands
+			ed.addCommand('mceAdvImage', function() {
+				var e = ed.selection.getNode();
 
-				// Language specific width and height addons
-				template['width']  += tinyMCE.getLang('lang_advimage_delta_width', 0);
-				template['height'] += tinyMCE.getLang('lang_advimage_delta_height', 0);
-
-				var inst = tinyMCE.getInstanceById(editor_id);
-				var elm = inst.getFocusElement();
-
-				if (elm != null && tinyMCE.getAttrib(elm, 'class').indexOf('mceItem') != -1)
-					return true;
-
-				tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
-
-				return true;
-		}
-
-		return false;
-	},
+				// Internal image object like a flash placeholder
+				if (ed.dom.getAttrib(e, 'class').indexOf('mceItem') != -1)
+					return;
 
-	cleanup : function(type, content) {
-		switch (type) {
-			case "insert_to_editor_dom":
-				var imgs = content.getElementsByTagName("img"), src, i;
-				for (i=0; i<imgs.length; i++) {
-					var onmouseover = tinyMCE.cleanupEventStr(tinyMCE.getAttrib(imgs[i], 'onmouseover'));
-					var onmouseout = tinyMCE.cleanupEventStr(tinyMCE.getAttrib(imgs[i], 'onmouseout'));
-
-					if ((src = this._getImageSrc(onmouseover)) != "") {
-						if (tinyMCE.getParam('convert_urls'))
-							src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
-
-						imgs[i].setAttribute('onmouseover', "this.src='" + src + "';");
-					}
-
-					if ((src = this._getImageSrc(onmouseout)) != "") {
-						if (tinyMCE.getParam('convert_urls'))
-							src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
+				ed.windowManager.open({
+					file : url + '/image.htm',
+					width : 480 + ed.getLang('advimage.delta_width', 0),
+					height : 385 + ed.getLang('advimage.delta_height', 0),
+					inline : 1
+				}, {
+					plugin_url : url
+				});
+			});
 
-						imgs[i].setAttribute('onmouseout', "this.src='" + src + "';");
-					}
-				}
-				break;
-
-			case "get_from_editor_dom":
-				var imgs = content.getElementsByTagName("img");
-				for (var i=0; i<imgs.length; i++) {
-					var onmouseover = tinyMCE.cleanupEventStr(tinyMCE.getAttrib(imgs[i], 'onmouseover'));
-					var onmouseout = tinyMCE.cleanupEventStr(tinyMCE.getAttrib(imgs[i], 'onmouseout'));
-
-					if ((src = this._getImageSrc(onmouseover)) != "") {
-						if (tinyMCE.getParam('convert_urls'))
-							src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
-
-						imgs[i].setAttribute('onmouseover', "this.src='" + src + "';");
-					}
-
-					if ((src = this._getImageSrc(onmouseout)) != "") {
-						if (tinyMCE.getParam('convert_urls'))
-							src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
-
-						imgs[i].setAttribute('onmouseout', "this.src='" + src + "';");
-					}
-				}
-				break;
-		}
-
-		return content;
-	},
-
-	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
-		if (node == null)
-			return;
+			// Register buttons
+			ed.addButton('image', {
+				title : 'advimage.image_desc',
+				cmd : 'mceAdvImage'
+			});
+		},
 
-		do {
-			if (node.nodeName == "IMG" && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {
-				tinyMCE.switchClass(editor_id + '_advimage', 'mceButtonSelected');
-				return true;
-			}
-		} while ((node = node.parentNode));
-
-		tinyMCE.switchClass(editor_id + '_advimage', 'mceButtonNormal');
-
-		return true;
-	},
+		getInfo : function() {
+			return {
+				longname : 'Advanced image',
+				author : 'Moxiecode Systems AB',
+				authorurl : 'http://tinymce.moxiecode.com',
+				infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
+				version : tinymce.majorVersion + "." + tinymce.minorVersion
+			};
+		}
+	});
 
-	/**
-	 * Returns the image src from a scripted mouse over image str.
-	 *
-	 * @param {string} s String to get real src from.
-	 * @return Image src from a scripted mouse over image str.
-	 * @type string
-	 */
-	_getImageSrc : function(s) {
-		var sr, p = -1;
-
-		if (!s)
-			return "";
-
-		if ((p = s.indexOf('this.src=')) != -1) {
-			sr = s.substring(p + 10);
-			sr = sr.substring(0, sr.indexOf('\''));
-
-			return sr;
-		}
-
-		return "";
-	}
-};
-
-tinyMCE.addPlugin("advimage", TinyMCE_AdvancedImagePlugin);
+	// Register plugin
+	tinymce.PluginManager.add('advimage', tinymce.plugins.AdvancedImagePlugin);
+})();
\ No newline at end of file