1/** 2 * @author Roeland Jago Douma <[email protected]> 3 * 4 * @copyright Copyright (c) 2015, ownCloud, Inc. 5 * @license AGPL-3.0 6 * 7 * This code is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Affero General Public License, version 3, 9 * as published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License, version 3, 17 * along with this program. If not, see <http://www.gnu.org/licenses/> 18 * 19 */ 20 21/** 22 * Namespace to hold functions related to convert mimetype to icons 23 * 24 * @namespace 25 */ 26OC.MimeType = { 27 28 /** 29 * Cache that maps mimeTypes to icon urls 30 */ 31 _mimeTypeIcons: {}, 32 33 /** 34 * Return the file icon we want to use for the given mimeType. 35 * The file needs to be present in the supplied file list 36 * 37 * @param {string} mimeType The mimeType we want an icon for 38 * @param {array} files The available icons in this theme 39 * @return {string} The icon to use or null if there is no match 40 */ 41 _getFile: function(mimeType, files) { 42 var icon = mimeType.replace(new RegExp('/', 'g'), '-'); 43 44 // Generate path 45 if (mimeType === 'dir' && $.inArray('folder', files) !== -1) { 46 return 'folder'; 47 } else if (mimeType === 'dir-encrypted' && $.inArray('folder-encrypted', files) !== -1) { 48 return 'folder-encrypted'; 49 } else if (mimeType === 'dir-shared' && $.inArray('folder-shared', files) !== -1) { 50 return 'folder-shared'; 51 } else if (mimeType === 'dir-public' && $.inArray('folder-public', files) !== -1) { 52 return 'folder-public'; 53 } else if (mimeType === 'dir-external' && $.inArray('folder-external', files) !== -1) { 54 return 'folder-external'; 55 } else if ($.inArray(icon, files) !== -1) { 56 return icon; 57 } else if ($.inArray(icon.split('-')[0], files) !== -1) { 58 return icon.split('-')[0]; 59 } else if ($.inArray('file', files) !== -1) { 60 return 'file'; 61 } 62 63 return null; 64 }, 65 66 /** 67 * Return the url to icon of the given mimeType 68 * 69 * @param {string} mimeType The mimeType to get the icon for 70 * @return {string} Url to the icon for mimeType 71 */ 72 getIconUrl: function(mimeType) { 73 if (_.isUndefined(mimeType)) { 74 return undefined; 75 } 76 77 while (mimeType in OC.MimeTypeList.aliases) { 78 mimeType = OC.MimeTypeList.aliases[mimeType]; 79 } 80 if (mimeType in OC.MimeType._mimeTypeIcons) { 81 return OC.MimeType._mimeTypeIcons[mimeType]; 82 } 83 84 // First try to get the correct icon from the current theme 85 var gotIcon = null; 86 var path = ''; 87 if (OC.theme.folder !== '' && $.isArray(OC.MimeTypeList.themes[OC.theme.folder])) { 88 path = OC.getRootPath() + '/themes/' + OC.theme.folder + '/core/img/filetypes/'; 89 var icon = OC.MimeType._getFile(mimeType, OC.MimeTypeList.themes[OC.theme.folder]); 90 91 if (icon !== null) { 92 gotIcon = true; 93 path += icon; 94 } 95 } 96 if(OCA.Theming && gotIcon === null) { 97 path = OC.generateUrl('/apps/theming/img/core/filetypes/'); 98 path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files); 99 gotIcon = true; 100 } 101 102 // If we do not yet have an icon fall back to the default 103 if (gotIcon === null) { 104 path = OC.getRootPath() + '/core/img/filetypes/'; 105 path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files); 106 } 107 108 path += '.svg'; 109 110 if(OCA.Theming) { 111 path += "?v=" + OCA.Theming.cacheBuster; 112 } 113 114 // Cache the result 115 OC.MimeType._mimeTypeIcons[mimeType] = path; 116 return path; 117 } 118 119}; 120 121 122/** 123* This file is automatically generated 124* DO NOT EDIT MANUALLY! 125* 126* You can update the list of MimeType Aliases in config/mimetypealiases.json 127* The list of files is fetched from core/img/filetypes 128* To regenerate this file run ./occ maintenance:mimetype:update-js 129*/ 130OC.MimeTypeList={ 131 aliases: { 132 "application/coreldraw": "image", 133 "application/epub+zip": "text", 134 "application/font-sfnt": "image", 135 "application/font-woff": "image", 136 "application/gpx+xml": "location", 137 "application/illustrator": "image", 138 "application/javascript": "text/code", 139 "application/json": "text/code", 140 "application/msaccess": "file", 141 "application/msexcel": "x-office/spreadsheet", 142 "application/msonenote": "x-office/document", 143 "application/mspowerpoint": "x-office/presentation", 144 "application/msword": "x-office/document", 145 "application/octet-stream": "file", 146 "application/postscript": "image", 147 "application/rss+xml": "application/xml", 148 "application/vnd.android.package-archive": "package/x-generic", 149 "application/vnd.lotus-wordpro": "x-office/document", 150 "application/vnd.garmin.tcx+xml": "location", 151 "application/vnd.google-earth.kml+xml": "location", 152 "application/vnd.google-earth.kmz": "location", 153 "application/vnd.ms-excel": "x-office/spreadsheet", 154 "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", 155 "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", 156 "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", 157 "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", 158 "application/vnd.ms-fontobject": "image", 159 "application/vnd.ms-powerpoint": "x-office/presentation", 160 "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", 161 "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", 162 "application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "x-office/presentation", 163 "application/vnd.ms-powerpoint.template.macroEnabled.12": "x-office/presentation", 164 "application/vnd.ms-visio.drawing.macroEnabled.12": "application/vnd.visio", 165 "application/vnd.ms-visio.drawing": "application/vnd.visio", 166 "application/vnd.ms-visio.stencil.macroEnabled.12": "application/vnd.visio", 167 "application/vnd.ms-visio.stencil": "application/vnd.visio", 168 "application/vnd.ms-visio.template.macroEnabled.12": "application/vnd.visio", 169 "application/vnd.ms-visio.template": "application/vnd.visio", 170 "application/vnd.ms-word.document.macroEnabled.12": "x-office/document", 171 "application/vnd.ms-word.template.macroEnabled.12": "x-office/document", 172 "application/vnd.oasis.opendocument.presentation": "x-office/presentation", 173 "application/vnd.oasis.opendocument.presentation-template": "x-office/presentation", 174 "application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet", 175 "application/vnd.oasis.opendocument.spreadsheet-template": "x-office/spreadsheet", 176 "application/vnd.oasis.opendocument.text": "x-office/document", 177 "application/vnd.oasis.opendocument.text-master": "x-office/document", 178 "application/vnd.oasis.opendocument.text-template": "x-office/document", 179 "application/vnd.oasis.opendocument.graphics": "x-office/drawing", 180 "application/vnd.oasis.opendocument.graphics-template": "x-office/drawing", 181 "application/vnd.oasis.opendocument.text-web": "x-office/document", 182 "application/vnd.oasis.opendocument.text-flat-xml": "x-office/document", 183 "application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet", 184 "application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing", 185 "application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation", 186 "application/vnd.openxmlformats-officedocument.presentationml.presentation": "x-office/presentation", 187 "application/vnd.openxmlformats-officedocument.presentationml.slideshow": "x-office/presentation", 188 "application/vnd.openxmlformats-officedocument.presentationml.template": "x-office/presentation", 189 "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "x-office/spreadsheet", 190 "application/vnd.openxmlformats-officedocument.spreadsheetml.template": "x-office/spreadsheet", 191 "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", 192 "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", 193 "application/vnd.visio": "x-office/document", 194 "application/vnd.wordperfect": "x-office/document", 195 "application/x-7z-compressed": "package/x-generic", 196 "application/x-bzip2": "package/x-generic", 197 "application/x-cbr": "text", 198 "application/x-compressed": "package/x-generic", 199 "application/x-dcraw": "image", 200 "application/x-deb": "package/x-generic", 201 "application/x-fictionbook+xml": "text", 202 "application/x-font": "image", 203 "application/x-gimp": "image", 204 "application/x-gzip": "package/x-generic", 205 "application/x-iwork-keynote-sffkey": "x-office/presentation", 206 "application/x-iwork-numbers-sffnumbers": "x-office/spreadsheet", 207 "application/x-iwork-pages-sffpages": "x-office/document", 208 "application/x-mobipocket-ebook": "text", 209 "application/x-perl": "text/code", 210 "application/x-photoshop": "image", 211 "application/x-php": "text/code", 212 "application/x-rar-compressed": "package/x-generic", 213 "application/x-tar": "package/x-generic", 214 "application/x-tex": "text", 215 "application/xml": "text/html", 216 "application/yaml": "text/code", 217 "application/zip": "package/x-generic", 218 "database": "file", 219 "httpd/unix-directory": "dir", 220 "text/css": "text/code", 221 "text/csv": "x-office/spreadsheet", 222 "text/html": "text/code", 223 "text/x-c": "text/code", 224 "text/x-c++src": "text/code", 225 "text/x-h": "text/code", 226 "text/x-java-source": "text/code", 227 "text/x-ldif": "text/code", 228 "text/x-python": "text/code", 229 "text/x-shellscript": "text/code", 230 "web": "text/code", 231 "application/internet-shortcut": "link", 232 "application/km": "mindmap", 233 "application/x-freemind": "mindmap", 234 "application/vnd.xmind.workbook": "mindmap" 235}, 236 files: [ 237 "application", 238 "application-pdf", 239 "audio", 240 "file", 241 "folder", 242 "folder-drag-accept", 243 "folder-encrypted", 244 "folder-external", 245 "folder-public", 246 "folder-shared", 247 "folder-starred", 248 "image", 249 "link", 250 "location", 251 "mindmap", 252 "package-x-generic", 253 "text", 254 "text-calendar", 255 "text-code", 256 "text-vcard", 257 "video", 258 "x-office-document", 259 "x-office-drawing", 260 "x-office-presentation", 261 "x-office-spreadsheet" 262], 263 themes: [] 264}; 265 266 267/* 268 * Copyright (c) 2015 269 * 270 * This file is licensed under the Affero General Public License version 3 271 * or later. 272 * 273 * See the COPYING-README file. 274 * 275 */ 276 277/* global Select2 */ 278 279/** 280 * Select2 extension for toggling values in a multi-select dropdown 281 */ 282(function(Select2) { 283 284 var Select2FindHighlightableChoices = Select2.class.multi.prototype.findHighlightableChoices; 285 Select2.class.multi.prototype.findHighlightableChoices = function () { 286 if (this.opts.toggleSelect) { 287 return this.results.find('.select2-result-selectable:not(.select2-disabled)'); 288 } 289 return Select2FindHighlightableChoices.apply(this, arguments); 290 }; 291 292 var Select2TriggerSelect = Select2.class.multi.prototype.triggerSelect; 293 Select2.class.multi.prototype.triggerSelect = function (data) { 294 if (this.opts.toggleSelect && this.val().indexOf(this.id(data)) !== -1) { 295 var self = this; 296 var val = this.id(data); 297 298 var selectionEls = this.container.find('.select2-search-choice').filter(function() { 299 return (self.id($(this).data('select2-data')) === val); 300 }); 301 302 if (this.unselect(selectionEls)) { 303 // also unselect in dropdown 304 this.results.find('.select2-result.select2-selected').each(function () { 305 var $this = $(this); 306 if (self.id($this.data('select2-data')) === val) { 307 $this.removeClass('select2-selected'); 308 } 309 }); 310 this.clearSearch(); 311 } 312 313 return false;
314 } else { 315 return Select2TriggerSelect.apply(this, arguments); 316 } 317 }; 318 319})(Select2); 320 321 322
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.