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 '.pdf': {mime:'', icon:'pdf.png'},
54 '.odp': {mime:'', icon:'ppt.png'},
55 '.ppt': {mime:'', icon:'ppt.png'},
56 '.wgt': {mime:'application/widget', icon:'etc.png'}
60 * Capitalise the first letter
62 * @param {string} text
65 UCFirst: function Helpers_UCFirst(text) {
66 return text.charAt(0).toUpperCase() + text.slice(1);
70 * @param {string} fileName
71 * @returns {string} file name without extension
73 getFileName: function Helpers_getFileName(fileName) {
74 var fileNameLen = fileName.indexOf('.');
75 if (fileNameLen !== -1) {
76 fileName = fileName.slice(0, fileNameLen);
82 * @param {string} fileName
83 * @returns {string} extension for specified file name
85 getFileExtension: function Helpers_getFileExtension(fileName) {
86 var splittedFileName = fileName.split('.'),
89 if (splittedFileName.length > 1) {
90 ext = '.' + splittedFileName.pop();
96 * Return icon filename for the given extension.
97 * For example, for '.mp3' returns 'music.png'
102 resolveFileIcon: function Helpers_resolveFileIcon(ext) {
103 ext = ext.toLowerCase();
104 var info = this.extensions[ext];
105 return info ? info.icon : 'etc.png';
109 * Resolve file extension to MIME type
111 * @param {string} ext File extension
114 resolveMimeType: function Helpers_resolveMimeType(ext) {
115 ext = ext.toLowerCase();
116 var info = this.extensions[ext];
117 return info ? info.mime : '';
121 * Returns thumbnail URI for specified file
122 * @param {string} fileName
126 getThumbnailURI: function Helpers_getThumbnailURI(fileName, node) {
127 var ext = this.getFileExtension(fileName);
129 if (!node.thumbnailURIs) {
130 return 'images/' + this.resolveFileIcon(ext);
133 if (node.thumbnailURIs[0] && $.inArray(ext, ['.mp4', '.jpg', '.png', '.gif'])) {
134 return node.thumbnailURIs[0];
137 return 'images/etc.png';
141 * File name automatic number increase for copy files
143 getCopyFileName: function (sourceName, filesList) {
144 var ext = this.getFileExtension(sourceName),
145 fileName = this.getFileName(sourceName),
146 copyFileName = sourceName,
149 while ($.inArray(copyFileName, filesList) !== -1) {
151 copyFileName = fileName + '(' + i + ')' + ext;