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 --- .../new-file-workflow-controller.js | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100755 js/io/ui/new-file-dialog/new-file-workflow-controller.js (limited to 'js/io/ui/new-file-dialog/new-file-workflow-controller.js') 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 new file mode 100755 index 00000000..cfe7db16 --- /dev/null +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -0,0 +1,116 @@ +/* +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/ui/new-file-dialog/new-file-options-navigator.reel"), + newFileWorkflowModelModule = require("js/io/ui/new-file-dialog/new-file-workflow-model"); + saveAsModule = require("js/io/ui/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 From 6890662caba94598675679f40dbb725301c93e98 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 17:45:22 -0800 Subject: integrated new file dialog with the template descriptor.json and document-controller.js Signed-off-by: Ananya Sen --- .../new-file-workflow-controller.js | 37 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-workflow-controller.js') 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 cfe7db16..16075ecf 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 @@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Popup = require("montage/ui/popup/popup.reel").Popup, newFileOptionsNavigatorModule = require("js/io/ui/new-file-dialog/new-file-options-navigator.reel"), - newFileWorkflowModelModule = require("js/io/ui/new-file-dialog/new-file-workflow-model"); + newFileWorkflowModelModule = require("js/io/ui/new-file-dialog/new-file-workflow-model").NewFileWorkflowModel; saveAsModule = require("js/io/ui/save-as-dialog.reel"); //singleton @@ -20,10 +20,6 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre 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 @@ -35,15 +31,20 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre model:{ writable: true, enumerable:true, - value: newFileWorkflowModelModule.NewFileWorkflowModel + value: null }, showNewFileDialog:{ writable:false, enumerable:true, value:function(data){ + this.model = newFileWorkflowModelModule; + + //read file descriptor to populate model + this.model.projectTypeData = this.loadDescriptor("js/io/templates/descriptor.json"); + //get default project type - this.model.defaultProjectType = "htmlTemplate"; + this.model.defaultProjectType = "files/html.txt"; this.model.callback = data.callback || null; this.model.callbackScope = data.callbackScope || null; @@ -112,5 +113,27 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre saveAsDialog.popup = popup;//handle to be used for hiding the popup } + }, + + loadDescriptor:{ + value: function(descriptorPath){ + var content = null, descriptorObj=null; + var xhr = new XMLHttpRequest(); + xhr.open("GET", descriptorPath, false); + xhr.send(); + if (xhr.readyState === 4) { + if(xhr.status == 200) { + content = xhr.responseText; + } + } + if(!!content && (content.length > 0)){ + try{ + descriptorObj = JSON.parse(content); + }catch(e){ + console.log(e,stack); + } + } + return descriptorObj; + } } }); \ No newline at end of file -- cgit v1.2.3 From c9d0cb73698066247c6267bba8fa446a979565fb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 9 Feb 2012 11:12:21 -0800 Subject: fixed templates descriptor, changed validation to on key up, fixed minor ui issues Signed-off-by: Ananya Sen --- js/io/ui/new-file-dialog/new-file-workflow-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io/ui/new-file-dialog/new-file-workflow-controller.js') 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 16075ecf..6cf2a2ae 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 @@ -44,7 +44,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.projectTypeData = this.loadDescriptor("js/io/templates/descriptor.json"); //get default project type - this.model.defaultProjectType = "files/html.txt"; + this.model.defaultProjectType = "/js/io/templates/files/html.txt"; this.model.callback = data.callback || null; this.model.callbackScope = data.callbackScope || null; -- 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 --- js/io/ui/new-file-dialog/new-file-workflow-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io/ui/new-file-dialog/new-file-workflow-controller.js') 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 6cf2a2ae..7b7f4572 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 @@ -44,7 +44,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.projectTypeData = this.loadDescriptor("js/io/templates/descriptor.json"); //get default project type - this.model.defaultProjectType = "/js/io/templates/files/html.txt"; + this.model.defaultProjectType = "js/io/templates/files/html.txt"; this.model.callback = data.callback || null; this.model.callbackScope = data.callbackScope || null; -- cgit v1.2.3