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 --- .../newFileDialog/new-file-workflow-controller.js | 75 +++++++++++++++++++--- 1 file changed, 66 insertions(+), 9 deletions(-) mode change 100644 => 100755 js/io/workflow/newFileDialog/new-file-workflow-controller.js (limited to 'js/io/workflow/newFileDialog/new-file-workflow-controller.js') diff --git a/js/io/workflow/newFileDialog/new-file-workflow-controller.js b/js/io/workflow/newFileDialog/new-file-workflow-controller.js old mode 100644 new mode 100755 index 5cc68bf9..18c84724 --- a/js/io/workflow/newFileDialog/new-file-workflow-controller.js +++ b/js/io/workflow/newFileDialog/new-file-workflow-controller.js @@ -8,9 +8,10 @@ var Montage = require("montage/core/core").Montage, Popup = require("montage/ui/popup/popup.reel").Popup, newFileOptionsNavigatorModule = require("js/io/workflow/newFileDialog/new-file-options-navigator.reel"), newFileWorkflowModelModule = require("js/io/workflow/newFileDialog/new-file-workflow-model"); + saveAsModule = require("js/io/workflow/save-as-dialog.reel"); //singleton -exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, { +var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, { /** * Register a listener for showPicker event */ @@ -20,40 +21,96 @@ exports.NewFileWorkflowController = Montage.create(require("montage/ui/component value:function(){ var that = this; this.eventManager.addEventListener("executeNewFile", function(evt){ - that.showNewFileDialog(); + var data = evt._event.data || {};//data will contain callback + that.showNewFileDialog(data); + }, false); + + 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); } }, + model:{ + writable: true, + enumerable:true, + value: newFileWorkflowModelModule.NewFileWorkflowModel + }, + showNewFileDialog:{ writable:false, enumerable:true, - value:function(){ - var aModel = null; + value:function(data){ + //get default project type + this.model.defaultProjectType = "htmlTemplate"; + this.model.callback = data.callback || null; + this.model.callbackScope = data.callbackScope || null; + + //populate the last opened folder first, if none then populate default root + var sessionStorage = window.sessionStorage; + var lastSelectedProjectType = sessionStorage.getItem("lastSelectedProjectType"); + + if(!!lastSelectedProjectType){ + this.model.defaultProjectType = lastSelectedProjectType; + } + //render modal dialog var newFileNavContent = document.createElement("div"); newFileNavContent.id = "newFileDialog"; - newFileNavContent.style.width = "650px"; - newFileNavContent.style.height = "350px"; - newFileNavContent.style.color = "#fff"; //elements needs to be on DOM to be drawn document.getElementById('modalContainer').appendChild(newFileNavContent); var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); - newFileOptionsNav.newFileModel = newFileWorkflowModelModule.NewFileWorkflowModel; + newFileOptionsNav.newFileModel = this.model; newFileOptionsNav.element = newFileNavContent; - //hack - remove after rendering and add in modal dialog + //remove after rendering and add in modal dialog document.getElementById('modalContainer').removeChild(newFileNavContent); var popup = Popup.create(); popup.content = newFileOptionsNav; popup.modal = true; + popup.type = "newFileDialog"; popup.show(); newFileOptionsNav.popup = popup;//handle to be used for hiding the popup } + }, + + showSaveAsDialog:{ + writable:false, + enumerable:true, + value:function(data){ + var fileName = data.fileName || "filename.txt"; + var folderUri = data.folderUri || "/Documents"; + + //render modal dialog + var saveAsDialogContainer = document.createElement("div"); + saveAsDialogContainer.id = "saveAsDialog"; + + //elements needs to be on DOM to be drawn + document.getElementById('modalContainer').appendChild(saveAsDialogContainer); + + var saveAsDialog = saveAsModule.SaveAsDialog.create(); + 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 + document.getElementById('modalContainer').removeChild(saveAsDialogContainer); + + var popup = Popup.create(); + popup.content = saveAsDialog; + popup.modal = true; + popup.type = "saveAsDialog"; + popup.show(); + + saveAsDialog.popup = popup;//handle to be used for hiding the popup + } } }); \ No newline at end of file -- cgit v1.2.3 From 0e595c4e11ce9b44eff157de8616ed15fcd5d6fc Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 12:37:29 -0800 Subject: refactoring some file names and locations, change made to maintain only one codemirror div. Signed-off-by: Ananya Sen --- .../newFileDialog/new-file-workflow-controller.js | 116 --------------------- 1 file changed, 116 deletions(-) delete mode 100755 js/io/workflow/newFileDialog/new-file-workflow-controller.js (limited to 'js/io/workflow/newFileDialog/new-file-workflow-controller.js') diff --git a/js/io/workflow/newFileDialog/new-file-workflow-controller.js b/js/io/workflow/newFileDialog/new-file-workflow-controller.js deleted file mode 100755 index 18c84724..00000000 --- a/js/io/workflow/newFileDialog/new-file-workflow-controller.js +++ /dev/null @@ -1,116 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage/core/core").Montage, - Popup = require("montage/ui/popup/popup.reel").Popup, - newFileOptionsNavigatorModule = require("js/io/workflow/newFileDialog/new-file-options-navigator.reel"), - newFileWorkflowModelModule = require("js/io/workflow/newFileDialog/new-file-workflow-model"); - saveAsModule = require("js/io/workflow/save-as-dialog.reel"); - -//singleton -var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.create(require("montage/ui/component").Component, { - /** - * Register a listener for showPicker event - */ - deserializedFromTemplate:{ - writable:false, - enumerable:true, - value:function(){ - var that = this; - this.eventManager.addEventListener("executeNewFile", function(evt){ - var data = evt._event.data || {};//data will contain callback - that.showNewFileDialog(data); - }, false); - - 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); - } - }, - - model:{ - writable: true, - enumerable:true, - value: newFileWorkflowModelModule.NewFileWorkflowModel - }, - - showNewFileDialog:{ - writable:false, - enumerable:true, - value:function(data){ - //get default project type - this.model.defaultProjectType = "htmlTemplate"; - this.model.callback = data.callback || null; - this.model.callbackScope = data.callbackScope || null; - - //populate the last opened folder first, if none then populate default root - var sessionStorage = window.sessionStorage; - var lastSelectedProjectType = sessionStorage.getItem("lastSelectedProjectType"); - - if(!!lastSelectedProjectType){ - 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; - popup.modal = true; - popup.type = "newFileDialog"; - popup.show(); - - newFileOptionsNav.popup = popup;//handle to be used for hiding the popup - - } - }, - - showSaveAsDialog:{ - writable:false, - enumerable:true, - value:function(data){ - var fileName = data.fileName || "filename.txt"; - var folderUri = data.folderUri || "/Documents"; - - //render modal dialog - var saveAsDialogContainer = document.createElement("div"); - saveAsDialogContainer.id = "saveAsDialog"; - - //elements needs to be on DOM to be drawn - document.getElementById('modalContainer').appendChild(saveAsDialogContainer); - - var saveAsDialog = saveAsModule.SaveAsDialog.create(); - 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 - document.getElementById('modalContainer').removeChild(saveAsDialogContainer); - - var popup = Popup.create(); - popup.content = saveAsDialog; - popup.modal = true; - popup.type = "saveAsDialog"; - popup.show(); - - saveAsDialog.popup = popup;//handle to be used for hiding the popup - } - } -}); \ No newline at end of file -- cgit v1.2.3