Updated Private -> RSA
authorji.ji <ji.ji@samsung.com>
Wed, 26 Jun 2013 10:08:51 +0000 (19:08 +0900)
committerji.ji <ji.ji@samsung.com>
Wed, 26 Jun 2013 10:08:51 +0000 (19:08 +0900)
Change-Id: I590fd15a821cb83f6eca686bec7c3f4baf63118f

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

diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..d31aa43
--- /dev/null
+++ b/.project
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>FileManager</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.wst.common.project.facet.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>json.validation.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.jslint.nature.JSLintBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.css.nature.CSSBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.wst.validation.validationbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.project.builder.WebBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.tizen.web.editor.css.nature.CSSBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>json.validation.nature</nature>
+               <nature>org.tizen.web.jslint.nature.JSLintNature</nature>
+               <nature>org.tizen.web.css.nature.CSSNature</nature>
+               <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+               <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+               <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+               <nature>org.tizen.web.project.builder.WebNature</nature>
+               <nature>org.tizen.web.editor.css.nature.CSSNature</nature>
+       </natures>
+</projectDescription>
index fea5bea..9c090dc 100644 (file)
@@ -1,6 +1,6 @@
 <?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"/>
+<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>
        <tizen:privilege name="http://tizen.org/privilege/content.read"/>
index 5e6d340..4ed5976 100644 (file)
@@ -12,7 +12,7 @@ body {
 }
 
 #mainTitle {
-       width: 260px;
+       width: 255px;
        text-transform: uppercase;
 }
 
@@ -71,7 +71,7 @@ body {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
-       background-color: #EEE;
+       background-color: rgba(255, 255, 255, 0.5);
        border-top: solid 1px #DDD;
        text-align: left;
 }
@@ -93,12 +93,26 @@ body {
        font-size: 18px;
 }
 
+#morePopup td.text a {
+       color:#FFF;
+       text-decoration:none;
+}
+
 #morePopup td.text {
        padding: 5px;
 }
 #morePopup {
        margin: 2px;
 }
+#alertPopup .text {
+       text-align:left;
+       padding:20px;
+}
+
+#confirmPopup .text {
+       text-align:left;
+       padding:20px;
+}
 
 .ui-header.ui-bar-s .ui-btn.standard {
        width: 100%;
@@ -107,7 +121,7 @@ body {
 
 #homeBtn,
 #levelUpBtn {
-       top:20px;
+       top:0px;
 }
 
 .ui-li-1line-bigicon1.ui-li.ui-li-static.ui-body-s.ui-li-has-thumb {
@@ -191,4 +205,8 @@ input.ui-input-text.new_folder {
 
 .ui-footer .ui-btn-text {
        text-transform: uppercase;
+}
+
+.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 5aea963..f6138c5 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -96,7 +96,9 @@ var App = null;
                 */
                addEvents: function 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');
@@ -174,19 +176,23 @@ var App = null;
                /**
                 * creates new dir in currently viewed dir
                 * @param {string} dirName
+                * @return {boolean} return status
                 */
                createDir: function App_createDir(dirName) {
-
+                       var status = true;
                        if (this.currentDirPath !== '') {
                                try {
                                        this.currentDirHandle.createDirectory(dirName);
                                } catch (e) {
-                                       alert(e.message);
+                                       status = false;
+                                       app.ui.alertPopup(e.message);
                                }
                                this.refreshCurrentPage();
                        } else {
-                               alert("You can't create new nodes in the main view");
+                               status = false;
+                               app.ui.alertPopup("You can't create new nodes in the main view");
                        }
+                       return status;
                },
 
                /**
@@ -217,10 +223,10 @@ var App = null;
 
                        if (clipboardLength > 0) {
                                this.clipboard.setMode(mode);
-                               alert('Data saved in clipboard');
+                               app.ui.alertPopup('Data saved in clipboard');
                                this.ui.clearTabbars();
                        } else {
-                               alert('Error occured. Data has not been saved in clipboard');
+                               app.ui.alertPopup('Error occured. Data has not been saved in clipboard');
                        }
 
                        this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
@@ -233,7 +239,7 @@ var App = null;
                        var clipboardData = this.clipboard.get();
 
                        if (clipboardData.length === 0) {
-                               alert('Clipboard is empty');
+                               app.ui.alertPopup('Clipboard is empty');
                                return false;
                        }
 
index 40f8f72..7b97033 100644 (file)
@@ -125,6 +125,12 @@ function Model() {
                        }
                },
 
+               refreshContent: function (path) {
+                       path = path.charAt(0).toUpperCase() + path.substr(1);
+                       path = '/opt/usr/media/' + path;
+                       tizen.content.scanFile(path, null, null);
+               },
+
                /**
                 * @param {File[]} nodes Collection of node objects
                 * @param {File} dir Directory handle
@@ -160,6 +166,7 @@ function Model() {
                                                onDeleteNodeSuccess.bind(this, nodes[i].id, false),
                                                onDeleteNodeError
                                        );
+                                       this.refreshContent(nodes[i].uri);
                                }
                        }
                },
@@ -174,7 +181,7 @@ function Model() {
                 * @param {function} onSuccess callback
                 */
                copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
-                       var len = paths.length,
+                       var len = paths.length, self = this,
                                copied = 0,
                                onCopyNodeSuccess = function () {
                                        copied += 1;
@@ -183,7 +190,7 @@ function Model() {
                                        }
                                },
                                onCopyNodeFailure = function () {
-                                       alert('Copying error');
+                                       app.ui.alertPopup('Copying error');
                                },
                                i,
                                sourceName,
@@ -192,7 +199,7 @@ function Model() {
                        this.systemIO.getFilesList(dir, function (filesList) {
                                for (i = 0; i < len; i = i + 1) {
                                        if (destinationPath.indexOf(paths[i]) !== -1) {
-                                               alert('Copying error');
+                                               app.ui.alertPopup('Copying error');
                                                return;
                                        }
                                }
@@ -204,6 +211,7 @@ function Model() {
 
                                        try {
                                                dir.copyTo(paths[i], destinationPath + '/' + sourceName, true, onCopyNodeSuccess, onCopyNodeFailure);
+                                               self.refreshContent(destinationPath + '/' + sourceName);
                                        } catch (e) {
                                                console.error(e);
                                        }
@@ -221,7 +229,7 @@ function Model() {
                 * @param {function} onSuccess callback
                 */
                moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
-                       var len = paths.length,
+                       var len = paths.length, self = this,
                                moved = 0,
                                onMoveNodeSuccess = function () {
                                        moved += 1;
@@ -230,7 +238,7 @@ function Model() {
                                        }
                                },
                                onMoveNodeFailure = function () {
-                                       alert('Moving error');
+                                       app.ui.alertPopup('Moving error');
                                },
                                i,
                                sourceName,
@@ -239,7 +247,7 @@ function Model() {
                        this.systemIO.getFilesList(dir, function (filesList) {
                                for (i = 0; i < len; i = i + 1) {
                                        if (destinationPath.indexOf(paths[i]) !== -1) {
-                                               alert('Moving error');
+                                               app.ui.alertPopup('Moving error');
                                                return;
                                        }
                                }
@@ -248,12 +256,12 @@ function Model() {
                                        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) {
+                                       try {
                                                dir.moveTo(paths[i], destinationPath + '/' + sourceName, true, onMoveNodeSuccess, onMoveNodeFailure);
+                                               self.refreshContent(paths[i]);
+                                               self.refreshContent(destinationPath + '/' + sourceName);
+                                       } catch (e) {
+                                               console.error(e);
                                        }
                                }
                        });
index 707f5f4..7969903 100644 (file)
@@ -110,6 +110,24 @@ function Ui() {
                 */
                addEvents: function Ui_addEvents() {
                        var self = this;
+
+                       document.addEventListener('webkitvisibilitychange', function (event) {
+                               if (document.webkitVisibilityState === 'visible') {
+                                       $.mobile.activePage.page('refresh');
+                               }
+                       });
+
+                       document.addEventListener('tizenhwkey', function(e) {
+                               var uri = $('#navbar span+span').attr('uri');
+                               if (e.keyName == "back") {
+                                       if (!uri) {
+                                               tizen.application.getCurrentApplication().exit();
+                                       } else {
+                                               app.goLevelUp();
+                                       }
+                               }
+                       });
+
                        // touch events for all nodes
                        $('ul#fileList')
                                .on('tap', 'li.levelUp', function () {
@@ -139,7 +157,7 @@ function Ui() {
                                if (uri === 'home') {
                                        app.displayStorages();
                                } else {
-                                       app.displayFolder(uri);
+                                       app.displayFolder(uri,true);
                                }
                        });
 
@@ -169,7 +187,10 @@ function Ui() {
                        $('#moveActionBtn').on('tap', this.handleMoveAction.bind(this));
 
                        // paste action
-                       $('a#pasteActionBtn').on('tap', app.pasteClipboard.bind(app));
+                       $('a#pasteActionBtn').on('tap', function () {
+                               app.pasteClipboard.bind(app)();
+                               $("#morePopup").popup('close');
+                       });
 
                        // remove active class
                        $('[data-role = "tabbar"] li > a').on('click', function () {
@@ -192,18 +213,6 @@ function Ui() {
 
                        $('#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);
-                       });
-
-                       /* workaround for UIFW & webkit scroll*/
-                       //$('.ui-page').css('min-height', 0);
                },
 
                saveNewFolder: function Ui_saveNewFolder(e) {
@@ -211,18 +220,54 @@ function Ui() {
                        e.preventDefault();
                        e.stopPropagation();
                        if (folderName === '') {
-                               alert("Empty folder name");
+                               this.alertPopup("Empty folder name");
                                status = false;
                        } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
-                               alert("The following special characters are not allowed: *./\\?:<>|'\"");
+                               this.alertPopup("The following special characters are not allowed: *./\\?:<>|'\"");
                                status = false;
                        } else {
-                               app.createDir(folderName);
-                               $("#addFolderPopup").popup('close');
+                               status = app.createDir(folderName);
+                               if (status === true) {
+                                       $("#addFolderPopup").popup('open');
+                                       setTimeout(function () {
+                                               $("#addFolderPopup").popup('close');
+                                       }, 200);
+                               }
                        }
                        return status;
                },
 
+               alertPopup: function (text) {
+                       $("#alertPopup .text").text(text);
+                       setTimeout(function () {
+                               $("#alertPopup").popup('close');
+                               setTimeout(function () {
+                                       $("#alertPopup").popup('open');
+                               }, 200);
+                       }, 200);
+               },
+
+               confirmPopup: function (text, confirmCallback, completeCallback) {
+                       $("#confirmPopup .text").text(text);
+                       setTimeout(function () {
+                               $("#confirmPopup").popup('close');
+                               setTimeout(function () {
+                                       $("#confirmPopup").popup('open');
+                                       $("#confirmPopup .confirm").one("tap", function () {
+                                               $("#confirmPopup").popup('close');
+                                               if (confirmCallback instanceof Function) {
+                                                       confirmCallback();
+                                               }
+                                       });
+                                       if (completeCallback instanceof Function) {
+                                               $("#confirmPopup").one('popupafterclose', function () {
+                                                       completeCallback();
+                                               });
+                                       }
+                               }, 200);
+                       }, 200);
+               },
+
                clearTabbars: function Ui_clearTabbars() {
                        $('[data-role = "tabbar"] li > a').removeClass('ui-focus, ui-btn-active');
                },
@@ -276,6 +321,9 @@ function Ui() {
                        $('.standardTabbar').show();
                        $('#fileList .folder .nodename').animate({'width': '75%'});
                        this.hideEditCheckBoxes();
+                       if (this.isFileListEmpty()) {
+                               $('#editActionBtn').addClass('vhidden');
+                       }
                },
 
                /**
@@ -284,6 +332,7 @@ function Ui() {
                handleDeleteAction: function Ui_handleDeleteAction() {
                        var nodesToDelete = [],
                                $rowElement,
+                               self = this,
                                conf;
 
                        $('ul#fileList input:checkbox:checked').each(function (index) {
@@ -296,15 +345,19 @@ function Ui() {
                                });
                        });
 
-                       conf = confirm('Selected nodes will be deleted. Are you sure?');
-                       this.clearTabbars();
-
-                       if (nodesToDelete.length > 0 && conf) {
-                               app.deleteNodes(nodesToDelete);
-                               this.scrollContentTo(0);
-                               $('ul#fileList input:checkbox:checked').remove();
-                               this.refreshEditMenu();
-                       }
+                       this.confirmPopup('Selected nodes will be deleted. Are you sure?',
+                               function () {
+                                       if (nodesToDelete.length > 0) {
+                                               app.deleteNodes(nodesToDelete);
+                                               self.scrollContentTo(0);
+                                               $('ul#fileList input:checkbox:checked').remove();
+                                               self.refreshEditMenu();
+                                       }
+                               },
+                               function () {
+                                       self.clearTabbars();
+                               }
+                       );
                },
 
                /**
@@ -429,9 +482,9 @@ function Ui() {
                        refresh = refresh || false;
 
                        // update title
-                       this.updateTitle(folderName);
+                       this.updateTitle(this.templateManager.modifiers.escape(folderName));
                        // update navbar
-                       this.updateNavbar(folderName);
+                       this.updateNavbar(this.templateManager.modifiers.escape(folderName));
                        this.refreshPasteActionBtn();
 
                        nodes.sort(this.fileComparison);
@@ -464,6 +517,10 @@ function Ui() {
                        if (listElements.length === 1) {
                                // set content for empty folder
                                listElements.push(this.templateManager.get('emptyFolder'));
+                               // hide edit button for empty content
+                               $('#editActionBtn').addClass('vhidden');
+                       } else {
+                               $('#editActionBtn').removeClass('vhidden');
                        }
 
                        // scroll to top of list
@@ -471,7 +528,6 @@ function Ui() {
 
                        $('#levelUpBtn').removeClass('vhidden');
                        $('#homeBtn').removeClass('vhidden');
-                       $('#editActionBtn').removeClass('vhidden');
                        $('#moreActionBtn').removeClass('vhidden');
 
                        if (refresh === true && this.editMode === true) {
@@ -503,6 +559,7 @@ function Ui() {
                                $('ul#fileList > li').css('paddingLeft', '0');
                                $('.my-ui-checkbox').addClass('hidden');
                        }
+                       this.hideSelectAllArea();
                },
 
                /**
@@ -745,6 +802,10 @@ function Ui() {
                        } else {
                                $('#pasteActionBtnRow').removeClass('hidden');
                        }
+               },
+
+               isFileListEmpty: function Ui_isFileListEmpty() {
+                       return ($('ul#fileList').children('.node').length < 1);
                }
        };
 }());
index 1d57ce7..fbcf3db 100644 (file)
@@ -30,6 +30,16 @@ function ModifierManager() {
                modifiers: {
                        escape: function escape(str) {
                                return $('<span>').text(str).html();
+                       },
+                       escapeEncies: function escapeEncies(str) {
+                               var tagsToReplace = {
+                                       '&': '&amp;',
+                                       '<': '&lt;',
+                                       '>': '&gt;'
+                               };
+                               return str.replace(/[&<>]/g, function(tag) {
+                                       return tagsToReplace[tag] || tag;
+                               });
                        }
                }
        };
index 5ca3e3a..360b951 100644 (file)
@@ -72,7 +72,7 @@ var app = null;
                 * Handle ajax errors
                 */
                onGetScriptError: function onGetScriptError(e, jqxhr, setting, exception) {
-                       alert('An error occurred: ' + e.message);
+                       app.ui.alertPopup('An error occurred: ' + e.message);
                }
        }).init(); // run the loader
 }());
index 47e30f2..c0b776d 100644 (file)
@@ -1,5 +1,5 @@
 <li class="node file 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="%thumbnailURI%" class="ui-li-bigicon"/>
-       <span class="ui-li-text-main nodename">%name%</span>
+       <span class="ui-li-text-main nodename">%name|escape%</span>
 </li>
\ No newline at end of file
index 8b1ec50..ba82018 100644 (file)
@@ -1,4 +1,4 @@
-<li class="node folder ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri%" fullUri="%fullUri%">
+<li class="node folder ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri|escapeEncies%" fullUri="%fullUri|escapeEncies%">
        <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|escape%</span>
index 2cc11ec..984e39f 100644 (file)
                                        <a data-role="button" id="cancelNewFolder" id="btn_textbox_popup_cancel" data-rel="back" data-inline="true">Cancel</a>
                                </div>
                        </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>
+                       <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>
                </div>
 
                <div data-role="footer" data-position="fixed">
@@ -35,7 +44,7 @@
                                <div data-role="tabbar" class="standardTabbar">
                                        <ul>
                                                <li><a id="editActionBtn" href="#">Edit</a></li>
-                                               <li><a id="moreActionBtn" href="#morePopup" data-rel="popupwindow">More</a></li>
+                                               <li><a id="moreActionBtn" href="#morePopup" data-rel="popup">More</a></li>
                                                <li id="li-myExit">
                                                        <a id="a-myExit" href="#" class="ui-myExit">Exit</a>
                                                </li>
                                                <li><a id="cancelActionBtn" href="#">Cancel</a></li>
                                        </ul>
                                </div>
-                               <div class="horizontal" id="morePopup" data-role="popupwindow" data-show-arrow="true">
-                                       <table>
-                                               <tr id="newFolderActionBtnRow">
-                                                       <td class="text">
-                                                               <a id="newFolderActionBtn" href="#addFolderPopup" class="newFolder" data-rel="popup" data-position-to="window" data-shadow="true">New folder</a>
-                                                       </td>
-                                               </tr>
-                                               <tr id="pasteActionBtnRow">
-                                                       <td class="text">
-                                                               <a id="pasteActionBtn" data-position-to="window" data-shadow="true">Paste to folder</a>
-                                                       </td>
-                                               </tr>
-                                       </table>
-                               </div>
+                       </div>
+                       <div id="morePopup" data-role="popup">
+                               <table>
+                                       <tr id="newFolderActionBtnRow">
+                                               <td class="text">
+                                                       <a id="newFolderActionBtn" href="#addFolderPopup" class="newFolder" data-rel="popup" data-position-to="window" data-shadow="true">New folder</a>
+                                               </td>
+                                       </tr>
+                                       <tr id="pasteActionBtnRow">
+                                               <td class="text">
+                                                       <a id="pasteActionBtn" data-position-to="window" data-shadow="true">Paste to folder</a>
+                                               </td>
+                                       </tr>
+                               </table>
                        </div>
                </div>
        </div>
\ No newline at end of file