diff options
author | Armen Kesablyan | 2012-05-17 14:01:38 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-05-17 14:01:38 -0700 |
commit | 6c8f3525b839e82cf43df43700a0160ee2c5458f (patch) | |
tree | 3fb801fa54b759c5568d75bb467e02652ce77c3e /js/document | |
parent | e8ae5db7ce7023b638375cbc27a3f7b7a2f77b23 (diff) | |
parent | 342c97ac9b727b22a7b0bfefca4d2a168bc3055b (diff) | |
download | ninja-6c8f3525b839e82cf43df43700a0160ee2c5458f.tar.gz |
Merge branch 'refs/heads/dom-architecture' into binding
Conflicts:
css/ninja.css
scss/imports/scss/_toolbar.scss
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 49 | ||||
-rwxr-xr-x | js/document/html-document.js | 65 | ||||
-rwxr-xr-x | js/document/models/base.js | 23 | ||||
-rwxr-xr-x | js/document/models/html.js | 5 | ||||
-rw-r--r-- | js/document/templates/app/main.js (renamed from js/document/templates/banner/main.js) | 18 | ||||
-rwxr-xr-x | js/document/templates/app/package.json (renamed from js/document/templates/banner/package.json) | 1 | ||||
-rwxr-xr-x | js/document/templates/banner/index.html | 2 | ||||
-rwxr-xr-x | js/document/templates/html/index.html | 7 | ||||
-rw-r--r-- | js/document/templates/html/main.js | 49 | ||||
-rwxr-xr-x | js/document/templates/html/package.json | 8 | ||||
-rwxr-xr-x | js/document/templates/preview/banner.html | 64 | ||||
-rwxr-xr-x | js/document/views/design.js | 6 |
12 files changed, 135 insertions, 162 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 9bbea4c9..56d9db02 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -41,14 +41,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
41 | //////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////// |
42 | // | 42 | // |
43 | exclusionList: { | 43 | exclusionList: { |
44 | value: ["HTML", "BODY"] //TODO: Update to correct list | 44 | value: ["HTML", "BODY", "NINJA-CONTENT"] //TODO: Update to correct list |
45 | }, | ||
46 | //////////////////////////////////////////////////////////////////// | ||
47 | // | ||
48 | uuid: { | ||
49 | get: function() { | ||
50 | return this._uuid; | ||
51 | } | ||
52 | }, | 45 | }, |
53 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
54 | // | 47 | // |
@@ -133,33 +126,37 @@ 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 | //////////////////////////////////////////////////////////////////// |
154 | // | 136 | // |
155 | saveAppState: { | 137 | serializeDocument: { |
156 | value: function () { | 138 | value: function () { |
157 | //TODO: Import functionality | 139 | // There are not needed for now ssince we cannot change them |
140 | //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; | ||
141 | //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | ||
142 | |||
143 | // Serialize the current scroll position | ||
144 | // TODO: Implement | ||
145 | |||
146 | // Serialize the selection | ||
147 | this.model.selection = this.application.ninja.selectedElements.slice(0); | ||
148 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | ||
149 | |||
150 | // Serialize the undo | ||
151 | // TODO: Save the montage undo queue | ||
152 | |||
153 | // Pause the videos | ||
154 | this.model.views.design.pauseVideos(); | ||
158 | } | 155 | } |
159 | }, | 156 | }, |
160 | //////////////////////////////////////////////////////////////////// | 157 | //////////////////////////////////////////////////////////////////// |
161 | // | 158 | // |
162 | restoreAppState: { | 159 | deserializeDocument: { |
163 | value: function () { | 160 | value: function () { |
164 | //TODO: Import functionality | 161 | //TODO: Import functionality |
165 | } | 162 | } |
diff --git a/js/document/html-document.js b/js/document/html-document.js index 9d083dd8..68c2a9fb 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -920,32 +920,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
920 | } | 920 | } |
921 | } | 921 | } |
922 | }, | 922 | }, |
923 | //////////////////////////////////////////////////////////////////// | ||
924 | saveAppState:{ | ||
925 | enumerable: false, | ||
926 | value: function () { | ||
927 | |||
928 | this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; | ||
929 | this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; | ||
930 | |||
931 | this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; | ||
932 | this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; | ||
933 | |||
934 | if(typeof this.application.ninja.selectedElements !== 'undefined'){ | ||
935 | this.selectionModel = this.application.ninja.selectedElements.slice(0); | ||
936 | } | ||
937 | |||
938 | this.draw3DGrid = this.application.ninja.appModel.show3dGrid; | ||
939 | |||
940 | //persist a clone of history per document | ||
941 | this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); | ||
942 | this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); | ||
943 | this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start | ||
944 | |||
945 | //pause videos on switching or closing the document, so that the browser does not keep downloading the media data | ||
946 | this.pauseVideos(); | ||
947 | } | ||
948 | }, | ||
949 | 923 | ||
950 | //////////////////////////////////////////////////////////////////// | 924 | //////////////////////////////////////////////////////////////////// |
951 | restoreAppState:{ | 925 | restoreAppState:{ |
@@ -972,44 +946,5 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
972 | 946 | ||
973 | 947 | ||
974 | } | 948 | } |
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 | } | 949 | } |
1014 | //////////////////////////////////////////////////////////////////// | ||
1015 | }); \ No newline at end of file | 950 | }); \ No newline at end of file |
diff --git a/js/document/models/base.js b/js/document/models/base.js index 5f2a5893..649539ea 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 && (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 | //////////////////////////////////////////////////////////////////// |
@@ -141,7 +149,8 @@ exports.BaseDocumentModel = Montage.create(Component, { | |||
141 | template: this.fileTemplate, | 149 | template: this.fileTemplate, |
142 | document: this.views.design.iframe.contentWindow.document, | 150 | document: this.views.design.iframe.contentWindow.document, |
143 | head: this.views.design.iframe.contentWindow.document.head, | 151 | head: this.views.design.iframe.contentWindow.document.head, |
144 | body: this.views.design.iframe.contentWindow.document.body | 152 | body: this.views.design.iframe.contentWindow.document.body, |
153 | mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator | ||
145 | }, callback.bind(this)); | 154 | }, callback.bind(this)); |
146 | } else { |