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-options-navigator.js | 378 +++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js new file mode 100644 index 00000000..cee8d4b7 --- /dev/null +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -0,0 +1,378 @@ +/* +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, + Component = require("montage/ui/component").Component, + iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), + treeModule = require("js/components/ui/tree-basic/tree.reel"), + newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"), + nj= require("js/lib/NJUtils.js").NJUtils; + +var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { + + newFileModel: { + writable: true, + enumerable:false, + value:null + }, + selectedProjectType:{ + writable: true, + enumerable:false, + value:null + }, + selectedTemplate:{ + writable: true, + enumerable:false, + value:null + }, + newFileName:{ + writable:true, + enumerable:false, + value:"" + }, + newFileDirectory:{ + writable:true, + enumerable:false, + value:"" + }, + templateWidth:{ + writable:true, + enumerable:false, + value:"0 px" + }, + templateHeight:{ + writable:true, + enumerable:false, + value:"0 px" + }, + willDraw: { + enumerable: false, + value: function() {} + }, + draw: { + enumerable: false, + value: function() {} + }, + didDraw: { + enumerable: false, + value: function() { + var that = this; + + this.templateList = null; + + //draw left nav project type tree + var tree = treeModule.Tree.create(); + tree.showIcons = false; + tree.expandTreeAfterDraw = true; + tree.directoryBold = true; + tree.highlightedUri = this.newFileModel.defaultProjectType; + tree.treeViewDataObject = this.newFileModel.prepareContents("categories"); + tree.element = this.projectTypeTree; + tree.needsDraw = true; + + //highlight defaultProjectType + + this.addIdentifiers(); + + this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); + this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only + this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); + this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + + if(!!this.newFileModel.defaultProjectType){ + var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); + this.templateList = iconsListModule.IconsList.create(); + this.templateList.iconsViewDataObject = templates; + this.templateList.element = this.templateIcons; + this.templateList.needsDraw = true; + + + this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; + } + } + + }, + + /** + * Event Listners + */ + + addIdentifiers:{ + value: function(){ + this.element.identifier = "newFileNav"; + } + }, + + handleNewFileNavDrawTree:{ + value: function(evt){ + //toggle open or close for directory + if((evt.uriType === "directory") && (!!evt.subTreeContainer)){ + var tree = treeModule.Tree.create(); + tree.showIcons = false; + tree.highlightedUri = this.newFileModel.defaultProjectType; + tree.treeViewDataObject = this.newFileModel.prepareContents(evt.uri); + tree.element = evt.subTreeContainer; + tree.needsDraw = true; + } + } + }, + + handleNewFileNavSelectedItem:{ + value: function(evt){ + var selectionType = this.newFileModel.projectTypeData[evt.uri].type; + if(evt.target.classList.contains("atreeItemContent") && (selectionType === "file")){//populate templates for project type selection + this.highlightSelection(evt.target, "projectType", evt.uri); + + //clear current template selection + if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){ + this.selectedTemplate.element.classList.remove("selected"); + } + + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + + //save project type selection + this.selectedProjectType = {"uri":evt.uri, "element":evt.target}; + + //render templates + var templates = this.newFileModel.prepareContents(evt.uri); + if(this.templatesContainer.querySelectorAll(".list").length > 0){ + this.templateList.iconsViewDataObject = templates; + }else{ + this.templateList = iconsListModule.IconsList.create(); + this.templateList.iconsViewDataObject = templates; + this.templateList.element = this.templateIcons; + this.templateList.needsDraw = true; + } + + + } + + if(evt.target.classList.contains("icon")){ + this.highlightSelection(evt.target, "template", evt.uri); + + //save template selection + this.selectedTemplate = {"uri":evt.uri, "element":evt.target}; + + this.enableOk(); + + } + } + }, + + handleCancelButtonAction :{ + value:function(evt){ + //clean up memory + this.cleanup(); + + if(this.popup){ + this.popup.hide(); + } + + } + }, + + handleOkButtonAction:{ + value: function(evt){ + var selectedProjectTypeID = this.selectedProjectType.uri, + templateID = this.selectedTemplate.uri, + projectName = this.newFileLocation.newFileName.value, + projectDirectory = this.newFileLocation.fileInputField.newFileDirectory.value, + projectWidth = this.newFileLocation.templateWidth, + projectHeight = this.newFileLocation.templateHeight, + + + selectionlog= "selectedProjectTypeID="+selectedProjectTypeID +"\n"+ + "templateID="+templateID+ "\n"+ + "projectName="+projectName+"\n"+ + "projectDirectory="+projectDirectory+"\n"+ + "projectWidth="+projectWidth+"\n"+ + "projectHeight="+projectHeight; + + if(!!this.selectedProjectType && !!this.selectedTemplate + && this.isValidFileName(projectName) && this.isValidUri(projectDirectory) + && !this.checkFileExists(projectName, projectDirectory, this.selectedProjectType) + ){ + this.error.innerHTML=""; + console.log("$$$ new file selections: \n" + selectionlog); + if(!!this.newFileModel.callback && !!this.newFileModel.callbackScope){//inform document-controller if save successful + this.newFileModel.callback.call(this.newFileModel.callbackScope, {"selectedProjectTypeID":selectedProjectTypeID, + "templateID":templateID, + "projectName": projectName, + "projectDirectory":projectDirectory, + "projectWidth":projectWidth, + "projectHeight":projectHeight});//document-controller api + }else{ + //send selection event + var newFileSelectionEvent = document.createEvent("Events"); + newFileSelectionEvent.initEvent("createNewFile", false, false); + newFileSelectionEvent.newFileOptions = {"selectedProjectTypeID":selectedProjectTypeID, + "templateID":templateID, + "projectName": projectName, + "projectDirectory":projectDirectory, + "projectWidth":projectWidth, + "projectHeight":projectHeight}; + this.eventManager.dispatchEvent(newFileSelectionEvent); + } + //store last selected project type + var dataStore = window.sessionStorage; + try { + dataStore.setItem('lastSelectedProjectType',escape(""+selectedProjectTypeID)); + } + catch(e){ + if(e.code == 22){ + dataStore.clear(); + } + } + + this.cleanup();//clear up any unnecessary memory + + if(this.popup){ + this.popup.hide(); + } + }else{ + if(this.error.innerHTML !== ""){ + this.showError("! Project Template, Name and Directory should be valid."); + } + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + } + } + }, + + handleNewFileDirectorySet:{ + value:function(evt){ + if(!!evt._event.newFileDirectory){ + this.newFileDirectory = evt._event.newFileDirectory; + if(this.isValidUri(this.newFileDirectory)){ + this.enableOk(); + } + } + } + }, + + handleNewFileNameSet:{ + value:function(evt){ + if(!!evt._event.newFileName){ + this.newFileName = evt._event.newFileName; + if(this.isValidFileName(this.newFileName)){ + this.enableOk(); + } + } + } + }, + + highlightSelection:{ + value: function(el, selectionType, uri){ + var elem; + //clear previous selection + if(selectionType === "projectType"){ + if((!!this.selectedProjectType) && (uri !== this.selectedProjectType.uri)){ + if(!!this.selectedProjectType.element){ + this.selectedProjectType.element.classList.remove("selected"); + }else{ + //find the selected element + elem = document.querySelector(".projectTypeTree").querySelector(".selected"); + if(!!elem){ + elem.classList.remove("selected"); + } + } + el.classList.add("selected"); + }else if(this.selectedProjectType === null){ + el.classList.add("selected"); + } + }else if(selectionType === "template"){ + if((!!this.selectedTemplate) && (uri !== this.selectedTemplate.element)){ + if(!!this.selectedTemplate.element){this.selectedTemplate.element.classList.remove("selected");} + el.classList.add("selected"); + }else if(this.selectedTemplate === null){ + el.classList.add("selected"); + } + } + + } + }, + + enableOk:{ + value: function(){ + var status = false; + + if(!!this.selectedProjectType && !!this.selectedTemplate + && this.isValidFileName(this.newFileName) && this.isValidUri(this.newFileDirectory) + && !this.checkFileExists(this.newFileName, this.newFileDirectory, this.selectedProjectType) + ){ + status = true; + this.okButton.removeAttribute("disabled"); + this.error.innerHTML=""; + } + return status; + } + }, + + cleanup:{ + value:function(){ + var that = this; + + this.newFileName = ""; + this.newFileDirectory = ""; + this.selectedProjectType = null; + this.selectedTemplate = null; + + //remove event listeners + this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); + this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only + this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); + this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + } + }, + + isValidUri:{ + value: function(uri){ + var status= nj.isValidUri(uri); + if(uri !== ""){ + if(!status){ + this.showError("! Invalid directory."); + } + } + return status; + } + }, + isValidFileName:{ + value: function(fileName){ + var status = nj.isValidFileName(fileName); + if(fileName !== ""){ + if(!status){ + this.showError("! Invalid file name."); + } + } + return status; + } + }, + checkFileExists:{ + value: function(fileUri, folderUri, fileType){ + var status= this.application.ninja.coreIoApi.checkFileExists(fileUri, folderUri, fileType); + if(status){ + this.showError("! File already exists."); + } + return status; + } + }, + showError:{ + value:function(errorString){ + this.error.innerHTML = ""; + this.error.innerHTML=errorString; + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + } + } + +}); \ No newline at end of file -- cgit v1.2.3 From 476a25e8a662270dfe5b37c560e4235f02b146e4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 12:59:41 -0800 Subject: uri validation moved to file io apis Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index cee8d4b7..a747b8de 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -335,7 +335,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C isValidUri:{ value: function(uri){ - var status= nj.isValidUri(uri); + var status= this.application.ninja.coreIoApi.isValidUri(uri); if(uri !== ""){ if(!status){ this.showError("! Invalid directory."); -- 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-options-navigator.js | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index a747b8de..467c5452 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -92,6 +92,14 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; } + + //update file Extension + if(!!this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension){ + var fileExtensionEl = this.element.querySelector(".fileExtension"); + if(!!fileExtensionEl){ + fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; + } + } } }, @@ -128,7 +136,15 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C //clear current template selection if((!!this.selectedTemplate) && (this.selectedTemplate.element.classList.contains("selected"))){ - this.selectedTemplate.element.classList.remove("selected"); + this.selectedTemplate.element.classList.remove("selected"); + } + + //update file Extension + if(!!this.newFileModel.projectTypeData[evt.uri].fileExtension){ + var fileExtensionEl = this.element.querySelector(".fileExtension"); + if(!!fileExtensionEl){ + fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[evt.uri].fileExtension; + } } //disable ok @@ -186,6 +202,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C projectWidth = this.newFileLocation.templateWidth, projectHeight = this.newFileLocation.templateHeight, + newFilePath = "", fileExtension=this.newFileModel.projectTypeData[selectedProjectTypeID].fileExtension, selectionlog= "selectedProjectTypeID="+selectedProjectTypeID +"\n"+ "templateID="+templateID+ "\n"+ @@ -194,29 +211,30 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C "projectWidth="+projectWidth+"\n"+ "projectHeight="+projectHeight; + + if(/[^/\\]$/g.test(projectDirectory)){ + projectDirectory = projectDirectory + "/"; + } + if(!!fileExtension && (projectName.lastIndexOf(fileExtension) !== (projectName.length - fileExtension.length))){ + projectName = projectName+fileExtension; + } + newFilePath = "" + projectDirectory + projectName; + + if(!!this.selectedProjectType && !!this.selectedTemplate && this.isValidFileName(projectName) && this.isValidUri(projectDirectory) && !this.checkFileExists(projectName, projectDirectory, this.selectedProjectType) ){ this.error.innerHTML=""; - console.log("$$$ new file selections: \n" + selectionlog); + //console.log("$$$ new file selections: \n" + selectionlog); if(!!this.newFileModel.callback && !!this.newFileModel.callbackScope){//inform document-controller if save successful - this.newFileModel.callback.call(this.newFileModel.callbackScope, {"selectedProjectTypeID":selectedProjectTypeID, - "templateID":templateID, - "projectName": projectName, - "projectDirectory":projectDirectory, - "projectWidth":projectWidth, - "projectHeight":projectHeight});//document-controller api + this.newFileModel.callback.call(this.newFileModel.callbackScope, {"fileTemplateUri":selectedProjectTypeID, + "newFilePath":newFilePath});//document-controller api }else{ //send selection event var newFileSelectionEvent = document.createEvent("Events"); newFileSelectionEvent.initEvent("createNewFile", false, false); - newFileSelectionEvent.newFileOptions = {"selectedProjectTypeID":selectedProjectTypeID, - "templateID":templateID, - "projectName": projectName, - "projectDirectory":projectDirectory, - "projectWidth":projectWidth, - "projectHeight":projectHeight}; + newFileSelectionEvent.newFileOptions = {"fileTemplateUri":selectedProjectTypeID, "newFilePath":newFilePath}; this.eventManager.dispatchEvent(newFileSelectionEvent); } //store last selected project type @@ -306,7 +324,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(!!this.selectedProjectType && !!this.selectedTemplate && this.isValidFileName(this.newFileName) && this.isValidUri(this.newFileDirectory) - && !this.checkFileExists(this.newFileName, this.newFileDirectory, this.selectedProjectType) + && !this.checkFileExists(this.newFileName, this.newFileDirectory, this.newFileModel.projectTypeData[this.selectedProjectType.uri].fileExtension) ){ status = true; this.okButton.removeAttribute("disabled"); -- cgit v1.2.3 From 79b0173eeca079dec42ff1480182656dbe3af44f Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 09:49:23 -0800 Subject: removed usage of NJUtils.js as it is being deleted. Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 467c5452..f17b15d5 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -8,8 +8,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), treeModule = require("js/components/ui/tree-basic/tree.reel"), - newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"), - nj= require("js/lib/NJUtils.js").NJUtils; + newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"); var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { @@ -364,7 +363,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }, isValidFileName:{ value: function(fileName){ - var status = nj.isValidFileName(fileName); + var status = this.isValidFileName(fileName); if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); @@ -391,6 +390,23 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.setAttribute("disabled", "true"); } } - } + }, + + /*** + * file name validation + */ + isValidFileName:{ + value: function(fileName){ + var status = false; + if(fileName !== ""){ + fileName = fileName.replace(/^\s+|\s+$/g,""); + status = !(/[/\\]/g.test(fileName)); + if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden + status = !(/^\./g.test(fileName)); + } + } + return status; + } + } }); \ No newline at end of file -- 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 --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index f17b15d5..6f8a9ee7 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -81,6 +81,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); + this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); -- cgit v1.2.3 From 1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 17:22:48 -0800 Subject: added editor tab save while switching code view tabs, integrated new file dialog with io mediator to open the new file in a new tab Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 6f8a9ee7..2f148621 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -231,12 +231,13 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C //console.log("$$$ new file selections: \n" + selectionlog); if(!!this.newFileModel.callback && !!this.newFileModel.callbackScope){//inform document-controller if save successful this.newFileModel.callback.call(this.newFileModel.callbackScope, {"fileTemplateUri":selectedProjectTypeID, - "newFilePath":newFilePath});//document-controller api + "newFilePath":newFilePath, + "fileExtension":fileExtension});//document-controller api }else{ //send selection event var newFileSelectionEvent = document.createEvent("Events"); newFileSelectionEvent.initEvent("createNewFile", false, false); - newFileSelectionEvent.newFileOptions = {"fileTemplateUri":selectedProjectTypeID, "newFilePath":newFilePath}; + newFileSelectionEvent.newFileOptions = {"fileTemplateUri":selectedProjectTypeID, "newFilePath":newFilePath,"fileExtension":fileExtension}; this.eventManager.dispatchEvent(newFileSelectionEvent); } //store last selected project type -- 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 --- .../new-file-options-navigator.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 2f148621..bcb9d123 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -217,8 +217,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(/[^/\\]$/g.test(projectDirectory)){ projectDirectory = projectDirectory + "/"; } - if(!!fileExtension && (projectName.lastIndexOf(fileExtension) !== (projectName.length - fileExtension.length))){ - projectName = projectName+fileExtension; + + if(!!fileExtension && ((projectName.lastIndexOf(fileExtension) === -1) || (projectName.lastIndexOf(fileExtension) !== (projectName.length - fileExtension.length)))){ + projectName = projectName+fileExtension;//append file extension if file extension is already not present or is actually part of the file name } newFilePath = "" + projectDirectory + projectName; @@ -367,7 +368,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }, isValidFileName:{ value: function(fileName){ - var status = this.isValidFileName(fileName); + var status = this.validateFileName(fileName); if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); @@ -399,7 +400,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C /*** * file name validation */ - isValidFileName:{ + validateFileName:{ value: function(fileName){ var status = false; if(fileName !== ""){ -- 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 --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index bcb9d123..f514b81a 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -230,10 +230,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C ){ this.error.innerHTML=""; //console.log("$$$ new file selections: \n" + selectionlog); - if(!!this.newFileModel.callback && !!this.newFileModel.callbackScope){//inform document-controller if save successful - this.newFileModel.callback.call(this.newFileModel.callbackScope, {"fileTemplateUri":selectedProjectTypeID, - "newFilePath":newFilePath, - "fileExtension":fileExtension});//document-controller api + if(!!this.newFileModel.callback){//inform document-controller if save successful + this.newFileModel.callback({"fileTemplateUri":selectedProjectTypeID, + "newFilePath":newFilePath, + "fileExtension":fileExtension});//document-controller api }else{ //send selection event var newFileSelectionEvent = document.createEvent("Events"); -- cgit v1.2.3 From c627ebb5735d55218813b073c655dae6cded6040 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 10 Feb 2012 15:50:14 -0800 Subject: show iframeContainer if all documents are closed Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index f514b81a..848e0cb8 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -226,7 +226,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(!!this.selectedProjectType && !!this.selectedTemplate && this.isValidFileName(projectName) && this.isValidUri(projectDirectory) - && !this.checkFileExists(projectName, projectDirectory, this.selectedProjectType) + && !this.checkFileExists(projectName, projectDirectory, fileExtension) ){ this.error.innerHTML=""; //console.log("$$$ new file selections: \n" + selectionlog); @@ -258,7 +258,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.popup.hide(); } }else{ - if(this.error.innerHTML !== ""){ + if(this.error.innerHTML === ""){ this.showError("! Project Template, Name and Directory should be valid."); } //disable ok @@ -328,7 +328,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(!!this.selectedProjectType && !!this.selectedTemplate && this.isValidFileName(this.newFileName) && this.isValidUri(this.newFileDirectory) - && !this.checkFileExists(this.newFileName, this.newFileDirectory, this.newFileModel.projectTypeData[this.selectedProjectType.uri].fileExtension) ){ status = true; this.okButton.removeAttribute("disabled"); -- cgit v1.2.3 From 50a40c4e21b9a4d53d6d1fb739d838c0319ab09b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 13 Feb 2012 19:55:46 -0800 Subject: new file dialog - preselect default template Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 848e0cb8..f5ab0027 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -88,6 +88,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; @@ -161,9 +164,15 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var templates = this.newFileModel.prepareContents(evt.uri); if(this.templatesContainer.querySelectorAll(".list").length > 0){ this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } }else{ this.templateList = iconsListModule.IconsList.create(); this.templateList.iconsViewDataObject = templates; + if(templates.length >0){ + this.templateList.selected = templates[0].uri; + } this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; } -- cgit v1.2.3