aboutsummaryrefslogtreecommitdiff
path: root/js/io/workflow
diff options
context:
space:
mode:
authorAnanya Sen2012-01-30 14:18:21 -0800
committerAnanya Sen2012-01-30 14:18:21 -0800
commit92161460a6cbbdebfd1b0263ec6eb790091920a9 (patch)
tree48136ac734f6e46d902b720387ac5693ed29ee8d /js/io/workflow
parent9c46c73141259ab4478935033cb4d8dda43f6bf2 (diff)
downloadninja-92161460a6cbbdebfd1b0263ec6eb790091920a9.tar.gz
Moving changes from Gerrit, on 1/27, to the github branch:
- added file existence check and validation to save as dialog - minor css fix for file picker, new file dialog Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/workflow')
-rw-r--r--[-rwxr-xr-x]js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js41
-rw-r--r--[-rwxr-xr-x]js/io/workflow/save-as-dialog.reel/save-as-dialog.css6
-rw-r--r--[-rwxr-xr-x]js/io/workflow/save-as-dialog.reel/save-as-dialog.html4
-rw-r--r--[-rwxr-xr-x]js/io/workflow/save-as-dialog.reel/save-as-dialog.js138
4 files changed, 118 insertions, 71 deletions
diff --git a/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js
index 61b963b3..7702b1a2 100755..100644
--- a/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js
+++ b/js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -9,7 +9,7 @@ var Montage = require("montage/core/core").Montage,
9 iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), 9 iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"),
10 treeModule = require("js/components/ui/tree-basic/tree.reel"), 10 treeModule = require("js/components/ui/tree-basic/tree.reel"),
11 newFileLocationSelectionModule = require("js/io/workflow/newFileDialog/new-file-workflow-controller"), 11 newFileLocationSelectionModule = require("js/io/workflow/newFileDialog/new-file-workflow-controller"),
12 fileSystem = require("js/io/system/filesystem").FileSystem; 12 fileUtils = require("js/io/utils/file-utils").FileUtils;
13 13
14var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { 14var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, {
15 15
@@ -244,7 +244,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
244 this.okButton.setAttribute("disabled", "true"); 244 this.okButton.setAttribute("disabled", "true");
245 } 245 }
246 } 246 }
247
248 } 247 }
249 }, 248 },
250 249
@@ -336,16 +335,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
336 335
337 isValidUri:{ 336 isValidUri:{
338 value: function(uri){ 337 value: function(uri){
339 var isWindowsUri=false, isUnixUri=false,status=false; 338 var status= fileUtils.isValidUri(uri);
340 if(uri !== ""){ 339 if(uri !== ""){
341 uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces
342
343 //for local machine folder uri
344 isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri);
345 isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix
346 status = isWindowsUri || isUnixUri;
347 if(isWindowsUri && isUnixUri){status = false;}
348
349 if(!status){ 340 if(!status){
350 this.showError("! Invalid directory."); 341 this.showError("! Invalid directory.");
351 } 342 }
@@ -355,14 +346,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
355 }, 346 },
356 isValidFileName:{ 347 isValidFileName:{
357 value: function(fileName){ 348 value: function(fileName){
358 var status = false; 349 var status = fileUtils.isValidFileName(fileName);
359 if(fileName !== ""){ 350 if(fileName !== ""){
360 fileName = fileName.replace(/^\s+|\s+$/g,"");
361 status = !(/[/\\]/g.test(fileName));
362 if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden
363 status = !(/^\./g.test(fileName));
364 }
365
366 if(!status){ 351 if(!status){
367 this.showError("! Invalid file name."); 352 this.showError("! Invalid file name.");
368 } 353 }
@@ -372,25 +357,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
372 }, 357 },
373 checkFileExists:{ 358 checkFileExists:{
374 value: function(fileUri, folderUri, fileType){ 359 value: function(fileUri, folderUri, fileType){
375 var uri = "", response=null, status=true; 360 var status= fileUtils.checkFileExists(fileUri, folderUri, fileType);
376 361 if(status){
377 //prepare absolute uri
378 if(/[^/\\]$/g.test(folderUri)){
379 folderUri = folderUri + "/";
380 }
381
382 //todo:add file extension check
383
384 uri = ""+folderUri+fileUri;
385
386 response = fileSystem.shellApiHandler.fileExists({"uri":uri});
387 if(!!response && response.success && (response.status === 204)){
388 this.showError("! File already exists."); 362 this.showError("! File already exists.");
389 status = true;
390 }else if(!!response && response.success && (response.status === 404)){
391 status = false;
392 }else{
393 this.showError("! Cloud Service Error.");
394 } 363 }
395 return status; 364 return status;
396 } 365 }
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
index 75f57125..7082f485 100755..100644
--- a/js/io/workflow/save-as-dialog.reel/save-as-dialog.css
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.css
@@ -1,3 +1,9 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
1.saveAsDialog{ 7.saveAsDialog{
2 font-size:12px; 8 font-size:12px;
3 width:450px; 9 width:450px;
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
index 1f20ee16..eca6801f 100755..100644
--- a/js/io/workflow/save-as-dialog.reel/save-as-dialog.html
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.html
@@ -54,7 +54,9 @@
54 "properties": { 54 "properties": {
55 "element": {"#": "saveAsDialog"}, 55 "element": {"#": "saveAsDialog"},
56 "fileInputField": {"@": "fileInputField"}, 56 "fileInputField": {"@": "fileInputField"},
57 "newFileName": {"#": "newFileName"} 57 "newFileName": {"#": "newFileName"},
58 "error":{"#": "error"},
59 "okButton":{"#": "okButton"}
58 } 60 }
59 } 61 }
60 } 62 }
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
index 1255a1bd..52e5ab82 100755..100644
--- a/js/io/workflow/save-as-dialog.reel/save-as-dialog.js
+++ b/js/io/workflow/save-as-dialog.reel/save-as-dialog.js
@@ -5,7 +5,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component,
9 fileUtils = require("js/io/utils/file-utils").FileUtils;
9 10
10var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { 11var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
11 12
@@ -19,6 +20,12 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
19 value: "" 20 value: ""
20 }, 21 },
21 22
23 folderUri:{
24 enumerable: true,
25 writable: true,
26 value: ""
27 },
28
22 callback : { 29 callback : {
23 enumerable: true, 30 enumerable: true,
24 writable: true, 31 writable: true,
@@ -42,10 +49,48 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
42 didDraw: { 49 didDraw: {
43 enumerable: false, 50 enumerable: false,
44 value: function() { 51 value: function() {
52 var self = this;
45 this.fileInputField.selectDirectory = true; 53 this.fileInputField.selectDirectory = true;
46 this.fileInputField.pickerName = "saveAsDirectoryPicker"; 54 this.fileInputField.pickerName = "saveAsDirectoryPicker";
47 this.newFileName.value = this.fileName; 55 this.newFileName.value = this.fileName;
48 this.fileInputField.newFileDirectory.value = this.folderUri; 56 this.fileInputField.newFileDirectory.value = this.folderUri;
57
58 this.newFileName.addEventListener("blur", function(evt){self.handleNewFileNameOnblur(evt);}, false);
59 this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false);
60
61 this.enableOk();
62 }
63 },
64
65 handleNewFileDirectorySet:{
66 value:function(evt){
67 if(!!evt._event.newFileDirectory){
68 this.folderUri = evt._event.newFileDirectory;
69 if(this.folderUri !== ""){
70 this.enableOk();
71 }
72 }
73 }
74 },
75
76 handleNewFileNameOnblur:{
77 value:function(evt){