application sources from tizen_2.2 78/10478/1 tizen
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Wed, 2 Oct 2013 08:19:12 +0000 (10:19 +0200)
committerPiotr Dabrowski <p.dabrowski2@samsung.com>
Wed, 2 Oct 2013 08:19:12 +0000 (10:19 +0200)
Change-Id: I29cf7c8e5cf2861cb9e924981263e6de99c54e7d

39 files changed:
description.xml [new file with mode: 0755]
description.xsl [new file with mode: 0755]
filemanager-snapshot.png [new file with mode: 0644]
project/.project [new file with mode: 0644]
project/AUTHORS [new file with mode: 0644]
project/LICENSE.Flora [new file with mode: 0644]
project/NOTICE [new file with mode: 0644]
project/config.xml [new file with mode: 0644]
project/css/style.css [new file with mode: 0644]
project/icon.png [new file with mode: 0644]
project/images/00_winset_Back.png [new file with mode: 0644]
project/images/etc.png [new file with mode: 0755]
project/images/folder.png [new file with mode: 0755]
project/images/img.png [new file with mode: 0755]
project/images/loader.png [new file with mode: 0644]
project/images/music.png [new file with mode: 0755]
project/images/pdf.png [new file with mode: 0755]
project/images/ppt.png [new file with mode: 0755]
project/images/text.png [new file with mode: 0755]
project/images/video.png [new file with mode: 0755]
project/index.html [new file with mode: 0644]
project/js/app.clipboard.js [new file with mode: 0644]
project/js/app.config.js [new file with mode: 0644]
project/js/app.helpers.js [new file with mode: 0644]
project/js/app.js [new file with mode: 0644]
project/js/app.model.js [new file with mode: 0644]
project/js/app.systemIO.js [new file with mode: 0644]
project/js/app.ui.js [new file with mode: 0644]
project/js/app.ui.templateManager.js [new file with mode: 0644]
project/js/app.ui.templateManager.modifiers.js [new file with mode: 0644]
project/js/main.js [new file with mode: 0644]
project/templates/emptyFolder.tpl [new file with mode: 0644]
project/templates/fileRow.tpl [new file with mode: 0644]
project/templates/folderRow.tpl [new file with mode: 0644]
project/templates/levelUpRow.tpl [new file with mode: 0644]
project/templates/main.tpl [new file with mode: 0644]
tizen-app-template.xml [new file with mode: 0755]
tizen_32.png [new file with mode: 0644]
tizen_64.png [new file with mode: 0644]

diff --git a/description.xml b/description.xml
new file mode 100755 (executable)
index 0000000..1b1d5c1
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<?xml-stylesheet type="text/xsl" href="description.xsl"?>\r
+<Overview version="1.0">\r
+  <SampleName>FileManager</SampleName>\r
+  <SampleVersion>2.1.0</SampleVersion>\r
+  <Preview>filemanager-snapshot.png</Preview>\r
+  <Description>\r
+         A sample application demonstrating the tizen device API usage.\r
+  </Description>\r
+</Overview>\r
diff --git a/description.xsl b/description.xsl
new file mode 100755 (executable)
index 0000000..1f4f57f
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 
+    This file provides a functionality to show template's description.xml in the project wizard.
+    Don't delete or move this file.
+ -->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:template match="/">
+    <html>
+      <head>
+        <style type="text/css">
+          html,body {
+          font-family:Arial;
+          margin: 0px;
+          }
+          td
+          {
+          font-size:13px;
+          }
+          .samplename
+          {
+          font-size:16px;
+          color:#ffffff;
+          height:26px;
+          background-color:#6d96ac;
+          }
+          .category
+          {
+          font-size:16px;
+          color:#ffffff;
+          height:30px;
+          background-color:#6d96ac;
+          }
+          .contents
+          {
+          padding: 6px 10px 14px 10px;
+          }
+          table#widgets td
+          {
+          border: solid 1px #6d96ac;
+          border-collapse: collapse;
+          }
+          .widgetname
+          {
+          font-weight: bold;
+          text-align: center;
+          width: 20%;
+          word-break:break-all;
+          }
+          table#references td
+          {
+          width: 100%;
+          border: 0px;
+          border-spacing: 0px;
+          padding: 5px;
+          }
+          .refname
+          {
+          width: 100%;
+          font-weight: bold;
+          }
+        </style>
+      </head>
+      <body>
+        <table width="400px" border="0" cellspacing="0">
+          <tr>
+            <td class="samplename" align="center">
+              <xsl:value-of select="Overview/SampleName"/>
+              <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
+                         <!--
+              <xsl:value-of select="Overview/SampleVersion"/>
+                         -->
+            </td>
+          </tr>
+          <tr bgcolor="#FFFFFF">
+            <td class="contents">
+                         <strong>Type</strong>: JavaScript
+                         <p>
+              <xsl:value-of select="Overview/Description"/>
+                         </p>
+            </td>
+          </tr>
+          <tr>
+            <td align="center" bgcolor="#FFFFFF" height="260px">
+              <img>
+                <xsl:attribute name="src">
+                  <xsl:value-of select="Overview/Preview"/>
+                </xsl:attribute>
+              </img>
+            </td>
+          </tr>
+        </table>
+      </body>
+    </html>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/filemanager-snapshot.png b/filemanager-snapshot.png
new file mode 100644 (file)
index 0000000..85a5c9b
Binary files /dev/null and b/filemanager-snapshot.png differ
diff --git a/project/.project b/project/.project
new file mode 100644 (file)
index 0000000..d31aa43
--- /dev/null
@@ -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>
diff --git a/project/AUTHORS b/project/AUTHORS
new file mode 100644 (file)
index 0000000..a447a9f
--- /dev/null
@@ -0,0 +1,6 @@
+Pawel Sierszen <p.sierszen at samsung dot com>
+Piotr Wronski <p.wronski at samsung dot com>
+Dariusz Paziewski <d.paziewski at samsung dot com>
+Tomasz Lukawski <t.lukawski at samsung dot com>
+Tomasz Paciorek <t.paciorek at samsung dot com>
+Aniela Rudy-Gawecka <a.rudy-gawec at samsung dot com>
diff --git a/project/LICENSE.Flora b/project/LICENSE.Flora
new file mode 100644 (file)
index 0000000..4a0af40
--- /dev/null
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License.  Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution.  You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works
+     a copy of this License; and
+  2. You must cause any modified files to carry prominent notices stating
+     that You changed the files; and
+  3. You must retain, in the Source form of any Derivative Works that
+     You distribute, all copyright, patent, trademark, and attribution
+     notices from the Source form of the Work, excluding those notices
+     that do not pertain to any part of the Derivative Works; and
+  4. If the Work includes a "NOTICE" text file as part of its distribution,
+     then any Derivative Works that You distribute must include a readable
+     copy of the attribution notices contained within such NOTICE file,
+     excluding those notices that do not pertain to any part of
+     the Derivative Works, in at least one of the following places:
+     within a NOTICE text file distributed as part of the Derivative Works;
+     within the Source form or documentation, if provided along with the
+     Derivative Works; or, within a display generated by the Derivative Works,
+     if and wherever such third-party notices normally appear.
+     The contents of the NOTICE file are for informational purposes only
+     and do not modify the License. You may add Your own attribution notices
+     within Derivative Works that You distribute, alongside or as an addendum
+     to the NOTICE text from the Work, provided that such additional attribution
+     notices cannot be construed as modifying the License. You may add Your own
+     copyright statement to Your modifications and may provide additional or
+     different license terms and conditions for use, reproduction, or
+     distribution of Your modifications, or for any such Derivative Works
+     as a whole, provided Your use, reproduction, and distribution of
+     the Work otherwise complies with the conditions stated in this License
+     and your own copyright statement or terms and conditions do not conflict
+     the conditions stated in the License including section 3.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks.  This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Flora License, Version 1.1 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://floralicense.org/license/
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
diff --git a/project/NOTICE b/project/NOTICE
new file mode 100644 (file)
index 0000000..092bc04
--- /dev/null
@@ -0,0 +1,4 @@
+Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.1
+Please, see the LICENSE.Flora file for Flora License, Version 1.1 terms and conditions.
+
diff --git a/project/config.xml b/project/config.xml
new file mode 100644 (file)
index 0000000..45f5279
--- /dev/null
@@ -0,0 +1,13 @@
+<?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.2.0" viewmodes="maximized">
+       <tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.2"/>
+       <icon src="icon.png"/>
+       <name>File Manager</name>
+       <feature name="http://tizen.org/feature/screen.size.normal.720.1280"/>
+       <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>
diff --git a/project/css/style.css b/project/css/style.css
new file mode 100644 (file)
index 0000000..94917c0
--- /dev/null
@@ -0,0 +1,245 @@
+* {
+       margin: 0px;
+       padding: 0px;
+}
+
+body {
+       overflow: hidden;
+}
+
+#fileList {
+       margin: 0;
+}
+
+#mainTitle {
+       width: 210px;
+}
+
+#fileList > li {
+       padding-top: 0.3rem;
+       padding-bottom: 0.3rem;
+       border-top: solid 1px #ddd;
+}
+
+#fileList > li > span.nodename {
+       display: inline-block;
+       position: absolute;
+       line-height: 32px;
+       white-space: nowrap;
+       text-overflow: ellipsis;
+       width: 75%;
+       overflow: hidden;
+       margin-top: 5px;
+}
+
+#fileList > li.gradientBackground > span.nodename {
+       color: #fff !important;
+}
+
+#fileList > li.file img {
+       width: 32px;
+       height: 32px;
+}
+
+#fileList > li.folder img {
+       margin-top: 0.1rem;
+}
+
+#fileList > li.levelUp {
+       padding-left: 47px !important;
+       height: 32px;
+}
+
+.selectAll {
+       padding-left: 6px;
+       display: inline-block;
+}
+
+.selectAll span.ui-btn-text {
+       padding-left: 2rem !important;
+       line-height: 40px;
+}
+
+#navbar {
+       height: 16px;
+       padding: 2px 10px;
+       font-size: 14px;
+       white-space: nowrap;
+       overflow: hidden;
+       text-overflow: ellipsis;
+       background-color: rgba(255, 255, 255, 0.5);
+       border-top: solid 1px #DDD;
+       text-align: left;
+}
+
+.ui-pathDiv {
+       position: absolute;
+       top: 49px;
+       left: 0px;
+       right: 0px;
+       bottom: 0px;
+}
+
+#pathDiv {
+       padding: 2px 0px 0px 5px;
+       border: 0px;
+}
+
+#pathDiv .ui-li-text-main {
+       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;
+       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 {
+       width: 100%;
+       height: 100%;
+}
+
+#homeBtn,
+#levelUpBtn {
+       top:0px;
+}
+
+.ui-li-1line-bigicon1.ui-li.ui-li-static.ui-body-s.ui-li-has-thumb {
+       padding-left: 0.7rem;
+       padding-right: 0rem;
+}
+
+.my-ui-checkbox {
+       display: inline-block;
+       margin-top: 0rem;
+       margin-right: 0rem;
+       position: relative !important;
+       top: -0.7rem;
+       left: -1.5rem;
+}
+
+ul.ui-listview > li.ui-li-1line-bigicon1 img.ui-li-bigicon {
+       display: inline-block;
+       margin-top: 0rem;
+       margin-right: 0.7rem;
+       position: relative;
+       left: 5px;
+}
+
+.ui-checkbox .ui-btn.ui-btn-icon-left .ui-btn-inner {
+       line-height: 1.1rem;
+       padding: 0 0 0 0rem;
+       width: 30px;
+}
+
+.ui-checkbox .ui-btn.ui-btn-icon-left .ui-btn-inner.ui-btn-hastxt {
+       width: 100%;
+}
+
+.ui-btn-corner-all {
+       -webkit-border-radius: 0px;
+       bordert-radius: 0px;
+}
+
+.ui-content.ui-scrollview-clip > div.ui-scrollview-view {
+       padding: 0px;
+}
+
+input.ui-input-text.new_folder {
+       width: 100%;
+       height: 50px;
+       padding: 0 0 0 .4em;
+}
+
+.gradientBackground {
+       background: -webkit-linear-gradient(top, #5A99BA 0%, #205473 100%) !important; /* from tizen-white */
+}
+
+.hidden {
+       display: none !important;
+}
+
+.vhidden {
+       visibility: hidden !important;
+}
+
+.ui-tabbar a {
+       color: #999 !important;
+}
+
+#newFolderName {
+       box-sizing: border-box;
+       width: 100%;
+}
+
+.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;
+}
+
+.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;
+}
+
+#overlay {
+       background-color: rgba(0, 0, 0, 0.5);
+       width: 100%;
+       height: 100%;
+       position: absolute;
+       left: 0px;
+       top: 0px;
+       z-index: 9000;
+       display: none;
+}
+
+#infoPopup {
+       background-color: #fff;
+       height: 130px;
+       padding: 15px 0px;
+       position: absolute;
+       text-align: center;
+       box-shadow: 0px 0px 20px #444;
+       border-radius: 5px;
+}
+
+#infoPopup img {
+       -webkit-animation: rotation 2s infinite linear;
+}
+
+@-webkit-keyframes rotation {
+       from {-webkit-transform: rotate(0deg);}
+       to {-webkit-transform: rotate(359deg);}
+}
\ No newline at end of file
diff --git a/project/icon.png b/project/icon.png
new file mode 100644 (file)
index 0000000..5934757
Binary files /dev/null and b/project/icon.png differ
diff --git a/project/images/00_winset_Back.png b/project/images/00_winset_Back.png
new file mode 100644 (file)
index 0000000..780e24e
Binary files /dev/null and b/project/images/00_winset_Back.png differ
diff --git a/project/images/etc.png b/project/images/etc.png
new file mode 100755 (executable)
index 0000000..26748d8
Binary files /dev/null and b/project/images/etc.png differ
diff --git a/project/images/folder.png b/project/images/folder.png
new file mode 100755 (executable)
index 0000000..c8395f5
Binary files /dev/null and b/project/images/folder.png differ
diff --git a/project/images/img.png b/project/images/img.png
new file mode 100755 (executable)
index 0000000..4dd3be3
Binary files /dev/null and b/project/images/img.png differ
diff --git a/project/images/loader.png b/project/images/loader.png
new file mode 100644 (file)
index 0000000..d420fa6
Binary files /dev/null and b/project/images/loader.png differ
diff --git a/project/images/music.png b/project/images/music.png
new file mode 100755 (executable)
index 0000000..449d29d
Binary files /dev/null and b/project/images/music.png differ
diff --git a/project/images/pdf.png b/project/images/pdf.png
new file mode 100755 (executable)
index 0000000..2480d81
Binary files /dev/null and b/project/images/pdf.png differ
diff --git a/project/images/ppt.png b/project/images/ppt.png
new file mode 100755 (executable)
index 0000000..42c1100
Binary files /dev/null and b/project/images/ppt.png differ
diff --git a/project/images/text.png b/project/images/text.png
new file mode 100755 (executable)
index 0000000..c937ef8
Binary files /dev/null and b/project/images/text.png differ
diff --git a/project/images/video.png b/project/images/video.png
new file mode 100755 (executable)
index 0000000..9786439
Binary files /dev/null and b/project/images/video.png differ
diff --git a/project/index.html b/project/index.html
new file mode 100644 (file)
index 0000000..9366eb2
--- /dev/null
@@ -0,0 +1,24 @@
+<!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="tizen-web-ui-fw/latest/js/jquery.min.js"></script>
+       <script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.min.js"></script>
+       <script src="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>
+       <div id="overlay">
+               <div id="infoPopup">
+                       <img src="images/loader.png">
+                       <p>Operation in progress.</p>
+               </div>
+       </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/project/js/app.clipboard.js b/project/js/app.clipboard.js
new file mode 100644 (file)
index 0000000..cee9925
--- /dev/null
@@ -0,0 +1,147 @@
+/*jslint devel: true*/
+/*global $*/
+
+/**
+ * @class Config
+ */
+function Clipboard() {
+       'use strict';
+       this.mode = this.INACTIVE_MODE;
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       Clipboard.prototype = {
+               /**
+                * Clipboard mode for copying
+                */
+               COPY_MODE_ID: 0,
+
+               /**
+                * Clipboard mode for moving
+                */
+               MOVE_MODE_ID: 1,
+
+               /**
+                * Clipbboard inactive mode
+                */
+               INACTIVE_MODE: -1,
+
+               /**
+                * Clipboard data
+                */
+               data: [],
+
+               /**
+                * Clipboard mode: [copy | move | inactive]
+                */
+               mode: undefined,
+
+               /**
+                * Returns all paths in clipboard
+                * @returns {array}
+                */
+               get: function Clipboard_get() {
+                       return this.data;
+               },
+
+               /**
+                * Add new path to clipboard
+                * @param {array} paths array of full paths
+                * @returns {number} current length of clipboard objects
+                */
+               add: function Clipboard_add(paths) {
+                       var len = paths.length,
+                               i;
+
+                       // clear clipboard
+                       this.clear();
+                       for (i = 0; i < len; i += 1) {
+                               if (this.has(paths[i]) === false) {
+                                       this.data.push(paths[i]);
+                               }
+                       }
+
+                       return this.data.length;
+               },
+
+               /**
+                * Remove specified path is already in clipboard
+                * @param {string} path full path
+                * @returns {number} current length of clipboard objects
+                */
+               remove: function Clipboard_remove(path) {
+                       var index = $.inArray(path, this.data);
+                       var length;
+                       if (index >= 0) {
+                               this.data.splice(index, 1);
+                               length = this.data.length;
+                               if (length === 0) {
+                                       this.mode = this.INACTIVE_MODE;
+                               }
+                       }
+                       return length;
+               },
+
+               /**
+                * Remove specified path and all children paths if already in clipboard
+                * @param {string} path full path
+                * @returns {number} current length of clipboard objects
+                */
+               removeRecursively: function Clipboard_removeRecursively(path) {
+                       var childPattern = new RegExp(path),
+                               index = this.data.length;
+                       while (index--) {
+                               if(childPattern.test(this.data[index])) {
+                                       this.data.splice(index, 1);
+                               }
+                       }
+                       return this.data.length;
+               },
+
+               /**
+                * Checks if specified path is already in clipboard
+                * @param {string} path full path
+                * @returns {boolean}
+                */
+               has: function Clipboard_has(path) {
+                       return $.inArray(path, this.data) === -1 ? false : true;
+               },
+
+               /**
+                * Clears all clipboard data and resets clipboard mode
+                */
+               clear: function Clipboard_clear() {
+                       this.data = [];
+                       this.mode = this.INACTIVE_MODE;
+               },
+
+               /**
+                * Sets clipboard mode
+                * @param {number} mode
+                * @returns {boolean}
+                */
+               setMode: function Clipboard_setMode(mode) {
+                       if ($.inArray(mode, [this.MOVE_MODE_ID, this.COPY_MODE_ID]) === false) {
+                               console.error('Incorrect clipboard mode');
+                               return false;
+                       }
+                       this.mode = mode;
+                       return true;
+               },
+
+               /**
+                * @returns {number} mode Clipboard mode
+                */
+               getMode: function Clipboard_getMode() {
+                       return this.mode;
+               },
+
+               /**
+                * @returns {boolean}
+                */
+               isEmpty: function Clipboard_isEmpty() {
+                       return this.data.length === 0;
+               }
+       };
+}());
diff --git a/project/js/app.config.js b/project/js/app.config.js
new file mode 100644 (file)
index 0000000..e0332c3
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * @class Config
+ */
+function Config() {
+       'use strict';
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       Config.prototype = {
+
+               properties: {
+                       'templateDir': 'templates',
+                       'templateExtension': '.tpl'
+               },
+
+               /**
+                * Returns config value
+                */
+               get: function (value, defaultValue) {
+
+                       if (this.properties.hasOwnProperty(value)) {
+                               return this.properties[value];
+                       }
+                       return defaultValue;
+               }
+       };
+}());
diff --git a/project/js/app.helpers.js b/project/js/app.helpers.js
new file mode 100644 (file)
index 0000000..12cd314
--- /dev/null
@@ -0,0 +1,162 @@
+/*jslint devel: true*/
+/*global $, jQuery */
+
+/**
+ * @class Helpers
+ */
+function Helpers() {
+       'use strict';
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       Helpers.prototype = {
+
+               extensions: {
+                       '.bmp':       {mime:'image/*',            icon:'img.png'},
+                       '.gif':       {mime:'image/*',            icon:'img.png'},
+                       '.jpeg':      {mime:'image/*',            icon:'img.png'},
+                       '.jpg':       {mime:'image/*',            icon:'img.png'},
+                       '.png':       {mime:'image/*',            icon:'img.png'},
+                       '.tiff':      {mime:'image/*',            icon:'img.png'},
+                       '.3ga':       {mime:'audio/*',            icon:'music.png'},
+                       '.aac':       {mime:'audio/*',            icon:'music.png'},
+                       '.ac3':       {mime:'audio/*',            icon:'music.png'},
+                       '.amr':       {mime:'audio/*',            icon:'music.png'},
+                       '.awb':       {mime:'audio/*',            icon:'music.png'},
+                       '.m4a':       {mime:'audio/*',            icon:'music.png'},
+                       '.m4p':       {mime:'audio/*',            icon:'music.png'},
+                       '.m4r':       {mime:'audio/*',            icon:'music.png'},
+                       '.mp3':       {mime:'audio/*',            icon:'music.png'},
+                       '.ogg':       {mime:'audio/*',            icon:'music.png'},
+                       '.wav':       {mime:'audio/*',            icon:'music.png'},
+                       '.wma':       {mime:'audio/*',            icon:'music.png'},
+                       '.3gp':       {mime:'video/*',            icon:'video.png'},
+                       '.avc':       {mime:'video/*',            icon:'video.png'},
+                       '.avi':       {mime:'video/*',            icon:'video.png'},
+                       '.m4v':       {mime:'video/*',            icon:'video.png'},
+                       '.mkv':       {mime:'video/*',            icon:'video.png'},
+                       '.mov':       {mime:'video/*',            icon:'video.png'},
+                       '.mp4':       {mime:'video/*',            icon:'video.png'},
+                       '.mpeg':      {mime:'video/*',            icon:'video.png'},
+                       '.mpg':       {mime:'video/*',            icon:'video.png'},
+                       '.ogv':       {mime:'video/*',            icon:'video.png'},
+                       '.vc1':       {mime:'video/*',            icon:'video.png'},
+                       '.wmv':       {mime:'video/*',            icon:'video.png'},
+                       '.doc':       {mime:'',                   icon:'text.png'},
+                       '.docx':      {mime:'',                   icon:'text.png'},
+                       '.odt':       {mime:'',                   icon:'text.png'},
+                       '.ods':       {mime:'',                   icon:'text.png'},
+                       '.txt':       {mime:'',                   icon:'text.png'},
+                       '.xls':       {mime:'',                   icon:'text.png'},
+                       '.xlsx':      {mime:'',                   icon:'text.png'},
+                       '.vcard':     {mime:'text/vcard',         icon:'text.png'},
+                       '.vcf':       {mime:'text/vcard',         icon:'text.png'},
+                       '.icalendar': {mime:'text/calendar',      icon:'text.png'},
+                       '.ical':      {mime:'text/calendar',      icon:'text.png'},
+                       '.ics':       {mime:'text/calendar',      icon:'text.png'},
+                       '.ifb':       {mime:'text/calendar',      icon:'text.png'},
+                       '.pdf':       {mime:'',                   icon:'pdf.png'},
+                       '.odp':       {mime:'',                   icon:'ppt.png'},
+                       '.ppt':       {mime:'',                   icon:'ppt.png'},
+                       '.wgt':       {mime:'application/widget', icon:'etc.png'}
+               },
+
+               /**
+                * Capitalise the first letter
+                *
+                * @param {string} text
+                * @returns {string}
+                */
+               UCFirst: function Helpers_UCFirst(text) {
+                       return text.charAt(0).toUpperCase() + text.slice(1);
+               },
+
+               /**
+                * @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) {
+                       var splittedFileName = fileName.split('.'),
+                               ext = '';
+
+                       if (splittedFileName.length > 1) {
+                               ext = '.' + splittedFileName.pop();
+                       }
+                       return ext;
+               },
+
+               /**
+                * Return icon filename for the given extension.
+                * For example, for '.mp3' returns 'music.png'
+                *
+                * @param {string} ext
+                * @return {string}
+                */
+               resolveFileIcon: function Helpers_resolveFileIcon(ext) {
+                       ext = ext.toLowerCase();
+                       var info = this.extensions[ext];
+                       return info ? info.icon : 'etc.png';
+               },
+
+               /**
+                * Resolve file extension to MIME type
+                *
+                * @param {string} ext File extension
+                * @returns {string}
+                */
+               resolveMimeType: function Helpers_resolveMimeType(ext) {
+                       ext = ext.toLowerCase();
+                       var info = this.extensions[ext];
+                       return info ? info.mime : '';
+               },
+
+               /**
+                * Returns thumbnail URI for specified file
+                * @param {string} fileName
+                * @param {File} node
+                * @returns {string}
+                */
+               getThumbnailURI: function Helpers_getThumbnailURI(fileName, node) {
+                       var ext = this.getFileExtension(fileName);
+
+                       if (!node.thumbnailURIs) {
+                               return  'images/' + this.resolveFileIcon(ext);
+                       }
+
+                       if (node.thumbnailURIs[0] && $.inArray(ext, ['.mp4', '.jpg', '.png', '.gif'])) {
+                               return node.thumbnailURIs[0];
+                       }
+
+                       return 'images/etc.png';
+               },
+
+               /**
+                * 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;
+               }
+       };
+}());
diff --git a/project/js/app.js b/project/js/app.js
new file mode 100644 (file)
index 0000000..297023b
--- /dev/null
@@ -0,0 +1,278 @@
+/*jslint devel: true*/
+/*global tizen, $, app, Ui, Model, Helpers, Config, Clipboard*/
+
+var App = null;
+
+(function () { // strict mode wrapper
+       'use strict';
+
+       /**
+        * Creates a new application object
+        *
+        * @class Application
+        * @constructor
+        */
+       App = function App() {
+       };
+
+       App.prototype = {
+               /**
+                * @type Array
+                */
+               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
+                */
+               model: null,
+
+               /**
+                * @type Ui
+                */
+               ui: null,
+
+               /**
+                * @type Config
+                */
+               config: null,
+
+               /**
+                * @type SystemIO
+                */
+               systemIO: null,
+
+               /**
+                * @type Helpers
+                */
+               helpers: null,
+
+               /**
+                * @type {string}
+                */
+               currentPath: 'root',
+
+               /**
+                *
+                */
+               currentDirHandle: null,
+
+               /**
+                * @type {Clipboard}
+                */
+               clipboard: null,
+
+               /**
+                * Initialization
+                */
+               init: function App_init() {
+                       this.config = new Config();
+                       this.model = new Model();
+                       this.ui = new Ui();
+                       this.helpers = new Helpers();
+                       this.clipboard = new Clipboard();
+
+                       this.initUi();
+               },
+
+               /**
+                * UI initialization
+                */
+               initUi: function App_initUi() {
+                       this.ui.init(this.model.getInternalStorages());
+               },
+
+               /**
+                * Displays media storages
+                */
+               displayStorages: function App_displayStorages() {
+                       this.currentPath = '';
+                       if (!this.ui.editMode) {
+                               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, refresh) {
+                       var self = this;
+
+                       refresh = refresh || false;
+
+                       // get folder data and push into rendering method
+                       this.model.getFolderData(path, function (dir, nodes) {
+                               // on success
+
+                               // update current path
+                               self.currentPath = path;
+
+                               // update current dir handle
+                               self.currentDirHandle = dir;
+
+                               // display folder UI
+                               if (refresh === undefined) {
+                                       self.ui.scrollContentTo(0);
+                               }
+                               self.ui.displayFolder(path, nodes, refresh);
+                       });
+               },
+
+               /**
+                * Opens specified file
+                * @params {string} uri File URI
+                */
+               openFile: function App_openFile(uri, fullUri) {
+                       var ext = this.helpers.getFileExtension(uri),
+                               mime = this.helpers.resolveMimeType(ext);
+
+                       if (mime !== '') {
+                               this.model.openFile(fullUri, mime);
+                       } else {
+                               console.error('Unsupported mime type for extension ' + ext);
+                       }
+               },
+
+               /**
+                * Displays parent location
+                */
+               goLevelUp: function App_goLevelUp() {
+                       // split current path and get proper path for parent location
+                       var newPath = this.currentPath.split('/').slice(0, -1).join('/');
+
+                       if (newPath !== '') {
+                               this.displayFolder(newPath);
+                       } else {
+                               this.displayStorages();
+                       }
+               },
+
+               /**
+                * creates new dir in currently viewed dir
+                * @param {string} dirName
+                * @return {boolean} return status
+                */
+               createDir: function App_createDir(dirName, callback) {
+                       var status = true;
+                       if (this.currentDirPath !== '') {
+                               try {
+                                       this.currentDirHandle.createDirectory(dirName);
+                               } catch (e) {
+                                       status = false;
+                                       app.ui.alertPopup(e.message, callback);
+                               }
+                               this.refreshCurrentPage();
+                       } else {
+                               status = false;
+                               app.ui.alertPopup("You can't create new nodes in the main view");
+                       }
+                       return status;
+               },
+
+               /**
+                * Triggers refresh current page
+                */
+               refreshCurrentPage: function App_refreshCurrentPage(refresh) {
+                       refresh = refresh || false;
+                       if (this.currentPath === 'root') {
+                               return;
+                       }
+                       if (this.currentPath !== '') {
+                               app.model.isStorageExists(this.currentPath,
+                                       app.displayFolder.bind(app, app.model.currentPath, refresh),
+                                       function () {
+                                               $.mobile.popup.active && $.mobile.popup.active.close();
+                                               app.displayStorages();
+                                               setTimeout(
+                                                       function(){
+                                                               app.ui.alertPopup(
+                                                                       'Path "' + app.model.currentPath + '" does no longer exist'
+                                                               );
+                                                       },
+                                                       200
+                                               );
+                                       });
+                       } else {
+                               this.displayStorages();
+                       }
+               },
+
+               /**
+                * Deletes nodes with specified paths
+                * @param {string[]} nodes nodePaths
+                */
+               deleteNodes: function App_deleteNodes(nodes) {
+                       this.model.deleteNodes(nodes, this.currentDirHandle, this.ui.removeNodeFromList.bind(this.ui));
+               },
+
+               /**
+                * @param {string[]} paths filepaths
+                * @param {number} mode clipboard mode
+                */
+               saveToClipboard: function App_saveToClipboard(paths, mode) {
+                       var clipboardLength = this.clipboard.add(paths);
+
+                       if (clipboardLength > 0) {
+                               this.clipboard.setMode(mode);
+                               app.ui.alertPopup('Data saved in clipboard');
+                               this.ui.clearTabbars();
+                       } else {
+                               app.ui.alertPopup('Error occured. Data has not been saved in clipboard');
+                       }
+
+                       this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
+               },
+
+               /**
+                * Paste nodes from clipboard to current dir
+                */
+               pasteClipboard: function App_pasteClipboard() {
+                       var clipboardData = this.clipboard.get();
+
+                       if (clipboardData.length === 0) {
+                               app.ui.alertPopup('Clipboard is empty');
+                               return false;
+                       }
+
+                       if (this.clipboard.getMode() === this.clipboard.COPY_MODE_ID) {
+                               this.model.copyNodes(this.currentDirHandle, clipboardData, this.currentPath, this.onPasteClipboardSuccess.bind(this));
+                       } else {
+                               this.model.moveNodes(this.currentDirHandle, clipboardData, this.currentPath, this.onPasteClipboardSuccess.bind(this));
+                       }
+
+                       this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
+
+                       return true;
+               },
+
+               emptyClipboard: function App_emptyClipboard() {
+                       return this.clipboard.get().length === 0;
+               },
+
+               /**
+                * Handler for paste clipboard success
+                */
+               onPasteClipboardSuccess: function App_onPasteClipboardSuccess() {
+                       this.clipboard.clear();
+                       this.refreshCurrentPage();
+               },
+
+               /**
+                * App exit
+                */
+               exit: function App_exit() {
+                       tizen.application.getCurrentApplication().exit();
+               }
+       };
+}());
diff --git a/project/js/app.model.js b/project/js/app.model.js
new file mode 100644 (file)
index 0000000..7b2b4a1
--- /dev/null
@@ -0,0 +1,352 @@
+/*jslint devel: true*/
+/*global tizen, SystemIO, $, app */
+
+/**
+ * @class Model
+ */
+function Model() {
+       'use strict';
+       this.init();
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       Model.prototype = {
+
+               /**
+                * file open unlock flag
+                * @type {boolean}
+                */
+               openFileUnLocked: true,
+
+               /**
+                * @type SystemIO
+                */
+               systemIO: null,
+
+               /**
+                * @type Array
+                */
+               storages: [{label: 'root', type: 'INTERNAL'}],
+
+               /**
+                * @type String
+                */
+               currentPath: '',
+
+               /**
+                * API module initialisation
+                */
+               init: function Model_init() {
+                       this.systemIO = new SystemIO();
+               },
+
+               /**
+                * @returns {FileSystemStorage[]} storages
+                */
+               getInternalStorages: function Model_getInternalStorages() {
+                       return this.storages;
+               },
+
+               /**
+                * Saves storages
+                * @param {function} onSuccess callback
+                */
+               loadInternalStorages: function Model_loadInternalStorages(onSuccess) {
+                       var self = this;
+
+                       this.systemIO.getStorages('INTERNAL', function (storages) {
+                               self.storages = storages;
+                               if (typeof onSuccess === 'function') {
+                                       onSuccess();
+                               }
+                       }, 'internal0');
+               },
+
+               /**
+                * Returns folder data
+                * @param {string} path Node path
+                * @param {function} onSuccess Success callback
+                * @param {function} onError Error callback
+                */
+               getFolderData: function Model_getFolderData(path, onSuccess, onError) {
+                       var self = this,
+                               onOpenSuccess = function (dir) {
+                               dir.listFiles(
+                                       function (files) {
+                                               self.currentPath = dir.fullPath;
+                                               onSuccess(dir, files);
+                                       },
+                                       function (e) {
+                                               console.error('Model_getFolderData listFiles error', e);
+                                       }
+                               );
+                       },
+                               onOpenError = function (e) {
+                                       console.error('Model_getFolderData openDir error', e);
+                               };
+
+                       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
+                * @param {string} mime uri
+                */
+               openFile: function Model_openFile(fullUri, mime) {
+                       if (this.openFileUnLocked) {
+                               var self = this, serviceReplyCB = {
+                                       onsuccess: function (reply) {
+                                               self.openFileUnLocked = true;
+                                       },
+                                       onfailure: function () {
+                                               self.openFileUnLocked = true;
+                                               console.error('Launch service failed');
+                                       }
+                               };
+                               this.openFileUnLocked = false;
+                               try {
+                                       console.log('Launching view for file "' + fullUri + '" (mime="' + mime + '")...');
+                                       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;
+                                                       console.error('Service launch failed. Exception message:' + e.message);
+                                               },
+                                               serviceReplyCB
+                                               );
+                               } catch (e) {
+                                       self.openFileUnLocked = true;
+                                       console.error('openFile failed', e);
+                               }
+                       }
+               },
+
+               refreshContent: function (path, successCallback, mode) {
+                       successCallback = successCallback || null;
+                       mode = mode || 'copy';
+                       var isDir = true,
+                               onResolveSuccess;
+                       if(app.helpers.getFileExtension(path) !== '') {
+                               isDir = false;
+                       }
+                       onResolveSuccess = function () {};
+
+                       if(isDir) {
+                               switch (mode) {
+                               case 'delete':
+                                       tizen.filesystem.resolve(path, onResolveSuccess, successCallback);
+                               break;
+                               default:
+                                       tizen.filesystem.resolve(path, successCallback);
+                               }
+                       } else {
+                               tizen.content.scanFile(path, successCallback);
+                       }
+               },
+
+               resolveAndRefresh: function (path, successCallback, mode) {
+                       var self = this;
+                       tizen.filesystem.resolve(path, function (file) {
+                               self.refreshContent(file.toURI(), successCallback);
+                       }, null);
+               },
+
+               /**
+                * @param {File[]} nodes Collection of node objects
+                * @param {File} dir Directory handle
+                * @param {function} onSuccess
+                * @param {function} onError
+                */
+               deleteNodes: function Model_deleteNodes(nodes, dir, onSuccess, onError) {
+                       var len = nodes.length,
+                               self = this,
+                               onDeleteNodeSuccess = function (node, isDir, fileobject) {
+                                       try {
+                                               this.refreshContent(fileobject.toURI(), function () {
+                                                       app.clipboard.removeRecursively(node.uri);
+                                                       app.ui.refreshPasteActionBtn();
+                                                       if (typeof onSuccess === 'function') {
+                                                               onSuccess(node.id);
+                                                       }
+                                               }, 'delete');
+                                       } catch (e) {
+                                               console.error(e);
+                                       }
+                               },
+                               onDeleteNodeError = function (e) {
+                                       console.error('Folder delete error', e);
+                                       if (typeof onError === 'function') {
+                                               onError();
+                                       }
+                               },
+                               i;
+
+                       for (i = 0; i < len; i = i + 1) {
+                               tizen.filesystem.resolve(
+                                       nodes[i].uri,
+                                       function (node, fileobject) {
+                                               if (node.folder) {
+                                                       dir.deleteDirectory(
+                                                               node.uri,
+                                                               true,
+                                                               onDeleteNodeSuccess.bind(this, node, true, fileobject),
+                                                               onDeleteNodeError
+                                                       );
+                                               } else {
+                                                       dir.deleteFile(
+                                                               node.uri,
+                                                               onDeleteNodeSuccess.bind(this, node, false, fileobject),
+                                                               onDeleteNodeError
+                                                       );
+                                               }
+                                       }.bind(this, nodes[i]),
+                                       null
+                               );
+                       }
+               },
+
+               /**
+                * Copy specified files to destination path
+                * Overwrites existing files
+                *
+                * @param {File} dir Directory handle
+                * @param {string[]} paths Array with absolute virtual file paths
+                * @param {string} destinationPath
+                * @param {function} onSuccess callback
+                */
+               copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
+                       var len = paths.length, self = this,
+                               scaned = 0,
+                               scanSuccess = function () {
+                                       scaned += 1;
+                                       if (scaned === len) {
+                                               onSuccess();
+                                       }
+                               },
+                               onCopyNodeSuccess = function (file) {
+                                       self.refreshContent(file.toURI(), scanSuccess, 'copy');
+                               },
+                               onCopyNodeFailure = function (e) {
+                                       console.error(e);
+                                       setTimeout(function () {
+                                               app.ui.alertPopup('Copying error');
+                                       }, 200);
+                               },
+                               i,
+                               sourceName,
+                               decision;
+
+                       this.systemIO.getFilesList(dir, function (filesList) {
+                               for (i = 0; i < len; i = i + 1) {
+                                       if (destinationPath.indexOf(paths[i]) !== -1) {
+                                               setTimeout(function () {
+                                                       app.ui.alertPopup('Copying error');
+                                               }, 200);
+                                               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);
+                                               self.resolveAndRefresh(paths[i]);
+                                       } catch (e) {
+                                               console.error(e);
+                                       }
+                               }
+                       });
+               },
+
+               /**
+                * Move specified files to destination path
+                * Overwrites existing files
+                *
+                * @param {File} dir Directory handle
+                * @param {string[]} paths Array with absolute virtual file paths
+                * @param {string} destinationPath
+                * @param {function} onSuccess callback
+                */
+               moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
+                       var len = paths.length, self = this,
+                               scaned = 0,
+                               toScan = len * 2,
+                               illegalMove = false,
+                               scanSuccess = function () {
+                                       scaned += 1;
+                                       if (scaned === toScan) {
+                                               onSuccess();
+                                       }
+                               },
+                               onMoveNodeSuccess = function (oldfile, file) {
+                                       self.refreshContent(oldfile.toURI(), scanSuccess, 'delete');
+                                       self.refreshContent(file.toURI(), scanSuccess, 'copy');
+                               },
+                               onMoveNodeFailure = function () {
+                                       app.ui.alertPopup('Moving error');
+                               },
+                               i,
+                               sourceName,
+                               decision;
+
+                       while (len--) {
+                               if (destinationPath.match(paths[len])) {
+                                       illegalMove = true;
+                                       break;
+                               }
+                       }
+
+                       len = paths.length;
+
+                       if (illegalMove) {
+                               setTimeout(function () {
+                                       app.ui.alertPopup('Can not move catalog into itself.');
+                               }, 200);
+                               return;
+                       }
+
+                       this.systemIO.getFilesList(dir, function (filesList) {
+                               for (i = 0; i < len; i = i + 1) {
+                                       if (destinationPath.indexOf(paths[i]) !== -1) {
+                                               app.ui.alertPopup('Moving error');
+                                               return;
+                                       }
+                               }
+
+                               for (i = 0; i < len; i = i + 1) {
+                                       decision = true;
+                                       sourceName = paths[i].split('/').pop();
+                                       try {
+                                               tizen.filesystem.resolve(
+                                                       paths[i],
+                                                       function (path, destinationPath, sourceName, oldfile) {
+                                                               dir.moveTo(path, destinationPath + '/' + sourceName, false, onMoveNodeSuccess.bind(self, oldfile), onMoveNodeFailure);
+                                                       }.bind(self, paths[i], destinationPath, sourceName),
+                                                       null
+                                               );
+                                       } catch (e) {
+                                               console.error(e);
+                                       }
+                               }
+                       });
+               }
+       };
+}());
diff --git a/project/js/app.systemIO.js b/project/js/app.systemIO.js
new file mode 100644 (file)
index 0000000..4c70377
--- /dev/null
@@ -0,0 +1,261 @@
+/*jslint devel: true*/
+/*global tizen, localStorage */
+
+/**
+ * @class SystemIO
+ */
+function SystemIO() {
+       'use strict';
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       SystemIO.prototype = {
+               /**
+                * Creates new empty file in specified location
+                *
+                * @param {File} directoryHandle
+                * @param {string} fileName
+                */
+               createFile: function SystemIO_createFile(directoryHandle, fileName) {
+
+                       try {
+                               return directoryHandle.createFile(fileName);
+                       } catch (e) {
+                               console.error('SystemIO_createFile error:' + e.message);
+                               return false;
+                       }
+               },
+
+               /**
+                * Writes content to file stream
+                *
+                * @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) {
+                       onError = onError || function () {};
+
+                       fileHandle.openStream('w', function (fileStream) {
+                               if (contentEncoding === 'base64') {
+                                       fileStream.writeBase64(fileContent);
+                               } else {
+                                       fileStream.write(fileContent);
+                               }
+
+                               fileStream.close();
+
+                               // launch onSuccess callback
+                               if (typeof onSuccess === 'function') {
+                                       onSuccess();
+                               }
+                       }, onError, 'UTF-8');
+               },
+
+               /**
+                * Opens specified location
+                *
+                * @param {string} directory path
+                * @param {function} on success callback
+                * @param {function} on error callback
+                * @param {string} mode
+                */
+               openDir: function SystemIO_openDir(directoryPath, onSuccess, onError, openMode) {
+                       openMode = openMode || 'rw';
+                       onSuccess = onSuccess || function () {};
+
+                       try {
+                               tizen.filesystem.resolve(directoryPath, onSuccess, onError, openMode);
+                       } catch (e) {
+                       }
+               },
+
+               /**
+                * Parse specified filepath and returns data parts
+                *
+                * @param {string} filePath
+                * @returns {array}
+                */
+               getPathData: function SystemIO_getPathData(filePath) {
+                       var path = {
+                               originalPath: filePath,
+                               fileName: '',
+                               dirName: ''
+                       },
+                               splittedPath = filePath.split('/');
+
+                       path.fileName = splittedPath.pop();
+                       path.dirName = splittedPath.join('/') || '/';
+
+                       return path;
+               },
+
+               /**
+                * Save specified content to file
+                *
+                * @param {string} file path
+                * @param {string} file content
+                * @param {string} file encoding
+                */
+               saveFileContent: function SystemIO_saveFileContent(filePath, fileContent, onSaveSuccess, fileEncoding) {
+                       var pathData = this.getPathData(filePath),
+                               self = this,
+                               fileHandle;
+
+                       function onOpenDirSuccess(dir) {
+                               // create new file
+                               fileHandle = self.createFile(dir, pathData.fileName);
+                               if (fileHandle !== false) {
+                                       // save data into this file
+                                       self.writeFile(fileHandle, fileContent, onSaveSuccess, false, fileEncoding);
+                               }
+                       }
+
+                       // open directory
+                       this.openDir(pathData.dirName, onOpenDirSuccess);
+               },
+
+               /**
+                * Deletes node with specified path
+                *
+                * @param {string} node path
+                * @param {function} success callback
+                */
+               deleteNode: function SystemIO_deleteNode(nodePath, onSuccess) {
+                       var pathData = this.getPathData(nodePath),
+                               self = this;
+
+                       function onDeleteSuccess() {
+                               onSuccess();
+                       }
+
+                       function onDeleteError(e) {
+                               console.error('SystemIO_deleteNode:_onDeleteError', e);
+                       }
+
+                       function onOpenDirSuccess(dir) {
+                               var onListFiles = function (files) {
+                                       if (files.length > 0) {
+                                               // file exists;
+                                               if (files[0].isDirectory) {
+                                                       self.deleteDir(dir, files[0].fullPath, onDeleteSuccess, onDeleteError);
+                                               } else {
+                                                       self.deleteFile(dir, files[0].fullPath, onDeleteSuccess, onDeleteError);
+                                               }
+                                       } else {
+                                               onDeleteSuccess();
+                                       }
+                               };
+
+                               // check file exists;
+                               dir.listFiles(onListFiles, function (e) {
+                                       console.error(e);
+                               }, {
+                                       name: pathData.fileName
+                               });
+                       }
+
+                       this.openDir(pathData.dirName, onOpenDirSuccess, function (e) {
+                               console.error('openDir error:' + e.message);
+                       });
+               },
+
+               /**
+                * Deletes specified file
+                *
+                * @param {File} dir
+                * @param {string} file path
+                * @param {function} delete success callback
+                * @param {function} delete error callback
+                */
+               deleteFile: function SystemIO_deleteFile(dir, filePath, onDeleteSuccess, onDeleteError) {
+                       try {
+                               dir.deleteFile(filePath, onDeleteSuccess, onDeleteError);
+                       } catch (e) {
+                               console.error('SystemIO_deleteFile error: ' + e.message);
+                               return false;
+                       }
+               },
+
+               /**
+                * Deletes specified directory
+                *
+                * @param {File} dir
+                * @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) {
+                       try {
+                               dir.deleteDirectory(dirPath, false, onDeleteSuccess, onDeleteError);
+                       } catch (e) {
+                               console.error('SystemIO_deleteDir error:' + e.message);
+                               return false;
+                       }
+
+                       return true;
+               },
+
+               /**
+                * @param {string} type storage type
+                * @param {function} onSuccess on success callback
+                * @param {string} excluded Excluded storage
+                */
+               getStorages: function SystemIO_getStorages(type, onSuccess, excluded) {
+                       try {
+                               tizen.filesystem.listStorages(function (storages) {
+                                       var tmp = [],
+                                               len = storages.length,
+                                               i;
+
+                                       if (type !== undefined) {
+                                               for (i = 0; i < len; i += 1) {
+                                                       if (storages[i].label !== excluded) {
+                                                               if (storages[i].type === 0 || storages[i].type === type) {
+                                                                       tmp.push(storages[i]);
+                                                               }
+                                                       }
+                                               }
+                                       } else {
+                                               tmp = storages;
+                                       }
+
+                                       if (typeof onSuccess === 'function') {
+                                               onSuccess(tmp);
+                                       }
+                               });
+                       } catch (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);
+                       }
+               }
+       };
+}());
\ No newline at end of file
diff --git a/project/js/app.ui.js b/project/js/app.ui.js
new file mode 100644 (file)
index 0000000..b6b30e1
--- /dev/null
@@ -0,0 +1,961 @@
+/*jslint devel: true */
+/*global $, app, TemplateManager, Helpers */
+
+/**
+ * @class Ui
+ */
+function Ui() {
+       'use strict';
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       Ui.prototype = {
+               /**
+                * root mode
+                * @type {boolean}
+                */
+               root: true,
+
+               /**
+                * locked folders
+                * @type {array}
+                */
+               lockedFolders: ['ringtones'],
+
+               /**
+                * UI edit mode
+                * @type {boolean}
+                */
+               editMode: false,
+
+               /**
+                * @type {bool} block clicks until the page change is completed
+                */
+               nodeTapBlock: false,
+
+               /**
+                * @type {TemplateManager}
+                */
+               templateManager: null,
+
+               /**
+                * @type Helpers
+                */
+               helpers: null,
+
+               /**
+                * @type Info popup lock
+                */
+               infoPopupVisibility: false,
+
+               /**
+                * @const {number}
+                */
+               PATH_DIV_HEIGHT: 20,
+
+               /**
+                * @const {number}
+                */
+               SELECT_ALL_HEIGHT: 32,
+
+               /**
+                * @const {number} header height, set on domReady
+                */
+               HEADER_HEIGHT: 53,
+
+               /**
+                * name of row gradient class
+                */
+               CSS_GRADIENT_CLASS: 'gradientBackground',
+
+               /**
+                * Standard tabbar actions
+                * @type {number}
+                */
+               STD_TABBAR_EDIT_ACTION: 0,
+               STD_TABBAR_MORE_ACTION: 1,
+               STD_TABBAR_EXIT_ACTION: 2,
+
+               /**
+                * Edit tabbar actions
+                * @type {number}
+                */
+               EDIT_TABBAR_DELETE_ACTION: 0,
+               EDIT_TABBAR_MOVE_ACTION: 1,
+               EDIT_TABBAR_COPY_ACTION: 2,
+               EDIT_TABBAR_CANCEL_ACTION: 3,
+
+               currentHeaderHeight: null,
+               currentScrollPosition: null,
+
+               /**
+                * UI Initialization
+                */
+               init: function Ui_init(storages) {
+                       this.templateManager = new TemplateManager();
+                       this.helpers = new Helpers();
+                       // Disable text selection
+                       $.mobile.tizen.disableSelection(document);
+                       $(document).ready(this.initDom.bind(this, storages));
+               },
+
+               initDom: function Ui_initDom(storages) {
+                       var self = this,
+                               overlay = $('#overlay'),
+                               popup = $('#infoPopup'),
+                               windowWidth,
+                               windowHeight,
+                               popWidth;
+
+                       this.templateManager.loadToCache(['main', 'fileRow', 'folderRow', 'levelUpRow', 'emptyFolder'], function () {
+                               $('#main').append($(self.templateManager.get('main')).children()).trigger('pagecreate');
+                               self.addEvents();
+                               self.displayStorages(storages);
+                       });
+
+                       windowWidth = $(window).width();
+                       windowHeight = $(window).height();
+
+                       overlay.css({
+                               'width': windowWidth + 'px',
+                               'height': windowHeight + 'px'
+                       });
+
+                       popWidth = windowWidth / 2 + 30;
+                       popup.css({
+                               'width': popWidth + 'px',
+                               'left': (windowWidth / 2 - popWidth / 2) + 'px',
+                               'top': (windowHeight / 2 - popup.height() / 2) + 'px'
+                       });
+               },
+
+               /**
+                * Add UI events
+                */
+               addEvents: function Ui_addEvents() {
+                       var self = this;
+
+                       document.addEventListener('webkitvisibilitychange', function () {
+                               if (document.webkitVisibilityState === 'visible') {
+                                       self.refreshSelectAllStatus();
+                                       app.refreshCurrentPage(true);
+                               }
+                       });
+
+                       window.addEventListener('tizenhwkey', function(e) {
+                               var uri = $('#navbar span+span').attr('uri');
+                               if (e.keyName == "back") {
+                                       if (self.infoPopupVisibility) {
+                                               return;
+                                       } else if ($.mobile.popup.active) {
+                                               $.mobile.popup.active.close();
+                                       } else if (self.editMode === true) {
+                                               self.handleCancelEditAction();
+                                       } else if (!uri) {
+                                               if ( app.ui.root === false ) {
+                                                       $('#fileList').empty();
+                                                       app.ui.prepareFolderRow(0, "root");
+                                                       app.ui.root = true;
+                                               } else {
+                                                       tizen.application.getCurrentApplication().exit();
+                                               }
+                                       } else {
+                                               app.goLevelUp();
+                                       }
+                               }
+                       });
+
+                       $(window).resize( function () {
+                               $.mobile.activePage.page('refresh')
+                       });
+
+                       // touch events for all nodes
+                       $('ul#fileList')
+                               .on('click', 'li.levelUp', function () {
+                                       if (self.editMode === true) {
+                                               self.handleCancelEditAction();
+                                       }
+                                       app.goLevelUp();
+                               })
+                               .on('click', 'li.node', function (e) {
+                                       e.preventDefault();
+                                       e.stopPropagation();
+                                       self.handleNodeClick($(this), true);
+                               })
+                               .on('change', 'input[type=checkbox]', function (e) {
+                                       self.handleNodeClick($(this).closest('li.node'), false);
+                               })
+                               .on('touchstart', 'li', function (event) {
+                                       $(this).addClass(self.CSS_GRADIENT_CLASS);
+                               })
+                               .on('touchend touchmove', 'li', function (event) {
+                                       $(this).removeClass(self.CSS_GRADIENT_CLASS);
+                               });
+
+                       $('.selectAll input').on('change', this.handleSelectAllChange.bind(this));
+
+                       // navbar
+                       $('#navbar').on('click', 'span', function () {
+                               var uri = $(this).attr('uri');
+                               if (uri === 'home') {
+                                       if (app.currentPath !== '') {
+                                               app.displayStorages();
+                                       }
+                               } else if (uri === app.model.currentPath) {
+                                       app.displayFolder(uri,true);
+                               } else {
+                                       if (self.editMode === true) {
+                                               self.handleCancelEditAction();
+                                       }
+                                       app.displayFolder(uri);
+                               }
+                       });
+
+                       // level up
+                       $('#levelUpBtn').on('click', function () {
+                               if (self.editMode === true) {
+                                       self.handleCancelEditAction();
+                               }
+                               app.goLevelUp();
+                       });
+
+                       $('#homeBtn').on('click', app.displayStorages.bind(app));
+
+                       // edit action
+                       $('#editActionBtn').on('click', this.handleEditAction.bind(this));
+
+                       // delete action
+                       $('#deleteActionBtn').on('click', this.handleDeleteAction.bind(this));
+
+                       // cancel edit
+                       $('#cancelActionBtn').on('click', function (e) {
+                               e.preventDefault();
+                               e.stopPropagation();
+                               self.handleCancelEditAction();
+                       });
+
+                       // copy action
+                       $('#copyActionBtn').on('click', this.handleCopyAction.bind(this));
+
+                       // move action
+                       $('#moveActionBtn').on('click', this.handleMoveAction.bind(this));
+
+                       // paste action
+                       $('a#pasteActionBtn').on('click', function () {
+                               if (!self.infoPopupVisibility) {
+                                       self.toggleInfoPopup();
+                                       setTimeout(app.pasteClipboard.bind(app), 100);
+                               }
+                               $("#morePopup").popup('close');
+                       });
+
+                       // remove active class
+                       $('[data-role = "tabbar"] li > a').on('click', function () {
+                               $(this).removeClass('ui-focus, ui-btn-active');
+                       });
+                       // exit
+                       $('.ui-myExit').on('click', app.exit);
+
+                       // add folder popup actions
+                       $('#addFolderPopup').on("popupafterclose", function () {
+                               // clear input value
+                               $('#newFolderName').val('New folder');
+                       });
+
+                       $('#newFolderName').on('click', function () {
+                               if ($(this).attr('value') === 'New folder') {
+                                       $(this).attr('value', '');
+                               }
+                       });
+
+                       $('#saveNewFolder').on('click', this.saveNewFolder.bind(this));
+                       $('#newFolderForm').on('submit', this.saveNewFolder.bind(this));
+               },
+
+               saveNewFolder: function Ui_saveNewFolder(e) {
+                       var folderName = $('#newFolderName').val().trim(), status = true,
+                               open = function () {
+                                       $("#addFolderPopup").popup('open', {
+                                               positionTo: "window"
+                                       });
+                               },
+                               self = this,
+                               buttons = $("#addFolderPopup .ui-popup-button-bg a"),
+                               activePopup;
+                       e.preventDefault();
+                       e.stopPropagation();
+                       buttons.addClass('ui-disabled');
+                       $("#addFolderPopup").one("popupafterclose", function () {
+                               if (folderName === '') {
+                                       self.alertPopup("Empty folder name", open);
+                                       status = false;
+                               } else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
+                                       self.alertPopup("The following special characters "
+                                               +"are not allowed: *./\\?:<>|'\"", open);
+                                       status = false;
+                               } else {
+                                       status = app.createDir(folderName, open);
+                               }
+                               buttons.removeClass('ui-disabled');
+                       });
+                       activePopup = $.mobile.popup.active;
+                       if (
+                               activePopup &&
+                               activePopup.element.attr('id') === 'addFolderPopup'
+                       ) {
+                               activePopup.close();
+                       }
+                       return status;
+               },
+
+               toggleInfoPopup: function () {
+                       var overlay = $('#overlay');
+
+                       if (this.infoPopupVisibility) {
+                               overlay.hide();
+                               document.onkeydown = null;
+                       } else {
+                               document.onkeydown = function(){return false;}
+                               overlay.show();
+                       }
+
+                       this.infoPopupVisibility = !this.infoPopupVisibility;
+               },
+
+               alertPopup: function (text, callback) {
+                       $("#alertPopup .text").text(text);
+                       $("#alertPopup").popup('open', {'positionTo': 'window'});
+                       if (callback instanceof Function) {
+                               $("#alertPopup").one("popupafterclose", function () {
+                                       callback();
+                               });
+                       }
+                       if (this.infoPopupVisibility) {
+                               this.toggleInfoPopup();
+                       }
+               },
+
+               confirmPopup: function (text, confirmCallback, completeCallback) {
+                       var popup = $("#confirmPopup");
+                       popup.find(".text").text(text);
+                       popup.popup('open', {positionTo: 'window'});
+                       popup.find(".confirm").one("click", function () {
+                               if (confirmCallback instanceof Function) {
+                                       confirmCallback();
+                               }
+                       });
+                       if (completeCallback instanceof Function) {
+                               popup.one('popupafterclose', function () {
+                                       completeCallback();
+                               });
+                       }
+               },
+
+               clearTabbars: function Ui_clearTabbars() {
+                       $('[data-role = "tabbar"] li > a').removeClass('ui-focus, ui-btn-active');
+               },
+
+               /**
+                * Handler for node click
+                * @param {File} node
+                * @param {boolean} toggleCheckbox
+                */
+               handleNodeClick: function Ui_handleNodeClick(node, toggleCheckbox) {
+                       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();
+                               this.refreshEditMenu();
+                       } else if (node.hasClass('folder')) {
+                               // otherwise display folder
+                               app.displayFolder(node.attr('uri'));
+                       } else {
+                               // file
+                               app.openFile(node.attr('uri'), node.attr('fullUri'));
+                       }
+               },
+
+               /**
+                * Handler for edit action
+                */
+               handleEditAction: function Ui_handleEditAction() {
+                       this.editMode = true;
+                       this.clearTabbars();
+                       $('.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, #fileList > li > span.nodename')
+                               .animate({'width': '70%'});
+                       this.showEditCheckBoxes();
+               },
+
+               /**
+                * Handler for cancel edit action
+                */
+               handleCancelEditAction: function Ui_handleCancelEditAction() {
+                       this.editMode = false;
+                       this.clearTabbars();
+                       $('div.editTabbar').hide();
+                       $('.standardTabbar').show();
+                       $('#fileList .folder .nodename,  #fileList > li > span.nodename')
+                               .animate({'width': '75%'});
+                       this.hideEditCheckBoxes();
+                       if (this.isFileListEmpty()) {
+                               $('#editActionBtn').addClass('vhidden').blur();
+                       }
+               },
+
+               /**
+                * Handler for delete action
+                */
+               handleDeleteAction: function Ui_handleDeleteAction(e) {
+                       var nodesToDelete = [],
+                               $rowElement,
+                               self = this,
+                               conf;
+
+                       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);
+                                               $('ul#fileList input:checkbox:checked').remove();
+                                               self.refreshEditMenu();
+                                       }
+                               },
+                               function () {
+                                       self.clearTabbars();
+                               }
+                       );
+               },
+
+               /**
+                * Handler for copy action
+                */
+               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'));
+                               });
+                               app.saveToClipboard(paths, app.clipboard.COPY_MODE_ID);
+                       }
+               },
+
+               /**
+                * Handler for move action
+                */
+               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'));
+                               });
+                               app.saveToClipboard(paths, app.clipboard.MOVE_MODE_ID);
+                       }
+               },
+
+               /**
+                * Handler for paste action
+                */
+               handlePasteAction: function 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) {
+                       var len = nodes.length, nodeName, i;
+
+                       this.updateNavbar('');
+                       $('#fileList').empty();
+
+                       for (i = 0; i < len; i = i + 1) {
+                               nodeName = nodes[i].label.trim();
+                               if (nodeName !== ''
+                                               && (nodes[i].type === 0 || nodes[i].type === 'INTERNAL')
+                                               && nodeName.indexOf('wgt-') === -1
+                                               && $.inArray(nodeName, this.lockedFolders) === -1
+                                       ) {
+                                       if (!this.root) {
+                                               app.model.isStorageExists(nodeName,
+                                                       app.ui.prepareFolderRow.bind(app.ui, i, nodeName), null);
+                                       } else {
+                                               this.prepareFolderRow(i, nodeName);
+                                       }
+                               }
+                       }
+
+                       $('#levelUpBtn').addClass('vhidden');
+                       $('#homeBtn').addClass('vhidden');
+
+                       $('#editActionBtn').addClass('vhidden').blur();
+                       $('#moreActionBtn').addClass('vhidden').blur();
+                       $('h1#mainTitle').html('Media');
+
+                       if (this.editMode) {
+                               this.scrollContentTo(0);
+                       }
+
+                       this.resetDefaultCheckBoxLabelEvents();
+                       this.hideSelectAllArea();
+                       this.handleCancelEditAction();
+
+                       if (this.infoPopupVisibility) {
+                               this.toggleInfoPopup();
+                       }
+               },
+
+               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)
+                *
+                * @param {File} x
+                * @param {File} y
+                * @returns {Number}
+                */
+               fileComparison: function fileComparison(x, y) {
+                       if(x.isDirectory !== y.isDirectory) {
+                               return x.isDirectory ? -1 : 1;
+                       }
+                       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, refresh) {
+                       var len = nodes.length,
+                               listElements = [this.templateManager.get('levelUpRow')],
+                               nodeName,
+                               checkedRows = [],
+                               checkedRowsLen,
+                               i;
+                       refresh = refresh || false;
+
+                       // update title
+                       this.updateTitle(this.templateManager.modifiers.escape(folderName));
+                       // update navbar
+                       this.updateNavbar(this.templateManager.modifiers.escape(folderName));
+                       this.refreshPasteActionBtn();
+
+                       nodes.sort(this.fileComparison);
+
+                       // render nodes
+                       for (i = 0; i < len; i = i + 1) {
+                               nodeName = nodes[i].name;
+                               if (nodeName !== '') {
+                                       if (nodes[i].isDirectory) {
+                                               // folder
+                                               listElements.push(this.templateManager.get('folderRow', {
+                                                       id: i,
+                                                       name: nodeName,
+                                                       uri: nodes[i].fullPath,
+                                                       fullUri: nodes[i].toURI()
+                                               }));
+                                       } else {
+                                               // file
+                                               listElements.push(this.templateManager.get('fileRow', {
+                                                       id: i,
+                                                       name: nodeName,
+                                                       uri: nodes[i].fullPath,
+                                                       fullUri: nodes[i].toURI(),
+                                                       thumbnailURI: this.helpers.getThumbnailURI(nodeName, nodes[i])
+                                               }));
+                                       }
+                               }
+                       }
+
+                       if (listElements.length === 1) {
+                               // set content for empty folder
+                               listElements.push(this.templateManager.get('emptyFolder'));
+                               // hide edit button for empty content
+                               $('#editActionBtn').addClass('vhidden').blur();
+                               this.handleCancelEditAction();
+                       } else {
+                               $('#editActionBtn').removeClass('vhidden');
+                       }
+
+                       // scroll to top of list
+                       this.scrollContentTo(0);
+
+                       $('#levelUpBtn').removeClass('vhidden');
+                       $('#homeBtn').removeClass('vhidden');
+                       $('#moreActionBtn').removeClass('vhidden');
+
+                       if (refresh === true && this.editMode === true) {
+                               $.each($('#fileList .ui-checkbox input:checked'), function () {
+                                       checkedRows.push($(this).closest('li').attr('uri'));
+                               });
+                       }
+
+                       // update file list
+                       $('#fileList').html(listElements.join(''))
+                               .trigger('refresh')
+                               .trigger('create');
+
+                       if (this.editMode === true) {
+                               $('.selectAll').show();
+                               $('#fileList .folder .nodename, #fileList > li > span.nodename')
+                                       .css('width', '70%');
+                               $('ul#fileList > li').css('paddingLeft', '2rem');
+                               $('.my-ui-checkbox').removeClass('hidden');
+
+                               if (refresh === true) {
+                                       checkedRowsLen = checkedRows.length;
+                                       if (checkedRowsLen) {
+                                               if (checkedRowsLen !== $('#fileList .ui-checkbox input').length) {
+                                                       this.setCheckboxValue('.selectAll input', false);
+                                               }
+                                               // restore checked checkboxes
+                                               for (i = 0; i < checkedRowsLen; i += 1) {
+                                                       this.setCheckboxValue(
+                                                               '#' +
+                                                               $('#fileList [uri="' +
+                                                               checkedRows[i] +
+                                                               '"]').attr('id') +
+                                                               ' input:checkbox',
+                                                               'checked'
+                                                       );
+                                               }
+
+                                               // if there are no checked checkboxes
+                                               if (!$('#fileList .ui-checkbox input:checked').length) {
+                                                       this.clearDeleteMode();
+                                               }
+                                       } else {
+                                               this.clearDeleteMode();
+                                       }
+                               }
+                       } else {
+                               $('.selectAll').hide();
+                               $('#fileList .folder .nodename, #fileList > li > span.nodename')
+                                       .css('width', '75%');
+                               $('ul#fileList > li').css('paddingLeft', '0');
+                               $('.my-ui-checkbox').addClass('hidden');
+                               this.clearDeleteMode();
+                       }
+                       if (!refresh) this.hideSelectAllArea();
+
+                       if (this.infoPopupVisibility) {
+                               this.toggleInfoPopup();
+                       }
+
+                       this.refreshSelectAllStatus();
+               },
+
+               /**
+                * Clear confirm popup and disable action buttons
+                */
+               clearDeleteMode: function Ui_clearDeleteMode () {
+                       if (
+                               $.mobile.popup.active &&
+                               $.mobile.popup.active.element.attr('id') === 'confirmPopup'
+                               ) {
+                                       $.mobile.popup.active.close();
+                       }
+                       this.disableControlBarButtons($('div.editTabbar'),
+                               [this.EDIT_TABBAR_DELETE_ACTION,
+                                this.EDIT_TABBAR_COPY_ACTION,
+                                this.EDIT_TABBAR_MOVE_ACTION]
+                       );
+               },
+
+               /**
+                * Toggle a checkbox associated with a given list element
+                * @param {jQuery} listElement
+                */
+               toggleCheckBoxState: function Ui_toggleCheckBoxState(listElement) {
+                       var checkboxInput = null;
+
+                       checkboxInput = listElement.find('form > div.ui-checkbox input');
+                       this.setCheckboxValue(checkboxInput, !checkboxInput.attr('checked'));
+               },
+
+               /**
+                * Shows item checkboxes and topbar with select all option
+                */
+               showEditCheckBoxes: function Ui_showEditCheckBoxes() {
+                       var self = this;
+
+                       this.showSelectAllArea();
+
+                       $('ul#fileList > li').animate({paddingLeft: '2rem'}, 500, 'swing', function () {
+                               self.editMode = true;
+                               $('.my-ui-checkbox').removeClass('hidden');
+                       });
+               },
+
+               /**
+                * Hides item checkboxes and topbar with select all option
+                * All checkboxes are auto uncheked
+                */
+               hideEditCheckBoxes: function Ui_hideEditCheckBoxes() {
+                       var self = this;
+
+                       this.hideSelectAllArea(); // hide select all option topbar
+
+                       $('ul#fileList > li').animate({paddingLeft: '0'}, 200, 'swing', function () {
+                               $('.my-ui-checkbox').addClass('hidden');
+                               $.mobile.activePage.page('refresh');
+                       });
+
+                       // uncheck all checkboxes
+                       $('ul#fileList input[type=checkbox]').each(function (index) {
+                               self.setCheckboxValue(this, false);
+                       });
+
+                       //uncheck select all input
+                       this.setCheckboxValue('.ui-header .selectAll input', false);
+               },
+
+               /**
+                * 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() {
+                       this.saveHeights();
+                       $('.selectAll').show();
+                       $.mobile.activePage.page('refresh');
+                       this.changeContentScrollPosition();
+               },
+
+               /**
+                * Hides topbar with select all option
+                */
+               hideSelectAllArea: function Ui_hideSelectAllArea() {
+                       this.saveHeights();
+                       $('.selectAll').hide();
+                       $.mobile.activePage.page('refresh');
+                       this.changeContentScrollPosition();
+               },
+
+               /**
+                * Enable specified options for tabbar
+                * @param {object} tabbar
+                * @param {array} enableOptions options to enable
+                */
+               enableControlBarButtons: function Ui_enableControlBarButtons(tabbar, enableOptions) {
+                       var i = 0,
+                               len = enableOptions.length;
+
+                       for (i = 0; i < len; i += 1) {
+                               tabbar.tabbar('enable', enableOptions[i]);
+                       }
+               },
+
+               /**
+                * Disable specified options for tabbar
+                * @param {object} tabbar controlbar
+                * @param {array} disableOptions options to enable
+                */
+               disableControlBarButtons: function Ui_disableControlBarButtons(tabbar, disableOptions) {
+                       var i = 0,
+                               len = disableOptions.length;
+
+                       for (i = 0; i < len; i += 1) {
+                               tabbar.tabbar('disable', disableOptions[i]);
+                       }
+               },
+
+               /**
+                * @param {string} path
+                */
+               updateTitle: function Ui_updateTitle(path) {
+                       var regexp = new RegExp('([^\/])+$', 'g'),
+                               match = path.match(regexp),
+                               lastDir = match[0] || '(dir)';
+                       $('h1#mainTitle').html(lastDir);
+               },
+
+               /**
+                * @param {string} path
+                */
+               updateNavbar: function Ui_updateNavbar(path) {
+                       var html = ['<span uri="home">Media</span>'],
+                               splitted,
+                               len,
+                               i;
+
+                       if (typeof path === 'string' && path !== '') {
+                               splitted = path.split('/');
+                               len = splitted.length;
+
+                               for (i = 0; i < len; i = i + 1) {
+                                       html.push('<span uri="' + splitted.slice(0, i + 1).join('/') + '">' + splitted[i] + '</span>');
+                               }
+                       }
+                       $('#navbar').html(html.join(' > '));
+               },
+
+               handleSelectAllChange: function Ui_handleSelectAllChange() {
+                       var $selectAllInput = $('.ui-header .selectAll .ui-checkbox input'),
+                               self = this;
+                       $selectAllInput.data('checkboxradio').refresh();
+
+                       if ($selectAllInput.is(':checked')) {
+                               // check all checkboxes
+                               $('ul#fileList input[type=checkbox]').each(function (index) {
+                                       self.setCheckboxValue(this, true);
+                               });
+
+                               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) {
+                                       self.setCheckboxValue(this, false);
+                               });
+
+                               this.disableControlBarButtons($('.editTabbar'), [this.EDIT_TABBAR_DELETE_ACTION, this.EDIT_TABBAR_COPY_ACTION, this.EDIT_TABBAR_MOVE_ACTION]);
+                       }
+               },
+
+               /**
+                *
+                */
+               refreshSelectAllStatus: function 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) {
+                               // all nodes checked
+                               this.setCheckboxValue($selectAllInput, true);
+                       } else {
+                               // some node is not checked
+                               this.setCheckboxValue($selectAllInput, false);
+                       }
+               },
+
+               /**
+                * 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() {
+                       $('div.ui-checkbox > label')
+                               .unbind('vmousedown')
+                               .unbind('vmouseup')
+                               .unbind('vmouseover')
+                               .unbind('vclick');
+               },
+
+               /**
+                * Remove html node element from list
+                * @param {string} nodeId node id
+                */
+               removeNodeFromList: function 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() {
+                       if (app.emptyClipboard()) {
+                               $('#pasteActionBtnRow').addClass('hidden');
+                       } else {
+                               $('#pasteActionBtnRow').removeClass('hidden');
+                       }
+               },
+
+               isFileListEmpty: function Ui_isFileListEmpty() {
+                       return ($('ul#fileList').children('.node').length < 1);
+               },
+
+               setCheckboxValue: function Ui_setCheckboxValue (element, value) {
+                       var $element = $(element),
+                               checkboxradio = $element.data('checkboxradio');
+
+                       $(element).attr('checked', value);
+                       if (checkboxradio) {
+                               checkboxradio.refresh();
+                       }
+
+               }
+       };
+}());
diff --git a/project/js/app.ui.templateManager.js b/project/js/app.ui.templateManager.js
new file mode 100644 (file)
index 0000000..e2a440a
--- /dev/null
@@ -0,0 +1,136 @@
+/*global tizen, $, app, ModifierManager */
+/**
+ * @class TemplateManager
+ */
+function TemplateManager() {
+       'use strict';
+       this.init();
+}
+
+(function () { // strict mode wrapper
+       'use strict';
+       TemplateManager.prototype = {
+
+               /**
+                * Template cache
+                */
+               cache: {},
+
+               /**
+                * UI module initialisation
+                */
+               init: function init() {
+                       this.modifiers = new ModifierManager().getAll();
+               },
+
+               /**
+                * Returns template html (from cache)
+                * @param {string} tplName
+                * @param {string} tplParams
+                */
+               get: function TemplateManager_get(tplName, tplParams) {
+                       if (this.cache[tplName] !== undefined) {
+                               return this.getCompleted(this.cache[tplName], tplParams);
+                       }
+                       return '';
+               },
+
+               /**
+                * Load templates to cache
+                * @param {string} tplNames
+                * @param {function} onSuccess
+                */
+               loadToCache: function TemplateManager_loadToCache(tplNames, onSuccess) {
+                       var self = this,
+                               cachedTemplates = 0,
+                               tplName,
+                               tplPath;
+
+                       if ($.isArray(tplNames)) {
+
+                               // for each template
+                               $.each(tplNames, function (index, fileName) {
+
+                                       // cache template html
+                                       if (self.cache[fileName] === undefined) {
+                                               tplName = [fileName, app.config.get('templateExtension')].join('');
+                                               tplPath = [app.config.get('templateDir'), tplName].join('/');
+
+                                               $.ajax({
+                                                       url: tplPath,
+                                                       cache: true,
+                                                       dataType: 'html',
+                                                       async: true,
+                                                       success: function (data) {
+                                                               // increase counter
+                                                               cachedTemplates += 1;
+
+                                                               // save to cache
+                                                               self.cache[fileName] = data;
+
+                                                               // if all templates are cached launch callback
+                                                               if (cachedTemplates >= tplNames.length && typeof onSuccess === 'function') {
+                                                                       onSuccess();
+                                                               }
+                                                       },
+                                                       error: function (jqXHR, textStatus, errorThrown) {
+                                                               console.error('templateManagerError: ' + errorThrown);
+                                                       }
+                                               });
+                                       } else {
+                                               // template is already cached
+                                               cachedTemplates += 1;
+                                               // if all templates are cached launch callback
+                                               if (cachedTemplates >= tplNames.length && typeof onSuccess === 'function') {
+                                                       onSuccess();
+                                               }
+                                       }
+                               });
+
+                       }
+               },
+
+               /**
+                * Returns template completed by specified params
+               * @param {string} tplHtml
+               * @param {string} tplParams
+                */
+               getCompleted: function TemplateManager_getCompleted(tplHtml, tplParams) {
+                       var tplParam;
+
+                       for (tplParam in tplParams) {
+                               if (tplParams.hasOwnProperty(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 + '\\|(.+?)%'),
+                               specRegExp = new RegExp('\\$','g'),
+                               modifier;
+
+                       if (content && (typeof content === 'string')) {
+                               content = content.replace(specRegExp, '$$$$');
+                       }
+
+                       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;
+               }
+       };
+
+}());
\ No newline at end of file
diff --git a/project/js/app.ui.templateManager.modifiers.js b/project/js/app.ui.templateManager.modifiers.js
new file mode 100644 (file)
index 0000000..95e9d0a
--- /dev/null
@@ -0,0 +1,47 @@
+/*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();
+                       },
+                       escapeEncies: function escapeEncies(str) {
+                               var tagsToReplace = {
+                                       '&': '&amp;',
+                                       '<': '&lt;',
+                                       '>': '&gt;',
+                                       '"': '&quot;'
+                               };
+                               return str.replace(/[&<>\"]/g, function(tag) {
+                                       return tagsToReplace[tag] || tag;
+                               });
+                       }
+               }
+       };
+}());
\ No newline at end of file
diff --git a/project/js/main.js b/project/js/main.js
new file mode 100644 (file)
index 0000000..360b951
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *      Copyright 2013  Samsung Electronics Co., Ltd
+ *
+ *      Licensed under the Flora License, Version 1.1 (the "License");
+ *      you may not use this file except in compliance with the License.
+ *      You may obtain a copy of the License at
+ *
+ *              http://floralicense.org/license/
+ *
+ *      Unless required by applicable law or agreed to in writing, software
+ *      distributed under the License is distributed on an "AS IS" BASIS,
+ *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *      See the License for the specific language governing permissions and
+ *      limitations under the License.
+ */
+
+/*jslint devel: true*/
+/*global $, tizen, App  */
+
+/**
+ * This file acts as a loader for the application and its dependencies
+ *
+ * First, the 'app.js' script is loaded .
+ * Then, scripts defined in 'app.requires' are loaded.
+ * Finally, the app is initialised - the app is instantiated ('app = new App()')
+ * and 'app.init()' is called.
+ */
+
+
+var app = null;
+
+(function () { // strict mode wrapper
+       'use strict';
+
+       ({
+               /**
+                * Loader init - load the App constructor
+                */
+               init: function init() {
+                       var self = this;
+                       $.getScript('js/app.js')
+                               .done(function () {
+                                       // once the app is loaded, create the app object
+                                       // and load the libraries
+                                       app = new App();
+                                       self.loadLibs();
+                               })
+                               .fail(this.onGetScriptError);
+               },
+
+               /**
+                * Load dependencies
+                */
+               loadLibs: function loadLibs() {
+                       var loadedLibs = 0;
+                       if ($.isArray(app.requires)) {
+                               $.each(app.requires, function (index, filename) {
+                                       $.getScript(filename)
+                                               .done(function () {
+                                                       loadedLibs += 1;
+                                                       if (loadedLibs >= app.requires.length) {
+                                                               // All dependencies are loaded - initialise the app
+                                                               app.init();
+                                                       }
+                                               })
+                                               .fail(this.onGetScriptError);
+                               });
+                       }
+               },
+
+               /**
+                * Handle ajax errors
+                */
+               onGetScriptError: function onGetScriptError(e, jqxhr, setting, exception) {
+                       app.ui.alertPopup('An error occurred: ' + e.message);
+               }
+       }).init(); // run the loader
+}());
diff --git a/project/templates/emptyFolder.tpl b/project/templates/emptyFolder.tpl
new file mode 100644 (file)
index 0000000..da09356
--- /dev/null
@@ -0,0 +1 @@
+<div data-role="nocontents" id="nocontents" data-text1="Folder is empty"></div>
\ No newline at end of file
diff --git a/project/templates/fileRow.tpl b/project/templates/fileRow.tpl
new file mode 100644 (file)
index 0000000..38f6b03
--- /dev/null
@@ -0,0 +1,5 @@
+<li class="node file 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="%thumbnailURI%" class="ui-li-bigicon"/>
+       <span class="ui-li-text-main nodename">%name|escape%</span>
+</li>
\ No newline at end of file
diff --git a/project/templates/folderRow.tpl b/project/templates/folderRow.tpl
new file mode 100644 (file)
index 0000000..ba82018
--- /dev/null
@@ -0,0 +1,6 @@
+<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>
+       </div>
+</li>
\ No newline at end of file
diff --git a/project/templates/levelUpRow.tpl b/project/templates/levelUpRow.tpl
new file mode 100644 (file)
index 0000000..ddbc7cf
--- /dev/null
@@ -0,0 +1,3 @@
+<li class="levelUp">
+       <span class="ui-li-text-main nodename">..</span>
+</li>
\ No newline at end of file
diff --git a/project/templates/main.tpl b/project/templates/main.tpl
new file mode 100644 (file)
index 0000000..d5d17e7
--- /dev/null
@@ -0,0 +1,83 @@
+       <div data-role="page" id="main">
+               <div data-role="header" data-position="fixed">
+                       <h1 id="mainTitle"></h1>
+                       <a id="homeBtn">Home</a>
+                       <a id="levelUpBtn">Up</a>
+                       <div id="navbar"></div>
+                       <div class="selectAll" style="display: none">
+                               <form>
+                                       <input type="checkbox" name="tizen-check1-1" id="normal-check1" />
+                                       <label for="normal-check1" class="select_all">&nbsp;Select&nbsp;all</label>
+                               </form>
+                       </div>
+               </div>
+
+               <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">
+                                       <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="cancelNewFolder" id="btn_textbox_popup_cancel" data-rel="back" data-inline="true">Cancel</a>
+                                       <a data-role="button" id="saveNewFolder" data-rel="back" data-inline="true">Save</a>
+                               </div>
+                       </div>
+                       <div data-role="popup" id="alertPopup" class="ui-corner-all">
+                               <p class="text"></p>
+                               <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">
+                               <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">CANCEL</a>
+                                       <a data-role="button" data-rel="back" data-inline="true" class="confirm">OK</a>
+                               </div>
+                       </div>
+               </div>
+
+               <div data-role="footer" data-position="fixed">
+                       <div class="ui-myToolBar">
+                               <div data-role="tabbar" class="standardTabbar">
+                                       <ul>
+                                               <li><a id="editActionBtn" href="#">Edit</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>
+                                       </ul>
+                               </div>
+                               <div data-role="tabbar" class="editTabbar" style="display: none">
+                                       <ul>
+                                               <li><a id="deleteActionBtn" href="#">Delete</a></li>
+                                               <li><a id="moveActionBtn" href="#">Move</a></li>
+                                               <li><a id="copyActionBtn" href="#">Copy</a></li>
+                                               <li><a id="cancelActionBtn" href="#">Cancel</a></li>
+                                       </ul>
+                               </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
diff --git a/tizen-app-template.xml b/tizen-app-template.xml
new file mode 100755 (executable)
index 0000000..19897f8
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<tizen-app-template xmlns="http://www.tizen.org/tizen-app-template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" template-version="" sdk-version="" icon32="tizen_32.png" icon64="tizen_64.png" xsi:schemaLocation="http://www.tizen.org/tizen-app-template tizen-app-template.xsd ">
+    <template-name>FileManager</template-name>
+    <widget-type>TIZEN</widget-type>
+    <build-property key="usedLibraryType" value="WebUIFramework"/>
+    <description-file-name>description.xml</description-file-name>
+    <options>
+        <supportLibraries>
+          <library name="Tizen Web UI Framework"/>
+        </supportLibraries>
+    </options>
+</tizen-app-template>
diff --git a/tizen_32.png b/tizen_32.png
new file mode 100644 (file)
index 0000000..61f35c0
Binary files /dev/null and b/tizen_32.png differ
diff --git a/tizen_64.png b/tizen_64.png
new file mode 100644 (file)
index 0000000..b188083
Binary files /dev/null and b/tizen_64.png differ