You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2009/04/22 23:03:56 UTC

svn commit: r767658 - in /labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0: ./ dijit/ dijit/_editor/ dijit/_editor/nls/ dijit/_editor/plugins/ dijit/_editor/resources/

Author: simoneg
Date: Wed Apr 22 21:03:55 2009
New Revision: 767658

URL: http://svn.apache.org/viewvc?rev=767658&view=rev
Log:
LABS-350 : Dojo 1.3.0

Added:
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/YoutubeVideoDialog.js
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/YoutubeVideoDialog.js
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/YouTube.css
    labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/youtube_icon.gif   (with props)

Added: labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/YoutubeVideoDialog.js
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/YoutubeVideoDialog.js?rev=767658&view=auto
==============================================================================
--- labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/YoutubeVideoDialog.js (added)
+++ labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/nls/YoutubeVideoDialog.js Wed Apr 22 21:03:55 2009
@@ -0,0 +1 @@
+({"set":"Set","text":"Description:","YoutubeVideoDialogTitle":"YouTube video","url":"URL:"})
\ No newline at end of file

Added: labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/YoutubeVideoDialog.js
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/YoutubeVideoDialog.js?rev=767658&view=auto
==============================================================================
--- labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/YoutubeVideoDialog.js (added)
+++ labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/plugins/YoutubeVideoDialog.js Wed Apr 22 21:03:55 2009
@@ -0,0 +1,181 @@
+/*
+	Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
+	Available via Academic Free License >= 2.1 OR the modified BSD license.
+	see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dijit._editor.plugins.YoutubeVideoDialog"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dijit._editor.plugins.YoutubeVideoDialog"] = true;
+dojo.provide("dijit._editor.plugins.YoutubeVideoDialog");
+
+dojo.require("dijit._Widget");
+dojo.require("dijit._Templated");
+dojo.require("dijit._editor._Plugin");
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.ValidationTextBox");
+dojo.require("dojo.i18n");
+dojo.require("dojo.string");
+dojo.requireLocalization("dijit._editor", "YoutubeVideoDialog", null, "ROOT");
+
+dojo.declare("dijit._editor.plugins.YoutubeVideoDialog",
+	dijit._editor._Plugin,
+	{
+		//	summary:
+		//		This plugin provides dialogs for inserting links only, so that images
+	    //      can be handled more specifically
+		//
+		//	description:
+		//		The commands provided by this plugin are:
+		//		* createLink
+
+		buttonClass: dijit.form.DropDownButton,
+		iconClassPrefix: "dijitEditorIcon",
+		useDefaultCommand: false,
+		urlRegExp: "http\\://www.youtube.com/watch\\?v\\=([0-9a-zA-Z\\_\\-]*)",
+		objTemplate: "<object width='425' height='344'><param name='movie' " + 
+		  "value='http://www.youtube.com/v/${videoid}&fs=1'></param>" +
+		  "<param name='allowFullScreen' value='true'></param>"+
+		  "<param name='allowscriptaccess' value='always'></param>" +
+		  "<embed src='http://www.youtube.com/v/${videoid}&fs=1' " +
+		  "type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' " +
+		  "width='425' height='344'></embed>" +
+		  "</object>",
+		mockTemplate: "<img dojoyoutube='${videoid}' width='425' height='344' dojomock='true'/>",
+		
+		linkDialogTemplate: [
+			"<table><tr><td>",
+			"<label for='${id}_urlInput'>${url}</label>",
+			"</td><td>",
+			"<input dojoType='dijit.form.ValidationTextBox' regExp='${urlRegExp}' required='true' id='${id}_urlInput' name='urlInput'>",
+			"</td></tr><tr><td colspan='2'>",
+			"<button dojoType='dijit.form.Button' type='submit'>${set}</button>",
+			"</td></tr></table>"
+		].join(""),
+
+		_initButton: function(props){
+			var _this = this;
+			this.tag = 'object';
+			var messages = dojo.i18n.getLocalization("dijit._editor", "YoutubeVideoDialog", this.lang);
+			var dropDown = (this.dropDown = new dijit.TooltipDialog({
+				title: messages["YoutubeVideoDialogTitle"],
+				execute: dojo.hitch(this, "setValue"),
+				onOpen: function(){
+					_this._onOpenDialog();
+					dijit.TooltipDialog.prototype.onOpen.apply(this, arguments);
+				},
+				onCancel: function(){
+					setTimeout(dojo.hitch(_this, "_onCloseDialog"),0);
+				},
+				onClose: dojo.hitch(this, "_onCloseDialog")
+			}));
+			messages.urlRegExp = this.urlRegExp;
+			messages.id = dijit.getUniqueId(this.editor.id);
+			this._setContent(dropDown.title + "<div style='border-bottom: 1px black solid;padding-bottom:2pt;margin-bottom:4pt'></div>" + dojo.string.substitute(this.linkDialogTemplate, messages));
+			dropDown.startup();
+
+			var label = messages["YoutubeVideoDialogTitle"];
+			var className = this.iconClassPrefix+" "+this.iconClassPrefix + "YouTube";
+			if(!this.button){
+				props = dojo.mixin({
+					label: label,
+					showLabel: false,
+					iconClass: className,
+					dropDown: this.dropDown,
+					tabIndex: "-1"
+				}, props || {});
+				this.button = new this.buttonClass(props);
+			}
+		},
+
+		_setContent: function(staticPanel){
+			this.dropDown.attr('content', staticPanel);
+		},
+		
+		getLabel: function(key){
+			return "YouTube";
+		},		
+		
+		setValue: function(args){
+			// summary: callback from the dialog when user hits "set" button
+			//TODO: prevent closing popup if the text is empty
+			this._onCloseDialog();
+			if(dojo.isIE){ //see #4151
+				var a = dojo.withGlobal(this.editor.window, "getAncestorElement", dijit._editor.selection, [this.tag]);
+				if(a){
+					dojo.withGlobal(this.editor.window, "selectElement", dijit._editor.selection, [a]);
+				}
+			}
+			args.tag = this.tag;
+			args.refAttr = 'href';
+			args.videoid = args.urlInput.match(this.urlRegExp)[1];
+			//TODO: textInput should be formatted by escapeXm1
+			this.editor.execCommand('inserthtml', dojo.string.substitute(this.mockTemplate, args));
+ 		},
+
+		_onCloseDialog: function(){
+			this.editor.focus();
+		},
+		
+		setEditor: function(){
+			this.inherited(arguments);
+			this.onEditorLoaded();
+		},
+		onEditorLoaded: function(){
+			this.editor.contentPostFilters.push(dojo.hitch(this, "replaceWithRealVideos"));
+		},
+				
+		replaceWithRealVideos: function(html){
+			var objTemplate = this.objTemplate;
+			return html.replace(/\<img[^>]*dojoyoutube\=["']([a-zA-Z0-9\-\_]*)['"][^>]*\>/g, function(match, videoid) {
+					return dojo.string.substitute(objTemplate, {videoid: videoid});
+			});
+		},
+		
+		_onOpenDialog: function(){
+			this.dropDown.reset();
+			this.dropDown.setValues({urlInput: ''});
+			//dijit.focus(this.urlInput);
+		}/*,
+
+//TODO we don't show this state anymore
+		updateState: function(){
+			// summary: change shading on button if we are over a link (or not)
+
+			var _e = this.editor;
+			if(!_e || !_e.isLoaded){ return; }
+			if(this.button){
+				// display button differently if there is an existing link associated with the current selection
+				var hasA = dojo.withGlobal(this.editor.window, "hasAncestorElement", dijit._editor.selection, [this.tag]);
+				this.button.attr('checked', hasA);
+			}
+		}
+*/
+	}
+);
+
+dojo.subscribe(dijit._scopeName + ".Editor.getPlugin",null,function(o){
+	if(o.plugin){ return; }
+	if (o.args.command == "youtube") {
+		try {
+			o.plugin = new dijit._editor.plugins.YoutubeVideoDialog({command: "inserthtml"});
+		} catch (e) {
+			alert(e);
+		}
+	}
+});
+
+dojo.subscribe(dijit._scopeName + "._editor.RichText::init", null, function(editor) {
+	editor.contentPreFilters.push(function(html){
+			var mockTemplate = "<img dojoyoutube='${videoid}' width='425' height='344' dojomock='true'/>";
+			return html.replace(/\<object .*\<param .*value\=["']http\:\/\/www\.youtube\.com\/v\/([0-9a-zA-Z]*).*\<\/object\>/g, function(match, videoid) {
+  					return dojo.string.substitute(mockTemplate, {videoid: videoid});
+  			});
+		});	
+});
+
+
+
+
+}

Added: labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/YouTube.css
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/YouTube.css?rev=767658&view=auto
==============================================================================
--- labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/YouTube.css (added)
+++ labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/YouTube.css Wed Apr 22 21:03:55 2009
@@ -0,0 +1,3 @@
+.dijitEditorIcon.dijitEditorIconYouTube {
+	background-image: url(youtube_icon.gif);
+}
\ No newline at end of file

Added: labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/youtube_icon.gif
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/youtube_icon.gif?rev=767658&view=auto
==============================================================================
Binary file - no diff available.

Propchange: labs/magma/trunk/website-dojo-textareas-youtubevideo/src/main/resources/dojo-1.3.0/dijit/_editor/resources/youtube_icon.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org