aboutsummaryrefslogtreecommitdiff
path: root/js/document/models
diff options
context:
space:
mode:
authorPushkar Joshi2012-06-06 07:54:11 -0700
committerPushkar Joshi2012-06-06 07:54:11 -0700
commitcfa1402ac2ce831a83a9d4263d06c452c157a414 (patch)
treeadb8f1f1ad1c4dd1e7e9eee1bd206f1ec338d20c /js/document/models
parent8606ee7ec851cb0a971e7556eba5d9386f1b3639 (diff)
parent5ba54dc275b07e7b2d0ed14751761d1e663d3d14 (diff)
downloadninja-cfa1402ac2ce831a83a9d4263d06c452c157a414.tar.gz
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/document/models')
-rwxr-xr-xjs/document/models/base.js35
-rwxr-xr-xjs/document/models/html.js11
-rwxr-xr-xjs/document/models/text.js3
3 files changed, 37 insertions, 12 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 6d9d2e89..0957145a 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -62,6 +62,20 @@ exports.BaseDocumentModel = Montage.create(Component, {
62 }, 62 },
63 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
64 // 64 //
65 _selection: {
66 value: []
67 },
68
69 selection: {
70 get: function() {
71 return this._selection;
72 },
73 set: function(value) {
74 this._selection = value;
75 }
76 },
77 ////////////////////////////////////////////////////////////////////
78 //
65 fileTemplate: { 79 fileTemplate: {
66 value: null 80 value: null
67 }, 81 },
@@ -85,11 +99,20 @@ exports.BaseDocumentModel = Montage.create(Component, {
85 //////////////////////////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////
86 //TODO: Add API to allow other browser support 100 //TODO: Add API to allow other browser support
87 browserPreview: { 101 browserPreview: {
88 value: function (browser) { 102 value: function (browser, screen, context) {
103 //Making call to show feedback screen
104 if (screen) screen.show(context);
89 //Generating URL for document 105 //Generating URL for document
90 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; 106 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1];
91 //TODO: Add logic to prompt user to save (all) before preview 107 //TODO: Add logic to prompt user to save (all) before preview
92 this.saveAll(function (result) { 108 this.saveAll(null,function (success) {
109 //Making call to show feedback screen
110 if (screen) screen.hide(context);
111 //TODO: Add error handling logic
112 if (!success) {
113 console.log('Error!');
114 return;
115 }
93 //Currently only supporting current browser (Chrome, obviously) 116 //Currently only supporting current browser (Chrome, obviously)
94 switch (this.browser) { 117 switch (this.browser) {
95 case 'chrome': 118 case 'chrome':
@@ -131,7 +154,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
131 //////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////
132 // 155 //
133 save: { 156 save: {
134 value: function (callback) { 157 value: function (callback, libCopyCallback) {
135 // 158 //
136 if (this.needsSave) { 159 if (this.needsSave) {
137 //Save 160 //Save
@@ -151,7 +174,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
151 head: this.views.design.iframe.contentWindow.document.head, 174 head: this.views.design.iframe.contentWindow.document.head,
152 body: this.views.design.iframe.contentWindow.document.body, 175 body: this.views.design.iframe.contentWindow.document.body,
153 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 176 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
154 }, this.handleSaved.bind({callback: callback, model: this})); 177 }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback);
155 } else { 178 } else {
156 //TODO: Add logic to save code view data 179 //TODO: Add logic to save code view data
157 } 180 }
@@ -160,7 +183,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
160 //////////////////////////////////////////////////////////////////// 183 ////////////////////////////////////////////////////////////////////
161 // 184 //
162 saveAll: { 185 saveAll: {
163 value: function (callback) { 186 value: function (callback, libCopyCallback) {
164 // 187 //
165 if (this.needsSave) { 188 if (this.needsSave) {
166 //Save 189 //Save
@@ -180,7 +203,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
180 head: this.views.design.iframe.contentWindow.document.head, 203 head: this.views.design.iframe.contentWindow.document.head,
181 body: this.views.design.iframe.contentWindow.document.body, 204 body: this.views.design.iframe.contentWindow.document.body,
182 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator 205 mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator
183 }, this.handleSaved.bind({callback: callback, model: this})); 206 }, this.handleSaved.bind({callback: callback, model: this}), libCopyCallback);
184 } else { 207 } else {
185 //TODO: Add logic to save code view data 208 //TODO: Add logic to save code view data
186 } 209 }
diff --git a/js/document/models/html.js b/js/document/models/html.js
index fd42d4de..9aa0d27e 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -18,9 +18,12 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
18 value: false 18 value: false
19 }, 19 },
20 //////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////
21 // 21 //Called by the document immidiately after the model is created
22 selection: { 22 init: {
23 value: [] 23 value:function() {
24 //Creating instance of the webGL helper for this model
25 this.webGlHelper = webGlDocumentHelper.create();
26 }
24 }, 27 },
25 //////////////////////////////////////////////////////////////////// 28 ////////////////////////////////////////////////////////////////////
26 // 29 //
@@ -57,7 +60,7 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
57 //////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////
58 // 61 //
59 webGlHelper: { 62 webGlHelper: {
60 value: webGlDocumentHelper 63 value: null
61 }, 64 },
62 //////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////
63 // 66 //
diff --git a/js/document/models/text.js b/js/document/models/text.js
index d1252b7d..6cb61d48 100755
--- a/js/document/models/text.js
+++ b/js/document/models/text.js
@@ -22,7 +22,7 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, {
22 save: { 22 save: {
23 enumerable: false, 23 enumerable: false,
24 value: function (callback) { 24 value: function (callback) {
25 this.application.ninja.documentController.activeDocument.model.views.code.editor.save();//save to textarea 25 this.application.ninja.currentDocument.model.views.code.editor.save();//save to textarea
26 26
27 var self = this; 27 var self = this;
28 28
@@ -60,7 +60,6 @@ exports.TextDocumentModel = Montage.create(BaseDocumentModel, {
60 } 60 }
61 // 61 //
62 this.parentContainer.removeChild(this.views.code.textViewContainer); 62 this.parentContainer.removeChild(this.views.code.textViewContainer);
63 this.application.ninja.stage.showCodeViewBar(false);
64 this.application.ninja.stage.restoreAllPanels(); 63 this.application.ninja.stage.restoreAllPanels();
65 this.views.code = null; 64 this.views.code = null;
66 65