From 4641dbefb6e8cb41f1f3d7f4d070d50bcaed94be Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 16 Feb 2012 17:32:57 -0800 Subject: remove similar function from coreioapi.js Signed-off-by: Ananya Sen --- js/io/system/coreioapi.js | 31 ---------------------- .../new-file-options-navigator.js | 21 +++++++++++++-- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 21 +++++++++++++-- 3 files changed, 38 insertions(+), 35 deletions(-) (limited to 'js') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 507804fd..b8aa8890 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -1110,37 +1110,6 @@ window.hack = function (path) { } return status; } - }, - - //////////////////////////////////////////////////////////////////// - /*** - * check if the file exists - */ - checkFileExists:{ - value: function(fileName, folderUri, fileType){ - var uri = "", response=null, status=true; - - //prepare absolute uri - if(/[^/\\]$/g.test(folderUri)){ - folderUri = folderUri + "/"; - } - - if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){ - fileName = fileName+fileType; - } - - uri = ""+folderUri+fileName; - - response = this.fileExists({"uri":uri}); - if(!!response && response.success && (response.status === 204)){ - status = true; - }else if(!!response && response.success && (response.status === 404)){ - status = false; - }else{ - status = false; - } - return status; - } } //////////////////////////////////////////////////////////////////// }); 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 f5ab0027..11b322fe 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 @@ -386,8 +386,25 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C } }, checkFileExists:{ - value: function(fileUri, folderUri, fileType){ - var status= this.application.ninja.coreIoApi.checkFileExists(fileUri, folderUri, fileType); + value: function(fileName, folderUri, fileType){ + var uri = "", response=null, status=true; + //prepare absolute uri + if(/[^/\\]$/g.test(folderUri)){ + folderUri = folderUri + "/"; + } + if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){ + fileName = fileName+fileType; + } + uri = ""+folderUri+fileName; + response= this.application.ninja.coreIoApi.fileExists({"uri":uri}); + if(!!response && response.success && (response.status === 204)){ + status = true; + }else if(!!response && response.success && (response.status === 404)){ + status = false; + }else{ + status = false; + } + if(status){ this.showError("! File already exists."); } diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index 786ef5c9..55a09fa8 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -175,8 +175,25 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } }, checkFileExists:{ - value: function(fileUri, folderUri, fileType){ - var status= this.application.ninja.coreIoApi.checkFileExists(fileUri, folderUri, fileType); + value: function(fileName, folderUri, fileType){ + var uri = "", response=null, status=true; + //prepare absolute uri + if(/[^/\\]$/g.test(folderUri)){ + folderUri = folderUri + "/"; + } + if(!!fileType && (fileName.lastIndexOf(fileType) !== (fileName.length - fileType.length))){ + fileName = fileName+fileType; + } + uri = ""+folderUri+fileName; + response= this.application.ninja.coreIoApi.fileExists({"uri":uri}); + if(!!response && response.success && (response.status === 204)){ + status = true; + }else if(!!response && response.success && (response.status === 404)){ + status = false; + }else{ + status = false; + } + if(status){ this.showError("! File already exists."); } -- cgit v1.2.3