aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-27 10:50:17 -0800
committerValerio Virgillito2012-02-27 10:50:17 -0800
commita5d635a29de97a7daa93b9036d7a7dce48f07670 (patch)
tree0199d2ed21ab474b88302abf57cb8b14a200f4fa /js/io/ui/new-file-dialog
parentd392751242f9a4aad4199c941fd416c19c422ee1 (diff)
parentc65eb4b983e8020346cda4dc7bcb050cb1a410e1 (diff)
downloadninja-a5d635a29de97a7daa93b9036d7a7dce48f07670.tar.gz
Merge branch 'FileIO-Build-Candidate' of https://github.com/joseeight/ninja-internal into integration-candidate
Diffstat (limited to 'js/io/ui/new-file-dialog')
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js38
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js36
-rwxr-xr-xjs/io/ui/new-file-dialog/new-file-workflow-controller.js19
3 files changed, 40 insertions, 53 deletions
diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js
index fae8f9c7..0e1e09a4 100755
--- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js
+++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js
@@ -11,46 +11,30 @@ var newFileWorkflowControllerModule = require("js/io/ui/new-file-dialog/new-file
11var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { 11var NewFileLocation = exports.NewFileLocation = Montage.create(Component, {
12 12
13 templateHeight:{ 13 templateHeight:{
14 enumerable: true,
15 value:"25 px" 14 value:"25 px"
16 }, 15 },
17 16
18 templateWidth:{ 17 templateWidth:{
19 enumerable: true,
20 value:"25 px" 18 value:"25 px"
21 }, 19 },
22 20
23 willDraw: {
24 enumerable: false,
25 value: function() {}
26 },
27
28 draw: {
29 enumerable: false,
30 value: function() {}
31 },
32
33 didDraw: { 21 didDraw: {
34 enumerable: false,
35 value: function() { 22 value: function() {
36 var that=this;
37
38 this.fileInputField.selectDirectory = true; 23 this.fileInputField.selectDirectory = true;
39 24
40 this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); 25 this.newFileName.addEventListener("keyup", this, false);
41 } 26 }
42
43 }, 27 },
44 28
45 handleNewFileNameOnkeyup:{ 29 handleKeyup:{
46 value:function(evt){ 30 value:function(evt){
47 if(this.newFileName.value !== ""){ 31 if(this.newFileName.value !== "") {
48 var newFileNameSetEvent = document.createEvent("Events"); 32 var newFileNameSetEvent = document.createEvent("Events");
49 newFileNameSetEvent.initEvent("newFileNameSet", false, false); 33 newFileNameSetEvent.initEvent("newFileNameSet", false, false);
50 newFileNameSetEvent.newFileName = this.newFileName.value; 34 newFileNameSetEvent.newFileName = this.newFileName.value;
51 this.eventManager.dispatchEvent(newFileNameSetEvent); 35 this.eventManager.dispatchEvent(newFileNameSetEvent);
52 } 36 }
53 } 37 }
54 } 38 }
55 39
56}); \ No newline at end of file 40}); \ No newline at end of file
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
index 11b322fe..aaf39005 100644
--- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -47,14 +47,36 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
47 enumerable:false, 47 enumerable:false,
48 value:"0 px" 48 value:"0 px"
49 }, 49 },
50 willDraw: { 50
51 enumerable: false, 51 // Populating the directory input field with the default save location or the last stored location.
52 value: function() {} 52 prepareForDraw: {
53 }, 53 value: function() {
54 draw: { 54 var defaultSaveDirectory;
55 enumerable: false, 55
56 value: function() {} 56 // Using session storage location
57 if(window.sessionStorage) {
58 var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection");
59 if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"));
60 }
61
62 // Use default if none found in session storage
63 if(!defaultSaveDirectory) {
64 var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"});
65 if(driveData.success){
66 var topLevelDirectories = (JSON.parse(driveData.content)).children;
67 defaultSaveDirectory = topLevelDirectories[0].uri;
68 } else {
69 console.log("** Error ** Cannot get directory listing");
70 defaultSaveDirectory = "";
71 }
72 }
73
74 // Set the input field to the correct directory
75 this.newFileLocation.fileInputField.newFileDirectory.value = defaultSaveDirectory;
76 this.newFileDirectory = defaultSaveDirectory;
77 }
57 }, 78 },
79
58 didDraw: { 80 didDraw: {
59 enumerable: false, 81 enumerable: false,
60 value: function() { 82 value: function() {
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 7b7f4572..901b61c7 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
@@ -19,17 +19,10 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
19 writable:false, 19 writable:false,
20 enumerable:true, 20 enumerable:true,
21 value:function(){ 21 value:function(){
22 var that = this;
23
24 this.eventManager.addEventListener("saveAs", function(evt){
25 var data = evt._event.data || {};//data will contain the current file name, directory location and callback
26 that.showSaveAsDialog(data);
27 }, false);
28 } 22 }
29 }, 23 },
30 24
31 model:{ 25 model:{
32 writable: true,
33 enumerable:true, 26 enumerable:true,
34 value: null 27 value: null
35 }, 28 },
@@ -56,19 +49,8 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
56 this.model.defaultProjectType = lastSelectedProjectType; 49 this.model.defaultProjectType = lastSelectedProjectType;
57 } 50 }
58 51
59 //render modal dialog
60 var newFileNavContent = document.createElement("div");
61 newFileNavContent.id = "newFileDialog";
62
63 //elements needs to be on DOM to be drawn
64 document.getElementById('modalContainer').appendChild(newFileNavContent);
65
66 var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); 52 var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create();
67 newFileOptionsNav.newFileModel = this.model; 53 newFileOptionsNav.newFileModel = this.model;
68 newFileOptionsNav.element = newFileNavContent;
69
70 //remove after rendering and add in modal dialog
71 document.getElementById('modalContainer').removeChild(newFileNavContent);
72 54
73 var popup = Popup.create(); 55 var popup = Popup.create();
74 popup.content = newFileOptionsNav; 56 popup.content = newFileOptionsNav;
@@ -99,7 +81,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre
99 saveAsDialog.fileName = fileName; 81 saveAsDialog.fileName = fileName;
100 saveAsDialog.folderUri = folderUri; 82 saveAsDialog.folderUri = folderUri;
101 saveAsDialog.callback = data.callback; 83 saveAsDialog.callback = data.callback;
102 saveAsDialog.callbackScope = data.callbackScope;
103 saveAsDialog.element = saveAsDialogContainer; 84 saveAsDialog.element = saveAsDialogContainer;
104 85
105 //remove after rendering and add in modal dialog 86 //remove after rendering and add in modal dialog