[pLog-svn] r6821 - in plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio: . images langs

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Feb 21 14:56:23 EST 2009


Author: jondaley
Date: 2009-02-21 14:56:23 -0500 (Sat, 21 Feb 2009)
New Revision: 6821

Removed:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/css/
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/functions.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/images/player.png
Modified:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/audioinput.html
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/editor_plugin.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/en.js
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/fr.js
Log:
wow.  when oscar complained about this code, I had no idea how bad it was.  I've removed about 75% of the code, and now it works much better...

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/audioinput.html
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/audioinput.html	2009-02-21 19:52:13 UTC (rev 6820)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/audioinput.html	2009-02-21 19:56:23 UTC (rev 6821)
@@ -2,7 +2,7 @@
 <head>
 	<title>{$lang_insertaudio_desc}</title>
 	<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
-	<script language="javascript" type="text/javascript" src="functions.js"></script>	
+	<script language="javascript" type="text/javascript" src="../../tiny_mce-plog-resourcelist.js"></script>	
 	<base target="_self" />
 </head>
 <body style="display: none">
@@ -25,7 +25,9 @@
 		</div>
 		<div class="mceActionPanel">
 		  <div style="float:left">		
-			<input type="button" name="insert" value="{$lang_insert}" onClick="insertAudioCode()" id="insert" />
+			<input type="button" name="insert" value="{$lang_insert}" 
+                   onClick="insertMediaPlayer(document.audio.url.value,
+                            true,'20','300')" id="insert" />
 		  </div>
 		  <div style="float:right">
 		    <input type="button" name="cancel" value="{$lang_close}" onclick="tinyMCEPopup.close();" id="cancel" />

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/editor_plugin.js	2009-02-21 19:52:13 UTC (rev 6820)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/editor_plugin.js	2009-02-21 19:56:23 UTC (rev 6821)
@@ -9,14 +9,10 @@
 			author : 'Gabriel ROUSSEAU',
 			authorurl : 'http://grvg.free.fr',
 			infourl : 'http://grvg.free.fr',
-			version : "0.3"
+			version : "0.4"
 		};
 	},
 
-	initInstance : function(inst) {
-		tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/insertaudio/css/content.css");	
-	},
-
 	getControlHTML : function(cn) {
 		switch (cn) {
 			case "insertaudio":
@@ -51,202 +47,14 @@
 					insertaudio['width'] = 500;
 					insertaudio['height'] = 120;
 
-					tinyMCE.openWindow(insertaudio, {editor_id : editor_id, resizable : "no", scrollbars : "no", inline : "yes"});
-				}
+					tinyMCE.openWindow(insertaudio, {editor_id : editor_id, resizable : "no", scrollbars : "no", inline : "yes"});	
+			}
 				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")== "ltVideoYouTube") {
-						if (tinyMCE.getAttrib(imgs[i], "class").substr(0,6) == "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").substr(0,6) == "ltAudio") {
-						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);
-					attribs = TinyMCE_insertaudioPlugin._parseAttributes( objectTag );
-					
-					var cssClass = "";					
-					if( attribs["data"] == undefined )
-					{
-						startPos++;
-						continue;
-					} else {
-						cssClass = "ltPlayer";
-					}
-					
-					// 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="' + attribs["data"] + '"';
-					content += ' alt="' + attribs["data"] + '" class="'+cssClass+'" />' + 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_insertaudioPlugin._parseAttributes(content.substring(startPos + 4, endPos));
-
-					// Is not flash, skip it
-					if (attribs['class'] != "ltFlashPlayer")
-						continue;
-
-					type = attribs['class'];
-
-					endPos += 2;
-
-					var embedHTML = '';
-					
-					embedHTML = getAudioFlashHTML( attribs["title"] );
-
-					// 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;
-	},
-
-	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
-		if (node == null)
-			return;
-
-		do {
-			if (node.nodeName == "IMG" && tinyMCE.getAttrib(node, 'class').indexOf('ltFlashPlayer') == 0) {
-				tinyMCE.switchClass(editor_id + '_flash', 'mceButtonSelected');
-				return true;
-			}
-		} while ((node = node.parentNode));
-
-		tinyMCE.switchClass(editor_id + '_flash', 'mceButtonNormal');
-
-		return true;
-	},
-
-	// 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 == '"' || chr == "'") && !withInValue)
-				withInValue = true;
-			else if ((chr == '"' || 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;
-	}
 };
 
-function getAudioFlashHTML( url )
-{		
-	var baseUrl = TinyMCE.baseURL.substring(0, TinyMCE.baseURL.indexOf("/js/tinymce",0));
-	var playerUrl = baseUrl + "/flash/mp3player/mp3player.swf";
-		
-	var html =	'<object data="'+playerUrl+'" type="application/x-shockwave-flash" width="320" height="20" class="ltPlayer">'+
-			'<param name="quality" value="best" />'+
-			'<param name="bgcolor" value="#FFFFFF" />'+
-            '<param name="movie" value="' + playerUrl + '" />' +
-			'<param name="FlashVars" value="&amp;file='+url+'&amp;height=20&amp;width=320" />'+
-			'</object>';
-	
-	return( html );
-}
-
-tinyMCE.addPlugin("insertaudio", TinyMCE_insertaudioPlugin );
\ No newline at end of file
+tinyMCE.addPlugin("insertaudio", TinyMCE_insertaudioPlugin );

Deleted: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/functions.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/functions.js	2009-02-21 19:52:13 UTC (rev 6820)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/functions.js	2009-02-21 19:56:23 UTC (rev 6821)
@@ -1,41 +0,0 @@
-function init() {
-	tinyMCEPopup.resizeToInnerSize();
-}
-
-function isValidUrl( url )
-{
-	var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
-	return regexp.test(url);
-}
-
-function insertAudioCode()
-{
-	// get and check the URL
-	urlField = document.forms[0].url;
-	url = urlField.value;
-	if( url == "" || !isValidUrl( url )) {
-		window.alert( tinyMCE.getLang('lang_insertvideo_badurl', 0) );
-		return( false );
-	}
-
-	css="ltFlashPlayer";
-	width=320;
-	height=20;
-	
-	insertFlash( url, css, width, height );
-}
-
-function insertFlash( file, css, width, height ) {
-
-	var html      = '';
-
-	html += ''
-		+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" mce_src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
-		+ 'width="' + width + '" height="' + height + '" '
-		+ 'border="0" alt="' + file + '" title="' + file + '" class="'+css+'" />';
-
-	tinyMCEPopup.execCommand("mceInsertContent", true, html);
-	tinyMCE.selectedInstance.repaint();
-
-	tinyMCEPopup.close();
-}
\ No newline at end of file

Deleted: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/images/player.png
===================================================================
(Binary files differ)

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/en.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/en.js	2009-02-21 19:52:13 UTC (rev 6820)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/en.js	2009-02-21 19:56:23 UTC (rev 6821)
@@ -3,6 +3,5 @@
 lang_insertaudio_desc : 'Insert Audio',
 lang_insertaudio_panellegend : 'Please provide a link to an mp3 audio file.',
 lang_insertaudio_url : 'Audio URL:',
-lang_insertaudio_badurl : 'Invalid URL',
 lang_insertaudio_inputurlstyle : 'style="width:350px"'
-});
\ No newline at end of file
+});

Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/fr.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/fr.js	2009-02-21 19:52:13 UTC (rev 6820)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertaudio/langs/fr.js	2009-02-21 19:56:23 UTC (rev 6821)
@@ -3,6 +3,5 @@
 lang_insertaudio_desc : 'Ins&eacute;rer audio',
 lang_insertaudio_panellegend : 'Veuillez indiquer un lien vers un fichier audio mp3.',
 lang_insertaudio_url : 'URL du fichier audio :',
-lang_insertaudio_badurl : 'L\'URL indique n\'est pas valide',
 lang_insertaudio_inputurlstyle : 'style="width:300px"'
-});
\ No newline at end of file
+});



More information about the pLog-svn mailing list