aboutsummaryrefslogtreecommitdiff
path: root/js/io/workflow/newFileDialog/new-file-workflow-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/workflow/newFileDialog/new-file-workflow-controller.js')
-rwxr-xr-x[-rw-r--r--]js/io/workflow/newFileDialog/new-file-workflow-controller.js75
1 files changed, 66 insertions, 9 deletions
diff --git a/js/io/workflow/newFileDialog/new-file-workflow-controller.js b/js/io/workflow/newFileDialog/new-file-workflow-controller.js
index 5cc68bf9..18c84724 100644..100755
--- a/js/io/workflow/newFileDialog/new-file-workflow-controller.js
+++ b/js/io/workflow/newFileDialog/new-file-workflow-controller.js
@@ -8,9 +8,10 @@ var 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/workflow/newFileDialog/new-file-options-navigator.reel"), 9 newFileOptionsNavigatorModule = require("js/io/workflow/newFileDialog/new-file-options-navigator.reel"),
10 newFileWorkflowModelModule = require("js/io/workflow/newFileDialog/new-file-workflow-model"); 10 newFileWorkflowModelModule = require("js/io/workflow/newFileDialog/new-file-workflow-model");
11 saveAsModule = require("js/io/workflow/save-as-dialog.reel");
11 12
12//singleton 13//singleton
13exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, { 14var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, {
14 /** 15 /**
15 * Register a listener for showPicker event 16 * Register a listener for showPicker event
16 */ 17 */
@@ -20,40 +21,96 @@ exports.NewFileWorkflowController = Montage.create(require("montage/ui/component
20 value:function(){ 21 value:function(){
21 var that = this; 22 var that = this;
22 this.eventManager.addEventListener("executeNewFile", function(evt){ 23 this.eventManager.addEventListener("executeNewFile", function(evt){
23 that.showNewFileDialog(); 24 var data = evt._event.data || {};//data will contain callback
25 that.showNewFileDialog(data);
26 }, false);
27
28 this.eventManager.addEventListener("saveAs", function(evt){
29 var data = evt._event.data || {};//data will contain the current file name, directory location and callback
30 that.showSaveAsDialog(data);
24 }, false); 31 }, false);
25 } 32 }
26 }, 33 },
27 34
35 model:{
36 writable: true,
37 enumerable:true,
38 value: newFileWorkflowModelModule.NewFileWorkflowModel
39 },
40
28 showNewFileDialog:{ 41 showNewFileDialog:{
29 writable:false, 42 writable:false,
30 enumerable:true, 43 enumerable:true,
31 value:function(){ 44 value:function(data){
32 var aModel = null; 45 //get default project type
46 this.model.defaultProjectType = "htmlTemplate";
47 this.model.callback = data.callback || null;
48 this.model.callbackScope = data.callbackScope || null;
49
50 //populate the last opened folder first, if none then populate default root
51 var sessionStorage = window.sessionStorage;
52 var lastSelectedProjectType = sessionStorage.getItem("lastSelectedProjectType");
53
54 if(!!lastSelectedProjectType){
55 this.model.defaultProjectType = lastSelectedProjectType;
56 }
57
33 //render modal dialog 58 //render modal dialog
34 var newFileNavContent = document.createElement("div"); 59 var newFileNavContent = document.createElement("div");
35 newFileNavContent.id = "newFileDialog"; 60 newFileNavContent.id = "newFileDialog";
36 newFileNavContent.style.width = "650px";
37 newFileNavContent.style.height = "350px";
38 newFileNavContent.style.color = "#fff";
39 61
40 //elements needs to be on DOM to be drawn 62 //elements needs to be on DOM to be drawn
41 document.getElementById('modalContainer').appendChild(newFileNavContent); 63 document.getElementById('modalContainer').appendChild(newFileNavContent);
42 64
43 var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); 65 var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create();
44 newFileOptionsNav.newFileModel = newFileWorkflowModelModule.NewFileWorkflowModel; 66 newFileOptionsNav.newFileModel = this.model;
45 newFileOptionsNav.element = newFileNavContent; 67 newFileOptionsNav.element = newFileNavContent;
46 68
47 //hack - remove after rendering and add in modal dialog 69 //remove after rendering and add in modal dialog
48 document.getElementById('modalContainer').removeChild(newFileNavContent); 70 document.getElementById('modalContainer').removeChild(newFileNavContent);
49 71
50 var popup = Popup.create(); 72 var popup = Popup.create();
51 popup.content = newFileOptionsNav; 73 popup.content = newFileOptionsNav;
52 popup.modal = true; 74 popup.modal = true;
75 popup.type = "newFileDialog";
53 popup.show(); 76 popup.show();
54 77
55 newFileOptionsNav.popup = popup;//handle to be used for hiding the popup 78 newFileOptionsNav.popup = popup;//handle to be used for hiding the popup
56 79
57 } 80 }
81 },
82
83 showSaveAsDialog:{
84 writable:false,
85 enumerable:true,
86 value:function(data){
87 var fileName = data.fileName || "filename.txt";
88 var folderUri = data.folderUri || "/Documents";
89
90 //render modal dialog
91 var saveAsDialogContainer = document.createElement("div");
92 saveAsDialogContainer.id = "saveAsDialog";
93
94 //elements needs to be on DOM to be drawn
95 document.getElementById('modalContainer').appendChild(saveAsDialogContainer);
96
97 var saveAsDialog = saveAsModule.SaveAsDialog.create();
98 saveAsDialog.fileName = fileName;
99 saveAsDialog.folderUri = folderUri;
100 saveAsDialog.callback = data.callback;
101 saveAsDialog.callbackScope = data.callbackScope;
102 saveAsDialog.element = saveAsDialogContainer;
103
104 //remove after rendering and add in modal dialog
105 document.getElementById('modalContainer').removeChild(saveAsDialogContainer);
106
107 var popup = Popup.create();
108 popup.content = saveAsDialog;
109 popup.modal = true;
110 popup.type = "saveAsDialog";
111 popup.show();
112
113 saveAsDialog.popup = popup;//handle to be used for hiding the popup
114 }
58 } 115 }
59}); \ No newline at end of file 116}); \ No newline at end of file