From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001
From: Jose Antonio Marquez
Date: Fri, 27 Jan 2012 12:05:17 -0800
Subject: Merged old FileIO
---
.../save-as-dialog.reel/save-as-dialog.css | 60 ++++++++++
.../save-as-dialog.reel/save-as-dialog.html | 84 ++++++++++++++
.../workflow/save-as-dialog.reel/save-as-dialog.js | 126 +++++++++++++++++++++
3 files changed, 270 insertions(+)
create mode 100755 js/io/workflow/save-as-dialog.reel/save-as-dialog.css
create mode 100755 js/io/workflow/save-as-dialog.reel/save-as-dialog.html
create mode 100755 js/io/workflow/save-as-dialog.reel/save-as-dialog.js
(limited to 'js/io/workflow/save-as-dialog.reel')
diff --git a/js/io/workflow/save-as-dialog.reel/save-as-dialog.css b/js/io/workflow/save-as-dialog.reel/save-as-dialog.css
new file mode 100755
index 00000000..75f57125
--- /dev/null
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.css
@@ -0,0 +1,60 @@
+.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;
+}
\ No newline at end of file
diff --git a/js/io/workflow/save-as-dialog.reel/save-as-dialog.html b/js/io/workflow/save-as-dialog.reel/save-as-dialog.html
new file mode 100755
index 00000000..1f20ee16
--- /dev/null
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.html
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
Save As
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/js/io/workflow/save-as-dialog.reel/save-as-dialog.js b/js/io/workflow/save-as-dialog.reel/save-as-dialog.js
new file mode 100755
index 00000000..1255a1bd
--- /dev/null
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.js
@@ -0,0 +1,126 @@
+/*
+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;
+
+var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
+
+ hasReel: {
+ value: true
+ },
+
+ fileName : {
+ 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() {
+ this.fileInputField.selectDirectory = true;
+ this.fileInputField.pickerName = "saveAsDirectoryPicker";
+ this.newFileName.value = this.fileName;
+ this.fileInputField.newFileDirectory.value = this.folderUri;
+ }
+ },
+
+ 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;
+ 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);
+ }
+
+ if(success){
+ //clean up memory
+ //this.cleanup();
+
+ if(this.popup){
+ this.popup.hide();
+ }
+ }
+ }
+ },
+
+ isValidUri:{
+ value: function(uri){
+ var isWindowsUri=false, isUnixUri=false,status=false;
+ if(uri !== ""){
+ uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces
+
+ //for local machine folder uri
+ isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri);
+ isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix
+ status = isWindowsUri || isUnixUri;
+ if(isWindowsUri && isUnixUri){status = false;}
+ }
+ return status;
+ }
+ },
+ 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