From adb90eff3323aa780f9a0879572e3cf3b9f0b969 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 21 Feb 2012 13:04:58 -0800 Subject: - file picker - select file on double click - check cloud availability before IO operations [open file, new file, Save, Save As]. Canceling operation if cloud was unavailable, as per team's agreement. Signed-off-by: Ananya Sen --- .../picker-navigator.reel/picker-navigator.js | 26 +++++++++++++++++----- .../new-file-workflow-controller.js | 7 ------ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 ++-- 3 files changed, 23 insertions(+), 14 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 411386f9..428e7bab 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -214,6 +214,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.element.addEventListener("openFolder", function(evt){that.handlePickerNavOpenFolder(evt);}, false);//add icon double click event listener to reload iconList with new set of data this.element.addEventListener("selectedItem", function(evt){that.handlePickerNavSelectedItem(evt);}, false);//for single selection only + this.element.addEventListener("selectFile", function(evt){that.handlePickerNavSelectedFile(evt);}, false);//for file selection this.element.addEventListener("showMetadata", function(evt){that.handlePickerNavShowMetadata(evt);}, false);//show metadata on hover of icon this.element.addEventListener("updateMetadata", function(evt){that.handlePickerNavUpdateMetadata(evt);}, false);//show metadata on click of icon //this.addressGo.addEventListener("click", this, false); @@ -669,14 +670,29 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { } }, + handlePickerNavSelectedFile:{ + value: function(evt){ + var uri = evt.fileUri; + + //do selection if in file selection mode + if(this.pickerModel.inFileMode && (this.application.ninja.filePickerController._directoryContentCache[uri].type === "file")){ + this.okButton.removeAttribute("disabled"); + //put into selectedItems..currently single selection is supported + this.selectedItems = [uri]; + this.currentURI = uri.substring(0, uri.lastIndexOf("/")); + this.handleOkButtonAction(); + } + } + }, + handlePickerNavShowMetadata: { value: function(evt){ - //update matadata only if nothing is already selected - if(this.currentSelectedNode == null){ - //console.log("handle showmetadata - true"); - this.metadataSection.innerHTML = evt.metadata; - } + //update matadata only if nothing is already selected + if(this.currentSelectedNode == null){ + //console.log("handle showmetadata - true"); + this.metadataSection.innerHTML = evt.metadata; } + } }, handlePickerNavUpdateMetadata:{ 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..f34ee000 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,12 +19,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre writable:false, enumerable:true, value:function(){ - var that = this; - - this.eventManager.addEventListener("saveAs", function(evt){ - var data = evt._event.data || {};//data will contain the current file name, directory location and callback - that.showSaveAsDialog(data); - }, false); } }, @@ -99,7 +93,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre saveAsDialog.fileName = fileName; saveAsDialog.folderUri = folderUri; saveAsDialog.callback = data.callback; - saveAsDialog.callbackScope = data.callbackScope; saveAsDialog.element = saveAsDialogContainer; //remove after rendering and add in modal dialog diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index 55a09fa8..0a322b99 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -117,8 +117,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { try{ //validate file name and folder path //check if file already exists - if(!!this.callback && !!this.callbackScope){//inform document-controller if save successful - this.callback.call(this.callbackScope, {"filename":filename, "destination": newFileDirectory});//document-controller api + if(!!this.callback){//inform document-controller if save successful + this.callback({"filename":filename, "destination": newFileDirectory});//document-controller api }else{ //send save as event var saveAsEvent = document.createEvent("Events"); -- cgit v1.2.3 From f86577d5083aeed2de7a932fe4147e9002e91554 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 21:11:54 -0800 Subject: cleanup - Removing temporary div to render the popups We don't need to render the popup before opening them. Removing that hack. Signed-off-by: Valerio Virgillito --- js/io/ui/file-picker/file-picker-controller.js | 14 -------------- js/io/ui/new-file-dialog/new-file-workflow-controller.js | 12 ------------ 2 files changed, 26 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 129bebad..5e4d0be8 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -33,7 +33,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require }, filePickerPopupType:{ - writable: true, enumerable: false, value: "filePicker" }, @@ -152,15 +151,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(callback, aModel){ - //render modal dialog - var pickerNavContent = document.createElement("div"); - pickerNavContent.id = "filePicker"; - - pickerNavContent.style.color = "#fff"; - - //hack (elements needs to be on DOM to be drawn) - document.getElementById('modalContainer').appendChild(pickerNavContent); - var pickerNavChoices = Montage.create(pickerNavigatorReel); var initUri = aModel.currentRoot; @@ -171,10 +161,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require pickerNavChoices.mainContentData = this.prepareContentList(initUri, aModel); pickerNavChoices.pickerModel = aModel; - pickerNavChoices.element = pickerNavContent; - - //hack - remove after rendering and add in modal dialog - document.getElementById('modalContainer').removeChild(pickerNavContent); var popup = Popup.create(); popup.content = pickerNavChoices; 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..c2be687a 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 @@ -29,7 +29,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre }, model:{ - writable: true, enumerable:true, value: null }, @@ -56,19 +55,8 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.defaultProjectType = lastSelectedProjectType; } - //render modal dialog - var newFileNavContent = document.createElement("div"); - newFileNavContent.id = "newFileDialog"; - - //elements needs to be on DOM to be drawn - document.getElementById('modalContainer').appendChild(newFileNavContent); - var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); newFileOptionsNav.newFileModel = this.model; - newFileOptionsNav.element = newFileNavContent; - - //remove after rendering and add in modal dialog - document.getElementById('modalContainer').removeChild(newFileNavContent); var popup = Popup.create(); popup.content = newFileOptionsNav; -- cgit v1.2.3 From 067ebae166ff82ae113a91517dfa59e7de5ae3d3 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:36:54 -0800 Subject: cleanup - using montage functions handlers and using the NJevent Signed-off-by: Valerio Virgillito --- .../file-input-field.reel/file-input-field.js | 21 ++++----------------- js/io/ui/file-picker/file-picker-controller.js | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 29 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 235be8ad..651fd7fa 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js @@ -9,24 +9,13 @@ var Montage = require("montage/core/core").Montage, var FileInputField = exports.FileInputField = Montage.create(Component, { - hasReel: { - value: true - }, - - willDraw: { - enumerable: false, - value: function() {} - }, - draw: { - enumerable: false, - value: function() {} - }, didDraw: { enumerable: false, value: function() { var that = this; this.findDirectory.identifier = "findDirectory"; - this.findDirectory.addEventListener("click", function(evt){that.handleFindDirectoryClick(evt);}, false); + + this.findDirectory.addEventListener("click", this, false); this.eventManager.addEventListener("pickerSelectionsDone", function(evt){that.handleFileInputPickerSelectionsDone(evt);}, false); @@ -60,8 +49,6 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { handleFindDirectoryClick: { value: function(evt){ - var openFilePicker = document.createEvent("Events"); - openFilePicker.initEvent("openFilePicker", false, false); var settings = {}; if(this.selectDirectory === true){ settings.inFileMode = false; @@ -71,8 +58,8 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { settings.pickerName = this.pickerName || "fileSelector"; } settings.callback = this.filePickerCallback.bind(this); - openFilePicker.settings = settings; - this.eventManager.dispatchEvent(openFilePicker); + + NJevent("openFilePicker", settings); } }, diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 5e4d0be8..3b19de83 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -19,16 +19,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(){ - var that = this; - - this.eventManager.addEventListener("openFilePicker", function(evt){ - var settings; - if(typeof evt._event.settings !== "undefined"){ - settings = evt._event.settings; - } - that.showFilePicker(settings); - }, false); - + this.eventManager.addEventListener("openFilePicker", this, false); } }, @@ -37,6 +28,12 @@ var FilePickerController = exports.FilePickerController = Montage.create(require value: "filePicker" }, + handleOpenFilePicker: { + value: function(evt) { + this.showFilePicker(evt.detail); + } + }, + /** *this function is used to create an instance of a file picker * @@ -128,7 +125,9 @@ var FilePickerController = exports.FilePickerController = Montage.create(require } if(!!storedUri){ - aModel.currentRoot = unescape(storedUri); + // This is depracated -- use decodeURI instead + //aModel.currentRoot = unescape(storedUri); + aModel.currentRoot = decodeURI(storedUri); } if(!!allFileFilters){aModel.fileFilters = allFileFilters;} @@ -137,7 +136,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require if(typeof pickerMode !== "undefined"){aModel.pickerMode = pickerMode;} - //logic: get file content data onDemand from the REST api for the default or last opened root. Cache the data in page [in local cache ? dirty fs? ]. Filter on client side to reduce network calls. this.openFilePickerAsModal(callback, aModel); -- cgit v1.2.3 From a8f5dcd8e85af6600f2e2b6a4536f05fd0c9916d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:37:36 -0800 Subject: Adding the default folder by default when opening a new file dialog. Adding the default folder name in the new file dialog input field. Also some more cleanup. Signed-off-by: Valerio Virgillito --- .../new-file-location.reel/new-file-location.js | 57 +++++++++++++--------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'js/io') 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..ee2847ca 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,55 @@ var newFileWorkflowControllerModule = require("js/io/ui/new-file-dialog/new-file var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { templateHeight:{ - enumerable: true, value:"25 px" }, templateWidth:{ - enumerable: true, value:"25 px" }, - willDraw: { - enumerable: false, - value: function() {} - }, + prepareForDraw: { + value: function() { + // Populate the file input field by using the session storage or the default user folder + var defaultSaveDirectory; + + if(window.sessionStorage) { + var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); + if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); + } + + 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 = ""; + } + } - draw: { - enumerable: false, - value: function() {} + this.fileInputField.newFileDirectory.value = defaultSaveDirectory; + } }, didDraw: { - enumerable: false, value: function() { - var that=this; - this.fileInputField.selectDirectory = true; - this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); - } - + this.newFileName.addEventListener("keyup", this, false); + } }, - handleNewFileNameOnkeyup:{ - value:function(evt){ - if(this.newFileName.value !== ""){ - var newFileNameSetEvent = document.createEvent("Events"); - newFileNameSetEvent.initEvent("newFileNameSet", false, false); - newFileNameSetEvent.newFileName = this.newFileName.value; - this.eventManager.dispatchEvent(newFileNameSetEvent); - } - } + handleKeyup:{ + value:function(evt){ + if(this.newFileName.value !== "") { + var newFileNameSetEvent = document.createEvent("Events"); + newFileNameSetEvent.initEvent("newFileNameSet", false, false); + newFileNameSetEvent.newFileName = this.newFileName.value; + this.eventManager.dispatchEvent(newFileNameSetEvent); + } + } } }); \ No newline at end of file -- cgit v1.2.3 From 69983b800d0179fcccd5b61b64ed22c02e22b93a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 22:43:45 -0800 Subject: Adding some comments. Signed-off-by: Valerio Virgillito --- js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/io') 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 ee2847ca..849c665c 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 @@ -18,16 +18,18 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { value:"25 px" }, + // Populating the directory input field with the default save location or the last stored location. prepareForDraw: { value: function() { - // Populate the file input field by using the session storage or the default user folder 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){ @@ -39,6 +41,7 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { } } + // Set the input field to the correct directory this.fileInputField.newFileDirectory.value = defaultSaveDirectory; } }, -- cgit v1.2.3 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-location.reel/new-file-location.js | 28 ----------------- .../new-file-options-navigator.js | 36 +++++++++++++++++----- 2 files changed, 29 insertions(+), 35 deletions(-) (limited to 'js/io') 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 849c665c..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 @@ -18,34 +18,6 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { value:"25 px" }, - // 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.fileInputField.newFileDirectory.value = defaultSaveDirectory; - } - }, - didDraw: { value: function() { this.fileInputField.selectDirectory = true; 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 From 2b672f6508a849b8023b0bc114ad15e9ddca5adc Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 24 Feb 2012 13:27:04 -0800 Subject: prefixing the local storage and using the new local-storage object. Signed-off-by: Valerio Virgillito --- js/io/system/coreioapi.js | 6 +++--- js/io/ui/cloudpopup.reel/cloudpopup.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'js/io') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 2051da43..f428a229 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -28,9 +28,9 @@ exports.CoreIoApi = Montage.create(Component, { value: function () { //////////////////////////////////////////////////////////// //Checking for local storage of URL for IO - if (window.localStorage['ioRootUrl']) { + if (this.application.localStorage.getItem("ioRootUrl")) { //Getting URL from local storage - this.rootUrl = window.localStorage['ioRootUrl']; + this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); //Checks for IO API to be active this.ioServiceDetected = this.cloudAvailable(); } else { @@ -156,7 +156,7 @@ exports.CoreIoApi = Montage.create(Component, { return this._rootUrl; }, set: function(value) { - this._rootUrl = window.localStorage["ioRootUrl"] = value; + this._rootUrl = this.application.localStorage.setItem("ioRootUrl", value); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.js b/js/io/ui/cloudpopup.reel/cloudpopup.js index d2e82662..a4656bb5 100755 --- a/js/io/ui/cloudpopup.reel/cloudpopup.js +++ b/js/io/ui/cloudpopup.reel/cloudpopup.js @@ -63,8 +63,8 @@ exports.CloudPopup = Montage.create(Component, { enumerable: false, value: function() { // - if (window.localStorage['ioRootUrl']) { - this.components.url.value = window.localStorage['ioRootUrl']; + if (this.application.localStorage.getItem("ioRootUrl")) { + this.components.url.value = this.application.localStorage.getItem("ioRootUrl"); } // this.testConnection(); -- cgit v1.2.3