[FileManager]Updated Private -> RSA
authorji.ji <ji.ji@samsung.com>
Tue, 9 Jul 2013 10:20:58 +0000 (19:20 +0900)
committerji.ji <ji.ji@samsung.com>
Tue, 9 Jul 2013 10:20:58 +0000 (19:20 +0900)
Change-Id: Icb1574cbc16a41cb793da5c01bc84d5d175af116

config.xml
css/style.css
js/app.helpers.js
js/app.js
js/app.model.js
js/app.ui.js
js/app.ui.templateManager.js
templates/main.tpl

index 9c090dc..23820ec 100644 (file)
@@ -2,7 +2,7 @@
 <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.2.0" viewmodes="maximized">
        <tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.2"/>
        <icon src="icon.png"/>
-       <name>FileManager</name>
+       <name>File manager</name>
        <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/application.launch"/>
index 4ed5976..ebae9ea 100644 (file)
@@ -12,8 +12,7 @@ body {
 }
 
 #mainTitle {
-       width: 255px;
-       text-transform: uppercase;
+       width: 210px;
 }
 
 #fileList > li {
@@ -52,16 +51,13 @@ body {
 }
 
 .selectAll {
-       padding-left: 12px;
+       padding-left: 6px;
        display: inline-block;
 }
 
-.selectAll span.ui-icon {
-       top: 40% !important;
-}
-
 .selectAll span.ui-btn-text {
-       padding-left: 1.5rem !important;
+       padding-left: 2rem !important;
+       line-height: 40px;
 }
 
 #navbar {
@@ -107,11 +103,17 @@ body {
 #alertPopup .text {
        text-align:left;
        padding:20px;
+       min-height: 100px !important;
+}
+
+#alertPopup .alertPopup-button {
+       padding-bottom: 10px;
 }
 
 #confirmPopup .text {
        text-align:left;
        padding:20px;
+       font-size: 18px;
 }
 
 .ui-header.ui-bar-s .ui-btn.standard {
@@ -209,4 +211,4 @@ input.ui-input-text.new_folder {
 
 .ui-tabbar:not(.ui-tabbar-persist) a.ui-btn-active .ui-btn-text, .ui-tabbar:not(.ui-tabbar-persist) .ui-btn-show-style .ui-btn-text {
        border:none;
-}
\ No newline at end of file
+}
index 2ed23ec..642d031 100644 (file)
@@ -102,10 +102,10 @@ function Helpers() {
 
                        if (ext === '.jpg' || ext === '.png' || ext === '.gif') {
                                mime = 'image/*';
-                       } else if (ext === '.mp4' || ext === '.ogv' || ext === '.avi') {
+                       } else if (ext === '.mp4' || ext === '.ogv' || ext === '.avi' || ext === '.wmv') {
                                mime = 'video/*';
-                       } else if (ext === '.mp3') {
-                               mime = 'audio/mp3';
+                       } else if (ext === '.mp3' || ext === '.wma') {
+                               mime = 'audio/*';
                        } else if (ext === '.txt' || ext === '.doc' || ext === '.html' || ext === '.ppt' || ext === '.xls' || ext === '.pdf') {
                                mime = ''; //mime = 'text/*';
                        }
@@ -149,43 +149,3 @@ function Helpers() {
                }
        };
 }());
-
-(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 f6138c5..eb80f3c 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -81,7 +81,6 @@ var App = null;
                        this.clipboard = new Clipboard();
 
                        this.initUi();
-                       this.addEvents();
                },
 
                /**
@@ -92,20 +91,6 @@ var App = null;
                },
 
                /**
-                * Add pages events
-                */
-               addEvents: function App_addEvents() {
-                       var self = this;
-                       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() {
@@ -198,9 +183,16 @@ var App = null;
                /**
                 * Triggers refresh current page
                 */
-               refreshCurrentPage: function App_refreshCurrentPage() {
+               refreshCurrentPage: function App_refreshCurrentPage(refresh) {
+                       refresh = refresh || false;
                        if (this.currentPath !== '') {
-                               this.displayFolder(this.currentPath, true);
+                               app.model.isStorageExists(this.currentPath,
+                                       app.displayFolder.bind(app, app.model.currentPath, refresh),
+                                       function () {
+                                               app.displayStorages();
+                                               app.ui.alertPopup("'" + app.model.currentPath
+                                                       + "'\nnot found");
+                                       });
                        } else {
                                this.displayStorages();
                        }
index 7b97033..9110171 100644 (file)
@@ -30,6 +30,11 @@ function Model() {
                storages: [{label: 'root', type: 'INTERNAL'}],
 
                /**
+                * @type String
+                */
+               currentPath: '',
+
+               /**
                 * API module initialisation
                 */
                init: function Model_init() {
@@ -65,10 +70,11 @@ function Model() {
                 * @param {function} onError Error callback
                 */
                getFolderData: function Model_getFolderData(path, onSuccess, onError) {
-
-                       var onOpenSuccess = function (dir) {
+                       var self = this,
+                               onOpenSuccess = function (dir) {
                                dir.listFiles(
                                        function (files) {
+                                               self.currentPath = dir.fullPath;
                                                onSuccess(dir, files);
                                        },
                                        function (e) {
@@ -83,6 +89,10 @@ function Model() {
                        this.systemIO.openDir(path, onOpenSuccess, onOpenError);
                },
 
+               isStorageExists: function (nodeName, success, error) {
+                       tizen.filesystem.resolve(nodeName, success, error);
+               },
+
                /**
                 * Launch a service to open the file
                 * @param {string} fullUri ext
@@ -126,11 +136,16 @@ function Model() {
                },
 
                refreshContent: function (path) {
-                       path = path.charAt(0).toUpperCase() + path.substr(1);
-                       path = '/opt/usr/media/' + path;
                        tizen.content.scanFile(path, null, null);
                },
 
+               resolveAndRefresh: function (path) {
+                       var self = this;
+                       tizen.filesystem.resolve(path, function(file) {
+                               self.refreshContent(file.toURI());
+                       }, null);
+               },
+
                /**
                 * @param {File[]} nodes Collection of node objects
                 * @param {File} dir Directory handle
@@ -139,6 +154,7 @@ function Model() {
                 */
                deleteNodes: function Model_deleteNodes(nodes, dir, onSuccess, onError) {
                        var len = nodes.length,
+                               self = this,
                                onDeleteNodeSuccess = function (nodeId, isDir) {
                                        if (typeof onSuccess === 'function') {
                                                onSuccess(nodeId);
@@ -166,7 +182,7 @@ function Model() {
                                                onDeleteNodeSuccess.bind(this, nodes[i].id, false),
                                                onDeleteNodeError
                                        );
-                                       this.refreshContent(nodes[i].uri);
+                                       this.resolveAndRefresh(nodes[i]);
                                }
                        }
                },
@@ -183,8 +199,9 @@ function Model() {
                copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
                        var len = paths.length, self = this,
                                copied = 0,
-                               onCopyNodeSuccess = function () {
+                               onCopyNodeSuccess = function (file) {
                                        copied += 1;
+                                       self.refreshContent(file.toURI());
                                        if (copied === len) {
                                                onSuccess();
                                        }
@@ -211,7 +228,7 @@ function Model() {
 
                                        try {
                                                dir.copyTo(paths[i], destinationPath + '/' + sourceName, true, onCopyNodeSuccess, onCopyNodeFailure);
-                                               self.refreshContent(destinationPath + '/' + sourceName);
+                                               self.resolveAndRefresh(paths[i]);
                                        } catch (e) {
                                                console.error(e);
                                        }
@@ -231,7 +248,8 @@ function Model() {
                moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
                        var len = paths.length, self = this,
                                moved = 0,
-                               onMoveNodeSuccess = function () {
+                               onMoveNodeSuccess = function (file) {
+                                       self.refreshContent(file.toURI());
                                        moved += 1;
                                        if (moved === len) {
                                                onSuccess();
@@ -258,8 +276,7 @@ function Model() {
 
                                        try {
                                                dir.moveTo(paths[i], destinationPath + '/' + sourceName, true, onMoveNodeSuccess, onMoveNodeFailure);
-                                               self.refreshContent(paths[i]);
-                                               self.refreshContent(destinationPath + '/' + sourceName);
+                                               self.resolveAndRefresh(paths[i]);
                                        } catch (e) {
                                                console.error(e);
                                        }
index 7969903..b82be5f 100644 (file)
@@ -111,9 +111,9 @@ function Ui() {
                addEvents: function Ui_addEvents() {
                        var self = this;
 
-                       document.addEventListener('webkitvisibilitychange', function (event) {
+                       document.addEventListener('webkitvisibilitychange', function () {
                                if (document.webkitVisibilityState === 'visible') {
-                                       $.mobile.activePage.page('refresh');
+                                       app.refreshCurrentPage(true);
                                }
                        });
 
@@ -123,6 +123,7 @@ function Ui() {
                                        if (!uri) {
                                                tizen.application.getCurrentApplication().exit();
                                        } else {
+                                               $(".ui-popup").popup('close');
                                                app.goLevelUp();
                                        }
                                }
@@ -156,8 +157,13 @@ function Ui() {
                                var uri = $(this).attr('uri');
                                if (uri === 'home') {
                                        app.displayStorages();
-                               } else {
+                               } else if (uri === app.model.currentPath) {
                                        app.displayFolder(uri,true);
+                               } else {
+                                       if (self.editMode === true) {
+                                               self.handleCancelEditAction();
+                                       }
+                                       app.displayFolder(uri);
                                }
                        });
 
@@ -228,7 +234,9 @@ function Ui() {
                        } else {
                                status = app.createDir(folderName);
                                if (status === true) {
-                                       $("#addFolderPopup").popup('open');
+                                       $("#addFolderPopup").popup('open', {
+                                               positionTo: "window"
+                                       });
                                        setTimeout(function () {
                                                $("#addFolderPopup").popup('close');
                                        }, 200);
@@ -238,11 +246,21 @@ function Ui() {
                },
 
                alertPopup: function (text) {
+                       var lastActivePopup = $.mobile.popup.active;
+
                        $("#alertPopup .text").text(text);
                        setTimeout(function () {
                                $("#alertPopup").popup('close');
                                setTimeout(function () {
                                        $("#alertPopup").popup('open');
+                                       $("#alertPopup").one("popupafterclose", function () {
+                                               if (lastActivePopup) {
+                                                       if (lastActivePopup.element.attr('id' === 'alertPopup')) {
+                                                               lastActivePopup = undefined;
+                                                       }
+                                                       $.mobile.popup.active = lastActivePopup;
+                                               }
+                                       });
                                }, 200);
                        }, 200);
                },
@@ -329,24 +347,26 @@ function Ui() {
                /**
                 * Handler for delete action
                 */
-               handleDeleteAction: function Ui_handleDeleteAction() {
+               handleDeleteAction: function Ui_handleDeleteAction(e) {
                        var nodesToDelete = [],
                                $rowElement,
                                self = this,
                                conf;
 
-                       $('ul#fileList input:checkbox:checked').each(function (index) {
-                               $rowElement = $(this).closest('li');
-                               nodesToDelete.push({
-                                       id: $rowElement.attr('id'),
-                                       uri: $rowElement.attr('uri'),
-                                       name: $rowElement.attr('label'),
-                                       folder: $rowElement.hasClass('folder')
-                               });
-                       });
+                       e.stopPropagation();
+                       e.preventDefault();
 
                        this.confirmPopup('Selected nodes will be deleted. Are you sure?',
                                function () {
+                                       $('ul#fileList input:checkbox:checked').each(function (index) {
+                                               $rowElement = $(this).closest('li');
+                                               nodesToDelete.push({
+                                                       id: $rowElement.attr('id'),
+                                                       uri: $rowElement.attr('uri'),
+                                                       name: $rowElement.attr('label'),
+                                                       folder: $rowElement.hasClass('folder')
+                                               });
+                                       });
                                        if (nodesToDelete.length > 0) {
                                                app.deleteNodes(nodesToDelete);
                                                self.scrollContentTo(0);
@@ -363,8 +383,12 @@ function Ui() {
                /**
                 * Handler for copy action
                 */
-               handleCopyAction: function Ui_handleCopyAction() {
+               handleCopyAction: function Ui_handleCopyAction(e) {
                        var paths = [];
+
+                       e.stopPropagation();
+                       e.preventDefault();
+
                        if (this.editMode === true) {
                                $('ul#fileList input:checkbox:checked').each(function (index) {
                                        paths.push($(this).closest('li').attr('uri'));
@@ -376,8 +400,12 @@ function Ui() {
                /**
                 * Handler for move action
                 */
-               handleMoveAction: function Ui_handleMoveAction() {
+               handleMoveAction: function Ui_handleMoveAction(e) {
                        var paths = [];
+
+                       e.stopPropagation();
+                       e.preventDefault();
+
                        if (this.editMode === true) {
                                $('ul#fileList input:checkbox:checked').each(function (index) {
                                        paths.push($(this).closest('li').attr('uri'));
@@ -403,12 +431,10 @@ function Ui() {
                 * @param {FileSystemStorage[]} nodes Storage elements
                 */
                displayStorages: function Ui_displayStorages(nodes) {
-                       var len = nodes.length,
-                               listElements = [],
-                               nodeName,
-                               listTemplate = '',
-                               i;
+                       var len = nodes.length, nodeName, i;
+
                        this.updateNavbar('');
+                       $('#fileList').empty();
 
                        for (i = 0; i < len; i = i + 1) {
                                nodeName = nodes[i].label.trim();
@@ -416,13 +442,13 @@ function Ui() {
                                                && (nodes[i].type === 0 || nodes[i].type === 'INTERNAL')
                                                && nodeName.indexOf('wgt-') === -1
                                                && $.inArray(nodeName, this.lockedFolders) === -1
-                                               ) {
-                                       listElements.push(this.templateManager.get('folderRow', {
-                                               id: i,
-                                               name: nodeName,
-                                               uri: nodeName,
-                                               fullUri: nodeName
-                                       }));
+                                       ) {
+                                       if (!this.root) {
+                                               app.model.isStorageExists(nodeName,
+                                                       app.ui.prepareFolderRow.bind(app.ui, i, nodeName), null);
+                                       } else {
+                                               this.prepareFolderRow(i, nodeName);
+                                       }
                                }
                        }
 
@@ -433,19 +459,24 @@ function Ui() {
                        $('#moreActionBtn').addClass('vhidden');
                        $('h1#mainTitle').html('Media');
 
-                       // update file list
-                       $('#fileList').empty();
                        if (this.editMode) {
                                this.scrollContentTo(0);
                        }
-                       listTemplate = listElements.join('');
-                       $(listTemplate).appendTo('#fileList');
 
                        this.resetDefaultCheckBoxLabelEvents();
                        this.hideSelectAllArea();
                        this.handleCancelEditAction();
                },
 
+               prepareFolderRow: function (id, name) {
+                       $(this.templateManager.get('folderRow', {
+                               id: id,
+                               name: name,
+                               uri: name,
+                               fullUri: name,
+                       })).appendTo('#fileList');
+               },
+
                /**
                 * File comparison function using their names (case insensitive)
                 *
@@ -541,6 +572,7 @@ function Ui() {
                                .trigger('refresh')
                                .trigger('create');
 
+
                        if (this.editMode === true) {
                                $('.selectAll').show();
                                $('ul#fileList > li').css('paddingLeft', '2rem');
@@ -559,7 +591,7 @@ function Ui() {
                                $('ul#fileList > li').css('paddingLeft', '0');
                                $('.my-ui-checkbox').addClass('hidden');
                        }
-                       this.hideSelectAllArea();
+                       if (!refresh) this.hideSelectAllArea();
                },
 
                /**
index c1db140..f4a75fc 100644 (file)
@@ -111,8 +111,13 @@ function TemplateManager() {
                        var regModOn = new RegExp('%' + tplParam + '\\|([a-zA-Z]){1,}%', 'g'),
                                regModOff = new RegExp(['%', tplParam, '%'].join(''), 'g'),
                                regModGet = new RegExp('%' + tplParam + '\\|(.+?)%'),
+                               specRegExp = new RegExp('\\$','g'),
                                modifier;
 
+                       if (content && (typeof content === 'string')) {
+                               content = content.replace(specRegExp, '$$$$');
+                       }
+
                        if (regModOn.test(tplHtml)) {
                                modifier = tplHtml.match(regModGet)[1];
                                try {
index 984e39f..a2e2998 100644 (file)
                        </div>
                        <div data-role="popup" id="alertPopup" class="ui-corner-all">
                                <p class="text"></p>
-                               <a href="#" data-role="button" data-inline="true" data-rel="back">OK</a>
+                               <div class="alertPopup-button">
+                                       <a href="#" data-role="button" data-inline="true" data-rel="back">OK</a>
+                               </div>
                        </div>
                        <div data-role="popup" id="confirmPopup" class="ui-corner-all">
-                               <p class="text"></p>
-                               <a href="#" data-role="button" data-inline="true" class="confirm">OK</a>
-                               <a href="#" data-role="button" data-inline="true" data-rel="back">CANCEL</a>
+                               <div class="ui-popup-text">
+                                       <p class="text"></p>
+                               </div>
+                               <div class="ui-popup-button-bg">
+                                       <a data-role="button" data-rel="back" data-inline="true" class="confirm">OK</a>
+                                       <a data-role="button" data-rel="back" data-inline="true">CANCEL</a>
+                               </div>
                        </div>
                </div>