|
413 | 413 |
|
414 | 414 | // noinspection JSUnfilteredForInLoop |
415 | 415 | var $icon = $('<a class="emuos-desktop-icon"'+ href + (icon_options['title'] ? 'data-title="' + icon_options['title'] + '"' : '') + '>' + |
416 | | - '<i class="icon overlay ribbon' + (icon_options['shortcut'] ? ' shortcut' : '') + (icon_options['prototype'] ? ' prototype' : '') + (icon_options['beta'] ? ' beta' : '') + (icon_options['new'] ? ' new' : '') + '" style="background-image: url(' + icon + ($sys.browser.isIE ? '.png' : '.ico') + ');"></i>' + |
| 416 | + '<i class="' + self._buildIconClasses(icon_options, self.desktopIconSize) + '" style="background-image: url(' + icon + ($sys.browser.isIE ? '.png' : '.ico') + ');"></i>' + |
417 | 417 | '<span>' + icon_options['name'] + '</span>' + |
418 | 418 | '</a>'); |
419 | 419 |
|
|
1828 | 1828 | '--desktop-icon-cell-width': preset.width + 'px', |
1829 | 1829 | '--desktop-icon-cell-height': preset.height + 'px' |
1830 | 1830 | }); |
| 1831 | + this._syncDesktopIconSizeClasses(size); |
1831 | 1832 | } |
1832 | 1833 | }; |
1833 | 1834 |
|
|
2055 | 2056 | return icon; |
2056 | 2057 | }; |
2057 | 2058 |
|
| 2059 | + EmuOS.prototype._getIconSizeClassName = function(size) { |
| 2060 | + size = parseInt(size, 10); |
| 2061 | + |
| 2062 | + return isNaN(size) ? '' : 'size-' + size; |
| 2063 | + }; |
| 2064 | + |
| 2065 | + EmuOS.prototype._buildIconClasses = function(item, size) { |
| 2066 | + item = item || {}; |
| 2067 | + var classes = 'icon overlay ribbon'; |
| 2068 | + |
| 2069 | + if (size) { |
| 2070 | + var sizeClass = this._getIconSizeClassName(size); |
| 2071 | + |
| 2072 | + if (sizeClass) { |
| 2073 | + classes += ' ' + sizeClass; |
| 2074 | + } |
| 2075 | + } |
| 2076 | + |
| 2077 | + if (item.shortcut) { |
| 2078 | + classes += ' shortcut'; |
| 2079 | + } |
| 2080 | + |
| 2081 | + if (item.prototype) { |
| 2082 | + classes += ' prototype'; |
| 2083 | + } |
| 2084 | + |
| 2085 | + if (item.beta) { |
| 2086 | + classes += ' beta'; |
| 2087 | + } |
| 2088 | + |
| 2089 | + if (item.new) { |
| 2090 | + classes += ' new'; |
| 2091 | + } |
| 2092 | + |
| 2093 | + return classes; |
| 2094 | + }; |
| 2095 | + |
| 2096 | + EmuOS.prototype._syncIconSizeClass = function($icon, size) { |
| 2097 | + if (!$icon || !$icon.length) { |
| 2098 | + return; |
| 2099 | + } |
| 2100 | + |
| 2101 | + var sizeClass = this._getIconSizeClassName(size); |
| 2102 | + |
| 2103 | + $icon.removeClass(function(index, className) { |
| 2104 | + return className.split(/\s+/).filter(function(name) { |
| 2105 | + return /^size-\d+$/.test(name); |
| 2106 | + }).join(' '); |
| 2107 | + }); |
| 2108 | + |
| 2109 | + if (sizeClass) { |
| 2110 | + $icon.addClass(sizeClass); |
| 2111 | + } |
| 2112 | + }; |
| 2113 | + |
| 2114 | + EmuOS.prototype._syncDesktopIconSizeClasses = function(size) { |
| 2115 | + var self = this; |
| 2116 | + |
| 2117 | + if (!this.$desktop || !this.$desktop.length) { |
| 2118 | + return; |
| 2119 | + } |
| 2120 | + |
| 2121 | + this.$desktop.find('.emuos-desktop-icon > i.icon').each(function() { |
| 2122 | + self._syncIconSizeClass($(this), size); |
| 2123 | + }); |
| 2124 | + }; |
| 2125 | + |
2058 | 2126 | EmuOS.prototype._resolveLink = function(link) { |
2059 | 2127 | if (typeof link === 'undefined' || link === null || link === '') { |
2060 | 2128 | return ''; |
|
2681 | 2749 | var detailIsFolder = detailItem.folder === true || Array.isArray(detailItem.items); |
2682 | 2750 | var detailIcon = self._resolveIcon(detailItem.icon, detailIsFolder ? 'assets/images/icons/desktop/folder' : 'assets/images/icons/desktop/joystick'); |
2683 | 2751 | var detailName = typeof detailItem.name !== 'undefined' ? detailItem.name : 'Untitled'; |
2684 | | - var detailIconClasses = 'icon overlay ribbon' + (detailItem.shortcut ? ' shortcut' : '') + (detailItem.prototype ? ' prototype' : '') + (detailItem.beta ? ' beta' : '') + (detailItem.new ? ' new' : ''); |
| 2752 | + var detailIconClasses = self._buildIconClasses(detailItem, 16); |
2685 | 2753 | var detailTitleAttr = detailItem.title ? ' data-title="' + detailItem.title + '"' : ''; |
2686 | 2754 | var detailSize = self._formatFolderItemSize(detailItem); |
2687 | 2755 | var detailType = self._getFolderItemType(detailItem); |
|
2712 | 2780 | var isFolder = item.folder === true || Array.isArray(item.items); |
2713 | 2781 | var itemIcon = self._resolveIcon(item.icon, isFolder ? 'assets/images/icons/desktop/folder' : 'assets/images/icons/desktop/joystick'); |
2714 | 2782 | var itemName = typeof item.name !== 'undefined' ? item.name : 'Untitled'; |
2715 | | - var iconClasses = 'icon overlay ribbon' + (item.shortcut ? ' shortcut' : '') + (item.prototype ? ' prototype' : '') + (item.beta ? ' beta' : '') + (item.new ? ' new' : ''); |
| 2783 | + var iconClasses = self._buildIconClasses(item, size); |
2716 | 2784 | var titleAttr = item.title ? ' data-title="' + item.title + '"' : ''; |
2717 | 2785 | var $item = $('<a class="emuos-folder-item" href="javascript:"' + titleAttr + '><i class="' + iconClasses + '"></i><span></span></a>'); |
2718 | 2786 |
|
|
0 commit comments