aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
authorArmen Kesablyan2012-06-11 11:04:29 -0700
committerArmen Kesablyan2012-06-11 11:04:29 -0700
commit0f040acabfb7a4bf3138debec5aff869487ceb11 (patch)
tree53eaa8ba54cf23a1c3ea0c8b39377773198c3e19 /js/io
parent7d3bdf39e6d1534de1848ca2744aed66dfeb5d2a (diff)
parent756cbfad2b98b300af8db3793aa21718b88dd950 (diff)
downloadninja-0f040acabfb7a4bf3138debec5aff869487ceb11.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/io')
-rw-r--r--js/io/system/ninjalibrary.js42
-rw-r--r--js/io/system/ninjalibrary.json2
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js5
3 files changed, 29 insertions, 20 deletions
diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js
index 12af5988..0470a166 100644
--- a/js/io/system/ninjalibrary.js
+++ b/js/io/system/ninjalibrary.js
@@ -57,35 +57,38 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
57 // 57 //
58 copyLibToCloud: { 58 copyLibToCloud: {
59 value: function (path, libName, callback) { 59 value: function (path, libName, callback) {
60 var libCheck = this.coreApi.directoryExists({uri: path+libName});
60 //Checking for library to exists 61 //Checking for library to exists
61 if(this.coreApi.directoryExists({uri: path+libName}).status === 404) { 62 if(libCheck.status === 404) {
62 //Getting contents to begin copying 63 //Getting contents to begin copying
63 this.chromeApi.directoryContents(this.chromeApi.fileSystem.root, function (contents) { 64 this.chromeApi.directoryContents(this.chromeApi.fileSystem.root, function (contents) {
64 for (var i in contents) { 65 for (var i in contents) {
65 if (libName === contents[i].name) { 66 if (libName === contents[i].name) {
66 //Getting contents of library to be copied 67 //Getting contents of library to be copied
67 this.chromeApi.directoryContents(contents[i], function (lib) { 68 this.chromeApi.directoryContents(contents[i], function (lib) {
68 //Copying to cloud, adding blocking if no callback specified 69 //Copying to cloud
69 if (!callback) { 70 if (callback) {
70 //TODO: Add blocking logic here 71 this.copyDirectoryToCloud(path, contents[i], path, {total: 0, copied: 0, callback: callback.bind(this)});
71 this.copyDirectoryToCloud(path, contents[i], path); 72 } else {
72 } else { 73 this.copyDirectoryToCloud(path, contents[i], path, {total: 0, copied: 0});
73 this.copyDirectoryToCloud(path, contents[i], path, callback); 74 }
74 }
75 }.bind(this)); 75 }.bind(this));
76 break; 76 break;
77 } 77 }
78 } 78 }
79 }.bind(this)); 79 }.bind(this));
80 } else if (libCheck.status === 204){
81 //Already present, so sending success
82 if (callback) callback(true);
80 } else { 83 } else {
81 //TODO: Add error handling 84 if (callback) callback(false);
82 } 85 }
83 } 86 }
84 }, 87 },
85 //////////////////////////////////////////////////////////////////// 88 ////////////////////////////////////////////////////////////////////
86 // 89 //
87 copyDirectoryToCloud: { 90 copyDirectoryToCloud: {
88 value: function(root, folder, fileRoot, callback) { 91 value: function(root, folder, fileRoot, tracking) {
89 //Setting up directory name 92 //Setting up directory name
90 if (folder.name) { 93 if (folder.name) {
91 var dir; 94 var dir;
@@ -109,19 +112,30 @@ exports.NinjaLibrary = Montage.create(Object.prototype, {
109 //Checking for file or directory 112 //Checking for file or directory
110 if (contents[i].isDirectory) { 113 if (contents[i].isDirectory) {
111 //Recursive call if directory 114 //Recursive call if directory
112 this.copyDirectoryToCloud(dir, contents[i], fileRoot); 115 this.copyDirectoryToCloud(dir, contents[i], fileRoot, tracking);
113 } else if (contents[i].isFile){ 116 } else if (contents[i].isFile){
117 //
118 tracking.total++;
114 //Copying file 119 //Copying file
115 this.chromeApi.fileContent(contents[i].fullPath, function (result) { 120 this.chromeApi.fileContent(contents[i].fullPath, function (result) {
116 //Using binary when copying files to allow images and such to work 121 //Using binary when copying files to allow images and such to work
117 this.coreApi.createFile({uri: (fileRoot+result.file.fullPath).replace(/\/\//gi, '/'), contents: result.content}); 122 var file = this.coreApi.createFile({uri: (fileRoot+result.file.fullPath).replace(/\/\//gi, '/'), contents: result.content});
123 //Checking for file copy success
124 if (file.status === 201) {
125 tracking.copied++;
126 } else {
127 //Error
128 tracking.callback(false);
129 }
130 //Checking for all files to be copied to make callback
131 if (tracking.copied === tracking.total && tracking.callback) {
132 tracking.callback(true);
133 }
118 }.bind(this)); 134 }.bind(this));
119 } 135 }
120 } 136 }
121 }.bind(this)); 137 }.bind(this));
122 } 138 }
123 //TODO Add logic for proper callback status(es)
124 if (callback) callback(true);
125 } 139 }
126 }, 140 },
127 //////////////////////////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 5c1eb875..e9df5e58 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.7.0"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.9.0"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
index ebe2df61..7227d532 100644
--- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
+++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
@@ -195,11 +195,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
195 } 195 }
196 } 196 }
197 197
198 //disable ok
199 if(!this.okButton.hasAttribute("disabled")){
200 this.okButton.setAttribute("disabled", "true");
201 }
202
203 //save project type selection 198 //save project type selection
204 this.selectedProjectType = {"uri":evt.uri, "element":evt.target}; 199 this.selectedProjectType = {"uri":evt.uri, "element":evt.target};
205 200