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 --- .../file-input-field.reel/file-input-field.js | 4 ++-- js/io/system/fileio.js | 2 +- js/io/templates/descriptor.json | 18 +++++++++--------- .../new-file-location.reel/new-file-location.js | 4 ++-- .../new-file-options-navigator.js | 9 +++++---- .../ui/new-file-dialog/new-file-workflow-controller.js | 2 +- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 12 ++++++------ js/mediators/io-mediator.js | 11 ++++++----- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js b/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js index f832e618..8710de63 100755 --- a/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js +++ b/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js @@ -30,7 +30,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { this.eventManager.addEventListener("pickerSelectionsDone", function(evt){that.handleFileInputPickerSelectionsDone(evt);}, false); - this.newFileDirectory.addEventListener("blur", function(evt){that.handleNewFileDirectoryOnblur(evt);}, false); + this.newFileDirectory.addEventListener("keyup", function(evt){that.handleNewFileDirectoryOnkeyup(evt);}, false); } }, @@ -77,7 +77,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { } }, - handleNewFileDirectoryOnblur:{ + handleNewFileDirectoryOnkeyup:{ value:function(evt){ if(this.newFileDirectory.value !== ""){ var newFileDirectorySetEvent = document.createEvent("Events"); diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index 2c49e849..23186cf2 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js @@ -20,7 +20,7 @@ NOTES: var Montage = require("montage/core/core").Montage; //////////////////////////////////////////////////////////////////////// //Exporting as File I/O -exports.FileIo = Montage.create(Object.prototype, { +exports.FileIo = Montage.create(require("montage/ui/component").Component, { //////////////////////////////////////////////////////////////////// //newFile Object (*required): {uri*, contents, contentType} //Return codes diff --git a/js/io/templates/descriptor.json b/js/io/templates/descriptor.json index f28455fa..20870934 100644 --- a/js/io/templates/descriptor.json +++ b/js/io/templates/descriptor.json @@ -6,58 +6,58 @@ "name":"Blank File", "uri":"/", "type":"directory", - "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"] + "children":["/js/io/templates/files/html.txt", "/js/io/templates/files/files/js.txt", "/js/io/templates/files/css.txt", "/js/io/templates/files/json.txt", "/js/io/templates/files/php.txt", "/js/io/templates/files/pl.txt", "/js/io/templates/files/py.txt", "/js/io/templates/files/rb.txt"] }, - "files/html.txt":{ + "/js/io/templates/files/html.txt":{ "name":"HTML", "uri":"/js/io/templates/files/html.txt", "type":"file", "fileExtension":".html", "children":["defaultTemplate"] }, - "files/js.txt":{ + "/js/io/templates/files/files/js.txt":{ "name":"JavaScript", "uri":"/js/io/templates/files/files/js.txt", "type":"file", "fileExtension":".js", "children":["defaultTemplate"] }, - "files/css.txt":{ + "/js/io/templates/files/css.txt":{ "name":"Cascading Style Sheets", "uri":"/js/io/templates/files/css.txt", "type":"file", "fileExtension":".css", "children":["defaultTemplate"] }, - "files/json.txt":{ + "/js/io/templates/files/json.txt":{ "name":"JSON", "uri":"/js/io/templates/files/json.txt", "type":"file", "fileExtension":".json", "children":["defaultTemplate"] }, - "files/php.txt":{ + "/js/io/templates/files/php.txt":{ "name":"PHP", "uri":"/js/io/templates/files/php.txt", "type":"file", "fileExtension":".php", "children":["defaultTemplate"] }, - "files/pl.txt":{ + "/js/io/templates/files/pl.txt":{ "name":"Perl", "uri":"/js/io/templates/files/pl.txt", "type":"file", "fileExtension":".pl", "children":["defaultTemplate"] }, - "files/py.txt":{ + "/js/io/templates/files/py.txt":{ "name":"Python", "uri":"/js/io/templates/files/py.txt", "type":"file", "fileExtension":".py", "children":["defaultTemplate"] }, - "files/rb.txt":{ + "/js/io/templates/files/rb.txt":{ "name":"Ruby", "uri":"/js/io/templates/files/rb.txt", "type":"file", diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index 7da13dfc..fae8f9c7 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -37,12 +37,12 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { this.fileInputField.selectDirectory = true; - this.newFileName.addEventListener("blur", function(evt){that.handleNewFileNameOnblur(evt);}, false); + this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); } }, - handleNewFileNameOnblur:{ + handleNewFileNameOnkeyup:{ value:function(evt){ if(this.newFileName.value !== ""){ var newFileNameSetEvent = document.createEvent("Events"); 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 !== ""){ 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; 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 d1f1c26b..4546e124 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 @@ -54,7 +54,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.newFileName.value = this.fileName; this.fileInputField.newFileDirectory.value = this.folderUri; - this.newFileName.addEventListener("blur", function(evt){self.handleNewFileNameOnblur(evt);}, false); + this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); @@ -68,18 +68,18 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { value:function(evt){ if(!!evt._event.newFileDirectory){ this.folderUri = evt._event.newFileDirectory; - if(this.folderUri !== ""){ + if(this.isValidUri(this.folderUri)){ this.enableOk(); } } } }, - handleNewFileNameOnblur:{ + handleNewFileNameOnkeyup:{ value:function(evt){ this.fileName = this.newFileName.value; if(this.fileName !== ""){ - if(this.fileName !== ""){ + if(this.isValidFileName(this.fileName)){ this.enableOk(); } } @@ -165,7 +165,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { }, isValidFileName:{ value: function(fileName){ - var status = this.isValidFileName(fileName); + var status = this.validateFileName(fileName); if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); @@ -198,7 +198,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { /*** * file name validation */ - isValidFileName:{ + validateFileName:{ value: function(fileName){ var status = false; if(fileName !== ""){ diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index b6d0e598..34e1eff2 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -32,7 +32,7 @@ exports.IoMediator = Montage.create(Component, { enumerable: false, value: function (file, template, callback) { // - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(), returnObj=null; xhr.open("GET", template, false); xhr.send(); if (xhr.readyState === 4) { @@ -49,10 +49,11 @@ exports.IoMediator = Montage.create(Component, { //callback('win'); - /* -var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} - callback(returnObj); -*/ + + + ///please keep until real data is ready so that I can test the flow + callback(returnObj);//returnObj will be like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} + ////end - please keep until real data is ready } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3