From c37f2cb15b90d7315e9580fee1ae7f6e0694052c Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Thu, 28 Jun 2012 16:50:46 -0700
Subject: Preventing video playback on open

This stops all videos from playing on open file. The same fix needs to be applied when an users sets autoplay in the PI.
---
 js/document/mediators/template.js | 10 ----------
 js/document/views/design.js       | 25 ++++++++++++++++++++++---
 2 files changed, 22 insertions(+), 13 deletions(-)

(limited to 'js/document')

diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js
index f43b1a2c..015a50ff 100755
--- a/js/document/mediators/template.js
+++ b/js/document/mediators/template.js
@@ -220,14 +220,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
     			linktags = template.file.content.document.getElementsByTagName('link'),
     			njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]');
     		
-    		//////////////////////////////////////////////////
-    		//TODO: Remove, temp hack, this is to be fixed by Montage
-    		var basetags = template.file.content.document.getElementsByTagName('base');
-    		for (var g in basetags) {
-    			if (basetags[g].getAttribute && basetags[g].href && basetags[g].href.indexOf('chrome-extension://') !== -1) toremovetags.push(basetags[g]);
-    		}
-    		//////////////////////////////////////////////////
-    		
     		//Adding to tags to be removed form template
     		for (var f in njtemplatetags) {
     			if (njtemplatetags[f].getAttribute) toremovetags.push(njtemplatetags[f]);
@@ -284,8 +276,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, {
             
             
             
-            
-            
             //TODO: Make proper CSS method
             
             
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 6a60e1f9..fea607ef 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -285,7 +285,8 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
                 userStyles,
                 stags = this.document.getElementsByTagName('style'),
             	ltags = this.document.getElementsByTagName('link'), i, orgNodes,
-            	scripttags = this.document.getElementsByTagName('script');
+            	scripttags = this.document.getElementsByTagName('script'),
+            	videotags = this.document.getElementsByTagName('video');
            	//Temporarily checking for disabled special case (we must enabled for Ninja to access styles)
            	this.ninjaDisableAttribute(stags);
            	this.ninjaDisableAttribute(ltags);
@@ -308,10 +309,28 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
 					}
 				}
 			}
-
+			//Checking for video tags
+			if (videotags.length > 0) {
+				//Looping through all video tags
+				for (i = 0; i < videotags.length; i++) {
+					//Stopping all videos from playing
+					if (videotags[i].getAttribute && videotags[i].getAttribute('autoplay') !== null) {
+						//Stopping the video on open
+						videotags[i].addEventListener('canplay', function(e) {
+							//TODO: Figure out why the video must be seeked to the end before pausing
+  							var time = Math.ceil(this.duration);
+  							//Trying to display the last frame (doing minus 2 seconds if long video)
+  							if (time > 2) this.currentTime = time - 2;
+  							else if (time > 1) this.currentTime = time - 1;
+  							else this.currentTime = time || 0;
+  							//Pauing video
+  							this.pause();
+  						}, false);
+					}
+				}
+			}
             // Assign the modelGenerator reference from the template to our own modelGenerator
             this.document.modelGenerator = ElementModel.modelGenerator;
-
            	//Checking for script tags then parsing check for montage and webgl
             if (scripttags.length > 0) {
             	//Checking and initializing webGL
-- 
cgit v1.2.3


From 8a9ac2255b9161102be21fca23ba892665fe75ab Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Fri, 29 Jun 2012 14:26:13 -0700
Subject: fixing some

Signed-off-by: Valerio Virgillito <valerio@motorola.com>
---
 js/document/views/design.js | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

(limited to 'js/document')

diff --git a/js/document/views/design.js b/js/document/views/design.js
index fea607ef..b7c50a7c 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -313,20 +313,17 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
 			if (videotags.length > 0) {
 				//Looping through all video tags
 				for (i = 0; i < videotags.length; i++) {
-					//Stopping all videos from playing
-					if (videotags[i].getAttribute && videotags[i].getAttribute('autoplay') !== null) {
-						//Stopping the video on open
-						videotags[i].addEventListener('canplay', function(e) {
-							//TODO: Figure out why the video must be seeked to the end before pausing
-  							var time = Math.ceil(this.duration);
-  							//Trying to display the last frame (doing minus 2 seconds if long video)
-  							if (time > 2) this.currentTime = time - 2;
-  							else if (time > 1) this.currentTime = time - 1;
-  							else this.currentTime = time || 0;
-  							//Pauing video
-  							this.pause();
-  						}, false);
-					}
+					//Stopping all videos from playing on open
+                    videotags[i].addEventListener('canplay', function(e) {
+                        //TODO: Figure out why the video must be seeked to the end before pausing
+                        var time = Math.ceil(this.duration);
+                        //Trying to display the last frame (doing minus 2 seconds if long video)
+                        if (time > 2) this.currentTime = time - 2;
+                        else if (time > 1) this.currentTime = time - 1;
+                        else this.currentTime = time || 0;
+                        //Pauing video
+                        this.pause();
+                    }, false);
 				}
 			}
             // Assign the modelGenerator reference from the template to our own modelGenerator
-- 
cgit v1.2.3