From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- .../pickerNavigator.reel/pickerNavigator.js | 67 +++++++++++----------- 1 file changed, 32 insertions(+), 35 deletions(-) mode change 100644 => 100755 js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js old mode 100644 new mode 100755 index 299d44f5..eec7c8e8 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -209,26 +209,27 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.refreshButton.addEventListener("click", this, false);//refresh - gets from file system directly this.backArrow.addEventListener("click", this, false); this.forwardArrow.addEventListener("click", this, false); - this.okButton.addEventListener("click", this, false); - this.cancelButton.addEventListener("click", this, false); - - //populate filters - var filtersDD = this.element.querySelector(".filters .dropdown"); - if(!!this.pickerModel.fileFilters - && (typeof this.pickerModel.fileFilters === "object") - && ('splice' in this.pickerModel.fileFilters) - && ('join' in this.pickerModel.fileFilters)){ - this.pickerModel.fileFilters.forEach(function(aFilter){ - var newDiv = document.createElement("div"); - newDiv.innerHTML = aFilter; - filtersDD.appendChild(newDiv); - newDiv.addEventListener("click", function(evt){that.handleFilterClick(evt, aFilter, filtersDD)}, false); - }, this); - } - var renderedWidth = this.getComputedWidth(filtersDD); - this.filters.style.width = "" + (parseInt((renderedWidth.substring(0, (renderedWidth.length - 2)))) + 20) + "px"; + //populate filters if in file selection mode + if(this.pickerModel.inFileMode === true){ + var filtersDD = this.element.querySelector(".filters .dropdown"); + if(!!this.pickerModel.fileFilters + && (typeof this.pickerModel.fileFilters === "object") + && ('splice' in this.pickerModel.fileFilters) + && ('join' in this.pickerModel.fileFilters)){ + this.pickerModel.fileFilters.forEach(function(aFilter){ + var newDiv = document.createElement("div"); + newDiv.innerHTML = aFilter; + filtersDD.appendChild(newDiv); + newDiv.addEventListener("click", function(evt){that.handleFilterClick(evt, aFilter, filtersDD)}, false); + }, this); + } + var renderedWidth = this.getComputedWidth(filtersDD); + this.filters.style.width = "" + (parseInt((renderedWidth.substring(0, (renderedWidth.length - 2)))) + 20) + "px"; + }else{ + this.filters.style.display = "none"; + } /** * attach click event listeners to the addressbar dropdown arrows */ @@ -263,11 +264,11 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { } }, - //TODO: add uri pattern validation - validateUri:{ + cleanupUri:{ writable: false, enumerable:true, value: function(folderUri){ + folderUri = folderUri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces //remove unnecessary / from end - for Win and Mac .... don't trim for the root if(((folderUri.charAt(folderUri.length - 1) === "/") || (folderUri.charAt(folderUri.length - 1) === "\\")) && (folderUri !== "/")){ folderUri = folderUri.substring(0, (folderUri.length - 1)); @@ -324,7 +325,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { writable:false, enumerable:true, value:function(uri){ - uri = this.validateUri(uri); + uri = this.cleanupUri(uri); var arr = []; var temp = new String(uri); while(temp.indexOf("/") != -1){ @@ -532,8 +533,6 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.refreshButton.identifier = "refreshButton"; this.backArrow.identifier = "backArrow"; this.forwardArrow.identifier = "forwardArrow"; - this.okButton.identifier = "okButton"; - this.cancelButton.identifier = "cancelButton"; this.iconView.identifier = "iconView"; this.treeView.identifier = "treeView"; this.resultsArea.identifier = "resultsArea"; @@ -651,7 +650,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { if(this.addressBarUri.value !== ""){ var uri = this.addressBarUri.value; - uri = this.validateUri(uri); + uri = this.cleanupUri(uri); this.currentURI = uri; var status = this.pickerViews()[this.selectedPickerView].call(this, uri);//dynamically calls the update function of the current picker view @@ -676,7 +675,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { value: function(evt){ if(evt.keyCode === 13 ){ var uri = this.addressBarUri.value; - uri = this.validateUri(uri); + uri = this.cleanupUri(uri); this.currentURI = uri; @@ -699,7 +698,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { handleRefreshButtonClick:{ value:function(evt){ var uri = this.addressBarUri.value; - uri = this.validateUri(uri); + uri = this.cleanupUri(uri); var status = this.pickerViews()[this.selectedPickerView].call(this, uri, false);//dynamically calls the update function of the current picker view @@ -768,22 +767,22 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { } }, - handleOkButtonClick : { + handleOkButtonAction : { value: function(evt){ - alert("selected "+ this.selectedItems.toString()); + console.log("$$$ File Picker : selected "+ this.selectedItems.toString()); var success = true; - if(!!this.pickerModel.callback && (this.selectedItems.length > 0)){//call the callback if it is available + if(!!this.pickerModel.callback && !!this.pickerModel.callbackScope && (this.selectedItems.length > 0)){//call the callback if it is available try{ - this.pickerModel.callback({"uri":this.selectedItems}); + this.pickerModel.callback.call(this.pickerModel.callbackScope, {"uri":this.selectedItems}); }catch(e){ success = false; - console.log("[ERROR] File IO failed to open URIs: "+ this.selectedItems.toString()); + console.log(e.stack); } }else{//else send an event with the selected files var pickerSelectionEvent = document.createEvent("Events"); pickerSelectionEvent.initEvent("pickerSelectionsDone", false, false); pickerSelectionEvent.selectedItems = this.selectedItems; - document.dispatchEvent(pickerSelectionEvent);//TODO: use eventManager when it is available + this.eventManager.dispatchEvent(pickerSelectionEvent); } //store last opened/saved folder, and view after IO is successful @@ -813,7 +812,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { } }, - handleCancelButtonClick :{ + handleCancelButtonAction :{ value:function(evt){ //clean up memory this.cleanup(); @@ -1005,8 +1004,6 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.refreshButton.removeEventListener("click", this, false);//refresh - gets from file system directly this.backArrow.removeEventListener("click", this, false); this.forwardArrow.removeEventListener("click", this, false); - this.okButton.removeEventListener("click", this, false); - this.cancelButton.removeEventListener("click", this, false); this.iconView.removeEventListener("click", this, false); this.treeView.removeEventListener("click", this, false); this.element.removeEventListener("drawTree", this, false); -- cgit v1.2.3 From 92161460a6cbbdebfd1b0263ec6eb790091920a9 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 30 Jan 2012 14:18:21 -0800 Subject: Moving changes from Gerrit, on 1/27, to the github branch: - added file existence check and validation to save as dialog - minor css fix for file picker, new file dialog Signed-off-by: Ananya Sen --- .../ui/FilePicker/pickerNavigator.reel/pickerNavigator.js | 11 +++++++++++ 1 file changed, 11 insertions(+) mode change 100755 => 100644 js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js old mode 100755 new mode 100644 index eec7c8e8..268ec41a --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -621,6 +621,16 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.currentSelectedNode = evt.target; }else{ + + + //test: highlight non-selectable icons too + if(!evt.target.classList.contains("selected")){ + evt.target.classList.add("selected"); + } + this.currentSelectedNode = evt.target; + //end- test + + //disable OK if(!this.okButton.hasAttribute("disabled")){ this.okButton.setAttribute("disabled", "true"); @@ -776,6 +786,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.pickerModel.callback.call(this.pickerModel.callbackScope, {"uri":this.selectedItems}); }catch(e){ success = false; + console.log("[Error] Failed to open "+ this.selectedItems.toString()); console.log(e.stack); } }else{//else send an event with the selected files -- cgit v1.2.3 From 7618cabe1945acc6392c48f3b57820f67f7973b0 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 10:22:26 -0800 Subject: removed using montage button, since it has changed in Montafe 0.6 Signed-off-by: Ananya Sen --- js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js index 268ec41a..d7a19c14 100644 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -245,6 +245,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); + this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); + this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + //ready to show picker now this.element.style.visibility = "visible"; } -- cgit v1.2.3 From ad0ee69be3512325ede94738f23597086a141a3e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 10 Feb 2012 01:55:30 -0800 Subject: file open and file new integrated again Signed-off-by: Ananya Sen --- .../pickerNavigator.reel/pickerNavigator.js | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js index d7a19c14..ff9c7073 100644 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -7,7 +7,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), - filePickerControllerModule = require("js/components/ui/FilePicker/file-picker-controller"), treeModule = require("js/components/ui/tree-basic/tree.reel"); var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { @@ -335,7 +334,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { temp = temp.substring(0, temp.lastIndexOf("/")); //populate dropdown irrespective of validity -// if(!!filePickerControllerModule.FilePickerController._directoryContentCache[temp]){//check if it is a valid location +// if(!!this.application.ninja.filePickerController._directoryContentCache[temp]){//check if it is a valid location // arr.push(temp); // }else{ // break; @@ -358,7 +357,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { value:function(element, uri){ if(!!element){ var tree = treeModule.Tree.create(); - tree.treeViewDataObject = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); + tree.treeViewDataObject = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel); //console.log("renderTree() for "+ uri); //console.log(tree.treeViewDataObject); tree.element = element; @@ -374,10 +373,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { var status = true; var iconViewContainer = this.element.querySelector(".iconViewContainer"); if((typeof fromCache === 'undefined') || (fromCache === true)){ - this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); + this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel); } else{ - this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); + this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false); } if(!!this.newContent && this.newContent.length > 0){ //clear selection @@ -423,10 +422,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { if(!!treeViewContainer){ var data = []; if((typeof fromCache === 'undefined') || (fromCache === true)){ - data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); + data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel); } else{ - data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); + data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false); } if(data.length > 0){ @@ -475,7 +474,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { enumerable: false, writable:false, value:function(currentUri){ - var data = filePickerControllerModule.FilePickerController._directoryContentCache[currentUri]; + var data = this.application.ninja.filePickerController._directoryContentCache[currentUri]; var metadata = ""; if(!!data){ if(data.name !== ""){ @@ -610,8 +609,8 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.currentSelectedNode = null; } //enable OK button if the selection is valid as per the picker mode - if((this.pickerModel.inFileMode && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "file")) - || (!this.pickerModel.inFileMode && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "directory"))){ + if((this.pickerModel.inFileMode && (this.application.ninja.filePickerController._directoryContentCache[uri].type === "file")) + || (!this.pickerModel.inFileMode && (this.application.ninja.filePickerController._directoryContentCache[uri].type === "directory"))){ this.okButton.removeAttribute("disabled"); //put into selectedItems..currently single selection is supported @@ -784,9 +783,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { value: function(evt){ console.log("$$$ File Picker : selected "+ this.selectedItems.toString()); var success = true; - if(!!this.pickerModel.callback && !!this.pickerModel.callbackScope && (this.selectedItems.length > 0)){//call the callback if it is available + if(!!this.pickerModel.callback && (this.selectedItems.length > 0)){//call the callback if it is available try{ - this.pickerModel.callback.call(this.pickerModel.callbackScope, {"uri":this.selectedItems}); + this.pickerModel.callback({"uri":this.selectedItems}); }catch(e){ success = false; console.log("[Error] Failed to open "+ this.selectedItems.toString()); @@ -803,12 +802,12 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { var dataStore = window.sessionStorage; try { if(this.pickerModel.pickerMode === "write"){ - filePickerControllerModule.FilePickerController._lastSavedFolderURI.lastSavedFolderUri_local = this.currentURI; dataStore.setItem('lastSavedFolderURI',escape(""+this.currentURI)); } - else{ - filePickerControllerModule.FilePickerController._lastOpenedFolderURI.lastFolderUri_local = this.currentURI; - dataStore.setItem('lastOpenedFolderURI',escape(""+this.currentURI)); + else if(this.pickerModel.inFileMode === true){ + dataStore.setItem('lastOpenedFolderURI_fileSelection',escape(""+this.currentURI)); + }else if(this.pickerModel.inFileMode === false){ + dataStore.setItem('lastOpenedFolderURI_folderSelection',escape(""+this.currentURI)); } } catch(e){ @@ -962,9 +961,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { handlePickerNavRefreshTreeSegment:{ value: function(evt){ -// if(filePickerControllerModule.FilePickerController.checkIfStale(evt.uri)){ +// if(this.application.ninja.filePickerController.checkIfStale(evt.uri)){ // //update tree segment if was stale -// evt.treeSegment.treeViewDataObject = filePickerControllerModule.FilePickerController.prepareContentList(evt.uri, this.pickerModel, true, false); +// evt.treeSegment.treeViewDataObject = this.application.ninja.filePickerController.prepareContentList(evt.uri, this.pickerModel, true, false); // } } }, @@ -1007,7 +1006,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { value:function(){ //clear memory - TODO:check for more memory leaks this.pickerModel = null; - filePickerControllerModule.FilePickerController._directoryContentCache = {}; + this.application.ninja.filePickerController._directoryContentCache = {}; //remove listeners this.element.removeEventListener("openFolder", this, false);//add icon double click event listener to reload iconList with new set of data this.element.removeEventListener("selectedItem", this, false);//for single selection only -- cgit v1.2.3 From a6948e635389768fc316f1fb86df2524b482b47c Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 13 Feb 2012 18:48:18 -0800 Subject: added logical drive selection to file picker Signed-off-by: Ananya Sen --- .../ui/FilePicker/pickerNavigator.reel/pickerNavigator.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js') diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js index ff9c7073..6b0d92f7 100644 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js @@ -149,6 +149,12 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { leftNav.appendChild(newDiv); if(dirObj.uri === this.pickerModel.currentRoot){ newDiv.classList.add("highlighted"); + //enable ok for logical drive selections, when in directory selection mode + if(this.pickerModel.inFileMode === false){ + this.okButton.removeAttribute("disabled"); + //put into selectedItems..currently single selection is supported + this.selectedItems = [dirObj.uri]; + } } newDiv.addEventListener("click", function(evt){that.handleTopLevelDirectoryClicks(evt, dirObj);}, false); @@ -571,6 +577,13 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { if(!evt.target.classList.contains("highlighted")){ evt.target.classList.add("highlighted"); } + + //enable ok for logical drive selections, when in directory selection mode + if(this.pickerModel.inFileMode === false){ + this.okButton.removeAttribute("disabled"); + //put into selectedItems..currently single selection is supported + this.selectedItems = [dirObj.uri]; + } } }, -- cgit v1.2.3