aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
Diffstat (limited to 'js/io')
-rwxr-xr-xjs/io/document/document-controller.js10
-rwxr-xr-xjs/io/system/coreioapi.js48
-rw-r--r--js/io/utils/file-utils.js75
-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
7 files changed, 202 insertions, 120 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index 6f363bc7..7cf7f409 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -15,7 +15,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
15var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
16 Component = require("montage/ui/component").Component, 16 Component = require("montage/ui/component").Component,
17 Uuid = require("montage/core/uuid").Uuid, 17 Uuid = require("montage/core/uuid").Uuid,
18 fileSystem = require("js/io/system/filesystem").FileSystem; 18 fileSystem = require("js/io/system/coreioapi").CoreIoApi;
19 19
20var HTMLDocument = require("js/io/document/html-document").HTMLDocument; 20var HTMLDocument = require("js/io/document/html-document").HTMLDocument;
21var TextDocument = require("js/io/document/text-document").TextDocument; 21var TextDocument = require("js/io/document/text-document").TextDocument;
@@ -104,7 +104,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
104 104
105 // Get file from Jose Code with a callback to here 105 // Get file from Jose Code with a callback to here
106 if(!!uri){ 106 if(!!uri){
107 response = fileSystem.shellApiHandler.openFile({"uri":uri}); 107 response = fileSystem.openFile({"uri":uri});
108 if((response.success === true) && ((response.status === 200) || (response.status === 304))){ 108 if((response.success === true) && ((response.status === 200) || (response.status === 304))){
109 fileContent = response.content; 109 fileContent = response.content;
110 } 110 }
@@ -417,10 +417,10 @@ _createTextAreaElement: {
417 417
418 codeMirrorDiv.appendChild(textArea); 418 codeMirrorDiv.appendChild(textArea);
419 419
420 if(!this._textHolder) this._textHolder = document.getElementById("codeViewContainer"); 420// if(!this._textHolder) this._textHolder = document.getElementById("codeViewContainer");
421 this._textHolder.appendChild(codeMirrorDiv); 421// this._textHolder.appendChild(codeMirrorDiv);
422 422
423 return codeMirrorDiv; 423 return textArea;
424 } 424 }
425 } 425 }
426}); \ No newline at end of file 426}); \ No newline at end of file
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 33c7bc28..5deeae73 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -134,6 +134,9 @@ exports.CoreIoApi = Montage.create(Component, {
134 directoryServiceURL: { 134 directoryServiceURL: {
135 enumerable: false, 135 enumerable: false,
136 get: function() { 136 get: function() {
137 if(!this.rootUrl){
138 this.rootUrl = 'http://localhost:16380';
139 }
137 return String(this.rootUrl+this._directoryServiceURL); 140 return String(this.rootUrl+this._directoryServiceURL);
138 }, 141 },
139 set: function(value) { 142 set: function(value) {
@@ -863,50 +866,7 @@ exports.CoreIoApi = Montage.create(Component, {
863 var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri), 866 var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri),
864 xhr = new XMLHttpRequest(); 867 xhr = new XMLHttpRequest();
865 xhr.open("GET", serviceURL, false); 868 xhr.open("GET", serviceURL, false);
866 xhr.setRequestHeader("get-attributes", "true"); 869 xhr.setRequestHeader("get-file-info", "true");
867 xhr.send();
868 if (xhr.readyState === 4) {
869 retValue.status = xhr.status;
870 if(xhr.status == 200) {
871 retValue.content = xhr.responseText;
872 }
873 retValue.success = true;
874 }
875 }
876 catch(error) {
877 xhr = null;
878 retValue.success = false;
879 }
880 }
881 return retValue;
882 }
883 },
884
885 ////////////////////////////////////////////////////////////////////
886 // Checks if the directory is writable
887 // Parameters:
888 // the file parameter must contain the following properties
889 // uri: string value containing the full directory path/URI i.e. "c:/foo"
890 //
891 // Return values:
892 // returns an object with two properties
893 // success: boolean indicating if the call succeeded or failed
894 // status: int indicating the request HTTP status code
895 // 204 - The file exists and response body has writable flag
896 // 404 - the file does not exist
897 // 500 - unknown server error occurred
898 //TODO:to be finalized
899 isDirectoryWritable:{
900 enumerable:true,
901 writable:false,
902 value:function(file){
903 var retValue = { success:null, status:null };
904 if(file && file.uri) {
905 try {
906 var serviceURL = this._prepareServiceURL(this.directoryServiceURL, file.uri),
907 xhr = new XMLHttpRequest();
908 xhr.open("GET", serviceURL, false);
909 xhr.setRequestHeader("get-attributes", "true");
910 xhr.send(); 870 xhr.send();
911 if (xhr.readyState === 4) { 871 if (xhr.readyState === 4) {
912 retValue.status = xhr.status; 872 retValue.status = xhr.status;
diff --git a/js/io/utils/file-utils.js b/js/io/utils/file-utils.js
new file mode 100644
index 00000000..0afdffc6
--- /dev/null
+++ b/js/io/utils/file-utils.js
@@ -0,0 +1,75 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
7var fileSystem = require("js/io/system/coreioapi").CoreIoApi;
8
9var FileUtils = exports.FileUtils = Object.create(Object.prototype, {
10
11 /***
12 * checks for valid uri pattern
13 * also flags if Windows uri pattern and Unix uri patterns are mixed
14 */
15 isValidUri:{
16 value: function(uri){
17 var isWindowsUri=false, isUnixUri=false,status=false;
18 if(uri !== ""){
19 uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces
20
21 //for local machine folder uri
22 isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri);
23 isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix
24 status = isWindowsUri || isUnixUri;
25 if(isWindowsUri && isUnixUri){status = false;}
26 }
27 return status;
28 }
29 },
30
31 /***
32 * file name validation
33 */
34 isValidFileName:{
35 value: function(fileName){
36 var status = false;
37 if(fileName !== ""){
38 fileName = fileName.replace(/^\s+|\s+$/g,"");
39 status = !(/[/\\]/g.test(fileName));
40 if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden
41 status = !(/^\./g.test(fileName));
42 }
43 }
44 return status;
45 }
46 },
47
48 /***
49 * check if the file exists
50 */
51 checkFileExists:{
52 value: function(fileUri, folderUri, fileType){
53 var uri = "", response=null, status=true;
54
55 //prepare absolute uri
56 if(/[^/\\]$/g.test(folderUri)){
57 folderUri = folderUri + "/";
58 }
59
60 //todo:add file extension check if fileType present
61
62 uri = ""+folderUri+fileUri;
63
64 response = fileSystem.fileExists({"uri":uri});
65 if(!!response && response.success && (response.status === 204)){
66 status = true;
67 }else if(!!response && response.success && (response.status === 404)){
68 status = false;
69 }else{
70 status = false;
71 }
72 return status;
73 }
74 }
75}); \ No newline at end of file
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