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 --- 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 @@ +/* + 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. +
*/ + +.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 @@ + + + + + + + + + +
+
Save As
+
+
+ Save As : + +
+
+ Location : +
+
+
+
+
+ + +
+ +
+ + \ 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 @@ +/* +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, + 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