11 (function () { // strict mode wrapper
16 '.bmp': {mime:'image/*', icon:'img.png'},
17 '.gif': {mime:'image/*', icon:'img.png'},
18 '.jpeg': {mime:'image/*', icon:'img.png'},
19 '.jpg': {mime:'image/*', icon:'img.png'},
20 '.png': {mime:'image/*', icon:'img.png'},
21 '.tiff': {mime:'image/*', icon:'img.png'},
22 '.3ga': {mime:'audio/*', icon:'music.png'},
23 '.aac': {mime:'audio/*', icon:'music.png'},
24 '.ac3': {mime:'audio/*', icon:'music.png'},
25 '.amr': {mime:'audio/*', icon:'music.png'},
26 '.awb': {mime:'audio/*', icon:'music.png'},
27 '.m4a': {mime:'audio/*', icon:'music.png'},
28 '.m4p': {mime:'audio/*', icon:'music.png'},
29 '.m4r': {mime:'audio/*', icon:'music.png'},
30 '.mp3': {mime:'audio/*', icon:'music.png'},
31 '.ogg': {mime:'audio/*', icon:'music.png'},
32 '.wav': {mime:'audio/*', icon:'music.png'},
33 '.wma': {mime:'audio/*', icon:'music.png'},
34 '.3gp': {mime:'video/*', icon:'video.png'},
35 '.avc': {mime:'video/*', icon:'video.png'},
36 '.avi': {mime:'video/*', icon:'video.png'},
37 '.m4v': {mime:'video/*', icon:'video.png'},
38 '.mkv': {mime:'video/*', icon:'video.png'},
39 '.mov': {mime:'video/*', icon:'video.png'},
40 '.mp4': {mime:'video/*', icon:'video.png'},
41 '.mpeg': {mime:'video/*', icon:'video.png'},
42 '.mpg': {mime:'video/*', icon:'video.png'},
43 '.ogv': {mime:'video/*', icon:'video.png'},
44 '.vc1': {mime:'video/*', icon:'video.png'},
45 '.wmv': {mime:'video/*', icon:'video.png'},
46 '.doc': {mime:'', icon:'text.png'},
47 '.docx': {mime:'', icon:'text.png'},
48 '.odt': {mime:'', icon:'text.png'},
49 '.ods': {mime:'', icon:'text.png'},
50 '.txt': {mime:'', icon:'text.png'},
51 '.xls': {mime:'', icon:'text.png'},
52 '.xlsx': {mime:'', icon:'text.png'},
53 '.vcard': {mime:'text/vcard', icon:'text.png'},
54 '.vcf': {mime:'text/vcard', icon:'text.png'},
55 '.icalendar': {mime:'text/calendar', icon:'text.png'},
56 '.ical': {mime:'text/calendar', icon:'text.png'},
57 '.ics': {mime:'text/calendar', icon:'text.png'},
58 '.ifb': {mime:'text/calendar', icon:'text.png'},
59 '.pdf': {mime:'', icon:'pdf.png'},
60 '.odp': {mime:'', icon:'ppt.png'},
61 '.ppt': {mime:'', icon:'ppt.png'},
62 '.wgt': {mime:'application/widget', icon:'etc.png'}
66 * Capitalise the first letter
68 * @param {string} text
71 UCFirst: function Helpers_UCFirst(text) {
72 return text.charAt(0).toUpperCase() + text.slice(1);
76 * @param {string} fileName
77 * @returns {string} file name without extension
79 getFileName: function Helpers_getFileName(fileName) {
80 var fileNameLen = fileName.indexOf('.');
81 if (fileNameLen !== -1) {
82 fileName = fileName.slice(0, fileNameLen);
88 * @param {string} fileName
89 * @returns {string} extension for specified file name
91 getFileExtension: function Helpers_getFileExtension(fileName) {
92 var splittedFileName = fileName.split('.'),
95 if (splittedFileName.length > 1) {
96 ext = '.' + splittedFileName.pop();
102 * Return icon filename for the given extension.
103 * For example, for '.mp3' returns 'music.png'
105 * @param {string} ext
108 resolveFileIcon: function Helpers_resolveFileIcon(ext) {
109 ext = ext.toLowerCase();
110 var info = this.extensions[ext];
111 return info ? info.icon : 'etc.png';
115 * Resolve file extension to MIME type
117 * @param {string} ext File extension
120 resolveMimeType: function Helpers_resolveMimeType(ext) {
121 ext = ext.toLowerCase();
122 var info = this.extensions[ext];
123 return info ? info.mime : '';
127 * Returns thumbnail URI for specified file
128 * @param {string} fileName
132 getThumbnailURI: function Helpers_getThumbnailURI(fileName, node) {
133 var ext = this.getFileExtension(fileName);
135 if (!node.thumbnailURIs) {
136 return 'images/' + this.resolveFileIcon(ext);
139 if (node.thumbnailURIs[0] && $.inArray(ext, ['.mp4', '.jpg', '.png', '.gif'])) {
140 return node.thumbnailURIs[0];
143 return 'images/etc.png';
147 * File name automatic number increase for copy files
149 getCopyFileName: function (sourceName, filesList) {
150 var ext = this.getFileExtension(sourceName),
151 fileName = this.getFileName(sourceName),
152 copyFileName = sourceName,
155 while ($.inArray(copyFileName, filesList) !== -1) {
157 copyFileName = fileName + '(' + i + ')' + ext;