| @@ 9049-9104 (lines=56) @@ | ||
| 9046 | } |
|
| 9047 | return self; |
|
| 9048 | }, |
|
| 9049 | renderHtml: function () { |
|
| 9050 | var self = this; |
|
| 9051 | var id = self._id; |
|
| 9052 | var settings = self.settings; |
|
| 9053 | var prefix = self.classPrefix; |
|
| 9054 | var text = self.state.get('text'); |
|
| 9055 | var icon = self.settings.icon, image = '', shortcut = settings.shortcut; |
|
| 9056 | var url = self.encode(settings.url), iconHtml = ''; |
|
| 9057 | function convertShortcut(shortcut) { |
|
| 9058 | var i, value, replace = {}; |
|
| 9059 | if (global$1.mac) { |
|
| 9060 | replace = { |
|
| 9061 | alt: '⌥', |
|
| 9062 | ctrl: '⌘', |
|
| 9063 | shift: '⇧', |
|
| 9064 | meta: '⌘' |
|
| 9065 | }; |
|
| 9066 | } else { |
|
| 9067 | replace = { meta: 'Ctrl' }; |
|
| 9068 | } |
|
| 9069 | shortcut = shortcut.split('+'); |
|
| 9070 | for (i = 0; i < shortcut.length; i++) { |
|
| 9071 | value = replace[shortcut[i].toLowerCase()]; |
|
| 9072 | if (value) { |
|
| 9073 | shortcut[i] = value; |
|
| 9074 | } |
|
| 9075 | } |
|
| 9076 | return shortcut.join('+'); |
|
| 9077 | } |
|
| 9078 | function escapeRegExp(str) { |
|
| 9079 | return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
|
| 9080 | } |
|
| 9081 | function markMatches(text) { |
|
| 9082 | var match = settings.match || ''; |
|
| 9083 | return match ? text.replace(new RegExp(escapeRegExp(match), 'gi'), function (match) { |
|
| 9084 | return '!mce~match[' + match + ']mce~match!'; |
|
| 9085 | }) : text; |
|
| 9086 | } |
|
| 9087 | function boldMatches(text) { |
|
| 9088 | return text.replace(new RegExp(escapeRegExp('!mce~match['), 'g'), '<b>').replace(new RegExp(escapeRegExp(']mce~match!'), 'g'), '</b>'); |
|
| 9089 | } |
|
| 9090 | if (icon) { |
|
| 9091 | self.parent().classes.add('menu-has-icons'); |
|
| 9092 | } |
|
| 9093 | if (settings.image) { |
|
| 9094 | image = ' style="background-image: url(\'' + settings.image + '\')"'; |
|
| 9095 | } |
|
| 9096 | if (shortcut) { |
|
| 9097 | shortcut = convertShortcut(shortcut); |
|
| 9098 | } |
|
| 9099 | icon = prefix + 'ico ' + prefix + 'i-' + (self.settings.icon || 'none'); |
|
| 9100 | iconHtml = text !== '-' ? '<i class="' + icon + '"' + image + '></i>\xA0' : ''; |
|
| 9101 | text = boldMatches(self.encode(markMatches(text))); |
|
| 9102 | url = boldMatches(self.encode(markMatches(url))); |
|
| 9103 | return '<div id="' + id + '" class="' + self.classes + '" tabindex="-1">' + iconHtml + (text !== '-' ? '<span id="' + id + '-text" class="' + prefix + 'text">' + text + '</span>' : '') + (shortcut ? '<div id="' + id + '-shortcut" class="' + prefix + 'menu-shortcut">' + shortcut + '</div>' : '') + (settings.menu ? '<div class="' + prefix + 'caret"></div>' : '') + (url ? '<div class="' + prefix + 'menu-item-link">' + url + '</div>' : '') + '</div>'; |
|
| 9104 | }, |
|
| 9105 | postRender: function () { |
|
| 9106 | var self = this, settings = self.settings; |
|
| 9107 | var textStyle = settings.textStyle; |
|
| @@ 8857-8912 (lines=56) @@ | ||
| 8854 | } |
|
| 8855 | return self; |
|
| 8856 | }, |
|
| 8857 | renderHtml: function () { |
|
| 8858 | var self = this; |
|
| 8859 | var id = self._id; |
|
| 8860 | var settings = self.settings; |
|
| 8861 | var prefix = self.classPrefix; |
|
| 8862 | var text = self.state.get('text'); |
|
| 8863 | var icon = self.settings.icon, image = '', shortcut = settings.shortcut; |
|
| 8864 | var url = self.encode(settings.url), iconHtml = ''; |
|
| 8865 | function convertShortcut(shortcut) { |
|
| 8866 | var i, value, replace = {}; |
|
| 8867 | if (global$8.mac) { |
|
| 8868 | replace = { |
|
| 8869 | alt: '⌥', |
|
| 8870 | ctrl: '⌘', |
|
| 8871 | shift: '⇧', |
|
| 8872 | meta: '⌘' |
|
| 8873 | }; |
|
| 8874 | } else { |
|
| 8875 | replace = { meta: 'Ctrl' }; |
|
| 8876 | } |
|
| 8877 | shortcut = shortcut.split('+'); |
|
| 8878 | for (i = 0; i < shortcut.length; i++) { |
|
| 8879 | value = replace[shortcut[i].toLowerCase()]; |
|
| 8880 | if (value) { |
|
| 8881 | shortcut[i] = value; |
|
| 8882 | } |
|
| 8883 | } |
|
| 8884 | return shortcut.join('+'); |
|
| 8885 | } |
|
| 8886 | function escapeRegExp(str) { |
|
| 8887 | return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); |
|
| 8888 | } |
|
| 8889 | function markMatches(text) { |
|
| 8890 | var match = settings.match || ''; |
|
| 8891 | return match ? text.replace(new RegExp(escapeRegExp(match), 'gi'), function (match) { |
|
| 8892 | return '!mce~match[' + match + ']mce~match!'; |
|
| 8893 | }) : text; |
|
| 8894 | } |
|
| 8895 | function boldMatches(text) { |
|
| 8896 | return text.replace(new RegExp(escapeRegExp('!mce~match['), 'g'), '<b>').replace(new RegExp(escapeRegExp(']mce~match!'), 'g'), '</b>'); |
|
| 8897 | } |
|
| 8898 | if (icon) { |
|
| 8899 | self.parent().classes.add('menu-has-icons'); |
|
| 8900 | } |
|
| 8901 | if (settings.image) { |
|
| 8902 | image = ' style="background-image: url(\'' + settings.image + '\')"'; |
|
| 8903 | } |
|
| 8904 | if (shortcut) { |
|
| 8905 | shortcut = convertShortcut(shortcut); |
|
| 8906 | } |
|
| 8907 | icon = prefix + 'ico ' + prefix + 'i-' + (self.settings.icon || 'none'); |
|
| 8908 | iconHtml = text !== '-' ? '<i class="' + icon + '"' + image + '></i>\xA0' : ''; |
|
| 8909 | text = boldMatches(self.encode(markMatches(text))); |
|
| 8910 | url = boldMatches(self.encode(markMatches(url))); |
|
| 8911 | return '<div id="' + id + '" class="' + self.classes + '" tabindex="-1">' + iconHtml + (text !== '-' ? '<span id="' + id + '-text" class="' + prefix + 'text">' + text + '</span>' : '') + (shortcut ? '<div id="' + id + '-shortcut" class="' + prefix + 'menu-shortcut">' + shortcut + '</div>' : '') + (settings.menu ? '<div class="' + prefix + 'caret"></div>' : '') + (url ? '<div class="' + prefix + 'menu-item-link">' + url + '</div>' : '') + '</div>'; |
|
| 8912 | }, |
|
| 8913 | postRender: function () { |
|
| 8914 | var self = this, settings = self.settings; |
|
| 8915 | var textStyle = settings.textStyle; |
|