--- /dev/null
+<?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>
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/file-manager" version="2.1.0" viewmodes="maximized">
- <tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.1"/>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/file-manager" version="2.2.0" viewmodes="maximized">
+ <tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.2"/>
<icon src="icon.png"/>
<name>FileManager</name>
<tizen:privilege name="http://tizen.org/privilege/content.read"/>
}
#mainTitle {
- width: 260px;
+ width: 255px;
text-transform: uppercase;
}
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- background-color: #EEE;
+ background-color: rgba(255, 255, 255, 0.5);
border-top: solid 1px #DDD;
text-align: left;
}
font-size: 18px;
}
+#morePopup td.text a {
+ color:#FFF;
+ text-decoration:none;
+}
+
#morePopup td.text {
padding: 5px;
}
#morePopup {
margin: 2px;
}
+#alertPopup .text {
+ text-align:left;
+ padding:20px;
+}
+
+#confirmPopup .text {
+ text-align:left;
+ padding:20px;
+}
.ui-header.ui-bar-s .ui-btn.standard {
width: 100%;
#homeBtn,
#levelUpBtn {
- top:20px;
+ top:0px;
}
.ui-li-1line-bigicon1.ui-li.ui-li-static.ui-body-s.ui-li-has-thumb {
.ui-footer .ui-btn-text {
text-transform: uppercase;
+}
+
+.ui-tabbar:not(.ui-tabbar-persist) a.ui-btn-active .ui-btn-text, .ui-tabbar:not(.ui-tabbar-persist) .ui-btn-show-style .ui-btn-text {
+ border:none;
}
\ No newline at end of file
*/
addEvents: function App_addEvents() {
var self = this;
- document.addEventListener('webkitvisibilitychange', function () { self.refreshCurrentPage(); });
+ document.addEventListener('webkitvisibilitychange', function () {
+ self.refreshCurrentPage();
+ });
// workaround: page refresh for on/off keyboard
window.addEventListener('softkeyboardchange', function () {
$.mobile.activePage.page('refresh');
/**
* creates new dir in currently viewed dir
* @param {string} dirName
+ * @return {boolean} return status
*/
createDir: function App_createDir(dirName) {
-
+ var status = true;
if (this.currentDirPath !== '') {
try {
this.currentDirHandle.createDirectory(dirName);
} catch (e) {
- alert(e.message);
+ status = false;
+ app.ui.alertPopup(e.message);
}
this.refreshCurrentPage();
} else {
- alert("You can't create new nodes in the main view");
+ status = false;
+ app.ui.alertPopup("You can't create new nodes in the main view");
}
+ return status;
},
/**
if (clipboardLength > 0) {
this.clipboard.setMode(mode);
- alert('Data saved in clipboard');
+ app.ui.alertPopup('Data saved in clipboard');
this.ui.clearTabbars();
} else {
- alert('Error occured. Data has not been saved in clipboard');
+ app.ui.alertPopup('Error occured. Data has not been saved in clipboard');
}
this.ui.refreshPasteActionBtn(this.clipboard.isEmpty());
var clipboardData = this.clipboard.get();
if (clipboardData.length === 0) {
- alert('Clipboard is empty');
+ app.ui.alertPopup('Clipboard is empty');
return false;
}
}
},
+ refreshContent: function (path) {
+ path = path.charAt(0).toUpperCase() + path.substr(1);
+ path = '/opt/usr/media/' + path;
+ tizen.content.scanFile(path, null, null);
+ },
+
/**
* @param {File[]} nodes Collection of node objects
* @param {File} dir Directory handle
onDeleteNodeSuccess.bind(this, nodes[i].id, false),
onDeleteNodeError
);
+ this.refreshContent(nodes[i].uri);
}
}
},
* @param {function} onSuccess callback
*/
copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
- var len = paths.length,
+ var len = paths.length, self = this,
copied = 0,
onCopyNodeSuccess = function () {
copied += 1;
}
},
onCopyNodeFailure = function () {
- alert('Copying error');
+ app.ui.alertPopup('Copying error');
},
i,
sourceName,
this.systemIO.getFilesList(dir, function (filesList) {
for (i = 0; i < len; i = i + 1) {
if (destinationPath.indexOf(paths[i]) !== -1) {
- alert('Copying error');
+ app.ui.alertPopup('Copying error');
return;
}
}
try {
dir.copyTo(paths[i], destinationPath + '/' + sourceName, true, onCopyNodeSuccess, onCopyNodeFailure);
+ self.refreshContent(destinationPath + '/' + sourceName);
} catch (e) {
console.error(e);
}
* @param {function} onSuccess callback
*/
moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
- var len = paths.length,
+ var len = paths.length, self = this,
moved = 0,
onMoveNodeSuccess = function () {
moved += 1;
}
},
onMoveNodeFailure = function () {
- alert('Moving error');
+ app.ui.alertPopup('Moving error');
},
i,
sourceName,
this.systemIO.getFilesList(dir, function (filesList) {
for (i = 0; i < len; i = i + 1) {
if (destinationPath.indexOf(paths[i]) !== -1) {
- alert('Moving error');
+ app.ui.alertPopup('Moving error');
return;
}
}
decision = true;
sourceName = paths[i].split('/').pop();
- if ($.inArray(sourceName, filesList) !== -1) {
- decision = confirm('A file with (' + sourceName + ') name already exists.\nDo you want to overwrite it?');
- }
-
- if (decision) {
+ try {
dir.moveTo(paths[i], destinationPath + '/' + sourceName, true, onMoveNodeSuccess, onMoveNodeFailure);
+ self.refreshContent(paths[i]);
+ self.refreshContent(destinationPath + '/' + sourceName);
+ } catch (e) {
+ console.error(e);
}
}
});
*/
addEvents: function Ui_addEvents() {
var self = this;
+
+ document.addEventListener('webkitvisibilitychange', function (event) {
+ if (document.webkitVisibilityState === 'visible') {
+ $.mobile.activePage.page('refresh');
+ }
+ });
+
+ document.addEventListener('tizenhwkey', function(e) {
+ var uri = $('#navbar span+span').attr('uri');
+ if (e.keyName == "back") {
+ if (!uri) {
+ tizen.application.getCurrentApplication().exit();
+ } else {
+ app.goLevelUp();
+ }
+ }
+ });
+
// touch events for all nodes
$('ul#fileList')
.on('tap', 'li.levelUp', function () {
if (uri === 'home') {
app.displayStorages();
} else {
- app.displayFolder(uri);
+ app.displayFolder(uri,true);
}
});
$('#moveActionBtn').on('tap', this.handleMoveAction.bind(this));
// paste action
- $('a#pasteActionBtn').on('tap', app.pasteClipboard.bind(app));
+ $('a#pasteActionBtn').on('tap', function () {
+ app.pasteClipboard.bind(app)();
+ $("#morePopup").popup('close');
+ });
// remove active class
$('[data-role = "tabbar"] li > a').on('click', function () {
$('#saveNewFolder').on('tap', this.saveNewFolder.bind(this));
$('#newFolderForm').on('submit', this.saveNewFolder.bind(this));
-
-
- $('#newFolderActionBtn, #pasteActionBtn').on('tap', function (e) {
-// $('a#pasteActionBtn').off('tap', app.pasteClipboard.bind(app));
- setTimeout(function () {
-// $('a#pasteActionBtn').on('tap', app.pasteClipboard.bind(app));
- $('#morePopup').popupwindow('close');
- }, 700);
- });
-
- /* workaround for UIFW & webkit scroll*/
- //$('.ui-page').css('min-height', 0);
},
saveNewFolder: function Ui_saveNewFolder(e) {
e.preventDefault();
e.stopPropagation();
if (folderName === '') {
- alert("Empty folder name");
+ this.alertPopup("Empty folder name");
status = false;
} else if (folderName.match(/[\*\.\/\\\?\"\'\:<>|]/)) {
- alert("The following special characters are not allowed: *./\\?:<>|'\"");
+ this.alertPopup("The following special characters are not allowed: *./\\?:<>|'\"");
status = false;
} else {
- app.createDir(folderName);
- $("#addFolderPopup").popup('close');
+ status = app.createDir(folderName);
+ if (status === true) {
+ $("#addFolderPopup").popup('open');
+ setTimeout(function () {
+ $("#addFolderPopup").popup('close');
+ }, 200);
+ }
}
return status;
},
+ alertPopup: function (text) {
+ $("#alertPopup .text").text(text);
+ setTimeout(function () {
+ $("#alertPopup").popup('close');
+ setTimeout(function () {
+ $("#alertPopup").popup('open');
+ }, 200);
+ }, 200);
+ },
+
+ confirmPopup: function (text, confirmCallback, completeCallback) {
+ $("#confirmPopup .text").text(text);
+ setTimeout(function () {
+ $("#confirmPopup").popup('close');
+ setTimeout(function () {
+ $("#confirmPopup").popup('open');
+ $("#confirmPopup .confirm").one("tap", function () {
+ $("#confirmPopup").popup('close');
+ if (confirmCallback instanceof Function) {
+ confirmCallback();
+ }
+ });
+ if (completeCallback instanceof Function) {
+ $("#confirmPopup").one('popupafterclose', function () {
+ completeCallback();
+ });
+ }
+ }, 200);
+ }, 200);
+ },
+
clearTabbars: function Ui_clearTabbars() {
$('[data-role = "tabbar"] li > a').removeClass('ui-focus, ui-btn-active');
},
$('.standardTabbar').show();
$('#fileList .folder .nodename').animate({'width': '75%'});
this.hideEditCheckBoxes();
+ if (this.isFileListEmpty()) {
+ $('#editActionBtn').addClass('vhidden');
+ }
},
/**
handleDeleteAction: function Ui_handleDeleteAction() {
var nodesToDelete = [],
$rowElement,
+ self = this,
conf;
$('ul#fileList input:checkbox:checked').each(function (index) {
});
});
- conf = confirm('Selected nodes will be deleted. Are you sure?');
- this.clearTabbars();
-
- if (nodesToDelete.length > 0 && conf) {
- app.deleteNodes(nodesToDelete);
- this.scrollContentTo(0);
- $('ul#fileList input:checkbox:checked').remove();
- this.refreshEditMenu();
- }
+ this.confirmPopup('Selected nodes will be deleted. Are you sure?',
+ function () {
+ if (nodesToDelete.length > 0) {
+ app.deleteNodes(nodesToDelete);
+ self.scrollContentTo(0);
+ $('ul#fileList input:checkbox:checked').remove();
+ self.refreshEditMenu();
+ }
+ },
+ function () {
+ self.clearTabbars();
+ }
+ );
},
/**
refresh = refresh || false;
// update title
- this.updateTitle(folderName);
+ this.updateTitle(this.templateManager.modifiers.escape(folderName));
// update navbar
- this.updateNavbar(folderName);
+ this.updateNavbar(this.templateManager.modifiers.escape(folderName));
this.refreshPasteActionBtn();
nodes.sort(this.fileComparison);
if (listElements.length === 1) {
// set content for empty folder
listElements.push(this.templateManager.get('emptyFolder'));
+ // hide edit button for empty content
+ $('#editActionBtn').addClass('vhidden');
+ } else {
+ $('#editActionBtn').removeClass('vhidden');
}
// scroll to top of list
$('#levelUpBtn').removeClass('vhidden');
$('#homeBtn').removeClass('vhidden');
- $('#editActionBtn').removeClass('vhidden');
$('#moreActionBtn').removeClass('vhidden');
if (refresh === true && this.editMode === true) {
$('ul#fileList > li').css('paddingLeft', '0');
$('.my-ui-checkbox').addClass('hidden');
}
+ this.hideSelectAllArea();
},
/**
} else {
$('#pasteActionBtnRow').removeClass('hidden');
}
+ },
+
+ isFileListEmpty: function Ui_isFileListEmpty() {
+ return ($('ul#fileList').children('.node').length < 1);
}
};
}());
modifiers: {
escape: function escape(str) {
return $('<span>').text(str).html();
+ },
+ escapeEncies: function escapeEncies(str) {
+ var tagsToReplace = {
+ '&': '&',
+ '<': '<',
+ '>': '>'
+ };
+ return str.replace(/[&<>]/g, function(tag) {
+ return tagsToReplace[tag] || tag;
+ });
}
}
};
* Handle ajax errors
*/
onGetScriptError: function onGetScriptError(e, jqxhr, setting, exception) {
- alert('An error occurred: ' + e.message);
+ app.ui.alertPopup('An error occurred: ' + e.message);
}
}).init(); // run the loader
}());
<li class="node file ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri%" fullUri="%fullUri%">
<form class="my-ui-checkbox hidden"><input type="checkbox" /></form>
<img src="%thumbnailURI%" class="ui-li-bigicon"/>
- <span class="ui-li-text-main nodename">%name%</span>
+ <span class="ui-li-text-main nodename">%name|escape%</span>
</li>
\ No newline at end of file
-<li class="node folder ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri%" fullUri="%fullUri%">
+<li class="node folder ui-li-1line-bigicon1" id="row%id%" label="%name%" uri="%uri|escapeEncies%" fullUri="%fullUri|escapeEncies%">
<form class="my-ui-checkbox hidden"><input type="checkbox" /></form>
<img src="images/folder.png" class="ui-li-bigicon" />
<span class="ui-li-text-main nodename">%name|escape%</span>
<a data-role="button" id="cancelNewFolder" id="btn_textbox_popup_cancel" data-rel="back" data-inline="true">Cancel</a>
</div>
</div>
+ <div data-role="popup" id="alertPopup" class="ui-corner-all">
+ <p class="text"></p>
+ <a href="#" data-role="button" data-inline="true" data-rel="back">OK</a>
+ </div>
+ <div data-role="popup" id="confirmPopup" class="ui-corner-all">
+ <p class="text"></p>
+ <a href="#" data-role="button" data-inline="true" class="confirm">OK</a>
+ <a href="#" data-role="button" data-inline="true" data-rel="back">CANCEL</a>
+ </div>
</div>
<div data-role="footer" data-position="fixed">
<div data-role="tabbar" class="standardTabbar">
<ul>
<li><a id="editActionBtn" href="#">Edit</a></li>
- <li><a id="moreActionBtn" href="#morePopup" data-rel="popupwindow">More</a></li>
+ <li><a id="moreActionBtn" href="#morePopup" data-rel="popup">More</a></li>
<li id="li-myExit">
<a id="a-myExit" href="#" class="ui-myExit">Exit</a>
</li>
<li><a id="cancelActionBtn" href="#">Cancel</a></li>
</ul>
</div>
- <div class="horizontal" id="morePopup" data-role="popupwindow" data-show-arrow="true">
- <table>
- <tr id="newFolderActionBtnRow">
- <td class="text">
- <a id="newFolderActionBtn" href="#addFolderPopup" class="newFolder" data-rel="popup" data-position-to="window" data-shadow="true">New folder</a>
- </td>
- </tr>
- <tr id="pasteActionBtnRow">
- <td class="text">
- <a id="pasteActionBtn" data-position-to="window" data-shadow="true">Paste to folder</a>
- </td>
- </tr>
- </table>
- </div>
+ </div>
+ <div id="morePopup" data-role="popup">
+ <table>
+ <tr id="newFolderActionBtnRow">
+ <td class="text">
+ <a id="newFolderActionBtn" href="#addFolderPopup" class="newFolder" data-rel="popup" data-position-to="window" data-shadow="true">New folder</a>
+ </td>
+ </tr>
+ <tr id="pasteActionBtnRow">
+ <td class="text">
+ <a id="pasteActionBtn" data-position-to="window" data-shadow="true">Paste to folder</a>
+ </td>
+ </tr>
+ </table>
</div>
</div>
</div>
\ No newline at end of file