| @@ 5095-5132 (lines=38) @@ | ||
| 5092 | ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; |
|
| 5093 | return '<div id="' + id + '" class="' + self$$1.classes + '" tabindex="-1"' + ariaPressed + '>' + '<button id="' + id + '-button" role="presentation" type="button" tabindex="-1">' + (icon ? '<i class="' + icon + '"' + image + '></i>' : '') + textHtml + '</button>' + '</div>'; |
|
| 5094 | }, |
|
| 5095 | bindStates: function () { |
|
| 5096 | var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; |
|
| 5097 | function setButtonText(text) { |
|
| 5098 | var $span = $('span.' + textCls, self$$1.getEl()); |
|
| 5099 | if (text) { |
|
| 5100 | if (!$span[0]) { |
|
| 5101 | $('button:first', self$$1.getEl()).append('<span class="' + textCls + '"></span>'); |
|
| 5102 | $span = $('span.' + textCls, self$$1.getEl()); |
|
| 5103 | } |
|
| 5104 | $span.html(self$$1.encode(text)); |
|
| 5105 | } else { |
|
| 5106 | $span.remove(); |
|
| 5107 | } |
|
| 5108 | self$$1.classes.toggle('btn-has-text', !!text); |
|
| 5109 | } |
|
| 5110 | self$$1.state.on('change:text', function (e) { |
|
| 5111 | setButtonText(e.value); |
|
| 5112 | }); |
|
| 5113 | self$$1.state.on('change:icon', function (e) { |
|
| 5114 | var icon = e.value; |
|
| 5115 | var prefix = self$$1.classPrefix; |
|
| 5116 | self$$1.settings.icon = icon; |
|
| 5117 | icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; |
|
| 5118 | var btnElm = self$$1.getEl().firstChild; |
|
| 5119 | var iconElm = btnElm.getElementsByTagName('i')[0]; |
|
| 5120 | if (icon) { |
|
| 5121 | if (!iconElm || iconElm !== btnElm.firstChild) { |
|
| 5122 | iconElm = document.createElement('i'); |
|
| 5123 | btnElm.insertBefore(iconElm, btnElm.firstChild); |
|
| 5124 | } |
|
| 5125 | iconElm.className = icon; |
|
| 5126 | } else if (iconElm) { |
|
| 5127 | btnElm.removeChild(iconElm); |
|
| 5128 | } |
|
| 5129 | setButtonText(self$$1.state.get('text')); |
|
| 5130 | }); |
|
| 5131 | return self$$1._super(); |
|
| 5132 | } |
|
| 5133 | }); |
|
| 5134 | ||
| 5135 | var BrowseButton = Button.extend({ |
|
| @@ 4913-4950 (lines=38) @@ | ||
| 4910 | ariaPressed = typeof settings.active === 'boolean' ? ' aria-pressed="' + settings.active + '"' : ''; |
|
| 4911 | return '<div id="' + id + '" class="' + self$$1.classes + '" tabindex="-1"' + ariaPressed + '>' + '<button id="' + id + '-button" role="presentation" type="button" tabindex="-1">' + (icon ? '<i class="' + icon + '"' + image + '></i>' : '') + textHtml + '</button>' + '</div>'; |
|
| 4912 | }, |
|
| 4913 | bindStates: function () { |
|
| 4914 | var self$$1 = this, $ = self$$1.$, textCls = self$$1.classPrefix + 'txt'; |
|
| 4915 | function setButtonText(text) { |
|
| 4916 | var $span = $('span.' + textCls, self$$1.getEl()); |
|
| 4917 | if (text) { |
|
| 4918 | if (!$span[0]) { |
|
| 4919 | $('button:first', self$$1.getEl()).append('<span class="' + textCls + '"></span>'); |
|
| 4920 | $span = $('span.' + textCls, self$$1.getEl()); |
|
| 4921 | } |
|
| 4922 | $span.html(self$$1.encode(text)); |
|
| 4923 | } else { |
|
| 4924 | $span.remove(); |
|
| 4925 | } |
|
| 4926 | self$$1.classes.toggle('btn-has-text', !!text); |
|
| 4927 | } |
|
| 4928 | self$$1.state.on('change:text', function (e) { |
|
| 4929 | setButtonText(e.value); |
|
| 4930 | }); |
|
| 4931 | self$$1.state.on('change:icon', function (e) { |
|
| 4932 | var icon = e.value; |
|
| 4933 | var prefix = self$$1.classPrefix; |
|
| 4934 | self$$1.settings.icon = icon; |
|
| 4935 | icon = icon ? prefix + 'ico ' + prefix + 'i-' + self$$1.settings.icon : ''; |
|
| 4936 | var btnElm = self$$1.getEl().firstChild; |
|
| 4937 | var iconElm = btnElm.getElementsByTagName('i')[0]; |
|
| 4938 | if (icon) { |
|
| 4939 | if (!iconElm || iconElm !== btnElm.firstChild) { |
|
| 4940 | iconElm = document.createElement('i'); |
|
| 4941 | btnElm.insertBefore(iconElm, btnElm.firstChild); |
|
| 4942 | } |
|
| 4943 | iconElm.className = icon; |
|
| 4944 | } else if (iconElm) { |
|
| 4945 | btnElm.removeChild(iconElm); |
|
| 4946 | } |
|
| 4947 | setButtonText(self$$1.state.get('text')); |
|
| 4948 | }); |
|
| 4949 | return self$$1._super(); |
|
| 4950 | } |
|
| 4951 | }); |
|
| 4952 | ||
| 4953 | var BrowseButton = Button.extend({ |
|