<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/file-manager" version="2.2.0" viewmodes="maximized">
<tizen:application id="km8AETYhee.FileManager" package="km8AETYhee" required_version="2.2"/>
<icon src="icon.png"/>
- <name>FileManager</name>
+ <name>File manager</name>
<tizen:privilege name="http://tizen.org/privilege/content.read"/>
<tizen:privilege name="http://tizen.org/privilege/content.write"/>
<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
}
#mainTitle {
- width: 255px;
- text-transform: uppercase;
+ width: 210px;
}
#fileList > li {
}
.selectAll {
- padding-left: 12px;
+ padding-left: 6px;
display: inline-block;
}
-.selectAll span.ui-icon {
- top: 40% !important;
-}
-
.selectAll span.ui-btn-text {
- padding-left: 1.5rem !important;
+ padding-left: 2rem !important;
+ line-height: 40px;
}
#navbar {
#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 {
.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
+}
if (ext === '.jpg' || ext === '.png' || ext === '.gif') {
mime = 'image/*';
- } else if (ext === '.mp4' || ext === '.ogv' || ext === '.avi') {
+ } else if (ext === '.mp4' || ext === '.ogv' || ext === '.avi' || ext === '.wmv') {
mime = 'video/*';
- } else if (ext === '.mp3') {
- mime = 'audio/mp3';
+ } else if (ext === '.mp3' || ext === '.wma') {
+ mime = 'audio/*';
} else if (ext === '.txt' || ext === '.doc' || ext === '.html' || ext === '.ppt' || ext === '.xls' || ext === '.pdf') {
mime = ''; //mime = 'text/*';
}
}
};
}());
-
-(function ($) {
- 'use strict';
-
- function height(t, el) {
- return t.height() > el.height();
- }
- function width(t, el) {
- return t.width() > el.width();
- }
-
- $.fn.ellipsis = function () {
- return this.each(function () {
- var el, text, multiline, t, func;
- el = $(this);
- if (el.css("overflow") === "hidden") {
- text = el.html();
- multiline = el.hasClass('multiline');
- t = $(this.cloneNode(true))
- .hide()
- .css('position', 'absolute')
- .css('overflow', 'visible')
- .width(multiline ? el.width() : 'auto')
- .height(multiline ? 'auto' : el.height());
-
- el.after(t);
-
- func = multiline ? height : width;
-
- while (text.length > 0 && func(t, el)) {
- text = text.substr(0, text.length - 1);
- t.html(text + "...");
- }
-
- el.html(t.html());
- t.remove();
- }
- });
- };
-}(jQuery));
this.clipboard = new Clipboard();
this.initUi();
- this.addEvents();
},
/**
},
/**
- * Add pages events
- */
- addEvents: function App_addEvents() {
- var self = this;
- document.addEventListener('webkitvisibilitychange', function () {
- self.refreshCurrentPage();
- });
- // workaround: page refresh for on/off keyboard
- window.addEventListener('softkeyboardchange', function () {
- $.mobile.activePage.page('refresh');
- });
- },
-
- /**
* Displays media storages
*/
displayStorages: function App_displayStorages() {
/**
* Triggers refresh current page
*/
- refreshCurrentPage: function App_refreshCurrentPage() {
+ refreshCurrentPage: function App_refreshCurrentPage(refresh) {
+ refresh = refresh || false;
if (this.currentPath !== '') {
- this.displayFolder(this.currentPath, true);
+ app.model.isStorageExists(this.currentPath,
+ app.displayFolder.bind(app, app.model.currentPath, refresh),
+ function () {
+ app.displayStorages();
+ app.ui.alertPopup("'" + app.model.currentPath
+ + "'\nnot found");
+ });
} else {
this.displayStorages();
}
storages: [{label: 'root', type: 'INTERNAL'}],
/**
+ * @type String
+ */
+ currentPath: '',
+
+ /**
* API module initialisation
*/
init: function Model_init() {
* @param {function} onError Error callback
*/
getFolderData: function Model_getFolderData(path, onSuccess, onError) {
-
- var onOpenSuccess = function (dir) {
+ var self = this,
+ onOpenSuccess = function (dir) {
dir.listFiles(
function (files) {
+ self.currentPath = dir.fullPath;
onSuccess(dir, files);
},
function (e) {
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
},
refreshContent: function (path) {
- path = path.charAt(0).toUpperCase() + path.substr(1);
- path = '/opt/usr/media/' + path;
tizen.content.scanFile(path, null, null);
},
+ resolveAndRefresh: function (path) {
+ var self = this;
+ tizen.filesystem.resolve(path, function(file) {
+ self.refreshContent(file.toURI());
+ }, null);
+ },
+
/**
* @param {File[]} nodes Collection of node objects
* @param {File} dir Directory handle
*/
deleteNodes: function Model_deleteNodes(nodes, dir, onSuccess, onError) {
var len = nodes.length,
+ self = this,
onDeleteNodeSuccess = function (nodeId, isDir) {
if (typeof onSuccess === 'function') {
onSuccess(nodeId);
onDeleteNodeSuccess.bind(this, nodes[i].id, false),
onDeleteNodeError
);
- this.refreshContent(nodes[i].uri);
+ this.resolveAndRefresh(nodes[i]);
}
}
},
copyNodes: function Model_copyNodes(dir, paths, destinationPath, onSuccess) {
var len = paths.length, self = this,
copied = 0,
- onCopyNodeSuccess = function () {
+ onCopyNodeSuccess = function (file) {
copied += 1;
+ self.refreshContent(file.toURI());
if (copied === len) {
onSuccess();
}
try {
dir.copyTo(paths[i], destinationPath + '/' + sourceName, true, onCopyNodeSuccess, onCopyNodeFailure);
- self.refreshContent(destinationPath + '/' + sourceName);
+ self.resolveAndRefresh(paths[i]);
} catch (e) {
console.error(e);
}
moveNodes: function Model_moveNodes(dir, paths, destinationPath, onSuccess) {
var len = paths.length, self = this,
moved = 0,
- onMoveNodeSuccess = function () {
+ onMoveNodeSuccess = function (file) {
+ self.refreshContent(file.toURI());
moved += 1;
if (moved === len) {
onSuccess();
try {
dir.moveTo(paths[i], destinationPath + '/' + sourceName, true, onMoveNodeSuccess, onMoveNodeFailure);
- self.refreshContent(paths[i]);
- self.refreshContent(destinationPath + '/' + sourceName);
+ self.resolveAndRefresh(paths[i]);
} catch (e) {
console.error(e);
}
addEvents: function Ui_addEvents() {
var self = this;
- document.addEventListener('webkitvisibilitychange', function (event) {
+ document.addEventListener('webkitvisibilitychange', function () {
if (document.webkitVisibilityState === 'visible') {
- $.mobile.activePage.page('refresh');
+ app.refreshCurrentPage(true);
}
});
if (!uri) {
tizen.application.getCurrentApplication().exit();
} else {
+ $(".ui-popup").popup('close');
app.goLevelUp();
}
}
var uri = $(this).attr('uri');
if (uri === 'home') {
app.displayStorages();
- } else {
+ } else if (uri === app.model.currentPath) {
app.displayFolder(uri,true);
+ } else {
+ if (self.editMode === true) {
+ self.handleCancelEditAction();
+ }
+ app.displayFolder(uri);
}
});
} else {
status = app.createDir(folderName);
if (status === true) {
- $("#addFolderPopup").popup('open');
+ $("#addFolderPopup").popup('open', {
+ positionTo: "window"
+ });
setTimeout(function () {
$("#addFolderPopup").popup('close');
}, 200);
},
alertPopup: function (text) {
+ var lastActivePopup = $.mobile.popup.active;
+
$("#alertPopup .text").text(text);
setTimeout(function () {
$("#alertPopup").popup('close');
setTimeout(function () {
$("#alertPopup").popup('open');
+ $("#alertPopup").one("popupafterclose", function () {
+ if (lastActivePopup) {
+ if (lastActivePopup.element.attr('id' === 'alertPopup')) {
+ lastActivePopup = undefined;
+ }
+ $.mobile.popup.active = lastActivePopup;
+ }
+ });
}, 200);
}, 200);
},
/**
* Handler for delete action
*/
- handleDeleteAction: function Ui_handleDeleteAction() {
+ handleDeleteAction: function Ui_handleDeleteAction(e) {
var nodesToDelete = [],
$rowElement,
self = this,
conf;
- $('ul#fileList input:checkbox:checked').each(function (index) {
- $rowElement = $(this).closest('li');
- nodesToDelete.push({
- id: $rowElement.attr('id'),
- uri: $rowElement.attr('uri'),
- name: $rowElement.attr('label'),
- folder: $rowElement.hasClass('folder')
- });
- });
+ e.stopPropagation();
+ e.preventDefault();
this.confirmPopup('Selected nodes will be deleted. Are you sure?',
function () {
+ $('ul#fileList input:checkbox:checked').each(function (index) {
+ $rowElement = $(this).closest('li');
+ nodesToDelete.push({
+ id: $rowElement.attr('id'),
+ uri: $rowElement.attr('uri'),
+ name: $rowElement.attr('label'),
+ folder: $rowElement.hasClass('folder')
+ });
+ });
if (nodesToDelete.length > 0) {
app.deleteNodes(nodesToDelete);
self.scrollContentTo(0);
/**
* Handler for copy action
*/
- handleCopyAction: function Ui_handleCopyAction() {
+ handleCopyAction: function Ui_handleCopyAction(e) {
var paths = [];
+
+ e.stopPropagation();
+ e.preventDefault();
+
if (this.editMode === true) {
$('ul#fileList input:checkbox:checked').each(function (index) {
paths.push($(this).closest('li').attr('uri'));
/**
* Handler for move action
*/
- handleMoveAction: function Ui_handleMoveAction() {
+ handleMoveAction: function Ui_handleMoveAction(e) {
var paths = [];
+
+ e.stopPropagation();
+ e.preventDefault();
+
if (this.editMode === true) {
$('ul#fileList input:checkbox:checked').each(function (index) {
paths.push($(this).closest('li').attr('uri'));
* @param {FileSystemStorage[]} nodes Storage elements
*/
displayStorages: function Ui_displayStorages(nodes) {
- var len = nodes.length,
- listElements = [],
- nodeName,
- listTemplate = '',
- i;
+ var len = nodes.length, nodeName, i;
+
this.updateNavbar('');
+ $('#fileList').empty();
for (i = 0; i < len; i = i + 1) {
nodeName = nodes[i].label.trim();
&& (nodes[i].type === 0 || nodes[i].type === 'INTERNAL')
&& nodeName.indexOf('wgt-') === -1
&& $.inArray(nodeName, this.lockedFolders) === -1
- ) {
- listElements.push(this.templateManager.get('folderRow', {
- id: i,
- name: nodeName,
- uri: nodeName,
- fullUri: nodeName
- }));
+ ) {
+ if (!this.root) {
+ app.model.isStorageExists(nodeName,
+ app.ui.prepareFolderRow.bind(app.ui, i, nodeName), null);
+ } else {
+ this.prepareFolderRow(i, nodeName);
+ }
}
}
$('#moreActionBtn').addClass('vhidden');
$('h1#mainTitle').html('Media');
- // update file list
- $('#fileList').empty();
if (this.editMode) {
this.scrollContentTo(0);
}
- listTemplate = listElements.join('');
- $(listTemplate).appendTo('#fileList');
this.resetDefaultCheckBoxLabelEvents();
this.hideSelectAllArea();
this.handleCancelEditAction();
},
+ prepareFolderRow: function (id, name) {
+ $(this.templateManager.get('folderRow', {
+ id: id,
+ name: name,
+ uri: name,
+ fullUri: name,
+ })).appendTo('#fileList');
+ },
+
/**
* File comparison function using their names (case insensitive)
*
.trigger('refresh')
.trigger('create');
+
if (this.editMode === true) {
$('.selectAll').show();
$('ul#fileList > li').css('paddingLeft', '2rem');
$('ul#fileList > li').css('paddingLeft', '0');
$('.my-ui-checkbox').addClass('hidden');
}
- this.hideSelectAllArea();
+ if (!refresh) this.hideSelectAllArea();
},
/**
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 {
</div>
<div data-role="popup" id="alertPopup" class="ui-corner-all">
<p class="text"></p>
- <a href="#" data-role="button" data-inline="true" data-rel="back">OK</a>
+ <div class="alertPopup-button">
+ <a href="#" data-role="button" data-inline="true" data-rel="back">OK</a>
+ </div>
</div>
<div data-role="popup" id="confirmPopup" class="ui-corner-all">
- <p class="text"></p>
- <a href="#" data-role="button" data-inline="true" class="confirm">OK</a>
- <a href="#" data-role="button" data-inline="true" data-rel="back">CANCEL</a>
+ <div class="ui-popup-text">
+ <p class="text"></p>
+ </div>
+ <div class="ui-popup-button-bg">
+ <a data-role="button" data-rel="back" data-inline="true" class="confirm">OK</a>
+ <a data-role="button" data-rel="back" data-inline="true">CANCEL</a>
+ </div>
</div>
</div>