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 -------------- 1 file changed, 14 deletions(-) (limited to 'js/io/ui/file-picker') 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; -- 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/ui/file-picker') 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