aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/styles-controller.js22
-rwxr-xr-xjs/document/mediators/template.js10
-rwxr-xr-xjs/document/views/design.js22
-rwxr-xr-xjs/tools/TagTool.js24
-rw-r--r--manifest.json2
5 files changed, 62 insertions, 18 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 478fc1db..6e363798 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -632,7 +632,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
632 if(!rule) { 632 if(!rule) {
633 ///// This should never be hit if providing cssText from existing rule (like those 633 ///// This should never be hit if providing cssText from existing rule (like those
634 ///// returned from getMatchedCSSRules() 634 ///// returned from getMatchedCSSRules()
635 console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.'); 635 //console.warn('StylesController::_getRuleWithCSSText - No rule found with given cssText.');
636 } 636 }
637 637
638 return rule; 638 return rule;
@@ -646,16 +646,31 @@ var stylesController = exports.StylesController = Montage.create(Component, {
646 getMatchingRules : { //TODO: Remove omitPseudos from here and usages 646 getMatchingRules : { //TODO: Remove omitPseudos from here and usages
647 value: function(element, omitPseudos, useStageStyleSheet) { 647 value: function(element, omitPseudos, useStageStyleSheet) {
648 var rules, 648 var rules,
649 matchedRules,
649 mappedRules, 650 mappedRules,
650 doc = element.ownerDocument, 651 doc = element.ownerDocument,
651 win = doc.defaultView; 652 win = doc.defaultView;
652 653
654 if(!element.parentNode) {
655 //console.warn('StylesController::getMatchingRules - Un-attached element queried');
656 return [];
657 }
658
653 try { 659 try {
654 mappedRules = nj.toArray(win.getMatchedCSSRules(element)).map(function(rule) { 660 matchedRules = win.getMatchedCSSRules(element);
661
662 if(!matchedRules) {
663 //console.warn('StylesController::getMatchingRules - matched rules are null');
664 return [];
665 }
666
667 mappedRules = nj.toArray(matchedRules).map(function(rule) {
655 return this._getRuleWithCSSText(rule.cssText, doc); 668 return this._getRuleWithCSSText(rule.cssText, doc);
656 }, this); 669 }, this);
657 670
658 rules = mappedRules.filter(function(rule) { 671 rules = mappedRules.filter(function(rule) {
672 if(!rule) { return false; }
673
659 //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet, 674 //// useStageStyleSheet flag indicates whether to only return rules from the stylesheet,
660 //// or only use rules for other stylesheets 675 //// or only use rules for other stylesheets
661 676
@@ -676,7 +691,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
676 }, this); 691 }, this);
677 692
678 } catch(ERROR) { 693 } catch(ERROR) {
679 console.warn('StylesController::getMatchingRules - Un-attached element queried.'); 694 //console.warn('StylesController::getMatchingRules - getMatchedCSSRules Exception.');
695 return [];
680 } 696 }
681 ///// Function for sorting by specificity values 697 ///// Function for sorting by specificity values
682 function sorter(ruleA, ruleB) { 698 function sorter(ruleA, ruleB) {
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..b7c50a7c 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,25 @@ 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 on open
317 videotags[i].addEventListener('canplay', function(e) {
318 //TODO: Figure out why the video must be seeked to the end before pausing
319 var time = Math.ceil(this.duration);
320 //Trying to display the last frame (doing minus 2 seconds if long video)
321 if (time > 2) this.currentTime = time - 2;
322 else if (time > 1) this.currentTime = time - 1;
323 else this.currentTime = time || 0;
324 //Pauing video
325 this.pause();
326 }, false);
327 }
328 }
312 // Assign the modelGenerator reference from the template to our own modelGenerator 329 // Assign the modelGenerator reference from the template to our own modelGenerator
313 this.document.modelGenerator = ElementModel.modelGenerator; 330 this.document.modelGenerator = ElementModel.modelGenerator;
314
315 //Checking for script tags then parsing check for montage and webgl 331 //Checking for script tags then parsing check for montage and webgl
316 if (scripttags.length > 0) { 332 if (scripttags.length > 0) {
317 //Checking and initializing webGL 333 //Checking and initializing webGL
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js
index 31918f92..80e6150d 100755
--- a/js/tools/TagTool.js
+++ b/js/tools/TagTool.js
@@ -86,11 +86,15 @@ exports.TagTool = Montage.create(DrawingTool, {
86 // Create the element 86 // Create the element
87 if(this.options.selectedElement === "custom") { 87 if(this.options.selectedElement === "custom") {
88 element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument); 88 element = document.application.njUtils.make(this.options.customName.value, null, this.application.ninja.currentDocument);
89
90 } else { 89 } else {
91 element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); 90 element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument);
92 } 91 }
93 92
93 // Adding a canplay event to videos to pause them and prevent autoplay on stage
94 if(this.options.selectedElement === "video") {
95 element.addEventListener("canplay", this, false);
96 }
97
94 // Create the styles 98 // Create the styles
95 styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); 99 styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData);
96 100
@@ -109,6 +113,24 @@ exports.TagTool = Montage.create(DrawingTool, {
109 // Add the element and styles 113 // Add the element and styles
110 this.application.ninja.elementMediator.addElements(element, styles); 114 this.application.ninja.elementMediator.addElements(element, styles);
111 } 115 }
116 },
117
118 handleCanplay: {
119 value: function(event) {
120 //TODO: Figure out why the video must be seeked to the end before pausing
121 var time = Math.ceil(event.target.duration);
122 //Trying to display the last frame (doing minus 2 seconds if long video)
123 if (time > 2) {
124 event.target.currentTime = time - 2;
125 } else if (time > 1) {
126 event.target.currentTime = time - 1;
127 } else {
128 event.target.currentTime = time || 0;
129 }
130 //Pauing video
131 event.target.pause();
132 }
112 } 133 }
134
113}); 135});
114 136
diff --git a/manifest.json b/manifest.json
index f1703b99..874f0c2f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
1{ 1{
2 "name": "Ninja", 2 "name": "Ninja",
3 "description": "Ninja HTML5 Authoring Tool - Alpha Release", 3 "description": "Ninja HTML5 Authoring Tool - Alpha Release",
4 "version": "0.6.0.0", 4 "version": "0.7.0.0",
5 "app": { 5 "app": {
6 "launch": { 6 "launch": {
7 "local_path": "index.html" 7 "local_path": "index.html"