diff options
Diffstat (limited to 'js/io')
46 files changed, 3129 insertions, 1783 deletions
diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js index 44f54f78..918b51ad 100644..100755 --- a/js/io/document/base-document.js +++ b/js/io/document/base-document.js | |||
@@ -82,7 +82,12 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { | |||
82 | value: function() { | 82 | value: function() { |
83 | // Have the XHR here? | 83 | // Have the XHR here? |
84 | } | 84 | } |
85 | } | 85 | }, |
86 | 86 | ||
87 | save:{ | ||
88 | value:function(){ | ||
89 | //base function - to be overridden | ||
90 | } | ||
91 | } | ||
87 | 92 | ||
88 | }); \ No newline at end of file | 93 | }); \ No newline at end of file |
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 99177de0..51575a24 100644..100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -12,26 +12,33 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
12 | @requires js/document/text-document | 12 | @requires js/document/text-document |
13 | */ | 13 | */ |
14 | 14 | ||
15 | // TODO : Fix deps from Montage V4 Archi | ||
16 | |||
17 | var Montage = require("montage/core/core").Montage, | 15 | var Montage = require("montage/core/core").Montage, |
18 | Component = require("montage/ui/component").Component, | 16 | Component = require("montage/ui/component").Component, |
19 | Uuid = require("montage/core/uuid").Uuid; | 17 | Uuid = require("montage/core/uuid").Uuid, |
20 | 18 | HTMLDocument = require("js/io/document/html-document").HTMLDocument, | |
21 | var HTMLDocument = require("js/io/document/html-document").HTMLDocument; | 19 | TextDocument = require("js/io/document/text-document").TextDocument; |
22 | var TextDocument = require("js/io/document/text-document").TextDocument; | ||
23 | 20 | ||
24 | var DocumentController = exports.DocumentController = Montage.create(Component, { | 21 | var DocumentController = exports.DocumentController = Montage.create(Component, { |
25 | hasTemplate: { value: false }, | 22 | hasTemplate: { |
23 | value: false | ||
24 | }, | ||
25 | |||
26 | _documents: { | ||
27 | value: [] | ||
28 | }, | ||
26 | 29 | ||
27 | _documents: { value: [] }, | ||
28 | _documentsHash: { value: {} }, | ||
29 | _activeDocument: { value: null }, | 30 | _activeDocument: { value: null }, |
30 | _iframeCounter: { value: 1, enumerable: false }, | 31 | _iframeCounter: { value: 1, enumerable: false }, |
31 | _iframeHolder: { value: null, enumerable: false }, | 32 | _iframeHolder: { value: null, enumerable: false }, |
32 | _textHolder: { value: null, enumerable: false }, | 33 | _textHolder: { value: null, enumerable: false }, |
33 | _codeMirrorCounter: {value: 1, enumerable: false}, | 34 | _codeMirrorCounter: {value: 1, enumerable: false}, |
34 | 35 | ||
36 | tmpSourceForTesting: { | ||
37 | value: "function CodeMirror(place, givenOptions) {" + | ||
38 | "// Determine effective options based on given values and defaults." + | ||
39 | "var options = {}, defaults = CodeMirror.defaults; }" | ||
40 | }, | ||
41 | |||
35 | _codeEditor: { | 42 | _codeEditor: { |
36 | value: { | 43 | value: { |
37 | "editor": { | 44 | "editor": { |
@@ -50,33 +57,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
50 | return this._activeDocument; | 57 | return this._activeDocument; |
51 | }, | 58 | }, |
52 | set: function(doc) { | 59 | set: function(doc) { |
53 | if(this._activeDocument) { | 60 | if(this._activeDocument) this._activeDocument.isActive = false; |
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 | 61 | ||
62 | if(this._documents.indexOf(doc) === -1) { | 62 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
63 | //this._documentsHash[doc.uuid] = this._documents.push(doc) - 1; | ||
64 | this._documents.push(doc); | ||
65 | } | ||
66 | 63 | ||
67 | this._activeDocument = doc; | 64 | this._activeDocument = doc; |
68 | this._activeDocument.isActive = true; | 65 | this._activeDocument.isActive = true; |
69 | 66 | ||
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 | } | 67 | } |
75 | }, | 68 | }, |
76 | 69 | ||
77 | deserializedFromTemplate: { | 70 | deserializedFromTemplate: { |
78 | value: function() { | 71 | value: function() { |
79 | this.eventManager.addEventListener("appLoaded", this, false); | 72 | this.eventManager.addEventListener("appLoaded", this, false); |
73 | this.eventManager.addEventListener("executeFileOpen", this, false); | ||
74 | this.eventManager.addEventListener("executeNewFile", this, false); | ||
80 | } | 75 | } |
81 | }, | 76 | }, |
82 | 77 | ||
@@ -86,59 +81,192 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
86 | } | 81 | } |
87 | }, | 82 | }, |
88 | 83 | ||
84 | handleExecuteFileOpen: { | ||
85 | value: function(event) { | ||
86 | var pickerSettings = event._event.settings || {}; | ||
87 | pickerSettings.callback = this.openFileWithURI; | ||
88 | pickerSettings.callbackScope = this; | ||
89 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | ||
90 | |||
91 | //this.openDocument({"type": "js", "source": this.tmpSourceForTesting}); | ||
92 | } | ||
93 | }, | ||
94 | |||
95 | handleExecuteNewFile: { | ||
96 | value: function(event) { | ||
97 | var newFileSettings = event._event.settings || {}; | ||
98 | newFileSettings.callback = this.createNewFile; | ||
99 | newFileSettings.callbackScope = this; | ||
100 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | ||
101 | } | ||
102 | }, | ||
103 | |||
104 | createNewFile:{ | ||