diff options
Diffstat (limited to 'js/io')
21 files changed, 3633 insertions, 0 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js new file mode 100644 index 00000000..44f54f78 --- /dev/null +++ b/js/io/document/base-document.js | |||
@@ -0,0 +1,88 @@ | |||
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 | |||
88 | }); \ No newline at end of file | ||
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js new file mode 100644 index 00000000..99177de0 --- /dev/null +++ b/js/io/document/document-controller.js | |||
@@ -0,0 +1,326 @@ | |||
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 | @module js/document/documentManager | ||
9 | @requires montage/core/core | ||
10 | @requires montage/ui/component | ||
11 | @requires js/document/html-document | ||
12 | @requires js/document/text-document | ||
13 | */ | ||
14 | |||
15 | // TODO : Fix deps from Montage V4 Archi | ||
16 | |||
17 | var Montage = require("montage/core/core").Montage, | ||
18 | Component = require("montage/ui/component").Component, | ||
19 | Uuid = require("montage/core/uuid").Uuid; | ||
20 | |||
21 | var HTMLDocument = require("js/io/document/html-document").HTMLDocument; | ||
22 | var TextDocument = require("js/io/document/text-document").TextDocument; | ||
23 | |||
24 | var DocumentController = exports.DocumentController = Montage.create(Component, { | ||
25 | hasTemplate: { value: false }, | ||
26 | |||
27 | _documents: { value: [] }, | ||
28 | _documentsHash: { value: {} }, | ||
29 | _activeDocument: { value: null }, | ||
30 | _iframeCounter: { value: 1, enumerable: false }, | ||
31 | _iframeHolder: { value: null, enumerable: false }, | ||
32 | _textHolder: { value: null, enumerable: false }, | ||
33 | _codeMirrorCounter: {value: 1, enumerable: false}, | ||
34 | |||
35 | _codeEditor: { | ||
36 | value: { | ||
37 | "editor": { | ||
38 | value: null, | ||
39 | enumerable: false | ||
40 | }, | ||
41 | "hline": { | ||
42 | value: null, | ||
43 | enumerable: false | ||
44 | } | ||
45 | } | ||
46 | }, | ||
47 | |||
48 | activeDocument: { | ||
49 | get: function() { | ||
50 | return this._activeDocument; | ||
51 | }, | ||
52 | set: function(doc) { | ||
53 | if(this._activeDocument) { | ||
54 | if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") { | ||
55 | // TODO selection should use the document own selectionModel | ||
56 | //this._activeDocument.selectionModel = selectionManagerModule.selectionManager._selectedItems; | ||
57 | } | ||
58 | |||
59 | this._activeDocument.isActive = false; | ||
60 | } | ||
61 | |||
62 | if(this._documents.indexOf(doc) === -1) { | ||
63 | //this._documentsHash[doc.uuid] = this._documents.push(doc) - 1; | ||
64 | this._documents.push(doc); | ||
65 | } | ||
66 | |||
67 | this._activeDocument = doc; | ||
68 | this._activeDocument.isActive = true; | ||
69 | |||
70 | if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") { | ||
71 | // TODO selection should use the document own selectionModel | ||
72 | //selectionManagerModule.selectionManager._selectedItems = this._activeDocument.selectionModel; | ||
73 | } | ||
74 | } | ||
75 | }, | ||
76 | |||
77 | deserializedFromTemplate: { | ||
78 | value: function() { | ||
79 | this.eventManager.addEventListener("appLoaded", this, false); | ||
80 | } | ||
81 | }, | ||
82 | |||
83 | handleAppLoaded: { | ||
84 | value: function() { | ||
85 | this.openDocument({"type": "html"}); | ||
86 | } | ||
87 | }, | ||
88 | |||
89 | /** Open a Document **/ | ||
90 | openDocument: { | ||
91 | value: function(doc) { | ||
92 | var d; | ||
93 | |||
94 | if(!doc) return false; | ||
95 | |||
96 | try { | ||
97 | if (doc.type === 'html' || doc.type === 'htm') { | ||
98 | d = Montage.create(HTMLDocument); | ||
99 | d.initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); | ||
100 | } else { | ||
101 | d = Montage.create(TextDocument); | ||
102 | d.initialize(doc, Uuid.generate(), this._createTextAreaElement(), this._onOpenTextDocument); | ||
103 | } | ||
104 | |||
105 | } catch (err) { | ||
106 | console.log("Could not open Document ", err); | ||
107 | } | ||
108 | } | ||
109 | }, | ||
110 | |||
111 | closeDocument: { | ||
112 | value: function(id) { | ||
113 | var doc = this._findDocu |