diff options
Diffstat (limited to 'js/document/models')
-rwxr-xr-x | js/document/models/base-document.js | 93 | ||||
-rwxr-xr-x | js/document/models/html-document.js | 492 | ||||
-rwxr-xr-x | js/document/models/text-document.js | 156 |
3 files changed, 741 insertions, 0 deletions
diff --git a/js/document/models/base-document.js b/js/document/models/base-document.js new file mode 100755 index 00000000..918b51ad --- /dev/null +++ b/js/document/models/base-document.js | |||
@@ -0,0 +1,93 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | //BaseDocument Object for all files types and base class for HTML documents. | ||
8 | |||
9 | var Montage = require("montage/core/core").Montage; | ||
10 | |||
11 | var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | ||
12 | /** Private Members **/ | ||
13 | _name: { value: null, enumerable: false }, | ||
14 | _uri: { value: null, enumerable: false }, | ||
15 | _documentType: { value: null, enumerable: false }, | ||
16 | _container: {value: null, enumerable: false }, | ||
17 | _uuid: { value: null, enumerable: false }, | ||
18 | _isActive: { value: true, enumerable: false }, | ||
19 | _dirtyFlag: { value: false, enumerable: false }, | ||
20 | _callback: { value: null, enumerable: false }, | ||
21 | _currentView: { value: null, enumerable: false}, | ||
22 | |||
23 | /** Getters/Setters **/ | ||
24 | name: { | ||
25 | get: function() { return this._name; }, | ||
26 | set: function(value) { this._name = value; } | ||
27 | }, | ||
28 | |||
29 | uri: { | ||
30 | get: function() { return this._uri; }, | ||
31 | set: function(value) { this._uri = value; } | ||
32 | }, | ||
33 | |||
34 | documentType: { | ||
35 | get: function() { return this._documentType; }, | ||
36 | set: function(value) { this._documentType = value; } | ||
37 | }, | ||
38 | |||
39 | container: { | ||
40 | get: function() { return this._container; }, | ||
41 | set: function(value) { this._container = value; } | ||
42 | }, | ||
43 | |||
44 | uuid: { | ||
45 | get: function() { return this._uuid; }, | ||
46 | set: function(value) { this._uuid = value; } | ||
47 | }, | ||
48 | |||
49 | isActive: { | ||
50 | get: function() { return this._isActive; }, | ||
51 | set: function(value) { this._isActive = value; } | ||
52 | }, | ||
53 | |||
54 | dirtyFlag: { | ||
55 | get: function() { return this._dirtyFlag; }, | ||
56 | set: function(value) { this._dirtyFlag = value; } | ||
57 | }, | ||
58 | |||
59 | callback: { | ||
60 | get: function() { return this._callback; }, | ||
61 | set: function(value) { this._callback = value; } | ||
62 | }, | ||
63 | |||
64 | currentView: { | ||
65 | get: function() { return this._currentView; }, | ||
66 | set: function(value) { this._currentView = value } | ||
67 | }, | ||
68 | |||
69 | /** Base Methods **/ | ||
70 | init: { | ||
71 | value: function(name, uri, type, container, uuid, callback) { | ||
72 | this.name = name; | ||
73 | this.uri = uri; | ||
74 | this.documentType = type; | ||
75 | this.container = container; | ||
76 | this.uuid = uuid; | ||
77 | this.callback = callback; | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | loadDocument: { | ||
82 | value: function() { | ||
83 | // Have the XHR here? | ||
84 | } | ||
85 | }, | ||
86 | |||
87 | save:{ | ||
88 | value:function(){ | ||
89 | //base function - to be overridden | ||
90 | } | ||
91 | } | ||
92 | |||
93 | }); \ No newline at end of file | ||
diff --git a/js/document/models/html-document.js b/js/document/models/html-document.js new file mode 100755 index 00000000..cb399f04 --- /dev/null +++ b/js/document/models/html-document.js | |||
@@ -0,0 +1,492 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | //////////////////////////////////////////////////////////////////////// | ||
8 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | BaseDocument = require("js/document/models/base-document").BaseDocument, | ||
11 | NJUtils = require("js/lib/NJUtils").NJUtils; | ||
12 | //////////////////////////////////////////////////////////////////////// | ||
13 | // | ||
14 | exports.HTMLDocument = Montage.create(BaseDocument, { | ||
15 | // PRIVATE MEMBERS | ||
16 | _selectionExclude: { value: null, enumerable: false }, | ||
17 | _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, | ||
18 | _iframe: { value: null, enumerable: false }, | ||
19 | _server: { value: null, enumerable: false }, | ||
20 | _templateDocument: { value: null, enumerable: false }, | ||
21 | _selectionModel: { value: [], enumerable: false }, | ||
22 | _undoModel: { value: { "queue" : [], "position" : 0 }, enumerable: false}, | ||
23 | |||
24 | _document: { value: null, enumerable: false }, | ||
25 | _documentRoot: { value: null, enumerable: false }, | ||
26 | _stageBG: { value: null, enumerable: false }, | ||
27 | _window: { value: null, enumerable: false }, | ||
28 | _styles: { value: null, enumerable: false }, | ||
29 | _stylesheets: { value: null, enumerable: false }, | ||
30 | _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, | ||
31 | _userDocument: { value: null, enumerable: false }, | ||
32 | _htmlSource: {value: "<html></html>", enumerable: false}, | ||
33 | _glData: {value: null, enumerable: false }, | ||
34 | |||
35 | _elementCounter: { value: 1, enumerable: false }, | ||
36 | _snapping : { value: true, enumerable: false }, | ||
37 | _layoutMode: { value: "all", enumerable: false }, | ||
38 | _draw3DGrid: { value: false, writable: true }, | ||
39 | _swfObject: { value: false, enumerable: false }, | ||
40 | |||
41 | _zoomFactor: { value: 100, enumerable: false }, | ||
42 | |||
43 | // PUBLIC MEMBERS | ||
44 | cssLoadInterval: { value: null, enumerable: false }, | ||
45 | |||
46 | _savedLeftScroll: {value:null}, | ||
47 | _savedTopScroll: {value:null}, | ||
48 | |||
49 | _codeViewDocument:{ | ||
50 | writable: true, | ||
51 | enumerable: true, | ||
52 | value:null | ||
53 | }, | ||
54 | |||
55 | /* | ||
56 | * PUBLIC API | ||
57 | */ | ||
58 | |||
59 | // GETTERS / SETTERS | ||
60 | |||
61 | codeViewDocument:{ | ||
62 | get: function() { return this._codeViewDocument; }, | ||
63 | set: function(value) { this._codeViewDocument = value} | ||
64 | }, | ||
65 | |||
66 | savedLeftScroll:{ | ||
67 | get: function() { return this._savedLeftScroll; }, | ||
68 | set: function(value) { this._savedLeftScroll = value} | ||
69 | }, | ||
70 | |||
71 | savedTopScroll:{ | ||
72 | get: function() { return this._savedTopScroll; }, | ||
73 | set: function(value) { this._savedTopScroll = value} | ||
74 | }, | ||
75 | |||
76 | selectionExclude: { | ||
77 | get: function() { return this._selectionExclude; }, | ||
78 | set: function(value) { this._selectionExclude = value; } | ||
79 | }, | ||
80 | |||
81 | iframe: { | ||
82 | get: function() { return this._iframe; }, | ||
83 | set: function(value) { this._iframe = value; } | ||
84 | }, | ||
85 | |||
86 | server: { | ||
87 | get: function() { return this._server; }, | ||
88 | set: function(value) { this._server = value; } | ||
89 | }, | ||
90 | |||
91 | selectionModel: { | ||
92 | get: function() { return this._selectionModel; }, | ||
93 | set: function(value) { this._selectionModel = value; } | ||
94 | }, | ||
95 | |||
96 | undoModel: { | ||
97 | get: function() { return this._undoModel; }, | ||
98 | set: function(value) { this._undoModel.queue = value.queue; this._undoModel.position = value.position; } | ||
99 | }, | ||
100 | |||
101 | documentRoot: { | ||
102 | get: function() { return this._documentRoot; }, | ||
103 | set: function(value) { this._documentRoot = value; } | ||
104 | }, | ||
105 | |||
106 | stageBG: { | ||
107 | get: function() { return this._stageBG; }, | ||
108 | set: function(value) { this._stageBG = value; } | ||
109 | }, | ||
110 | |||
111 | elementCounter: { | ||
112 | set: function(value) { this._elementCounter = value; }, | ||
113 | get: function() { return this._elementCounter; } | ||
114 | }, | ||
115 | |||
116 | snapping: { | ||
117 | get: function() { return this._snapping; }, | ||
118 | set: function(value) { | ||
119 | if(this._snapping !== value) { | ||
120 | this._snapping = value; | ||
121 | } | ||
122 | } | ||
123 | }, | ||
124 | |||
125 | // TODO SEND THE EVENT --> Redraw the desired layout | ||
126 | layoutMode: { | ||
127 | get: function() { return this._layoutMode; }, | ||
128 | set: function(mode) { this._layoutMode = mode; } | ||
129 | }, | ||
130 | |||
131 | draw3DGrid: { | ||
132 | get: function() { return this._draw3DGrid; }, | ||
133 | set: function(value) { | ||
134 | if(this._draw3DGrid !== value) { | ||
135 | this._draw3DGrid = value; | ||
136 | } | ||
137 | } | ||
138 | }, | ||
139 | |||
140 | _userComponentSet: { | ||
141 | value: {}, | ||