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/ui') 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