aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog/new-file-workflow-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-workflow-controller.js')
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-workflow-controller.js37
1 files changed, 30 insertions, 7 deletions
diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js
index cfe7db16..16075ecf 100755
--- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js
+++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js
@@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Popup = require("montage/ui/popup/popup.reel").Popup, 8 Popup = require("montage/ui/popup/popup.reel").Popup,
9 newFileOptionsNavigatorModule = require("js/io/ui/new-file-dialog/new-file-options-navigator.reel"), 9 newFileOptionsNavigatorModule = require("js/io/ui/new-file-dialog/new-file-options-navigator.reel"),
10 newFileWorkflowModelModule = require("js/io/ui/new-file-dialog/new-file-workflow-model"); 10 newFileWorkflowModelModule = require("js/io/ui/new-file-dialog/new-file-workflow-model").NewFileWorkflowModel;
11 saveAsModule = require("js/io/ui/save-as-dialog.reel"); 11 saveAsModule = require("js/io/ui/save-as-dialog.reel");
12 12
13//singleton 13//singleton
@@ -20,10 +20,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
20 enumerable:true, 20 enumerable:true,
21 value:function(){ 21 value:function(){
22 var that = this; 22 var that = this;
23 this.eventManager.addEventListener("executeNewFile", function(evt){
24 var data = evt._event.data || {};//data will contain callback
25 that.showNewFileDialog(data);
26 }, false);
27 23
28 this.eventManager.addEventListener("saveAs", function(evt){ 24 this.eventManager.addEventListener("saveAs", function(evt){
29 var data = evt._event.data || {};//data will contain the current file name, directory location and callback 25 var data = evt._event.data || {};//data will contain the current file name, directory location and callback
@@ -35,15 +31,20 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
35 model:{ 31 model:{
36 writable: true, 32 writable: true,
37 enumerable:true, 33 enumerable:true,
38 value: newFileWorkflowModelModule.NewFileWorkflowModel 34 value: null
39 }, 35 },
40 36
41 showNewFileDialog:{ 37 showNewFileDialog:{
42 writable:false, 38 writable:false,
43 enumerable:true, 39 enumerable:true,
44 value:function(data){ 40 value:function(data){
41 this.model = newFileWorkflowModelModule;
42
43 //read file descriptor to populate model
44 this.model.projectTypeData = this.loadDescriptor("js/io/templates/descriptor.json");
45
45 //get default project type 46 //get default project type
46 this.model.defaultProjectType = "htmlTemplate"; 47 this.model.defaultProjectType = "files/html.txt";
47 this.model.callback = data.callback || null; 48 this.model.callback = data.callback || null;
48 this.model.callbackScope = data.callbackScope || null; 49 this.model.callbackScope = data.callbackScope || null;
49 50
@@ -112,5 +113,27 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
112 113
113 saveAsDialog.popup = popup;//handle to be used for hiding the popup 114 saveAsDialog.popup = popup;//handle to be used for hiding the popup
114 } 115 }
116 },
117
118 loadDescriptor:{
119 value: function(descriptorPath){
120 var content = null, descriptorObj=null;
121 var xhr = new XMLHttpRequest();
122 xhr.open("GET", descriptorPath, false);
123 xhr.send();
124 if (xhr.readyState === 4) {
125 if(xhr.status == 200) {
126 content = xhr.responseText;
127 }
128 }
129 if(!!content && (content.length > 0)){
130 try{
131 descriptorObj = JSON.parse(content);
132 }catch(e){
133 console.log(e,stack);
134 }
135 }
136 return descriptorObj;
137 }
115 } 138 }
116}); \ No newline at end of file 139}); \ No newline at end of file