[FileManager]update FileManager(tizen_2.1)
authorji.ji <ji.ji@samsung.com>
Tue, 4 Jun 2013 07:10:35 +0000 (16:10 +0900)
committerji.ji <ji.ji@samsung.com>
Tue, 4 Jun 2013 07:10:35 +0000 (16:10 +0900)
Change-Id: If15a54c424e26dfa16d8ee02c4bde743e1121a5a

config.xml
css/style.css
icon.png
js/app.js
js/app.ui.js
js/app.ui.templateManager.js
js/app.ui.templateManager.modifiers.js [new file with mode: 0644]
templates/folderRow.tpl
templates/main.tpl

index e866411..fea5bea 100644 (file)
@@ -1,17 +1,12 @@
 <?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="km8AETYhee.FileManager"
-               package="km8AETYhee" required_version="2.1" />
-       <icon src="icon.png" />
+<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="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.1"/>
+       <icon src="icon.png"/>
        <name>FileManager</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" />
-       <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="disable" encryption="disable"
-               install-location="auto" />
+       <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"/>
+       <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="disable" encryption="disable" install-location="auto"/>
 </widget>
index ff788d0..5e6d340 100644 (file)
@@ -96,6 +96,9 @@ body {
 #morePopup td.text {
        padding: 5px;
 }
+#morePopup {
+       margin: 2px;
+}
 
 .ui-header.ui-bar-s .ui-btn.standard {
        width: 100%;
index 9765b1b..5934757 100644 (file)
Binary files a/icon.png and b/icon.png differ
index 9b4c7c4..5aea963 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -19,7 +19,16 @@ var App = null;
                /**
                 * @type Array
                 */
-               requires: ['js/app.config.js', 'js/app.model.js', 'js/app.ui.js', 'js/app.ui.templateManager.js', 'js/app.systemIO.js', 'js/app.helpers.js', 'js/app.clipboard.js'],
+               requires: [
+                       'js/app.config.js',
+                       'js/app.model.js',
+                       'js/app.ui.js',
+                       'js/app.ui.templateManager.js',
+                       'js/app.ui.templateManager.modifiers.js',
+                       'js/app.systemIO.js',
+                       'js/app.helpers.js',
+                       'js/app.clipboard.js'
+               ],
 
                /**
                 * @type Model
@@ -239,6 +248,10 @@ var App = null;
                        return true;
                },
 
+               emptyClipboard: function App_emptyClipboard() {
+                       return this.clipboard.get().length === 0;
+               },
+
                /**
                 * Handler for paste clipboard success
                 */
index f1ca91b..707f5f4 100644 (file)
@@ -190,19 +190,14 @@ function Ui() {
                                }
                        });
 
-                       $('#saveNewFolder').on('tap', function () {
-                               var folderName = $('#newFolderName').val().trim();
-                               if (folderName === '') {
-                                       alert("Empty folder name");
-                               } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
-                                       alert("The following special characters are not allowed: *./\\?:<>|'\"");
-                               } else {
-                                       app.createDir(folderName);
-                               }
-                       });
+                       $('#saveNewFolder').on('tap', this.saveNewFolder.bind(this));
+                       $('#newFolderForm').on('submit', this.saveNewFolder.bind(this));
+
 
                        $('#newFolderActionBtn, #pasteActionBtn').on('tap', function (e) {
+//                             $('a#pasteActionBtn').off('tap', app.pasteClipboard.bind(app));
                                setTimeout(function () {
+//                                     $('a#pasteActionBtn').on('tap', app.pasteClipboard.bind(app));
                                        $('#morePopup').popupwindow('close');
                                }, 700);
                        });
@@ -211,6 +206,23 @@ function Ui() {
                        //$('.ui-page').css('min-height', 0);
                },
 
+               saveNewFolder: function Ui_saveNewFolder(e) {
+                       var folderName = $('#newFolderName').val().trim(), status = true;
+                       e.preventDefault();
+                       e.stopPropagation();
+                       if (folderName === '') {
+                               alert("Empty folder name");
+                               status = false;
+                       } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
+                               alert("The following special characters are not allowed: *./\\?:<>|'\"");
+                               status = false;
+                       } else {
+                               app.createDir(folderName);
+                               $("#addFolderPopup").popup('close');
+                       }
+                       return status;
+               },
+
                clearTabbars: function Ui_clearTabbars() {
                        $('[data-role = "tabbar"] li > a').removeClass('ui-focus, ui-btn-active');
                },
@@ -250,6 +262,7 @@ function Ui() {
                        $('.standardTabbar').hide();
                        $('div.editTabbar').show();
                        this.disableControlBarButtons($('div.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
+                       $('#fileList .folder .nodename').animate({'width': '70%'});
                        this.showEditCheckBoxes();
                },
 
@@ -261,6 +274,7 @@ function Ui() {
                        this.clearTabbars();
                        $('div.editTabbar').hide();
                        $('.standardTabbar').show();
+                       $('#fileList .folder .nodename').animate({'width': '75%'});
                        this.hideEditCheckBoxes();
                },
 
@@ -418,6 +432,7 @@ function Ui() {
                        this.updateTitle(folderName);
                        // update navbar
                        this.updateNavbar(folderName);
+                       this.refreshPasteActionBtn();
 
                        nodes.sort(this.fileComparison);
 
@@ -724,8 +739,8 @@ function Ui() {
                /**
                 * Enable/Disable
                 */
-               refreshPasteActionBtn: function Ui_refreshPasteActionBtn(clipboardEmpty) {
-                       if (clipboardEmpty === true) {
+               refreshPasteActionBtn: function Ui_refreshPasteActionBtn() {
+                       if (app.emptyClipboard()) {
                                $('#pasteActionBtnRow').addClass('hidden');
                        } else {
                                $('#pasteActionBtnRow').removeClass('hidden');
index 68c6678..c1db140 100644 (file)
@@ -1,4 +1,4 @@
-/*global tizen, $, app */
+/*global tizen, $, app, ModifierManager */
 /**
  * @class TemplateManager
  */
@@ -20,6 +20,7 @@ function TemplateManager() {
                 * UI module initialisation
                 */
                init: function init() {
+                       this.modifiers = new ModifierManager().getAll();
                },
 
                /**
@@ -95,16 +96,36 @@ function TemplateManager() {
                * @param {string} tplParams
                 */
                getCompleted: function TemplateManager_getCompleted(tplHtml, tplParams) {
-                       var tplParam, replaceRegExp;
+                       var tplParam;
 
                        for (tplParam in tplParams) {
                                if (tplParams.hasOwnProperty(tplParam)) {
-                                       replaceRegExp = new RegExp(['%', tplParam, '%'].join(''), 'g');
-                                       tplHtml = tplHtml.replace(replaceRegExp, tplParams[tplParam]);
+                                       tplHtml = this.passThruModifiers(tplHtml, tplParam, tplParams[tplParam]);
                                }
                        }
 
                        return tplHtml;
+               },
+
+               passThruModifiers: function (tplHtml, tplParam, content) {
+                       var regModOn = new RegExp('%' + tplParam + '\\|([a-zA-Z]){1,}%', 'g'),
+                               regModOff = new RegExp(['%', tplParam, '%'].join(''), 'g'),
+                               regModGet = new RegExp('%' + tplParam + '\\|(.+?)%'),
+                               modifier;
+
+                       if (regModOn.test(tplHtml)) {
+                               modifier = tplHtml.match(regModGet)[1];
+                               try {
+                                       content = this.modifiers[modifier](content);
+                               } catch (error) {
+                                       console.error('unknown modifier: ' + modifier);
+                               }
+                               tplHtml = tplHtml.replace(regModOn, content);
+                       } else {
+                               tplHtml = tplHtml.replace(regModOff, content);
+                       }
+
+                       return tplHtml;
                }
        };
 
diff --git a/js/app.ui.templateManager.modifiers.js b/js/app.ui.templateManager.modifiers.js
new file mode 100644 (file)
index 0000000..1d57ce7
--- /dev/null
@@ -0,0 +1,36 @@
+/*global $*/
+/**
+ * @class ModifierManager
+ */
+function ModifierManager() {
+       'use strict';
+       this.init();
+}
+
+(function () {
+       'use strict';
+       ModifierManager.prototype = {
+
+               /**
+                * UI module initialisation
+                */
+               init: function () {
+               },
+
+               /**
+                * @return modifiers object
+                */
+               getAll: function () {
+                       return this.modifiers;
+               },
+
+               /**
+                * modifiers definitions
+                */
+               modifiers: {
+                       escape: function escape(str) {
+                               return $('<span>').text(str).html();
+                       }
+               }
+       };
+}());
\ No newline at end of file
index c4e91e3..8b1ec50 100644 (file)
@@ -1,6 +1,6 @@
 <li class="node folder ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri%" fullUri="%fullUri%">
        <form class="my-ui-checkbox hidden"><input type="checkbox" /></form>
        <img src="images/folder.png" class="ui-li-bigicon" />
-       <span class="ui-li-text-main nodename">%name%</span>
+       <span class="ui-li-text-main nodename">%name|escape%</span>
        </div>
 </li>
\ No newline at end of file
index 85a9e3a..2cc11ec 100644 (file)
@@ -19,7 +19,9 @@
                                        <h1>Add new folder<h1>
                                </div>
                                <div class="ui-popup-text">
-                                       <input id="newFolderName" type="text" value="New folder" class="newFolder" maxlength="255" />
+                                       <form id="newFolderForm">
+                                               <input id="newFolderName" type="text" value="New folder" class="newFolder" maxlength="255" />
+                                       </form>
                                </div>
                                <div class="ui-popup-button-bg">
                                        <a data-role="button" id="saveNewFolder" data-rel="back" data-inline="true">Save</a>