diff options
Diffstat (limited to 'js/io/workflow/newFileDialog/new-file-options-navigator.reel')
-rw-r--r--[-rwxr-xr-x] | js/io/workflow/newFileDialog/new-file-options-navigator.reel/new-file-options-navigator.js | 41 |
1 files changed, 5 insertions, 36 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 | ||
14 | var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { | 14 | var 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 | } |