From 2e766c9eaa98fa20f311b3eb2f892a1a240e90cf Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 16 Feb 2012 06:43:33 -0800 Subject: file picker: Enable ok if user double clicks folder and enter it. Validate path if user enter it manually in addressbar. Signed-off-by: Ananya Sen --- .../pickerNavigator.reel/pickerNavigator.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js index edc24a2c..411386f9 100644 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -203,6 +203,13 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.pickerModel.storeHistory(this.pickerModel.currentRoot);//populate history this.updateMetadata(this.currentURI); + + //for directory selection, selected url is the folder entered + if(!this.pickerModel.inFileMode ){ + this.okButton.removeAttribute("disabled"); + //put into selectedItems..currently single selection is supported + this.selectedItems = [this.pickerModel.currentRoot]; + } } this.element.addEventListener("openFolder", function(evt){that.handlePickerNavOpenFolder(evt);}, false);//add icon double click event listener to reload iconList with new set of data @@ -211,6 +218,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.element.addEventListener("updateMetadata", function(evt){that.handlePickerNavUpdateMetadata(evt);}, false);//show metadata on click of icon //this.addressGo.addEventListener("click", this, false); this.addressBarUri.addEventListener("keydown", this, false); + this.addressBarUri.addEventListener("keyup", this, false); this.refreshButton.addEventListener("click", this, false);//refresh - gets from file system directly this.backArrow.addEventListener("click", this, false); this.forwardArrow.addEventListener("click", this, false); @@ -608,6 +616,13 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.backArrow.classList.remove("disable"); } + //for directory selection, selected url is the folder entered + if(!this.pickerModel.inFileMode ){ + this.okButton.removeAttribute("disabled"); + //put into selectedItems..currently single selection is supported + this.selectedItems = [evt.folderUri]; + } + } }, @@ -720,6 +735,21 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { } }, + handleAddressBarUriKeyup:{ + value: function(evt){ + //disable ok if user enters an invalid uri + if(!this.application.ninja.coreIoApi.isValidUri(this.addressBarUri.value)){ + //disable OK + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + }else{ + this.okButton.removeAttribute("disabled"); + this.selectedItems = [this.addressBarUri.value]; + } + } + }, + handleRefreshButtonClick:{ value:function(evt){ var uri = this.addressBarUri.value; -- cgit v1.2.3