From 91f6f672ee96c6e7e942b555af7057d6db52d90f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 22 Feb 2012 11:50:25 -0800 Subject: moving the default folder location to the navigator to fix the ok button issue Signed-off-by: Valerio Virgillito --- .../new-file-options-navigator.js | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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 enumerable:false, value:"0 px" }, - willDraw: { - enumerable: false, - value: function() {} - }, - draw: { - enumerable: false, - value: function() {} + + // Populating the directory input field with the default save location or the last stored location. + prepareForDraw: { + value: function() { + var defaultSaveDirectory; + + // Using session storage location + if(window.sessionStorage) { + var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); + if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); + } + + // Use default if none found in session storage + if(!defaultSaveDirectory) { + var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); + if(driveData.success){ + var topLevelDirectories = (JSON.parse(driveData.content)).children; + defaultSaveDirectory = topLevelDirectories[0].uri; + } else { + console.log("** Error ** Cannot get directory listing"); + defaultSaveDirectory = ""; + } + } + + // Set the input field to the correct directory + this.newFileLocation.fileInputField.newFileDirectory.value = defaultSaveDirectory; + this.newFileDirectory = defaultSaveDirectory; + } }, + didDraw: { enumerable: false, value: function() { -- cgit v1.2.3