diff options
-rwxr-xr-x | js/components/tools-properties/tag-properties.reel/tag-properties.js | 14 | ||||
-rwxr-xr-x | js/document/mediators/template.js | 10 | ||||
-rwxr-xr-x | js/document/views/design.js | 25 |
3 files changed, 36 insertions, 13 deletions
diff --git a/js/components/tools-properties/tag-properties.reel/tag-properties.js b/js/components/tools-properties/tag-properties.reel/tag-properties.js index ab745049..f14183e0 100755 --- a/js/components/tools-properties/tag-properties.reel/tag-properties.js +++ b/js/components/tools-properties/tag-properties.reel/tag-properties.js | |||
@@ -54,6 +54,7 @@ var TagProperties = exports.TagProperties = Montage.create(ToolProperties, { | |||
54 | this.divElement.addEventListener("click", this, false); | 54 | this.divElement.addEventListener("click", this, false); |
55 | this.imageElement.addEventListener("click", this, false); | 55 | this.imageElement.addEventListener("click", this, false); |
56 | this.videoElement.addEventListener("click", this, false); | 56 | this.videoElement.addEventListener("click", this, false); |
57 | this.videoElement.addEventListener("canplay", this, false); | ||
57 | this.canvasElement.addEventListener("click", this, false); | 58 | this.canvasElement.addEventListener("click", this, false); |
58 | this.customElement.addEventListener("click", this, false); | 59 | this.customElement.addEventListener("click", this, false); |
59 | } | 60 | } |
@@ -99,6 +100,19 @@ var TagProperties = exports.TagProperties = Montage.create(ToolProperties, { | |||
99 | } | 100 | } |
100 | } | 101 | } |
101 | }, | 102 | }, |
103 | |||
104 | handleCanplay: { | ||
105 | value: function (e) { | ||
106 | //TODO: Figure out why the video must be seeked to the end before pausing | ||
107 | var time = Math.ceil(this.duration); | ||
108 | //Trying to display the last frame (doing minus 2 seconds if long video) | ||
109 | if (time > 2) this.currentTime = time - 2; | ||
110 | else if (time > 1) this.currentTime = time - 1; | ||
111 | else this.currentTime = time || 0; | ||
112 | //Pauing video | ||
113 | this.pause(); | ||
114 | } | ||
115 | }, | ||
102 | 116 | ||
103 | _selectedElement: { | 117 | _selectedElement: { |
104 | value: "div", enumerable: false | 118 | value: "div", enumerable: false |
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, { | |||
220 | linktags = template.file.content.document.getElementsByTagName('link'), | 220 | linktags = template.file.content.document.getElementsByTagName('link'), |
221 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); | 221 | njtemplatetags = template.file.content.document.querySelectorAll('[data-ninja-template]'); |
222 | 222 | ||
223 | ////////////////////////////////////////////////// | ||
224 | //TODO: Remove, temp hack, this is to be fixed by Montage | ||
225 | var basetags = template.file.content.document.getElementsByTagName('base'); | ||
226 | for (var g in basetags) { | ||
227 | if (basetags[g].getAttribute && basetags[g].href && basetags[g].href.indexOf('chrome-extension://') !== -1) toremovetags.push(basetags[g]); | ||
228 | } | ||
229 | ////////////////////////////////////////////////// | ||
230 | |||
231 | //Adding to tags to be removed form template | 223 | //Adding to tags to be removed form template |
232 | for (var f in njtemplatetags) { | 224 | for (var f in njtemplatetags) { |
233 | if (njtemplatetags[f].getAttribute) toremovetags.push(njtemplatetags[f]); | 225 | if (njtemplatetags[f].getAttribute) toremovetags.push(njtemplatetags[f]); |
@@ -284,8 +276,6 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
284 | 276 | ||
285 | 277 | ||
286 | 278 | ||
287 | |||
288 | |||
289 | //TODO: Make proper CSS method | 279 | //TODO: Make proper CSS method |
290 | 280 | ||
291 | 281 | ||
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, { | |||
285 | userStyles, | 285 | userStyles, |
286 | stags = this.document.getElementsByTagName('style'), | 286 | stags = this.document.getElementsByTagName('style'), |
287 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, | 287 | ltags = this.document.getElementsByTagName('link'), i, orgNodes, |
288 | scripttags = this.document.getElementsByTagName('script'); | 288 | scripttags = this.document.getElementsByTagName('script'), |
289 | videotags = this.document.getElementsByTagName('video'); | ||
289 | //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) | 290 | //Temporarily checking for disabled special case (we must enabled for Ninja to access styles) |
290 | this.ninjaDisableAttribute(stags); | 291 | this.ninjaDisableAttribute(stags); |
291 | this.ninjaDisableAttribute(ltags); | 292 | this.ninjaDisableAttribute(ltags); |
@@ -308,10 +309,28 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { | |||
308 | } | 309 | } |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | //Checking for video tags | |
313 | if (videotags.length > 0) { | ||
314 | //Looping through all video tags | ||
315 | for (i = 0; i < videotags.length; i++) { | ||
316 | //Stopping all videos from playing | ||
317 | if (videotags[i].getAttribute && videotags[i].getAttribute('autoplay') !== null) { | ||
318 | //Stopping the video on open | ||
319 | videotags[i].addEventListener('canplay', function(e) { | ||
320 | //TODO: Figure out why the video must be seeked to the end before pausing | ||
321 | var time = Math.ceil(this.duration); | ||
322 | //Trying to display the last frame (doing minus 2 seconds if long video) | ||
323 | if (time > 2) this.currentTime = time - 2; | ||
324 | else if (time > 1) this.currentTime = time - 1; | ||
325 | else this.currentTime = time || 0; | ||
326 | //Pauing video | ||
327 | this.pause(); | ||
328 | }, false); | ||
329 | } | ||
330 | } | ||
331 | } | ||
312 | // Assign the modelGenerator reference from the template to our own modelGenerator | 332 | // Assign the modelGenerator reference from the template to our own modelGenerator |
313 | this.document.modelGenerator = ElementModel.modelGenerator; | 333 | this.document.modelGenerator = ElementModel.modelGenerator; |
314 | |||
315 | //Checking for script tags then parsing check for montage and webgl | 334 | //Checking for script tags then parsing check for montage and webgl |
316 | if (scripttags.length > 0) { | 335 | if (scripttags.length > 0) { |
317 | //Checking and initializing webGL | 336 | //Checking and initializing webGL |