[FileManager]update FileManager(tizen_2.1)
authorgs86.lee <gs86.lee@samsung.com>
Fri, 12 Apr 2013 06:29:33 +0000 (15:29 +0900)
committergs86.lee <gs86.lee@samsung.com>
Fri, 12 Apr 2013 06:29:33 +0000 (15:29 +0900)
Change-Id: I37f107514b4cd217ddde7e1e643dfff082fd8b6e

14 files changed:
NOTICE [new file with mode: 0644]
config.xml
css/style.css
index.html
js/app.clipboard.js
js/app.config.js
js/app.helpers.js
js/app.js
js/app.model.js
js/app.systemIO.js
js/app.ui.js
js/app.ui.templateManager.js
js/main.js
templates/main.tpl

diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..85044e4
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.
+Please, see the LICENSE.Flora file for Flora License terms and conditions.
+
index 3bc4bb5..f18a5d3 100644 (file)
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/file-manager" version="2.1.0" viewmodes="maximized">
-       <tizen:application id="DncjwaRfgh" required_version="1.0"/>
+       <tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.1"/>
        <icon src="icon.png"/>
        <name>FileManager</name>
-       <tizen:privilege name="http://tizen.org/privilege/tizen"/>
        <tizen:privilege name="http://tizen.org/privilege/content.read"/>
        <tizen:privilege name="http://tizen.org/privilege/content.write"/>
        <tizen:privilege name="http://tizen.org/privilege/systeminfo"/>
@@ -11,5 +10,5 @@
        <tizen:privilege name="http://tizen.org/privilege/application.read"/>
        <tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>
        <tizen:privilege name="http://tizen.org/privilege/filesystem.write"/>
-       <tizen:setting screen-orientation="portrait" context-menu="disable" background-support="enable" encryption="disable" nodisplay="false"/>
+       <tizen:setting screen-orientation="portrait" context-menu="disable" background-support="enable" encryption="disable" install-location="auto"/>
 </widget>
index f81279e..2be9239 100644 (file)
@@ -13,6 +13,7 @@ body {
 
 #mainTitle {
        width: 260px;
+       text-transform: uppercase;
 }
 
 #fileList > li {
@@ -102,6 +103,11 @@ body {
        height: 100%;
 }
 
+#homeBtn,
+#levelUpBtn {
+       top:20px;
+}
+
 .ui-li-1line-bigicon1.ui-li.ui-li-static.ui-body-s.ui-li-has-thumb {
        padding-left: 0.7rem;
        padding-right: 0rem;
@@ -163,4 +169,24 @@ input.ui-input-text.new_folder {
 
 .ui-tabbar a {
        color: #999 !important;
+}
+
+#newFolderName {
+       margin:0.4em;
+}
+
+.ui-header.ui-bar-s > .ui-btn {
+       width: 2rem;
+}
+/** workaround to prevent hiding footer caused by broken softkeyboardupdate event**/
+[data-role="footer"] {
+       display: block !important;
+}
+
+.ui-ctxpopup .horizontal a.ui-link {
+       display: block;
+}
+
+.ui-footer .ui-btn-text {
+       text-transform: uppercase;
 }
\ No newline at end of file
index 3b69ba6..008c256 100644 (file)
@@ -1,15 +1,17 @@
 <!DOCTYPE html>
 <html>
 <head>
+       <meta name="viewport" content="width=360,user-scalable=no">
        <meta charset="utf-8"/>
        <meta name="description" content="file manager"/>
-       <title>file manager</title>
-       <script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.js"></script>
-       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
-       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js" data-framework-theme="tizen-white" data-framework-viewport-scale="false"></script>
+       <title>File Manager</title>
+       <script src="/usr/share/tizen-web-ui-fw/latest/js/jquery.min.js"></script>
+       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
+       <script src="/usr/share/tizen-web-ui-fw/latest/js/tizen-web-ui-fw.min.js" data-framework-theme="tizen-white" data-framework-viewport-scale="false"></script>
        <script type="text/javascript" src="./js/main.js"></script>
        <link rel="stylesheet" type="text/css" href="./css/style.css"/>
 </head>
+
 <body>
        <div data-role="page" data-footer-Exist="false" id="main"></div>
 </body>
index a944925..6dd0c4a 100644 (file)
@@ -1,4 +1,4 @@
-/*jslint browser: true, devel: true */
+/*jslint devel: true*/
 /*global $*/
 
 /**
@@ -47,7 +47,7 @@ function Clipboard() {
 
                /**
                 * Add new path to clipboard
-                * @param {array} full path
+                * @param {array} paths array of full paths
                 * @returns {number} current length of clipboard objects
                 */
                add: function Clipboard_add(paths) {
@@ -58,7 +58,6 @@ function Clipboard() {
                        this.clear();
                        for (i = 0; i < len; i += 1) {
                                if (this.has(paths[i]) === false) {
-                                       console.log('Adding file ' + paths[i] + ' to clipboard');
                                        this.data.push(paths[i]);
                                }
                        }
@@ -68,19 +67,17 @@ function Clipboard() {
 
                /**
                 * Checks if specified path is already in clipboard
-                * @param {string} full path
+                * @param {string} path full path
                 * @returns {boolean}
                 */
                has: function Clipboard_has(path) {
-                       console.log('Clipboard_has', path);
                        return $.inArray(path, this.data) === -1 ? false : true;
                },
 
                /**
-                * Clears all clipboard data and reset clipboard mode
+                * Clears all clipboard data and resets clipboard mode
                 */
                clear: function Clipboard_clear() {
-                       console.log('Clipboard_clear');
                        this.data = [];
                        this.mode = this.INACTIVE_MODE;
                },
index 32b92f5..e0332c3 100644 (file)
@@ -1,5 +1,3 @@
-/*jslint devel: true */
-
 /**
  * @class Config
  */
index 43687e1..5cc3311 100644 (file)
@@ -1,4 +1,4 @@
-/*jslint devel: true */
+/*jslint devel: true*/
 /*global $ */
 
 /**
@@ -24,10 +24,21 @@ function Helpers() {
 
                /**
                 * @param {string} fileName
+                * @returns {string} file name without extension
+                */
+               getFileName: function Helpers_getFileName(fileName) {
+                       var fileNameLen = fileName.indexOf('.');
+                       if (fileNameLen !== -1) {
+                               fileName = fileName.slice(0, fileNameLen);
+                       }
+                       return fileName;
+               },
+
+               /**
+                * @param {string} fileName
                 * @returns {string} extension for specified file name
                 */
                getFileExtension: function Helpers_getFileExtension(fileName) {
-                       console.log('Helpers_getFileExtension', fileName);
                        var splittedFileName = fileName.split('.'),
                                ext = '';
 
@@ -45,7 +56,9 @@ function Helpers() {
                 * @return {string}
                 */
                resolveFileIcon: function Helpers_resolveFileIcon(ext) {
-                       console.log('Helpers_resolveFileIcon', ext);
+
+                       ext = ext.toLowerCase();
+
                        switch (ext) {
                        case '.jpg':
                                return 'img.png';
@@ -57,6 +70,8 @@ function Helpers() {
                                return 'pdf.png';
                        case '.mp3':
                                return 'music.png';
+                       case '.avi':
+                               return 'video.png';
                        case '.mp4':
                                return 'video.png';
                        case '.ppt':
@@ -81,15 +96,16 @@ function Helpers() {
                 * @returns {string}
                 */
                resolveMimeType: function Helpers_resolveMimeType(ext) {
-                       console.log('Helpers_resolveMimeType', ext);
                        var mime = '';
 
+                       ext = ext.toLowerCase();
+
                        if (ext === '.jpg' || ext === '.png' || ext === '.gif') {
                                mime = 'image/*';
-                       } else if (ext === '.mp4' || ext === '.ogv') {
+                       } else if (ext === '.mp4' || ext === '.ogv' || ext === '.avi') {
                                mime = 'video/*';
                        } else if (ext === '.mp3') {
-                               mime = 'audio/*';
+                               mime = 'audio/mp3';
                        } else if (ext === '.txt' || ext === '.doc' || ext === '.html' || ext === '.ppt' || ext === '.xls' || ext === '.pdf') {
                                mime = 'text/*';
                        }
@@ -104,18 +120,72 @@ function Helpers() {
                 * @returns {string}
                 */
                getThumbnailURI: function Helpers_getThumbnailURI(fileName, node) {
-                       console.log('Helpers_getThumbnailURI', fileName, node);
                        var ext = this.getFileExtension(fileName),
                                thumbnailURI = '';
 
                        if (!node.thumbnailURIs) {
-                               console.log('getFileListItem: get icon');
                                thumbnailURI = 'images/' + this.resolveFileIcon(ext);
                        } else if (node.thumbnailURIs[0] && $.inArray(ext, ['.mp4', '.jpg', '.png', '.gif'])) {
                                thumbnailURI = node.thumbnailURIs[0];
                        }
 
                        return thumbnailURI;
+               },
+
+               /**
+                * File name automatic number increase for copy files
+                */
+               getCopyFileName: function (sourceName, filesList) {
+                       var ext = this.getFileExtension(sourceName),
+                               fileName = this.getFileName(sourceName),
+                               copyFileName = sourceName, i = 1;
+                       while ($.inArray(copyFileName, filesList) !== -1) {
+                               i+=1;
+                               copyFileName = fileName+'('+i+')'+ext;
+                       }
+                       return copyFileName;
                }
        };
-}());
\ No newline at end of file
+}());
+
+(function($) {
+       'use strict';
+
+       function height(t, el) {
+               return t.height() > el.height();
+       }
+       function width(t, el) {
+               return t.width() > el.width();
+       }
+
+       $.fn.ellipsis = function ()
+       {
+               return this.each(function () {
+                       var el, text, multiline, t, func;
+                       el = $(this);
+                       if(el.css("overflow") === "hidden") {
+                               text = el.html();
+                               multiline = el.hasClass('multiline');
+                               t = $(this.cloneNode(true))
+                                       .hide()
+                                       .css('position', 'absolute')
+                                       .css('overflow', 'visible')
+                                       .width(multiline ? el.width() : 'auto')
+                                       .height(multiline ? 'auto' : el.height())
+                                       ;
+
+                               el.after(t);
+
+                               func = multiline ? height : width;
+
+                               while (text.length > 0 && func(t, el)) {
+                                       text = text.substr(0, text.length - 1);
+                                       t.html(text + "...");
+                               }
+
+                               el.html(t.html());
+                               t.remove();
+                       }
+               });
+       };
+}(jQuery));
index 08bd63a..36062d7 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -1,4 +1,4 @@
-/*jslint devel: true */
+/*jslint devel: true*/
 /*global tizen, $, app, Ui, Model, Helpers, Config, Clipboard*/
 
 var App = null;
@@ -65,14 +65,13 @@ var App = null;
                 * Initialization
                 */
                init: function App_init() {
-                       console.log('App_init');
                        this.config = new Config();
                        this.model = new Model();
                        this.ui = new Ui();
                        this.helpers = new Helpers();
                        this.clipboard = new Clipboard();
 
-                       this.model.loadInternalStorages(this.initUi.bind(this));
+                       this.initUi();
                        this.addEvents();
                },
 
@@ -80,7 +79,6 @@ var App = null;
                 * UI initialization
                 */
                initUi: function App_initUi() {
-                       console.log('App_initUi');
                        this.ui.init(this.model.getInternalStorages());
                },
 
@@ -88,30 +86,36 @@ var App = null;
                 * Add pages events
                 */
                addEvents: function App_addEvents() {
-                       console.log('App_addEvents');
                        var self = this;
-                       document.addEventListener('webkitvisibilitychange', function() { self.refreshCurrentPage(); } );
+                       document.addEventListener('webkitvisibilitychange', function () { self.refreshCurrentPage(); });
+                       // workaround: page refresh for on/off keyboard
+                       window.addEventListener('softkeyboardchange',function () {
+                               $.mobile.activePage.page('refresh');
+                       });
                },
 
                /**
                 * Displays media storages
                 */
                displayStorages: function App_displayStorages() {
+                       this.currentPath = '';
+                       this.ui.scrollContentTo(0);
                        this.ui.displayStorages(this.model.getInternalStorages());
                },
 
                /**
                 * Displays specified folder
                 * @param {string} path
+                * @param {bool} [refresh=false]
                 */
-               displayFolder: function App_displayFolder(path) {
-                       console.log('App_displayFolder', path);
+               displayFolder: function App_displayFolder(path, refresh) {
                        var self = this;
 
+                       refresh = refresh || false;
+
                        // get folder data and push into rendering method
                        this.model.getFolderData(path, function (dir, nodes) {
                                // on success
-                               console.log('App_displayFolder success', dir, nodes);
 
                                // update current path
                                self.currentPath = path;
@@ -120,7 +124,10 @@ var App = null;
                                self.currentDirHandle = dir;
 
                                // display folder UI
-                               self.ui.displayFolder(path, nodes);
+                               if (refresh === undefined) {
+                                       self.ui.scrollContentTo(0);
+                               }
+                               self.ui.displayFolder(path, nodes, refresh);
                        });
                },
 
@@ -129,14 +136,13 @@ var App = null;
                 * @params {string} uri File URI
                 */
                openFile: function App_openFile(uri, fullUri) {
-                       console.log('App_openFile', uri);
                        var ext = this.helpers.getFileExtension(uri),
                                mime = this.helpers.resolveMimeType(ext);
 
                        if (mime !== '') {
                                this.model.openFile(fullUri, mime);
                        } else {
-                               console.error('Unsupported mime type', mime);
+                               console.error('Unsupported mime type for extension ' + ext);
                        }
                },
 
@@ -159,17 +165,16 @@ var App = null;
                 * @param {string} dirName
                 */
                createDir: function App_createDir(dirName) {
-                       console.log('App_createDir', dirName);
 
                        if (this.currentDirPath !== '') {
                                try {
                                        this.currentDirHandle.createDirectory(dirName);
                                } catch (e) {
-                                       console.error('App_createDir error', e);
+                                       alert(e.message);
                                }
                                this.refreshCurrentPage();
                        } else {
-                               alert("you can't create new nodes in main view");
+                               alert("You can't create new nodes in the main view");
                        }
                },
 
@@ -177,9 +182,8 @@ var App = null;
                 * Triggers refresh current page
                 */
                refreshCurrentPage: function App_refreshCurrentPage() {
-                       console.log('App_refreshCurrentPage');
                        if (this.currentPath !== '') {
-                               this.displayFolder(this.currentPath);
+                               this.displayFolder(this.currentPath, true);
                        } else {
                                this.displayStorages();
                        }
@@ -187,20 +191,26 @@ var App = null;
 
                /**
                 * Deletes nodes with specified paths
-                * @param {string[]} nodePaths
+                * @param {string[]} nodes nodePaths
                 */
                deleteNodes: function App_deleteNodes(nodes) {
-                       console.log('App_deleteNodes', nodes);
                        this.model.deleteNodes(nodes, this.currentDirHandle, this.ui.removeNodeFromList.bind(this.ui));
                },
 
                /**
-                * @param {string[]} filepaths
-                * @param {number} clipboard mode
+                * @param {string[]} paths filepaths
+                * @param {number} mode clipboard mode
                 */
                saveToClipboard: function App_saveToClipboard(paths, mode) {
-                       this.clipboard.add(paths);
-                       this.clipboard.setMode(mode);
+                       var clipboardLength = this.clipboard.add(paths);
+
+                       if (clipboardLength > 0) {
+                               this.clipboard.setMode(mode);
+                               alert('Data saved in clipboard');
+                       } else {
+                               alert('Error occured. Data has not been saved in clipboard');
+                       }
+
                        this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
                },
 
@@ -208,7 +218,6 @@ var App = null;
                 * Paste nodes from clipboard to current dir
                 */
                pasteClipboard: function App_pasteClipboard() {
-                       console.log('App_pasteClipboard');
                        var clipboardData = this.clipboard.get();
 
                        if (clipboardData.length === 0) {
@@ -223,13 +232,14 @@ var App = null;
                        }
 
                        this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
+
+                       return true;
                },
 
                /**
                 * Handler for paste clipboard success
                 */
                onPasteClipboardSuccess: function App_onPasteClipboardSuccess() {
-                       console.log('App_onPasteClipboardSuccess');
                        this.clipboard.clear();
                        this.refreshCurrentPage();
                },
index fa1223d..7983b0f 100644 (file)
@@ -1,5 +1,5 @@
-/*jslint devel: true */
-/*global tizen, SystemIO */
+/*jslint devel: true*/
+/*global tizen, SystemIO, $ */
 
 /**
  * @class Model
@@ -14,66 +14,61 @@ function Model() {
        Model.prototype = {
 
                /**
-                * @type SystemIO
+                * file open unlock flag
+                * @type {boolean}
                 */
-               systemIO: null,
+               openFileUnLocked: true,
 
                /**
-                * @type Array
+                * @type SystemIO
                 */
-               storages: [],
+               systemIO: null,
 
                /**
-                * @type MediaSource
+                * @type Array
                 */
-               mediaSource: null,
+               storages: [{label: 'root', type: 'INTERNAL'}],
 
                /**
                 * API module initialisation
                 */
                init: function Model_init() {
-                       console.log('Model_init');
                        this.systemIO = new SystemIO();
-                       //this.mediaSource = tizen.mediacontent.getLocalMediaSource();
                },
 
                /**
                 * @returns {FileSystemStorage[]} storages
                 */
                getInternalStorages: function Model_getInternalStorages() {
-                       console.log('Model_getInternalStorages');
                        return this.storages;
                },
 
                /**
                 * Saves storages
-                * @param {function} callback
+                * @param {function} onSuccess callback
                 */
                loadInternalStorages: function Model_loadInternalStorages(onSuccess) {
-                       console.log('Model_loadInternalStorages', onSuccess);
                        var self = this;
 
                        this.systemIO.getStorages('INTERNAL', function (storages) {
                                self.storages = storages;
                                if (typeof onSuccess === 'function') {
-                                       console.log('Storages loaded successfully');
                                        onSuccess();
                                }
-                       });
+                       }, 'internal0');
                },
 
                /**
                 * Returns folder data
-                * @param {string} node Node path
+                * @param {string} path Node path
                 * @param {function} onSuccess Success callback
+                * @param {function} onError Error callback
                 */
                getFolderData: function Model_getFolderData(path, onSuccess, onError) {
-                       console.log('Model_getFolderData', path);
 
                        var onOpenSuccess = function (dir) {
                                dir.listFiles(
                                        function (files) {
-                                               console.log('Model_getFolderData listFiles success', files);
                                                onSuccess(dir, files);
                                        },
                                        function (e) {
@@ -89,40 +84,44 @@ function Model() {
                },
 
                /**
-                * Launch a service associated with 'ext' to launch the 'uri'
-                * @param  {string} ext
-                * @param  {string} uri
-                * @returns {ApplicationSevice}
+                * Launch a service to open the file
+                * @param {string} fullUri ext
+                * @param {string} mime uri
                 */
                openFile: function Model_openFile(fullUri, mime) {
-                       var serviceReplyCB = {
-                               onsuccess: function (reply) {
-                                       var num = 0;
-                                       for (num = 0; num < reply.data.length; num += 1) {
-                                               console.log('reply.data[' + num + '].key = ' + reply.data[num].key);
-                                               console.log('reply.data[' + num + '].value = ' + reply.data[num].value);
+                       if (this.openFileUnLocked) {
+                               var self = this, serviceReplyCB = {
+                                       onsuccess: function (reply) {
+                                               self.openFileUnLocked = true;
+                                       },
+                                       onfailure: function () {
+                                               self.openFileUnLocked = true;
+                                               console.error('Launch service failed');
                                        }
-                               },
-                               onfailure: function () {
-                                       console.log('Launch service failed');
+                               };
+                               this.openFileUnLocked = false;
+                               try {
+                                       tizen.application.launchAppControl(new tizen.ApplicationControl(
+                                               'http://tizen.org/appcontrol/operation/view',
+                                               fullUri,
+                                               mime
+                                       ),
+                                               null,
+                                               function () {
+                                                       setTimeout(function () {
+                                                               self.openFileUnLocked = true;
+                                                       }, 500);
+                                               },
+                                               function (e) {
+                                                       self.openFileUnLocked = true;
+                                                       alert('launch sevice failed. reason :' + e.message);
+                                               },
+                                               serviceReplyCB
+                                               );
+                               } catch (e) {
+                                       self.openFileUnLocked = true;
+                                       console.error('openFile error:', e);
                                }
-                       };
-
-                       try {
-                               tizen.application.launchAppControl(new tizen.ApplicationControl(
-                                       'http://tizen.org/appcontrol/operation/view',
-                                       fullUri,
-                                       mime
-                               ),
-                                       null,
-                                       function () { },
-                                       function (e) {
-                                               alert('launch sevice failed. reason :' + e.message);
-                                       },
-                                       serviceReplyCB
-                                       );
-                       } catch (e) {
-                               console.error('openFile error:', e);
                        }
                },
 
@@ -133,16 +132,14 @@ function Model() {
                 * @param {function} onError
                 */
                deleteNodes: function Model_deleteNodes(nodes, dir, onSuccess, onError) {
-                       console.log('Model_deleteNodes', nodes, dir);
                        var len = nodes.length,
                                onDeleteNodeSuccess = function (nodeId, isDir) {
-                                       console.log((isDir ? 'Folder' : 'File') + nodeId + ' deleted successfully');
                                        if (typeof onSuccess === 'function') {
                                                onSuccess(nodeId);
                                        }
                                },
                                onDeleteNodeError = function (e) {
-                                       console.log('Folder delete error', e);
+                                       console.error('Folder delete error', e);
                                        if (typeof onError === 'function') {
                                                onError();
                                        }
@@ -177,7 +174,6 @@ function Model() {
                 * @param {function} onSuccess callback
                 */
                copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
-                       console.log('Model_copyNodes', dir, paths, destinationPath);
                        var len = paths.length,
                                copied = 0,
                                onCopyNodeSuccess = function () {
@@ -186,11 +182,33 @@ function Model() {
                                                onSuccess();
                                        }
                                },
-                               i;
+                               onCopyNodeFailure = function () {
+                                       alert('Copying error');
+                               },
+                               i,
+                               sourceName,
+                               decision;
 
-                       for (i = 0; i < len; i = i + 1) {
-                               dir.copyTo(paths[i], destinationPath, true, onCopyNodeSuccess);
-                       }
+                       this.systemIO.getFilesList(dir, function (filesList) {
+                               for (i = 0; i < len; i = i + 1) {
+                                       if (destinationPath.indexOf(paths[i]) !== -1) {
+                                               alert('Copying error');
+                                               return;
+                                       }
+                               }
+
+                               for (i = 0; i < len; i = i + 1) {
+                                       decision = true;
+                                       sourceName = paths[i].split('/').pop();
+                                       sourceName = app.helpers.getCopyFileName(sourceName, filesList);
+
+                                       try {
+                                               dir.copyTo(paths[i], destinationPath + '/' + sourceName, true, onCopyNodeSuccess, onCopyNodeFailure);
+                                       } catch (e) {
+                                               console.error(e);
+                                       }
+                               }
+                       });
                },
 
                /**
@@ -203,7 +221,6 @@ function Model() {
                 * @param {function} onSuccess callback
                 */
                moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
-                       console.log('Model_moveNodes', dir, paths, destinationPath);
                        var len = paths.length,
                                moved = 0,
                                onMoveNodeSuccess = function () {
@@ -212,11 +229,34 @@ function Model() {
                                                onSuccess();
                                        }
                                },
-                               i;
+                               onMoveNodeFailure = function () {
+                                       alert('Moving error');
+                               },
+                               i,
+                               sourceName,
+                               decision;
 
-                       for (i = 0; i < len; i = i + 1) {
-                               dir.moveTo(paths[i], destinationPath, true, onMoveNodeSuccess);
-                       }
+                       this.systemIO.getFilesList(dir, function (filesList) {
+                               for (i = 0; i < len; i = i + 1) {
+                                       if (destinationPath.indexOf(paths[i]) !== -1) {
+                                               alert('Moving error');
+                                               return;
+                                       }
+                               }
+
+                               for (i = 0; i < len; i = i + 1) {
+                                       decision = true;
+                                       sourceName = paths[i].split('/').pop();
+
+                                       if ($.inArray(sourceName, filesList) !== -1) {
+                                               decision = confirm('A file with (' + sourceName + ') name already exists.\nDo you want to overwrite it?');
+                                       }
+
+                                       if (decision) {
+                                               dir.moveTo(paths[i], destinationPath + '/' + sourceName, true, onMoveNodeSuccess, onMoveNodeFailure);
+                                       }
+                               }
+                       });
                }
        };
 }());
index 41c6c96..4c70377 100644 (file)
@@ -1,4 +1,4 @@
-/*jslint devel: true */
+/*jslint devel: true*/
 /*global tizen, localStorage */
 
 /**
@@ -18,12 +18,11 @@ function SystemIO() {
                 * @param {string} fileName
                 */
                createFile: function SystemIO_createFile(directoryHandle, fileName) {
-                       console.log('SystemIO_createFile', directoryHandle, fileName);
 
                        try {
                                return directoryHandle.createFile(fileName);
                        } catch (e) {
-                               console.error('SystemIO_createFile error:'e);
+                               console.error('SystemIO_createFile error:' + e.message);
                                return false;
                        }
                },
@@ -31,17 +30,16 @@ function SystemIO() {
                /**
                 * Writes content to file stream
                 *
-                * @param {File} file handler
-                * @param {string} file content
-                * @param {function} on success callback
+                * @param {File} fileHandle file handler
+                * @param {string} fileContent file content
+                * @param {function} onSuccess on success callback
+                * @param {function} onError on error callback
                 * @param {string} content encoding
                 */
                writeFile: function SystemIO_writeFile(fileHandle, fileContent, onSuccess, onError, contentEncoding) {
-                       console.log('SystemIO_writeFile', fileHandle, fileContent.length, contentEncoding);
                        onError = onError || function () {};
 
                        fileHandle.openStream('w', function (fileStream) {
-                               console.log('SystemIO_writeFile:_onOpenStreamSuccess', fileStream);
                                if (contentEncoding === 'base64') {
                                        fileStream.writeBase64(fileContent);
                                } else {
@@ -66,14 +64,12 @@ function SystemIO() {
                 * @param {string} mode
                 */
                openDir: function SystemIO_openDir(directoryPath, onSuccess, onError, openMode) {
-                       console.log('SystemIO_openDir', directoryPath, openMode);
                        openMode = openMode || 'rw';
                        onSuccess = onSuccess || function () {};
 
                        try {
                                tizen.filesystem.resolve(directoryPath, onSuccess, onError, openMode);
                        } catch (e) {
-                               console.log('SystemIO_openDir error:' + e.message);
                        }
                },
 
@@ -84,7 +80,6 @@ function SystemIO() {
                 * @returns {array}
                 */
                getPathData: function SystemIO_getPathData(filePath) {
-                       console.log('SystemIO_getPathData', filePath);
                        var path = {
                                originalPath: filePath,
                                fileName: '',
@@ -106,13 +101,11 @@ function SystemIO() {
                 * @param {string} file encoding
                 */
                saveFileContent: function SystemIO_saveFileContent(filePath, fileContent, onSaveSuccess, fileEncoding) {
-                       console.log('SystemIO_saveFileContent', filePath, fileContent.length, fileEncoding);
                        var pathData = this.getPathData(filePath),
                                self = this,
                                fileHandle;
 
                        function onOpenDirSuccess(dir) {
-                               console.log('SystemIO_saveFileContent:_onOpenDirSuccess', dir);
                                // create new file
                                fileHandle = self.createFile(dir, pathData.fileName);
                                if (fileHandle !== false) {
@@ -132,23 +125,19 @@ function SystemIO() {
                 * @param {function} success callback
                 */
                deleteNode: function SystemIO_deleteNode(nodePath, onSuccess) {
-                       console.log('SystemIO_deleteNode', nodePath);
                        var pathData = this.getPathData(nodePath),
                                self = this;
 
                        function onDeleteSuccess() {
-                               console.log('SystemIO_deleteNode:_onDeleteSuccess');
                                onSuccess();
                        }
 
                        function onDeleteError(e) {
-                               console.log('SystemIO_deleteNode:_onDeleteError', e);
+                               console.error('SystemIO_deleteNode:_onDeleteError', e);
                        }
 
                        function onOpenDirSuccess(dir) {
-                               console.log('SystemIO_deleteNode:_onOpenDirSuccess', dir);
                                var onListFiles = function (files) {
-                                       console.log('SystemIO_deleteNode:_onListFiles', files);
                                        if (files.length > 0) {
                                                // file exists;
                                                if (files[0].isDirectory) {
@@ -183,11 +172,10 @@ function SystemIO() {
                 * @param {function} delete error callback
                 */
                deleteFile: function SystemIO_deleteFile(dir, filePath, onDeleteSuccess, onDeleteError) {
-                       console.log('SystemIO_deleteFile', filePath);
                        try {
                                dir.deleteFile(filePath, onDeleteSuccess, onDeleteError);
                        } catch (e) {
-                               console.error('SystemIO_deleteFile error:' + e.message);
+                               console.error('SystemIO_deleteFile error: ' + e.message);
                                return false;
                        }
                },
@@ -196,13 +184,12 @@ function SystemIO() {
                 * Deletes specified directory
                 *
                 * @param {File} dir
-                * @param {string} dir path
-                * @param {function} delete success callback
-                * @param {function} delete error callback
+                * @param {string} dirPath dir path
+                * @param {function} onDeleteSuccess delete success callback
+                * @param {function} onDeleteError delete error callback
                 * @returns {boolean}
                 */
                deleteDir: function SystemIO_deleteDir(dir, dirPath, onDeleteSuccess, onDeleteError) {
-                       console.log('SystemIO_deleteDir', dir, dirPath);
                        try {
                                dir.deleteDirectory(dirPath, false, onDeleteSuccess, onDeleteError);
                        } catch (e) {
@@ -214,21 +201,23 @@ function SystemIO() {
                },
 
                /**
-                * @param {string} storage type
+                * @param {string} type storage type
+                * @param {function} onSuccess on success callback
+                * @param {string} excluded Excluded storage
                 */
-               getStorages: function SystemIO_getStorages(type, onSuccess) {
-                       console.log('SystemIO_getStorages', type);
+               getStorages: function SystemIO_getStorages(type, onSuccess, excluded) {
                        try {
                                tizen.filesystem.listStorages(function (storages) {
-                                       console.log('...listStorages success', storages);
                                        var tmp = [],
                                                len = storages.length,
                                                i;
 
                                        if (type !== undefined) {
                                                for (i = 0; i < len; i += 1) {
-                                                       if (storages[i].type === 0 || storages[i].type === type) {
-                                                               tmp.push(storages[i]);
+                                                       if (storages[i].label !== excluded) {
+                                                               if (storages[i].type === 0 || storages[i].type === type) {
+                                                                       tmp.push(storages[i]);
+                                                               }
                                                        }
                                                }
                                        } else {
@@ -240,7 +229,32 @@ function SystemIO() {
                                        }
                                });
                        } catch (e) {
-                               console.error('SystemIO_getStorages error:', e);
+                               console.error('SystemIO_getStorages error:' + e.message);
+                       }
+               },
+
+               getFilesList: function SystemIO_getFilesList(dir, onSuccess) {
+                       try {
+                               dir.listFiles(
+                                       function (files) {
+                                               var tmp = [],
+                                                       len = files.length,
+                                                       i;
+
+                                               for (i = 0; i < len; i += 1) {
+                                                       tmp.push(files[i].name);
+                                               }
+
+                                               if (typeof onSuccess === 'function') {
+                                                       onSuccess(tmp);
+                                               }
+                                       },
+                                       function (e) {
+                                               console.error('SystemIO_getFilesList dir.listFiles() error:', e);
+                                       }
+                               );
+                       } catch (e) {
+                               console.error('SystemIO_getFilesList error:', e.message);
                        }
                }
        };
index f931c02..cb7ced7 100644 (file)
@@ -12,6 +12,12 @@ function Ui() {
        'use strict';
        Ui.prototype = {
                /**
+                * root mode
+                * @type {boolean}
+                */
+               root: true,
+
+               /**
                 * UI edit mode
                 * @type {boolean}
                 */
@@ -69,11 +75,13 @@ function Ui() {
                EDIT_TABBAR_COPY_ACTION: 2,
                EDIT_TABBAR_CANCEL_ACTION: 3,
 
+               currentHeaderHeight: null,
+               currentScrollPosition: null,
+
                /**
                 * UI Initialization
                 */
                init: function Ui_init(storages) {
-                       console.log('Ui_init', storages);
                        this.templateManager = new TemplateManager();
                        this.helpers = new Helpers();
                        // Disable text selection
@@ -82,7 +90,6 @@ function Ui() {
                },
 
                initDom: function Ui_initDom(storages) {
-                       console.log('Ui_initDom', storages);
                        var self = this;
 
                        this.templateManager.loadToCache(['main', 'fileRow', 'folderRow', 'levelUpRow', 'emptyFolder'], function () {
@@ -96,7 +103,6 @@ function Ui() {
                 * Add UI events
                 */
                addEvents: function Ui_addEvents() {
-                       console.log('Ui_addEvents');
                        var self = this;
                        // touch events for all nodes
                        $('ul#fileList')
@@ -132,7 +138,12 @@ function Ui() {
                        });
 
                        // level up
-                       $('#levelUpBtn').on('tap', app.goLevelUp.bind(app));
+                       $('#levelUpBtn').on('tap', function () {
+                               if (self.editMode === true) {
+                                       self.handleCancelEditAction();
+                               }
+                               app.goLevelUp();
+                       });
 
                        $('#homeBtn').on('tap', app.displayStorages.bind(app));
 
@@ -169,20 +180,14 @@ function Ui() {
                                }
                        });
 
-                       $('#cancelNewFolder').on('tap', function () {
-                               $('#addFolderPopup').popup('close');
-                               $('#morePopup').popupwindow('close');
-                       });
-
-                       $('#saveNewFolder').on('tap', function () {
+                       $('#saveNewFolder').on('click', function () {
                                var folderName = $('#newFolderName').val().trim();
-                               $('#addFolderPopup').popup('close');
-                               $('#morePopup').popupwindow('close');
-
-                               if (folderName !== '') {
-                                       app.createDir(folderName);
+                               if (folderName === '') {
+                                       alert("Empty folder name");
+                               } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
+                                       alert("The following special characters are not allowed: *./\\?:<>|'\"");
                                } else {
-                                       alert("Wrong name of folder");
+                                       app.createDir(folderName);
                                }
                        });
 
@@ -192,6 +197,8 @@ function Ui() {
                                }, 700);
                        });
 
+                       /* workaround for UIFW & webkit scroll*/
+                       //$('.ui-page').css('min-height', 0);
                },
 
                /**
@@ -200,20 +207,17 @@ function Ui() {
                 * @param {boolean} toggleCheckbox
                 */
                handleNodeClick: function Ui_handleNodeClick(node, toggleCheckbox) {
-                       console.log('Ui_handleNodeClick', node);
-                       if (this.editMode === true) {
+                       if (this.root) {
+                               app.model.loadInternalStorages(function(){app.displayStorages()});
+                               this.root = false;
+                       } else if (this.editMode === true) {
                                //if edit mode is on toggle checkbox state
                                if (toggleCheckbox === true) {
                                        this.toggleCheckBoxState(node); // select the checkbox
                                }
 
                                this.refreshSelectAllStatus();
-
-                               if ($('ul#fileList input:checkbox:checked').length > 0) {
-                                       this.enableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
-                               } else {
-                                       this.disableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
-                               }
+                               this.refreshEditMenu();
                        } else if (node.hasClass('folder')) {
                                // otherwise display folder
                                app.displayFolder(node.attr('uri'));
@@ -227,7 +231,6 @@ function Ui() {
                 * Handler for edit action
                 */
                handleEditAction: function Ui_handleEditAction() {
-                       console.log('Ui_handleEditAction');
                        this.editMode = true;
                        $('.standardTabbar').hide();
                        $('div.editTabbar').show();
@@ -239,7 +242,7 @@ function Ui() {
                 * Handler for cancel edit action
                 */
                handleCancelEditAction: function Ui_handleCancelEditAction() {
-                       console.log('Ui_handleCancelEditAction');
+                       this.editMode = false;
                        $('div.editTabbar').hide();
                        $('.standardTabbar').show();
                        this.hideEditCheckBoxes();
@@ -249,7 +252,6 @@ function Ui() {
                 * Handler for delete action
                 */
                handleDeleteAction: function Ui_handleDeleteAction() {
-                       console.log('Ui_handleDeleteAction');
                        var nodesToDelete = [],
                                $rowElement;
 
@@ -265,6 +267,9 @@ function Ui() {
 
                        if (nodesToDelete.length > 0 && confirm('Selected nodes will be deleted. Are you sure?')) {
                                app.deleteNodes(nodesToDelete);
+                               this.scrollContentTo(0);
+                               $('ul#fileList input:checkbox:checked').remove();
+                               this.refreshEditMenu();
                        }
                },
 
@@ -272,7 +277,6 @@ function Ui() {
                 * Handler for copy action
                 */
                handleCopyAction: function Ui_handleCopyAction() {
-                       console.log('Ui_handleCopyAction');
                        var paths = [];
                        if (this.editMode === true) {
                                $('ul#fileList input:checkbox:checked').each(function (index) {
@@ -286,7 +290,6 @@ function Ui() {
                 * Handler for move action
                 */
                handleMoveAction: function Ui_handleMoveAction() {
-                       console.log('Ui_handleMoveAction');
                        var paths = [];
                        if (this.editMode === true) {
                                $('ul#fileList input:checkbox:checked').each(function (index) {
@@ -300,20 +303,24 @@ function Ui() {
                 * Handler for paste action
                 */
                handlePasteAction: function Ui_handlePasteAction() {
-                       console.log('Ui_handlePasteAction');
+               },
+
+               /**
+                * Scrolls content to the specified position
+                */
+               scrollContentTo: function scrollContentTo(value) {
+                       $('#main [data-role="content"]').scrollview('scrollTo', 0, value);
                },
 
                /**
                 * @param {FileSystemStorage[]} nodes Storage elements
                 */
                displayStorages: function Ui_displayStorages(nodes) {
-                       console.log('Ui_displayStorages', nodes, nodes.length);
                        var len = nodes.length,
                                listElements = [],
                                nodeName,
                                listTemplate = '',
                                i;
-
                        this.updateNavbar('');
 
                        for (i = 0; i < len; i = i + 1) {
@@ -340,9 +347,8 @@ function Ui() {
                        listTemplate = listElements.join('');
                        $(listTemplate).appendTo('#fileList');
                        // reset scrollview position
-                       $('#main .ui-scrollview-view').css('-webkit-transform','none');
-                       $('#fileList')
-                               .trigger("refresh");
+                       //$('#main .ui-scrollview-view').css('-webkit-transform', 'none');
+                       $('#fileList').listview("refresh");
 
                        this.resetDefaultCheckBoxLabelEvents();
                        this.hideSelectAllArea();
@@ -350,25 +356,50 @@ function Ui() {
                },
 
                /**
+                * File comparison function using their names (case insensitive)
+                * 
+                * @param {File} x
+                * @param {File} y
+                * @returns {Number}
+                */
+               fileComparison: function fileComparison(x, y) {
+                       var a = x.name.toLowerCase(),
+                               b = y.name.toLowerCase();
+
+                       if (a < b) {
+                               return -1;
+                       }
+                       if (a > b) {
+                               return 1;
+                       }
+                       return 0;
+               },
+
+               /**
                 * renders node list for folder
+                * @param {string} folderName
                 * @param {File[]} nodes
+                * @param {bool} [refresh=false]
                 */
-               displayFolder: function Ui_displayFolder(folderName, nodes) {
-                       console.log('Ui_displayFolder', nodes, nodes.length);
+               displayFolder: function Ui_displayFolder(folderName, nodes, refresh) {
                        var len = nodes.length,
                                listElements = [this.templateManager.get('levelUpRow')],
                                nodeName,
+                               checkedRows = [],
                                i;
 
+                       refresh = refresh || false;
+
                        // update title
                        this.updateTitle(folderName);
                        // update navbar
                        this.updateNavbar(folderName);
 
+                       nodes.sort(this.fileComparison);
+
                        // render nodes
                        for (i = 0; i < len; i = i + 1) {
                                nodeName = nodes[i].name.trim();
-                               console.log('node:', nodeName);
                                if (nodeName !== '') {
                                        if (nodes[i].isDirectory) {
                                                // folder
@@ -396,16 +427,47 @@ function Ui() {
                                listElements.push(this.templateManager.get('emptyFolder'));
                        }
 
+                       // scroll to top of list
+                       this.scrollContentTo(0);
+
                        $('#levelUpBtn').removeClass('vhidden');
                        $('#homeBtn').removeClass('vhidden');
                        $('#editActionBtn').removeClass('vhidden');
                        $('#moreActionBtn').removeClass('vhidden');
-                       this.hideSelectAllArea();
+
+                       if (refresh === true && this.editMode === true) {
+                               $.each($('#fileList .ui-checkbox input:checked'), function () {
+                                       checkedRows.push($(this).closest('li').attr('id'));
+                               });
+                       }
 
                        // update file list
                        $('#fileList').html(listElements.join(''))
                                .trigger('refresh')
                                .trigger('create');
+                       // fixing ellisis for Bengali language
+                       $(".ui-li-text-main.nodename").ellipsis();
+                       $("#mainTitle").ellipsis();
+                       $("#navbar").ellipsis();
+
+                       if (this.editMode === true) {
+                               $('.selectAll').show();
+                               $('ul#fileList > li').css('paddingLeft', '2rem');
+                               $('.my-ui-checkbox').removeClass('hidden');
+
+                               if (refresh === true) {
+                                       // restore checked checkboxes
+                                       for (i = 0; i < checkedRows.length; i += 1) {
+                                               $('#' + checkedRows[i] + ' input:checkbox')
+                                                       .attr('checked', 'checked')
+                                                       .data('checkboxradio').refresh();
+                                       }
+                               }
+                       } else {
+                               $('.selectAll').hide();
+                               $('ul#fileList > li').css('paddingLeft', '0');
+                               $('.my-ui-checkbox').addClass('hidden');
+                       }
                },
 
                /**
@@ -413,10 +475,8 @@ function Ui() {
                 * @param {jQuery} listElement
                 */
                toggleCheckBoxState: function Ui_toggleCheckBoxState(listElement) {
-                       console.log('Ui_toggleCheckBoxState', listElement);
-                       var checkboxInput = null,
-                               checkboxesInputChecked = null,
-                               editTabbar = null;
+
+                       var checkboxInput = null;
 
                        checkboxInput = listElement.find('form > div.ui-checkbox input');
                        checkboxInput
@@ -428,7 +488,6 @@ function Ui() {
                 * Shows item checkboxes and topbar with select all option
                 */
                showEditCheckBoxes: function Ui_showEditCheckBoxes() {
-                       console.log('Ui_showEditCheckBoxes');
                        var self = this;
 
                        this.showSelectAllArea();
@@ -444,21 +503,24 @@ function Ui() {
                 * All checkboxes are auto uncheked
                 */
                hideEditCheckBoxes: function Ui_hideEditCheckBoxes() {
-                       console.log('Ui_hideEditCheckBoxes');
                        var self = this;
 
                        this.hideSelectAllArea(); // hide select all option topbar
 
                        $('ul#fileList > li').animate({paddingLeft: '0'}, 200, 'swing', function () {
-                               self.editMode = false;
                                $('.my-ui-checkbox').addClass('hidden');
                                $.mobile.activePage.page('refresh');
                        });
 
                        // uncheck all checkboxes
                        $('ul#fileList input[type=checkbox]').each(function (index) {
+                               var checkboxradio = $(this).data('checkboxradio');
+
                                $(this).attr('checked', false);
-                               //$(this).data('checkboxradio').refresh();      // element undefined
+
+                               if (checkboxradio) {
+                                       checkboxradio.refresh();
+                               }
                        });
 
                        //uncheck select all input
@@ -469,30 +531,50 @@ function Ui() {
                },
 
                /**
+                * Save current header and content height
+                */
+               saveHeights: function Ui_saveHeights() {
+                       this.currentHeaderHeight = $('#main div[data-role="header"]').height();
+                       this.currentScrollPosition = $('#main div[data-role="content"]').scrollview('getScrollPosition').y;
+               },
+
+               /**
+                * Changes content scroll position after showing/hiding selectAllArea
+                */
+               changeContentScrollPosition: function Ui_changeContentScrollPosition() {
+                       var diff;
+                       if (this.currentScrollPosition !== 0) {
+                               diff = $('#main div[data-role="header"]').height() - this.currentHeaderHeight;
+                               $('#main div[data-role="content"]').scrollview('scrollTo', 0, -(this.currentScrollPosition + diff));
+                       }
+               },
+
+               /**
                 * Shows topbar with select all option
                 */
                showSelectAllArea: function Ui_showSelectAllArea() {
-                       console.log('showSelectAllArea');
+                       this.saveHeights();
                        $('.selectAll').show();
                        $.mobile.activePage.page('refresh');
+                       this.changeContentScrollPosition();
                },
 
                /**
                 * Hides topbar with select all option
                 */
                hideSelectAllArea: function Ui_hideSelectAllArea() {
-                       console.log('hideSelectAllArea');
+                       this.saveHeights();
                        $('.selectAll').hide();
                        $.mobile.activePage.page('refresh');
+                       this.changeContentScrollPosition();
                },
 
                /**
                 * Enable specified options for tabbar
                 * @param {object} tabbar
-                * @param {array} options to enable
+                * @param {array} enableOptions options to enable
                 */
                enableControlBarButtons: function Ui_enableControlBarButtons(tabbar, enableOptions) {
-                       console.log('Ui_enableControlBarButtons', tabbar, enableOptions);
                        var i = 0,
                                len = enableOptions.length;
 
@@ -503,11 +585,10 @@ function Ui() {
 
                /**
                 * Disable specified options for tabbar
-                * @param {object} controlbar
-                * @param {array} options to enable
+                * @param {object} tabbar controlbar
+                * @param {array} disableOptions options to enable
                 */
                disableControlBarButtons: function Ui_disableControlBarButtons(tabbar, disableOptions) {
-                       console.log('Ui_disableControlBarButtons', tabbar, disableOptions);
                        var i = 0,
                                len = disableOptions.length;
 
@@ -520,7 +601,6 @@ function Ui() {
                 * @param {string} path
                 */
                updateTitle: function Ui_updateTitle(path) {
-                       console.log('Ui_updateTitle', path);
                        var regexp = new RegExp('([^\/])+$', 'g'),
                                match = path.match(regexp),
                                lastDir = match[0] || '(dir)';
@@ -531,7 +611,6 @@ function Ui() {
                 * @param {string} path
                 */
                updateNavbar: function Ui_updateNavbar(path) {
-                       console.log('Ui_updateNavbar', path);
                        var html = ['<span uri="home">Media</span>'],
                                splitted,
                                len,
@@ -549,25 +628,24 @@ function Ui() {
                },
 
                handleSelectAllChange: function Ui_handleSelectAllChange() {
-                       console.log('Ui_handleSelectAllChange');
                        var $selectAllInput = $('.ui-header .selectAll .ui-checkbox input');
                        $selectAllInput.data('checkboxradio').refresh();
 
                        if ($selectAllInput.is(':checked')) {
-                               this.enableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
-
                                // check all checkboxes
                                $('ul#fileList input[type=checkbox]').each(function (index) {
                                        $(this).attr('checked', true);
                                        $(this).data('checkboxradio').refresh();
                                });
-                       } else {
-                               this.disableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
 
+                               this.enableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
+                       } else {
                                $('ul#fileList input[type=checkbox]').each(function (index) {
                                        $(this).attr('checked', false);
                                        $(this).data('checkboxradio').refresh();
                                });
+
+                               this.disableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
                        }
                },
 
@@ -575,7 +653,6 @@ function Ui() {
                 *
                 */
                refreshSelectAllStatus: function Ui_refreshSelectAllStatus() {
-                       console.log('Ui_refreshSelectAllStatus');
                        var $selectAllInput = $('.ui-header .selectAll .ui-checkbox input');
                        // update status of select all checkbox
                        if ($('ul#fileList input:checkbox:not(:checked)').length === 0) {
@@ -588,10 +665,22 @@ function Ui() {
                },
 
                /**
+                * Refresh activity of edit menu
+                */
+               refreshEditMenu: function () {
+                       if ($('ul#fileList input:checkbox:checked').length > 0) {
+                               this.enableControlBarButtons($('.editTabbar'),
+                                       [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
+                       } else {
+                               this.disableControlBarButtons($('.editTabbar'),
+                                       [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
+                       }
+               },
+
+               /**
                 * Unbinds default events for checkbox labels
                 */
                resetDefaultCheckBoxLabelEvents: function Ui_resetDefaultCheckBoxLabelEvents() {
-                       console.log('Ui_resetDefaultCheckBoxLabelEvents');
                        $('div.ui-checkbox > label')
                                .unbind('vmousedown')
                                .unbind('vmouseup')
@@ -601,18 +690,21 @@ function Ui() {
 
                /**
                 * Remove html node element from list
-                * @param {string} node id
+                * @param {string} nodeId node id
                 */
                removeNodeFromList: function Ui_removeNodeFromList(nodeId) {
-                       console.log('Ui_removeNodeFromList', nodeId);
                        $('ul#fileList > li#' + nodeId).remove();
+
+                       // hide select All checkbox if removed all elements;
+                       if ($('ul#fileList > li.node').length === 0) {
+                               this.hideSelectAllArea();
+                       }
                },
 
                /**
                 * Enable/Disable
                 */
                refreshPasteActionBtn: function Ui_refreshPasteActionBtn(clipboardEmpty) {
-                       console.log('Ui_refreshPasteActionBtn', clipboardEmpty);
                        if (clipboardEmpty === true) {
                                $('#pasteActionBtnRow').addClass('hidden');
                        } else {
index bfe2b73..68c6678 100644 (file)
@@ -1,5 +1,4 @@
-/*jslint devel: true*/
-/*global $, app */
+/*global tizen, $, app */
 /**
  * @class TemplateManager
  */
@@ -21,15 +20,14 @@ function TemplateManager() {
                 * UI module initialisation
                 */
                init: function init() {
-
                },
 
                /**
                 * Returns template html (from cache)
+                * @param {string} tplName
+                * @param {string} tplParams
                 */
                get: function TemplateManager_get(tplName, tplParams) {
-                       console.log('TemplateManager_get:' + tplName);
-
                        if (this.cache[tplName] !== undefined) {
                                return this.getCompleted(this.cache[tplName], tplParams);
                        }
@@ -38,6 +36,8 @@ function TemplateManager() {
 
                /**
                 * Load templates to cache
+                * @param {string} tplNames
+                * @param {function} onSuccess
                 */
                loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess) {
                        var self = this,
@@ -66,7 +66,6 @@ function TemplateManager() {
 
                                                                // save to cache
                                                                self.cache[fileName] = data;
-                                                               console.log('Cached template: ' + fileName);
 
                                                                // if all templates are cached launch callback
                                                                if (cachedTemplates >= tplNames.length && typeof onSuccess === 'function') {
@@ -74,7 +73,7 @@ function TemplateManager() {
                                                                }
                                                        },
                                                        error: function (jqXHR, textStatus, errorThrown) {
-                                                               alert(errorThrown);
+                                                               console.error('templateManagerError: ' + errorThrown);
                                                        }
                                                });
                                        } else {
@@ -92,6 +91,8 @@ function TemplateManager() {
 
                /**
                 * Returns template completed by specified params
+               * @param {string} tplHtml
+               * @param {string} tplParams
                 */
                getCompleted: function TemplateManager_getCompleted(tplHtml, tplParams) {
                        var tplParam, replaceRegExp;
index e3440f4..45d59e6 100644 (file)
@@ -14,7 +14,7 @@
  *      limitations under the License.
  */
 
-/*jslint devel: true */
+/*jslint devel: true*/
 /*global $, tizen, App  */
 
 /**
@@ -40,7 +40,6 @@ var app = null;
                        var self = this;
                        $.getScript('js/app.js')
                                .done(function () {
-                                       console.log('Loaded app.js');
                                        // once the app is loaded, create the app object
                                        // and load the libraries
                                        app = new App();
@@ -59,7 +58,6 @@ var app = null;
                                        $.getScript(filename)
                                                .done(function () {
                                                        loadedLibs += 1;
-                                                       console.log('Loaded subscript: ' + filename + ' : ' + loadedLibs);
                                                        if (loadedLibs >= app.requires.length) {
                                                                // All dependencies are loaded - initialise the app
                                                                app.init();
index 1069bb3..f6871ca 100644 (file)
 
                <div data-role="content">
                        <ul id="fileList" data-role="listview"></ul>
+                       <div data-role="popup" class="center_title_2btn" id="addFolderPopup">
+                               <div class="ui-popup-title">
+                                       <h1>Add new folder<h1>
+                               </div>
+                               <div class="ui-popup-text">
+                                       <input id="newFolderName" type="text" value="New folder" class="newFolder" />
+                               </div>
+                               <div class="ui-popup-button-bg">
+                                       <a data-role="button" id="saveNewFolder" data-rel="back" data-inline="true">Save</a>
+                                       <a data-role="button" id="cancelNewFolder" id="btn_textbox_popup_cancel" data-rel="back" data-inline="true">Cancel</a>
+                               </div>
+                       </div>
                </div>
 
                <div data-role="footer" data-position="fixed">
                                                </tr>
                                        </table>
                                </div>
-                               <div class="horizontal" id="addFolderPopup" data-role="popup" data-style="center_title_2btn" data-corners="true" >
-                                       <p data-role="title">Add new folder</p>
-                                       <p data-role="text">
-                                               <input id="newFolderName" type="text" value="New folder" class="newFolder" />
-                                       </p>
-                                       <p data-role="text">
-                                               <input type="button" id="saveNewFolder" value="Save" data-inline="true" />
-                                               <input type="button" id="cancelNewFolder" value="Cancel" data-inline="true" />
-                                       </p>
-                               </div>
                        </div>
                </div>
        </div>
\ No newline at end of file