[pLog-svn] r7048 - in plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource: . css langs

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Wed Sep 22 17:59:33 EDT 2010


Author: jondaley
Date: 2010-09-22 17:59:33 -0400 (Wed, 22 Sep 2010)
New Revision: 7048

Added:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/img/
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en_dlg.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr_dlg.js
Removed:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/images/
Modified:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/css/content.css
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr.js
Log:
starting to upgrade plugin

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/css/content.css
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/css/content.css	2010-09-22 21:54:59 UTC (rev 7047)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/css/content.css	2010-09-22 21:59:33 UTC (rev 7048)
@@ -1,7 +1,7 @@
 .ltFlashPlayer {
-	background-image: url('../images/player.png');	
+	background-image: url('../img/player.png');	
 	border: 1px dotted #cc0000;
 	background-position: center;
 	background-repeat: no-repeat;
 	background-color: #ffffcc;
-}
\ No newline at end of file
+}

Deleted: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js	2010-09-22 21:54:59 UTC (rev 7047)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -1,262 +0,0 @@
-/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.12 $
- * $Date: 2006/02/22 20:06:23 $
- *
- * @author Moxiecode
- * @copyright Copyright ?2004-2006, Moxiecode Systems AB, All rights reserved.
- */
-
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('insertresource', 'en,tr,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl'); // <- Add a comma separated list of all supported languages
-
-// Singleton class
-var TinyMCE_insertresourcePlugin = {
-	getInfo : function() {
-		return {
-			longname : 'insertresource plugin',
-			author : 'Mark Wu',
-			authorurl : 'http://blog.markplace.net',
-			infourl : 'http://blog.markplace.net',
-			version : "1.0"
-		};
-	},
-
-	initInstance : function(inst) {
-		tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/insertresource/css/content.css");		
-	},
-
-	getControlHTML : function(cn) {
-		switch (cn) {
-			case "insertresource":
-				return tinyMCE.getButtonHTML(cn, 'lang_insertresource_desc', '{$pluginurl}/images/insertresource.gif', 'mceinsertresource', true);
-		}
-
-		return "";
-	},
-
-	/**
-	 * Executes a specific command, this function handles plugin commands.
-	 *
-	 * @param {string} editor_id TinyMCE editor instance id that issued the command.
-	 * @param {HTMLElement} element Body or root element for the editor instance.
-	 * @param {string} command Command name to be executed.
-	 * @param {string} user_interface True/false if a user interface should be presented.
-	 * @param {mixed} value Custom value argument, can be anything.
-	 * @return true/false if the command was executed by this plugin or not.
-	 * @type
-	 */
-	execCommand : function(editor_id, element, command, user_interface, value) {
-		// Handle commands
-		switch (command) {
-			// Remember to have the "mce" prefix for commands so they don't intersect with built in ones in the browser.
-			case "mceinsertresource":
-				// Show UI/Popup
-				if (user_interface) {
-					// Open a popup window and send in some custom data in a window argument
-					var insertresource = new Array();
-
-					insertresource['file'] = '../../../../admin.php?op=resourceList&mode=1'; // Relative to theme
-					insertresource['width'] = 500;
-					insertresource['height'] = 450;
-
-					tinyMCE.openWindow(insertresource, {editor_id : editor_id, resizable : "yes", scrollbars : "yes"});
-
-					// Let TinyMCE know that something was modified
-					tinyMCE.triggerNodeChange(false);
-				} else {
-					// Do a command this gets called from the insertresource popup
-					alert("execCommand: mceinsertresource gets called from popup.");
-				}
-
-				return true;
-		}
-
-		// Pass to next handler in chain
-		return false;
-	},
-
-	cleanup : function(type, content) {
-		switch (type) {
-			case "insert_to_editor_dom":
-				// Force relative/absolute
-				if (tinyMCE.getParam('convert_urls')) {
-					var imgs = content.getElementsByTagName("img");
-					for (var i=0; i<imgs.length; i++) {
-						if (tinyMCE.getAttrib(imgs[i], "class") == "ltFlashPlayer") {
-							var src = tinyMCE.getAttrib(imgs[i], "alt");
-
-							if (tinyMCE.getParam('convert_urls'))
-								src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
-
-							imgs[i].setAttribute('alt', src);
-							imgs[i].setAttribute('title', src);
-						}
-					}
-				}
-				break;
-
-			case "get_from_editor_dom":
-				var imgs = content.getElementsByTagName("img");
-				for (var i=0; i<imgs.length; i++) {
-						if (tinyMCE.getAttrib(imgs[i], "class")== "ltFlashPlayer") {
-							var src = tinyMCE.getAttrib(imgs[i], "alt");
-
-							if (tinyMCE.getParam('convert_urls'))
-								src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
-
-								imgs[i].setAttribute('alt', src);
-								imgs[i].setAttribute('title', src);
-					}
-				}
-				break;
-
-			case "insert_to_editor":
-				var startPos = 0;
-				var embedList = new Array();			
-
-				// Fix the embed and object elements
-				content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
-				content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');			
-				
-				// Parse all object tags and replace them with images from the embed data
-				var index = 0;
-				while ((startPos = content.indexOf('<object', startPos)) != -1) {
-
-					// Find end of object
-					endPos = content.indexOf('</object>', startPos);
-					endPos += 9;
-					
-					objectTag = content.substring(startPos,endPos);
-					
-					/**
-					 * NOTE: this method call relies in a bug of the _parseAttributes method.
-					 * This method parses a tag and returns a list of its attributes. It works fine
-					 * when presented with a single tag but now that we're passing a whole <object>...</object>
-					 * block, it will also parse any other tags in the block. This means that it will return the
-					 * value we're looking for as long as "FlashVars" is passed as the last parameter
-					 * in the <object> block.
-					 */
-					attribs = TinyMCE_insertresourcePlugin._parseAttributes( objectTag );
-					
-					var cssClass = "";					
-					if( !attribs || attribs["value"] == undefined || attribs["class"] != "ltPlayer" ) {
-						startPos++;
-						continue;
-					}
-					
-					// find the value in "file=XXX"
-					var regexp = /.*file=([a-zA-Z0-9\-\/:._%]*)/i;
-					result = regexp.exec( attribs["value"] );
-					var fileUrl = "";
-					if( result ) {
-						fileUrl = result[1];
-					}			
-					//window.alert("val = " + attribs["value"] + " - " + fileUrl);		
-					
-					// default values for height and width in case they were not defined (for some reason)
-					if( attribs["height"] == undefined )
-						attribs["height"] = 20;
-					if( attribs["width"] == undefined )
-						attribs["width"] = 320;
-					// Insert image						
-					var contentAfter = content.substring(endPos);
-					content = content.substring(0, startPos);
-					content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
-					content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + fileUrl + '"';
-					content += ' alt="' + fileUrl + '" class="ltFlashPlayer" />' + content.substring(endPos);
-					content += contentAfter;
-					
-					index++;
-
-					startPos++;
-				}
-				
-				break;
-
-			case "get_from_editor":
-				// Parse all img tags and replace them with object+embed
-				var startPos = -1;
-
-				while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
-					var endPos = content.indexOf('/>', startPos);
-					var attribs = TinyMCE_insertresourcePlugin._parseAttributes(content.substring(startPos + 4, endPos));
-
-					// If not flash, skip it
-					if (!attribs || attribs['class'] != "ltFlashPlayer" )
-						continue;					
-
-					type = attribs['class'];
-
-					endPos += 2;
-
-					var embedHTML = '';
-					
-					if( attribs["height"] == undefined )
-						attribs["height"] = 20;
-					if( attribs["width"] == undefined )
-						attribs["width"] = 320;			
-						
-					embedHTML = getFlashPlayerHTML( attribs["alt"], attribs["height"], attribs["width"] );
-
-					// Insert embed/object chunk
-					chunkBefore = content.substring(0, startPos);
-					chunkAfter = content.substring(endPos);
-					content = chunkBefore + embedHTML + chunkAfter;
-				}
-				break;
-		}
-
-		// Pass through to next handler in chain
-		return content;
-	},
-
-	// Private plugin internal functions
-
-	_parseAttributes : function(attribute_string) {
-		var attributeName = "";
-		var attributeValue = "";
-		var withInName;
-		var withInValue;
-		var attributes = new Array();
-		var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
-
-		if (attribute_string == null || attribute_string.length < 2)
-			return null;
-
-		withInName = withInValue = false;
-
-		for (var i=0; i<attribute_string.length; i++) {
-			var chr = attribute_string.charAt(i);
-
-			if ((chr == '"' ) && !withInValue)
-				withInValue = true;
-			else if ((chr == '"' ) && withInValue) {
-				withInValue = false;
-
-				var pos = attributeName.lastIndexOf(' ');
-				if (pos != -1)
-					attributeName = attributeName.substring(pos+1);
-
-				attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
-
-				attributeName = "";
-				attributeValue = "";
-			} else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
-				withInName = true;
-
-			if (chr == '=' && withInName)
-				withInName = false;
-
-			if (withInName)
-				attributeName += chr;
-
-			if (withInValue)
-				attributeValue += chr;
-		}
-
-		return attributes;
-	}
-};
-
-tinyMCE.addPlugin("insertresource", TinyMCE_insertresourcePlugin);

Copied: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js (from rev 7042, plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js)
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js	                        (rev 0)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -0,0 +1,206 @@
+(function() {
+	// Load plugin specific language pack
+	tinymce.PluginManager.requireLangPack('insertresource');
+
+	tinymce.create('tinymce.plugins.InsertResourcePlugin', {
+		/**
+		 * Initializes the plugin, this will be executed after the plugin has been created.
+		 * This call is done before the editor instance has finished it's initialization so use the onInit event
+		 * of the editor instance to intercept that event.
+		 *
+		 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+		 * @param {string} url Absolute URL to where the plugin is located.
+		 */
+		init : function(ed, url) {
+			// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceInsertResource');
+			ed.addCommand('mceInsertResource', function() {
+				ed.windowManager.open({
+                    file : '../../../../admin.php?op=resourceList&mode=1'; // Relative to theme
+					width : 500 + parseInt(ed.getLang('InsertResource.delta_width', 0)),
+					height : 450 + parseInt(ed.getLang('InsertResource.delta_height', 0)),
+					inline : 1
+				}, {
+					plugin_url : url, // Plugin absolute URL
+				});
+			});
+
+			// Register insertresource button
+			ed.addButton('insertresource', {
+				title : 'insertresource.desc',
+				cmd : 'mceInsertResource',
+				image : url + '/img/insertresource.gif'
+			});
+
+            ed.onInit.add(function() {
+                    if (ed.settings.content_css !== false)
+                        ed.dom.loadCSS(url + "/css/content.css");
+            });
+
+			// Add a node change handler, selects the button in the UI when a image is selected
+			ed.onNodeChange.add(function(ed, cm, n) {
+				cm.setActive('insertresource', n.nodeName == 'IMG');
+			});
+		},
+
+		/**
+		 * Creates control instances based in the incomming name. This method is normally not
+		 * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
+		 * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
+		 * method can be used to create those.
+		 *
+		 * @param {String} n Name of the control to create.
+		 * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
+		 * @return {tinymce.ui.Control} New control instance or null if no control was created.
+		 */
+		createControl : function(n, cm) {
+			return null;
+		},
+
+		/**
+		 * Returns information about the plugin as a name/value array.
+		 * The current keys are longname, author, authorurl, infourl and version.
+		 *
+		 * @return {Object} Name/value array containing information about the plugin.
+		 */
+		getInfo : function() {
+			return {
+				longname : 'InsertResource plugin',
+				author : 'LifeType',
+				authorurl : 'http://lifetype.net',
+				infourl : '',
+				version : "1.0"
+			};
+		}
+        });
+/////////////////////////////////////
+
+	cleanup : function(type, content) {
+		switch (type) {
+			case "insert_to_editor_dom":
+				// Force relative/absolute
+				if (tinyMCE.getParam('convert_urls')) {
+					var imgs = content.getElementsByTagName("img");
+					for (var i=0; i<imgs.length; i++) {
+						if (tinyMCE.getAttrib(imgs[i], "class") == "ltFlashPlayer") {
+							var src = tinyMCE.getAttrib(imgs[i], "alt");
+
+							if (tinyMCE.getParam('convert_urls'))
+								src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
+
+							imgs[i].setAttribute('alt', src);
+							imgs[i].setAttribute('title', src);
+						}
+					}
+				}
+				break;
+
+			case "get_from_editor_dom":
+				var imgs = content.getElementsByTagName("img");
+				for (var i=0; i<imgs.length; i++) {
+						if (tinyMCE.getAttrib(imgs[i], "class")== "ltFlashPlayer") {
+							var src = tinyMCE.getAttrib(imgs[i], "alt");
+
+							if (tinyMCE.getParam('convert_urls'))
+								src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, null, true);");
+
+								imgs[i].setAttribute('alt', src);
+								imgs[i].setAttribute('title', src);
+					}
+				}
+				break;
+
+			case "insert_to_editor":
+				var startPos = 0;
+				var embedList = new Array();			
+
+				// Fix the embed and object elements
+				content = content.replace(new RegExp('<[ ]*object','gi'),'<object');
+				content = content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');			
+				
+				// Parse all object tags and replace them with images from the embed data
+				var index = 0;
+				while ((startPos = content.indexOf('<object', startPos)) != -1) {
+
+					// Find end of object
+					endPos = content.indexOf('</object>', startPos);
+					endPos += 9;
+					
+					objectTag = content.substring(startPos,endPos);
+					
+					/**
+					 * NOTE: this method call relies in a bug of the _parseAttributes method.
+					 * This method parses a tag and returns a list of its attributes. It works fine
+					 * when presented with a single tag but now that we're passing a whole <object>...</object>
+					 * block, it will also parse any other tags in the block. This means that it will return the
+					 * value we're looking for as long as "FlashVars" is passed as the last parameter
+					 * in the <object> block.
+					 */
+					attribs = TinyMCE_insertresourcePlugin._parseAttributes( objectTag );
+					
+					var cssClass = "";					
+					if( !attribs || attribs["value"] == undefined || attribs["class"] != "ltPlayer" ) {
+						startPos++;
+						continue;
+					}
+					
+					// find the value in "file=XXX"
+					var regexp = /.*file=([a-zA-Z0-9\-\/:._%]*)/i;
+					result = regexp.exec( attribs["value"] );
+					var fileUrl = "";
+					if( result ) {
+						fileUrl = result[1];
+					}			
+					//window.alert("val = " + attribs["value"] + " - " + fileUrl);		
+					
+					// default values for height and width in case they were not defined (for some reason)
+					if( attribs["height"] == undefined )
+						attribs["height"] = 20;
+					if( attribs["width"] == undefined )
+						attribs["width"] = 320;
+					// Insert image						
+					var contentAfter = content.substring(endPos);
+					content = content.substring(0, startPos);
+					content += '<img width="' + attribs["width"] + '" height="' + attribs["height"] + '"';
+					content += ' src="' + (tinyMCE.getParam("theme_href") + '/images/spacer.gif') + '" title="' + fileUrl + '"';
+					content += ' alt="' + fileUrl + '" class="ltFlashPlayer" />' + content.substring(endPos);
+					content += contentAfter;
+					
+					index++;
+
+					startPos++;
+				}
+				
+				break;
+
+			case "get_from_editor":
+				// Parse all img tags and replace them with object+embed
+				var startPos = -1;
+
+				while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
+					var endPos = content.indexOf('/>', startPos);
+					var attribs = TinyMCE_insertresourcePlugin._parseAttributes(content.substring(startPos + 4, endPos));
+
+					// If not flash, skip it
+					if (!attribs || attribs['class'] != "ltFlashPlayer" )
+						continue;					
+
+					type = attribs['class'];
+
+					endPos += 2;
+
+					var embedHTML = '';
+					
+					if( attribs["height"] == undefined )
+						attribs["height"] = 20;
+					if( attribs["width"] == undefined )
+						attribs["width"] = 320;			
+						
+					embedHTML = getFlashPlayerHTML( attribs["alt"], attribs["height"], attribs["width"] );
+
+					// Insert embed/object chunk
+					chunkBefore = content.substring(0, startPos);
+					chunkAfter = content.substring(endPos);
+					content = chunkBefore + embedHTML + chunkAfter;
+				}
+				break;
+		}

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en.js	2010-09-22 21:54:59 UTC (rev 7047)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -1,6 +1,3 @@
-// UK lang variables
-
-/* Remember to namespace the language parameters lang_<your plugin>_<some name> */
-
-tinyMCELang['lang_insertresource_title'] = 'Insert Resource/Album';
-tinyMCELang['lang_insertresource_desc'] = 'Insert Resource/Album';
+tinyMCE.addI18n('en.insertresource',{
+	title : 'Insert Resource/Album'
+});

Added: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en_dlg.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en_dlg.js	                        (rev 0)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/en_dlg.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('en.insertresource_dlg',{
+	title : 'Insert Resource/Album'
+});

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr.js	2010-09-22 21:54:59 UTC (rev 7047)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -1,6 +1,3 @@
-// UK lang variables
-
-/* Remember to namespace the language parameters lang_<your plugin>_<some name> */
-
-tinyMCELang['lang_insertresource_title'] = 'Ins&eacute;rer ressource/album';
-tinyMCELang['lang_insertresource_desc'] = 'Ins&eacute;rer ressource/album';
+tinyMCE.addI18n('fr.insertresource',{
+	title : 'Ins&eacute;rer ressource/album'
+});

Copied: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr_dlg.js (from rev 7042, plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr.js)
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr_dlg.js	                        (rev 0)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/langs/fr_dlg.js	2010-09-22 21:59:33 UTC (rev 7048)
@@ -0,0 +1,3 @@
+tinyMCE.addI18n('fr.insertresource_dlg',{
+	title : 'Ins&eacute;rer ressource/album'
+});



More information about the pLog-svn mailing list