diff options
author | Valerio Virgillito | 2012-05-16 00:54:40 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-16 00:54:40 -0700 |
commit | a9672abd32c2e03b8607c1af4903c90f7ff9531c (patch) | |
tree | 30da60ed624d3d60b09fc04672c502bbed3b11f8 /js/document | |
parent | 6dfe2e62b1d7a71daf097aac3a31213d564e6122 (diff) | |
parent | 2b21e91a3343229bb87179e08be1e532fcf9b8f9 (diff) | |
download | ninja-a9672abd32c2e03b8607c1af4903c90f7ff9531c.tar.gz |
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into dom-architecture
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 32 | ||||
-rwxr-xr-x | js/document/html-document.js | 39 | ||||
-rwxr-xr-x | js/document/models/base.js | 19 | ||||
-rwxr-xr-x | js/document/templates/banner/index.html | 46 | ||||
-rwxr-xr-x | js/document/templates/preview/banner.html | 64 | ||||
-rwxr-xr-x | js/document/views/design.js | 27 |
6 files changed, 136 insertions, 91 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 4767271f..87c776d5 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -43,13 +43,6 @@ exports.HtmlDocument = Montage.create(Component, { | |||
43 | exclusionList: { | 43 | exclusionList: { |
44 | value: ["HTML", "BODY"] //TODO: Update to correct list | 44 | value: ["HTML", "BODY"] //TODO: Update to correct list |
45 | }, | 45 | }, |
46 | //////////////////////////////////////////////////////////////////// | ||
47 | // | ||
48 | uuid: { | ||
49 | get: function() { | ||
50 | return this._uuid; | ||
51 | } | ||
52 | }, | ||
53 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
54 | // | 47 | // |
55 | inExclusion: { | 48 | inExclusion: { |
@@ -100,14 +93,14 @@ exports.HtmlDocument = Montage.create(Component, { | |||
100 | this._document = this.model.views.design.document; | 93 | this._document = this.model.views.design.document; |
101 | //TODO: Remove usage, seems as not needed | 94 | //TODO: Remove usage, seems as not needed |
102 | if (template && template.type === 'banner') { | 95 | if (template && template.type === 'banner') { |
103 | this.documentRoot = this.model.views.design.document.body.getElementsByTagName('ninja-banner')[0]; | 96 | this.documentRoot = this.model.views.design.document.body.getElementsByTagName('ninja-content')[0]; |
104 | } else { | 97 | } else { |
105 | this.documentRoot = this.model.views.design.document.body; | 98 | this.documentRoot = this.model.views.design.document.body; |
106 | } | 99 | } |
107 | //TODO: Why is this needed? | 100 | //TODO: Why is this needed? |
108 | this._liveNodeList = this.model.views.design.document.body.getElementsByTagName('*'); | 101 | this._liveNodeList = this.documentRoot.getElementsByTagName('*'); |
109 | //Initiliazing document model | 102 | //Initiliazing document model |
110 | document.application.njUtils.makeElementModel(this.model.views.design.document.body, "Body", "body"); | 103 | document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); |
111 | //Adding observer to know when template is ready | 104 | //Adding observer to know when template is ready |
112 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 105 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
113 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 106 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
@@ -133,21 +126,10 @@ exports.HtmlDocument = Montage.create(Component, { | |||
133 | //////////////////////////////////////////////////////////////////// | 126 | //////////////////////////////////////////////////////////////////// |
134 | // | 127 | // |
135 | closeDocument: { | 128 | closeDocument: { |
136 | value: function () { | 129 | value: function (context, callback) { |
137 | // | 130 | var closed = this.model.close(null); |
138 | this.model.close(null, this.handleCloseDocument.bind(this)); | 131 | |
139 | } | 132 | callback.call(context, this); |
140 | }, | ||
141 | //////////////////////////////////////////////////////////////////// | ||
142 | // | ||
143 | handleCloseDocument: { | ||
144 | value: function (success) { | ||
145 | //TODO: Add logic for handling success or failure | ||
146 | // | ||
147 | this.application.ninja.documentController._documents.splice(this.uuid, 1); | ||
148 | // | ||
149 | NJevent("closeDocument", this.model.file.uri); | ||
150 | //TODO: Delete object here | ||
151 | } | 133 | } |
152 | }, | 134 | }, |
153 | //////////////////////////////////////////////////////////////////// | 135 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/document/html-document.js b/js/document/html-document.js index 9d083dd8..6a84abdf 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -972,44 +972,5 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
972 | 972 | ||
973 | 973 | ||
974 | } | 974 | } |
975 | }, | ||
976 | //////////////////////////////////////////////////////////////////// | ||
977 | /** | ||
978 | *pause videos on switching or closing the document, so that the browser does not keep downloading the media data | ||
979 | */ | ||
980 | pauseVideos:{ | ||
981 | value:function(){ | ||
982 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
983 | for(i=0;i<videosArr.length;i++){ | ||
984 | if(!videosArr[i].paused){ | ||
985 | videosArr[i].pause(); | ||
986 | } | ||
987 | } | ||
988 | } | ||
989 | }, | ||
990 | |||
991 | /** | ||
992 | * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected | ||
993 | *removeSrc : boolean to remove the src if the video... set only in the close document flow | ||
994 | */ | ||
995 | stopVideos:{ | ||
996 | value:function(){ | ||
997 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
998 | for(i=0;i<videosArr.length;i++){ | ||
999 | videosArr[i].src = ""; | ||
1000 | } | ||
1001 | } | ||
1002 | }, | ||
1003 | pauseAndStopVideos:{ | ||
1004 | value:function(){ | ||
1005 | var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; | ||
1006 | for(i=0;i<videosArr.length;i++){ | ||
1007 | if(!videosArr[i].paused){ | ||
1008 | videosArr[i].pause(); | ||
1009 | } | ||
1010 | videosArr[i].src = ""; | ||
1011 | } | ||
1012 | } | ||
1013 | } | 975 | } |
1014 | //////////////////////////////////////////////////////////////////// | ||
1015 | }); \ No newline at end of file | 976 | }); \ No newline at end of file |
diff --git a/js/document/models/base.js b/js/document/models/base.js index 0f58e75c..f9844b70 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js | |||
@@ -93,13 +93,21 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
93 | //Currently only supporting current browser (Chrome, obviously) | 93 | //Currently only supporting current browser (Chrome, obviously) |
94 | switch (this.browser) { | 94 | switch (this.browser) { |
95 | case 'chrome': | 95 | case 'chrome': |
96 | window.open(this.url); | 96 | if (this.template.type === 'banner' || this.template.type === 'animation') { |
97 | window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); | ||
98 | } else { | ||
99 | window.open(this.url); | ||
100 | } | ||
97 | break; | 101 | break; |
98 | default: | 102 | default: |
99 | window.open(this.url); | 103 | if (this.template.type === 'banner' || this.template.type === 'animation') { |
104 | window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); | ||
105 | } else { | ||
106 | window.open(this.url); | ||
107 | } | ||
100 | break; | 108 | break; |
101 | } | 109 | } |
102 | }.bind({browser: browser, url: url})); | 110 | }.bind({browser: browser, url: url, template: this.fileTemplate})); |
103 | } | 111 | } |
104 | }, | 112 | }, |
105 | //////////////////////////////////////////////////////////////////// | 113 | //////////////////////////////////////////////////////////////////// |
@@ -138,6 +146,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
138 | file: this.file, | 146 | file: this.file, |
139 | webgl: this.webGlHelper.glData, | 147 | webgl: this.webGlHelper.glData, |
140 | styles: this.getStyleSheets(), | 148 | styles: this.getStyleSheets(), |
149 | template: this.fileTemplate, | ||
141 | document: this.views.design.iframe.contentWindow.document, | 150 | document: this.views.design.iframe.contentWindow.document, |
142 | head: this.views.design.iframe.contentWindow.document.head, | 151 | head: this.views.design.iframe.contentWindow.document.head, |
143 | body: this.views.design.iframe.contentWindow.document.body | 152 | body: this.views.design.iframe.contentWindow.document.body |
@@ -165,6 +174,7 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
165 | file: this.file, | 174 | file: this.file, |
166 | webgl: this.webGlHelper.glData, | 175 | webgl: this.webGlHelper.glData, |
167 | css: this.getStyleSheets(), | 176 | css: this.getStyleSheets(), |
177 | template: this.fileTemplate, | ||
168 | document: this.views.design.iframe.contentWindow.document, | 178 | document: this.views.design.iframe.contentWindow.document, |
169 | head: this.views.design.iframe.contentWindow.document.head, | 179 | head: this.views.design.iframe.contentWindow.document.head, |
170 | body: this.views.design.iframe.contentWindow.document.body | 180 | body: this.views.design.iframe.contentWindow.document.body |
@@ -204,10 +214,11 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
204 | if (this.views.design && (!view || view === 'design')) { | 214 | if (this.views.design && (!view || view === 'design')) { |
205 | // | 215 | // |
206 | this.parentContainer.removeChild(this.views.design.iframe); | 216 | this.parentContainer.removeChild(this.views.design.iframe); |
217 | this.views.design.pauseAndStopVideos(); | ||
207 | this.views.design = null; | 218 | this.views.design = null; |
208 | } | 219 | } |
209 | // | 220 | // |
210 | if (callback) callback(success); | 221 | return success; |
211 | } | 222 | } |
212 | } | 223 | } |
213 | //////////////////////////////////////////////////////////////////// | 224 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index 2cd82f51..91ef06de 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html | |||
@@ -27,8 +27,6 @@ | |||
27 | margin: 0; | 27 | margin: 0; |
28 | padding: 0; | 28 | padding: 0; |
29 | position: absolute; | 29 | position: absolute; |
30 | -webkit-transform-style: preserve-3d; | ||
31 | -webkit-transform: perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); | ||
32 | } | 30 | } |
33 | 31 | ||
34 | html { | 32 | html { |
@@ -40,10 +38,6 @@ | |||
40 | height: 100%; | 38 | height: 100%; |
41 | background: #666; | 39 | background: #666; |
42 | } | 40 | } |
43 | |||
44 | ninjaloadinghack { | ||
45 | display: none; | ||
46 | } | ||
47 | 41 | ||
48 | .active-element-outline { |