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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.css | 100 ++++++++++++ js/io/ui/save-as-dialog.reel/save-as-dialog.html | 86 ++++++++++ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 196 +++++++++++++++++++++++ 3 files changed, 382 insertions(+) create mode 100644 js/io/ui/save-as-dialog.reel/save-as-dialog.css create mode 100644 js/io/ui/save-as-dialog.reel/save-as-dialog.html create mode 100644 js/io/ui/save-as-dialog.reel/save-as-dialog.js (limited to 'js/io/ui/save-as-dialog.reel') diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.css b/js/io/ui/save-as-dialog.reel/save-as-dialog.css new file mode 100644 index 00000000..40434c25 --- /dev/null +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.css @@ -0,0 +1,100 @@ +/* <copyright> + This file contains proprietary software owned by Motorola Mobility, Inc.<br/> + No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> + (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + </copyright> */ + +.saveAsDialog{ + font-size:12px; + width:450px; + height:150px; + padding-left: 15px; + padding-right: 15px; + background-color:#313131; + color: #ffffff; +} + +.saveAsDialog .title{ + font-size:14px; + height:15px; + padding:5px; + text-align: center; + font-weight: bold; + color: #C1C1C1; +} + +.saveAsDialog .locationSelection{ + border: 1px groove #000000; + overflow: auto; + height:38%; + padding: 15px; + background-color:#5f5f5f; +} + +.saveAsDialog .newFileName{ + width:80%; + margin-left:5px; +} + +.saveAsDialog .fileInputField .newFileDirectory{ + width: 80%; +} + +.saveAsDialog .nameText{ + margin-right:10px; +} + +.saveAsDialog .buttons{ + float:right; + margin-top: 10px; +} + +.saveAsDialog .filename{ + margin-bottom: 10px; +} + +.saveAsDialog .errorMsg{ + float:left; + margin-top: 7px; +} +.saveAsDialog .errorMsg span{ + color: #BF3B3B; +} + +.saveAsDialog .fileInputField{ + margin-left:3px; +} + +.saveAsDialog .okButton{ + margin-right:25px; + -webkit-box-align: center; + text-align: center; + cursor: default; + padding: 0px 6px 0px; + border:2px solid #d1d1d1; + background-color: #e1e1e1; + box-sizing: border-box; + border-radius:10px; + background-image: -webkit-linear-gradient(bottom, #e1e1e1 13%, #d1d1d1 58%, #e1e1e1 40%); + cursor:pointer; +} + +.saveAsDialog .cancelButton{ + -webkit-box-align: center; + text-align: center; + cursor: default; + padding: 0px 6px 0px; + border:2px solid #d1d1d1; + background-color: #e1e1e1; + box-sizing: border-box; + border-radius:10px; + background-image: -webkit-linear-gradient(bottom, #e1e1e1 13%, #d1d1d1 58%, #e1e1e1 40%); + cursor:pointer; +} + +.saveAsDialog input[type="button"]:disabled{ + background-color: #a1a1a1; + border:2px solid #a1a1a1; + background-image:none; + cursor:auto; +} \ No newline at end of file diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.html b/js/io/ui/save-as-dialog.reel/save-as-dialog.html new file mode 100644 index 00000000..968512f6 --- /dev/null +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.html @@ -0,0 +1,86 @@ +<!DOCTYPE HTML> +<!-- <copyright> + This file contains proprietary software owned by Motorola Mobility, Inc.<br/> + No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> + (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + </copyright> --> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" type="text/css" href="save-as-dialog.css"> + <script type="text/montage-serialization"> + { + "okButton": { + "module": "montage/ui/button.reel", + "name": "Button", + "properties": { + "element": {"#": "okButton"}, + "identifier": "okButton" + }, + "listeners": [ + { + "type": "action", + "listener": {"@": "owner"} + } + ] + }, + + "cancelButton": { + "module": "montage/ui/button.reel", + "name": "Button", + "properties": { + "element": {"#": "cancelButton"}, + "identifier": "cancelButton" + }, + "listeners": [ + { + "type": "action", + "listener": {"@": "owner"} + } + ] + }, + + "fileInputField":{ + "module": "js/components/ui/FilePicker/file-input-field.reel", + "name": "FileInputField", + "properties": { + "element": {"#": "fileInputField"} + } + }, + + "owner":{ + "module": "js/io/ui/new-file-dialog/new-file-location.reel", + "name": "SaveAsDialog", + "properties": { + "element": {"#": "saveAsDialog"}, + "fileInputField": {"@": "fileInputField"}, + "newFileName": {"#": "newFileName"}, + "error":{"#": "error"}, + "okButton":{"#": "okButton"} + } + } + } + </script> +</head> +<body> +<div id="saveAsDialog" class="saveAsDialog"> + <div class="title">Save As</div> + <div class="locationSelection"> + <div class="filename"> + <span class="nameText">Save As :</span> + <input id="newFileName" class="nj-skinned newFileName" type="search" value="" /> + </div> + <div> + <span>Location :</span> + <div id="fileInputField"></div> + </div> + </div> + <div class="errorMsg"><span id="error" class="error"></span></div> + <div class="buttons"> + <input id="cancelButton" type="button" value="CANCEL" class="cancelButton nj-skinned" /> + <input id="okButton" disabled="true" type="button" value="OK" class="okButton nj-skinned" /> + </div> + +</div> +</body> +</html> \ 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 new file mode 100644 index 00000000..371aa9a7 --- /dev/null +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -0,0 +1,196 @@ +/* <copyright> +This file contains proprietary software owned by Motorola Mobility, Inc.<br/> +No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> +(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +</copyright> */ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + nj= require("js/lib/NJUtils.js").NJUtils; + +var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { + + hasReel: { + value: true + }, + + fileName : { + enumerable: true, + writable: true, + value: "" + }, + + folderUri:{ + enumerable: true, + writable: true, + value: "" + }, + + callback : { + enumerable: true, + writable: true, + value: null + }, + + callbackScope : { + enumerable: true, + writable: true, + value: null + }, + + willDraw: { + enumerable: false, + value: function() {} + }, + draw: { + enumerable: false, + value: function() {} + }, + didDraw: { + enumerable: false, + value: function() { + var self = this; + this.fileInputField.selectDirectory = true; + this.fileInputField.pickerName = "saveAsDirectoryPicker"; + this.newFileName.value = this.fileName; + this.fileInputField.newFileDirectory.value = this.folderUri; + + this.newFileName.addEventListener("blur", function(evt){self.handleNewFileNameOnblur(evt);}, false); + this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); + + this.enableOk(); + } + }, + + handleNewFileDirectorySet:{ + value:function(evt){ + if(!!evt._event.newFileDirectory){ + this.folderUri = evt._event.newFileDirectory; + if(this.folderUri !== ""){ + this.enableOk(); + } + } + } + }, + + handleNewFileNameOnblur:{ + value:function(evt){ + this.fileName = this.newFileName.value; + if(this.fileName !== ""){ + if(this.fileName !== ""){ + this.enableOk(); + } + } + } + }, + + + enableOk:{ + value: function(){ + if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){ + this.okButton.removeAttribute("disabled"); + this.error.innerHTML=""; + } + } + }, + + handleCancelButtonAction :{ + value:function(evt){ + //clean up memory + //this.cleanup(); + + if(this.popup){ + this.popup.hide(); + } + + } + }, + + handleOkButtonAction:{ + value: function(evt){ + var filename = this.fileName, + newFileDirectory = this.newFileDirectory, + success = true; + if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){ + try{ + //validate file name and folder path + //check if file already exists + if(!!this.callback && !!this.callbackScope){//inform document-controller if save successful + this.callback.call(this.callbackScope, {"filename":filename, "destination": newFileDirectory});//document-controller api + }else{ + //send save as event + var saveAsEvent = document.createEvent("Events"); + saveAsEvent.initEvent("saveAsFile", false, false); + saveAsEvent.saveAsOptions = {"filename":filename, "destination": newFileDirectory}; + this.eventManager.dispatchEvent(saveAsEvent); + } + }catch(e){ + success = false; + console.log("[ERROR] Failed to save: "+ this.fileName + " at "+ this.newFileDirectory); + console.log(e.stack); + } + + if(success){ + //clean up memory + //this.cleanup(); + + if(this.popup){ + this.popup.hide(); + } + } + }else{ + if(this.error.innerHTML !== ""){ + this.showError("! Name and Location should be valid."); + } + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + } + } + }, + + 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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 371aa9a7..b20bed87 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 @@ -152,7 +152,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { 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 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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 </copyright> */ 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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.html | 33 ++---------------------- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 3 +++ 2 files changed, 5 insertions(+), 31 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.html b/js/io/ui/save-as-dialog.reel/save-as-dialog.html index 968512f6..f2011a34 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.html +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.html @@ -10,36 +10,6 @@ <link rel="stylesheet" type="text/css" href="save-as-dialog.css"> <script type="text/montage-serialization"> { - "okButton": { - "module": "montage/ui/button.reel", - "name": "Button", - "properties": { - "element": {"#": "okButton"}, - "identifier": "okButton" - }, - "listeners": [ - { - "type": "action", - "listener": {"@": "owner"} - } - ] - }, - - "cancelButton": { - "module": "montage/ui/button.reel", - "name": "Button", - "properties": { - "element": {"#": "cancelButton"}, - "identifier": "cancelButton" - }, - "listeners": [ - { - "type": "action", - "listener": {"@": "owner"} - } - ] - }, - "fileInputField":{ "module": "js/components/ui/FilePicker/file-input-field.reel", "name": "FileInputField", @@ -56,7 +26,8 @@ "fileInputField": {"@": "fileInputField"}, "newFileName": {"#": "newFileName"}, "error":{"#": "error"}, - "okButton":{"#": "okButton"} + "okButton":{"#": "okButton"}, + "cancelButton":{"#": "cancelButton"} } } } 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 1de2eaf1..d1f1c26b 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 @@ -57,6 +57,9 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.newFileName.addEventListener("blur", function(evt){self.handleNewFileNameOnblur(evt);}, false); this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); + this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); + this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + this.enableOk(); } }, -- 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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 !== ""){ -- 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 <Ananya.Sen@motorola.com> --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 4546e124..786ef5c9 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 @@ -89,7 +89,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { enableOk:{ value: function(){ - if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){ + if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri)){ this.okButton.removeAttribute("disabled"); this.error.innerHTML=""; } @@ -141,7 +141,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } } }else{ - if(this.error.innerHTML !== ""){ + if(this.error.innerHTML === ""){ this.showError("! Name and Location should be valid."); } //disable ok -- cgit v1.2.3