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 --- css/ninja.css | 2 +- js/io/document/document-controller.js | 17 +++- js/io/system/coreioapi.js | 8 +- js/io/templates/descriptor.json | 64 ++++++++----- .../new-file-location.reel/new-file-location.css | 7 +- .../new-file-location.reel/new-file-location.html | 10 +- .../new-file-options-navigator.css | 4 + .../new-file-options-navigator.html | 2 +- .../new-file-options-navigator.js | 48 +++++++--- .../new-file-workflow-controller.js | 37 ++++++-- .../ui/new-file-dialog/new-file-workflow-model.js | 101 +-------------------- 11 files changed, 147 insertions(+), 153 deletions(-) diff --git a/css/ninja.css b/css/ninja.css index bf71955f..84600f12 100755 --- a/css/ninja.css +++ b/css/ninja.css @@ -72,7 +72,7 @@ body { position: absolute; margin: 0px; width: 100%; height: 100%; background-co #appWorkspace { display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-pack: center; -webkit-box-align: center; -webkit-box-sizing: stretch; position: relative; padding: 2px 0px; border: 1px solid #333; overflow: hidden; } -#topMenu { background-color: #474747; position: absolute; height: 28px; width: 100%; top: 0px; left: 0px; z-index: 9999; } +#topMenu { background-color: #474747; position: absolute; height: 28px; width: 100%; top: 0px; left: 0px; z-index: 6995; } #topPanelContainer, #leftPanelContainer, #rightPanelContainer, #bottomPanelContainer { background-color: #282828; } diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 8ce43dcc..dd62b40b 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -71,8 +71,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, deserializedFromTemplate: { value: function() { this.eventManager.addEventListener("appLoaded", this, false); - this.eventManager.addEventListener("executeFileOpen", this, false); + this.eventManager.addEventListener("executeNewFile", this, false); } }, @@ -93,6 +93,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, + handleExecuteNewFile: { + value: function(event) { + var newFileSettings = event._event.settings || {}; + newFileSettings.callback = this.createNewFile; + newFileSettings.callbackScope = this; + this.application.ninja.newFileController.showNewFileDialog(newFileSettings); + } + }, + + createNewFile:{ + value:function(newFileObj){ + //console.log(newFileObj); + } + }, + openFileWithURI: { value: function(uriArrayObj) { var uri = "", fileContent = "", response=null, filename="", fileType="js"; diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index f0ca568f..e448d981 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -1009,7 +1009,7 @@ exports.CoreIoApi = Montage.create(Component, { * check if the file exists */ checkFileExists:{ - value: function(fileUri, folderUri, fileType){ + value: function(fileName, folderUri, fileType){ var uri = "", response=null, status=true; //prepare absolute uri @@ -1017,9 +1017,11 @@ exports.CoreIoApi = Montage.create(Component, { folderUri = folderUri + "/"; } - //todo:add file extension check if fileType present + if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){ + fileName = fileName+fileType; + } - uri = ""+folderUri+fileUri; + uri = ""+folderUri+fileName; response = this.fileExists({"uri":uri}); if(!!response && response.success && (response.status === 204)){ diff --git a/js/io/templates/descriptor.json b/js/io/templates/descriptor.json index 3d8391c5..d8fb7da4 100644 --- a/js/io/templates/descriptor.json +++ b/js/io/templates/descriptor.json @@ -1,51 +1,73 @@ { "categories":{ - "children":["newFile"] + "children":["/"] }, - "newFile":{ - "name":"Blank Template", + "/":{ + "name":"Blank File", "uri":"/", "type":"directory", - "children":["html", "js", "css", "json", "php", "pl", "py", "rb"] + "children":["files/html.txt", "files/js.txt", "files/css.txt", "files/json.txt", "files/php.txt", "files/pl.txt", "files/py.txt", "files/rb.txt"] }, - "html":{ + "files/html.txt":{ "name":"HTML", "uri":"files/html.txt", - "type":"file" + "type":"file", + "fileExtension":".html", + "children":["defaultTemplate"] }, - "js":{ + "files/js.txt":{ "name":"JavaScript", "uri":"files/js.txt", - "type":"file" + "type":"file", + "fileExtension":".js", + "children":["defaultTemplate"] }, - "css":{ + "files/css.txt":{ "name":"Cascading Style Sheets", "uri":"files/css.txt", - "type":"file" + "type":"file", + "fileExtension":".css", + "children":["defaultTemplate"] }, - "json":{ + "files/json.txt":{ "name":"JSON", "uri":"files/json.txt", - "type":"file" + "type":"file", + "fileExtension":".json", + "children":["defaultTemplate"] }, - "php":{ + "files/php.txt":{ "name":"PHP", "uri":"files/php.txt", - "type":"file" + "type":"file", + "fileExtension":".php", + "children":["defaultTemplate"] }, - "pl":{ + "files/pl.txt":{ "name":"Perl", "uri":"files/pl.txt", - "type":"file" + "type":"file", + "fileExtension":".pl", + "children":["defaultTemplate"] }, - "py":{ + "files/py.txt":{ "name":"Python", "uri":"files/py.txt", - "type":"file" + "type":"file", + "fileExtension":".py", + "children":["defaultTemplate"] }, - "rb":{ + "files/rb.txt":{ "name":"Ruby", "uri":"files/rb.txt", - "type":"file" - } + "type":"file", + "fileExtension":".rb", + "children":["defaultTemplate"] + }, + "defaultTemplate":{ + "name": "Basic", + "uri": "defaultTemplate", + "type":"file" + } + } \ No newline at end of file diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css index 7f11c225..092ca626 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.css @@ -5,7 +5,7 @@ */ .newfileLocation .newFileName{ - width:70%; + width:65%; margin-left:5px; } @@ -49,7 +49,7 @@ } .newfileLocation .nameText{ - margin-right:31px; + margin-right:28px; } .newfileLocation .hottextunit{ @@ -57,3 +57,6 @@ display: inline; } +.newfileLocation .fileExtension{ + color:#d7d7d7; +} diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html index d7fbc235..8c0327eb 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html @@ -76,14 +76,18 @@
-
NAME:
+
+ NAME: + + +
DIRECTORY:

-
WIDTH:
-
HEIGHT:
+
WIDTH:
+
HEIGHT:
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.css b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.css index 7ef6d2ce..95ce01f9 100755 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.css +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.css @@ -153,4 +153,8 @@ border:2px solid #a1a1a1; background-image:none; cursor:auto; +} + +.newfile .atree ul{ + -webkit-padding-start: 10px; } \ No newline at end of file diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.html b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.html index eb4a8045..c9178d65 100755 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.html +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.html @@ -70,7 +70,7 @@
Create New File
-
File Type
+
Choose Type
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"); 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 diff --git a/js/io/ui/new-file-dialog/new-file-workflow-model.js b/js/io/ui/new-file-dialog/new-file-workflow-model.js index bcaf8132..892dd3cf 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-model.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-model.js @@ -42,105 +42,8 @@ exports.NewFileWorkflowModel = Object.create(Object.prototype, { }, projectTypeData:{ - writable:false, + writable:true, enumerable:false, - value:{//dummy data for testing - "categories":{ - "children":["newFile", "newProject", "fromTemplate"] - }, - "newProject":{ - "type":"directory", - "name":"New Project", - "uri":"newProject", - "children":["animation", "bannerAd", "montageComponent", "androidApp"] - }, - "newFile":{ - "name":"Blank Template", - "uri":"newFile", - "type":"directory", - "children":["htmlTemplate", "javascriptTemplate", "cssTemplate"] - }, - "fromTemplate":{ - "name":"From Template", - "uri":"fromTemplate", - "type":"directory", - "children":["xoomApp", "website", "iosApp"] - }, - "bannerAd":{ - "name":"Banner Ad", - "uri":"bannerAd", - "type":"file", - "children":["176x208", "176x220", "208x320", "230x240", "208x320", "230x240", "208x320", "230x240"] - }, - "animation":{ - "name":"Animation", - "uri":"animation", - "type":"file", - "children":["176x208", "176x220", "208x320", "230x240"] - }, - "montageComponent":{ - "name":"Montage Component", - "uri":"montageComponent", - "type":"file", - "children":["176x208", "176x208", "176x220", "208x320", "230x240","176x208", "176x220", "208x320", "230x240"] - }, - "androidApp":{ - "name":"Android App", - "uri":"androidApp", - "type":"file", - "children":["176x208", "176x220"] - }, - "xoomApp":{ - "name":"Xoom Application", - "uri":"xoomApp", - "type":"file", - "children":["176x208", "176x208", "176x220", "208x320", "176x220", "208x320", "230x240"] - }, - "iosApp":{ - "name":"iOS Application", - "uri":"iosApp", - "type":"file", - "children":["176x208"] - }, - "176x208":{ - "name":"176 x 208", - "uri":"176x208", - "type":"file" - }, - "176x220":{ - "name":"176 x 220", - "uri":"176x220", - "type":"file" - }, - "208x320":{ - "name":"208 x 320", - "uri":"208x320", - "type":"file" - }, - "htmlTemplate":{ - "name":"HTML", - "uri":"htmlTemplate", - "type":"file", - "children":["defaultTemplate", "xoomApp", "iosApp", "androidApp", "bannerAd"] - }, - "cssTemplate":{ - "name":"CSS", - "uri":"cssTemplate", - "type":"file", - "children":["defaultTemplate"] - }, - "javascriptTemplate":{ - "name":"JavaScript", - "uri":"javascriptTemplate", - "type":"file", - "children":["defaultTemplate"] - }, - defaultTemplate:{ - "name": "default", - "uri": "defaultTemplate", - "type":"file" - } - - } + value:{} } }); -- 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 --- js/io/document/document-controller.js | 14 ++++++++++--- .../new-file-options-navigator.js | 24 ++++++++++++++++++---- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 24 ++++++++++++++++++---- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index dd62b40b..7cc0eeeb 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -15,7 +15,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, Uuid = require("montage/core/uuid").Uuid, - nj= require("js/lib/NJUtils.js").NJUtils, HTMLDocument = require("js/io/document/html-document").HTMLDocument, TextDocument = require("js/io/document/text-document").TextDocument; @@ -123,7 +122,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n"); - filename = nj.getFileNameFromPath(uri); + filename = this.getFileNameFromPath(uri); if(uri.indexOf('.') != -1){ fileType = uri.substr(uri.lastIndexOf('.') + 1); } @@ -430,5 +429,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { return "userDocument_" + (this._iframeCounter++); } - } + }, + + ///// Return the last part of a path (e.g. filename) + getFileNameFromPath : { + value: function(path) { + path = path.replace(/[/\\]$/g,""); + path = path.replace(/\\/g,"/"); + return path.substr(path.lastIndexOf('/') + 1); + } + } }); \ No newline at end of file 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 diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index b20bed87..1de2eaf1 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -5,8 +5,7 @@ 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, - nj= require("js/lib/NJUtils.js").NJUtils; + Component = require("montage/ui/component").Component; var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { @@ -163,7 +162,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { }, isValidFileName:{ value: function(fileName){ - var status = nj.isValidFileName(fileName); + var status = this.isValidFileName(fileName); if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); @@ -191,6 +190,23 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { 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 --- .../pickerNavigator.reel/pickerNavigator.html | 30 -------------------- .../pickerNavigator.reel/pickerNavigator.js | 3 ++ .../new-file-options-navigator.html | 30 -------------------- .../new-file-options-navigator.js | 3 ++ js/io/ui/save-as-dialog.reel/save-as-dialog.html | 33 ++-------------------- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 3 ++ 6 files changed, 11 insertions(+), 91 deletions(-) diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.html b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.html index b5da0e6e..bd427f97 100755 --- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.html +++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.html @@ -10,36 +10,6 @@