[FileManager] updated FileManager sources
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Tue, 16 Jul 2013 08:14:04 +0000 (10:14 +0200)
committerPiotr Dabrowski <p.dabrowski2@samsung.com>
Tue, 16 Jul 2013 08:14:04 +0000 (10:14 +0200)
Change-Id: I62fb3d1d64da1b763b3292ed3ecf89eb63228147

js/app.js
js/app.ui.js

index eb80f3c..42a2420 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -58,7 +58,7 @@ var App = null;
                /**
                 * @type {string}
                 */
-               currentPath: '',
+               currentPath: 'root',
 
                /**
                 *
@@ -163,14 +163,14 @@ var App = null;
                 * @param {string} dirName
                 * @return {boolean} return status
                 */
-               createDir: function App_createDir(dirName) {
+               createDir: function App_createDir(dirName, callback) {
                        var status = true;
                        if (this.currentDirPath !== '') {
                                try {
                                        this.currentDirHandle.createDirectory(dirName);
                                } catch (e) {
                                        status = false;
-                                       app.ui.alertPopup(e.message);
+                                       app.ui.alertPopup(e.message, callback);
                                }
                                this.refreshCurrentPage();
                        } else {
index 2a861cd..36f27e4 100644 (file)
@@ -128,8 +128,9 @@ function Ui() {
                                                } else {
                                                        tizen.application.getCurrentApplication().exit();
                                                }
-                                       } else {
+                                       } else if ($.mobile.popup.active !== undefined) {
                                                $(".ui-popup").popup('close');
+                                       } else {
                                                app.goLevelUp();
                                        }
 
@@ -170,7 +171,9 @@ function Ui() {
                        $('#navbar').on('tap', 'span', function () {
                                var uri = $(this).attr('uri');
                                if (uri === 'home') {
-                                       app.displayStorages();
+                                       if (app.currentPath !== '') {
+                                               app.displayStorages();
+                                       }
                                } else if (uri === app.model.currentPath) {
                                        app.displayFolder(uri,true);
                                } else {
@@ -240,41 +243,38 @@ function Ui() {
                },
 
                saveNewFolder: function Ui_saveNewFolder(e) {
-                       var folderName = $('#newFolderName').val().trim(), status = true;
-                       e.preventDefault();
-                       e.stopPropagation();
-                       if (folderName === '') {
-                               this.alertPopup("Empty folder name");
-                               status = false;
-                       } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
-                               this.alertPopup("The following special characters are not allowed: *./\\?:<>|'\"");
-                               status = false;
-                       } else {
-                               status = app.createDir(folderName);
-                               if (status === true) {
+                       var folderName = $('#newFolderName').val().trim(), status = true,
+                               open = function () {
                                        $("#addFolderPopup").popup('open', {
                                                positionTo: "window"
                                        });
-                                       setTimeout(function () {
-                                               $("#addFolderPopup").popup('close');
-                                       }, 200);
+                               }, self = this;
+                       e.preventDefault();
+                       e.stopPropagation();
+                       $("#addFolderPopup").one("popupafterclose", function () {
+                               if (folderName === '') {
+                                       self.alertPopup("Empty folder name", open);
+                                       status = false;
+                               } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
+                                       self.alertPopup("The following special characters "
+                                               +"are not allowed: *./\\?:<>|'\"", open);
+                                       status = false;
+                               } else {
+                                       status = app.createDir(folderName, open);
                                }
-                       }
+                       });
+                       $("#addFolderPopup").popup('close');
                        return status;
                },
 
-               alertPopup: function (text) {
-                       var lastActivePopup = $.mobile.popup.active;
-
+               alertPopup: function (text, callback) {
                        $("#alertPopup .text").text(text);
-
-                       $("#alertPopup").popup('close')
-                               .popup('open', {'positionTo': 'window'})
-                               .one("popupafterclose", function () {
-                                       if (lastActivePopup) {
-                                               $.mobile.popup.active = lastActivePopup;
-                                       }
+                       $("#alertPopup").popup('open', {'positionTo': 'window'})
+                       if (callback instanceof Function) {
+                               $("#alertPopup").one("popupafterclose", function () {
+                                       callback();
                                });
+                       }
                },
 
                confirmPopup: function (text, confirmCallback, completeCallback) {