aboutsummaryrefslogtreecommitdiff
path: root/js/document/models
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 11:52:06 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch)
tree8f0f55557bd0c47a84e49c1977c950645d284607 /js/document/models
parentaedd14b18695d031f695d27dfbd94df5614495bb (diff)
downloadninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz
Expand tabs
Diffstat (limited to 'js/document/models')
-rwxr-xr-xjs/document/models/base.js448
-rwxr-xr-xjs/document/models/html.js46
-rwxr-xr-xjs/document/models/text.js62
3 files changed, 278 insertions, 278 deletions
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 97992324..21bb6a6f 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -30,63 +30,63 @@ POSSIBILITY OF SUCH DAMAGE.
30 30
31//////////////////////////////////////////////////////////////////////// 31////////////////////////////////////////////////////////////////////////
32// 32//
33var Montage = require("montage/core/core").Montage, 33var Montage = require("montage/core/core").Montage,
34 Component = require("montage/ui/component").Component, 34 Component = require("montage/ui/component").Component,
35 NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt; 35 NinjaPrompt = require("js/components/prompt.reel").NinjaPrompt;
36//////////////////////////////////////////////////////////////////////// 36////////////////////////////////////////////////////////////////////////
37// 37//
38exports.BaseDocumentModel = Montage.create(Component, { 38exports.BaseDocumentModel = Montage.create(Component, {
39 //////////////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////////////
40 // 40 //
41 hasTemplate: { 41 hasTemplate: {
42 value: false 42 value: false
43 }, 43 },
44 //////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////
45 // 45 //
46 _file: { 46 _file: {
47 value: null 47 value: null
48 }, 48 },
49 //////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////
50 // 50 //
51 file: { 51 file: {
52 get: function() {return this._file;}, 52 get: function() {return this._file;},
53 set: function(value) {this._file = value;} 53 set: function(value) {this._file = value;}
54 }, 54 },
55 //////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////
56 // 56 //
57 _isActive: { 57 _isActive: {
58 value: true 58 value: true
59 }, 59 },
60 //////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////
61 // 61 //
62 isActive: { 62 isActive: {
63 get: function() {return this._isActive;}, 63 get: function() {return this._isActive;},
64 set: function(value) {this._isActive = value;} 64 set: function(value) {this._isActive = value;}
65 }, 65 },
66 //////////////////////////////////////////////////////////////////// 66 ////////////////////////////////////////////////////////////////////
67 // 67 //
68 _needsSave: { 68 _needsSave: {
69 value: null 69 value: null
70 }, 70 },
71 //////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////
72 // 72 //
73 needsSave: { 73 needsSave: {
74 get: function() {return this._needsSave;}, 74 get: function() {return this._needsSave;},
75 set: function(value) {this._needsSave = value;} 75 set: function(value) {this._needsSave = value;}
76 }, 76 },
77 //////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////
78 // 78 //
79 _currentView: { 79 _currentView: {
80 value: null 80 value: null
81 }, 81 },
82 //////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////
83 // 83 //
84 currentView: { 84 currentView: {
85 get: function() {return this._currentView;}, 85 get: function() {return this._currentView;},
86 set: function(value) {this._currentView = value;} 86 set: function(value) {this._currentView = value;}
87 }, 87 },
88 //////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////
89 // 89 //
90 _selection: { 90 _selection: {
91 value: [] 91 value: []
92 }, 92 },
@@ -105,18 +105,18 @@ exports.BaseDocumentModel = Montage.create(Component, {
105 value: null 105 value: null
106 }, 106 },
107 //////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////
108 // 108 //
109 parentContainer: { 109 parentContainer: {
110 value: null 110 value: null
111 }, 111 },
112 //////////////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////////////
113 // 113 //
114 views: { 114 views: {
115 value: null 115 value: null
116 }, 116 },
117 //////////////////////////////////////////////////////////////////// 117 ////////////////////////////////////////////////////////////////////
118 // 118 //
119 libs: { 119 libs: {
120 value: null 120 value: null
121 }, 121 },
122 122
@@ -133,233 +133,233 @@ exports.BaseDocumentModel = Montage.create(Component, {
133 } 133 }
134 }, 134 },
135 //////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////
136 // 136 //
137 switchViewTo: { 137 switchViewTo: {
138 value: function (view) { 138 value: function (view) {
139 // 139 //
140 } 140 }
141 }, 141 },
142 //////////////////////////////////////////////////////////////////// 142 ////////////////////////////////////////////////////////////////////
143 //TODO: Add API to allow other browser support 143 //TODO: Add API to allow other browser support
144 browserPreview: { 144 browserPreview: {
145 value: function (browser, screen, context) { 145 value: function (browser, screen, context) {
146 //Making call to show feedback screen 146 //Making call to show feedback screen
147 if (screen) screen.show(context); 147 if (screen) screen.show(context);
148 //Generating URL for document 148 //Generating URL for document
149 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]; 149 var url = this.application.ninja.coreIoApi.rootUrl + this.file.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1];
150 //TODO: Add logic to prompt user to save (all) before preview 150 //TODO: Add logic to prompt user to save (all) before preview
151 this.saveAll(null,function (success) { 151 this.saveAll(null,function (success) {
152 //Making call to show feedback screen 152 //Making call to show feedback screen
153 if (screen) screen.hide(context); 153 if (screen) screen.hide(context);
154 //TODO: Add error handling logic 154 //TODO: Add error handling logic
155 if (!success) { 155 if (!success) {
156 console.log('Error!'); 156 console.log('Error!');
157 return; 157 return;
158 } 158 }
159 //Currently only supporting current browser (Chrome, obviously) 159 //Currently only supporting current browser (Chrome, obviously)
160 switch (this.browser) { 160 switch (this.browser) {
161 case 'chrome': 161 case 'chrome':
162 if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { 162 if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) {
163 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); 163 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url);
164 } else { 164 } else {
165 window.open(this.url); 165 window.open(this.url);
166 } 166 }
167 break; 167 break;
168 default: 168 default:
169 if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) { 169 if (this.template && (this.template.type === 'banner' || this.template.type === 'animation')) {
170 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url); 170 window.open('/js/document/templates/preview/banner.html?width='+this.template.size.width+'&height='+this.template.size.height+'&url='+this.url);
171 } else { 171 } else {
172 window.open(this.url); 172 window.open(this.url);
173 } 173 }
174 break; 174 break;
175 } 175 }
176 }.bind({browser: browser, url: url, template: this.fileTemplate})); 176 }.bind({browser: browser, url: url, template: this.fileTemplate}));
177 } 177 }
178 }, 178 },
179 //////////////////////////////////////////////////////////////////// 179 ////////////////////////////////////////////////////////////////////
180 //Gets all stylesheets in document 180 //Gets all stylesheets in document
181 getStyleSheets: { 181 getStyleSheets: {
182 value: function () { 182 value: function () {
183 //Array to store styles (style and link tags) 183 //Array to store styles (style and link tags)
184 var styles = []; 184 var styles = [];
185 //Looping through document sytles 185 //Looping through document sytles
186 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) { 186 for (var k in this.views.design.iframe.contentWindow.document.styleSheets) {
187 //Check for styles to has proper propeties 187 //Check for styles to has proper propeties
188 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) { 188 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode && this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute) {
189 //Check for ninja-template styles, if so, exclude 189 //Check for ninja-template styles, if so, exclude
190 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) { 190 if (this.views.design.iframe.contentWindow.document.styleSheets[k].ownerNode.getAttribute('data-ninja-template') === null) {
191 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]); 191 styles.push(this.views.design.iframe.contentWindow.document.styleSheets[k]);
192