|
1 | 1 | /*! |
2 | | - * jQuery Pretty Dropdowns Plugin v4.12.2 by T. H. Doan (https://thdoan.github.io/pretty-dropdowns/) |
| 2 | + * jQuery Pretty Dropdowns Plugin v4.13.0 by T. H. Doan (https://thdoan.github.io/pretty-dropdowns/) |
3 | 3 | * |
4 | 4 | * jQuery Pretty Dropdowns by T. H. Doan is licensed under the MIT License. |
5 | 5 | * Read a copy of the license in the LICENSE file or at https://choosealicense.com/licenses/mit/ |
|
12 | 12 | oOptions = $.extend({ |
13 | 13 | classic: false, |
14 | 14 | customClass: 'arrow', |
| 15 | + width: null, |
15 | 16 | height: 50, |
16 | 17 | hoverIntent: 200, |
17 | 18 | multiDelimiter: '; ', |
|
22 | 23 |
|
23 | 24 | oOptions.selectedMarker = '<span aria-hidden="true" class="checked"> ' + oOptions.selectedMarker + '</span>'; |
24 | 25 | // Validate options |
25 | | - if (isNaN(oOptions.height) || oOptions.height<8) oOptions.height = 8; |
| 26 | + if (isNaN(oOptions.width) && !/^\d+%$/.test(oOptions.width)) oOptions.width = null; |
| 27 | + if (isNaN(oOptions.height)) oOptions.height = 50; |
| 28 | + else if (oOptions.height<8) oOptions.height = 8; |
26 | 29 | if (isNaN(oOptions.hoverIntent) || oOptions.hoverIntent<0) oOptions.hoverIntent = 200; |
27 | 30 | if (isNaN(oOptions.multiVerbosity)) oOptions.multiVerbosity = 99; |
28 | 31 |
|
|
137 | 140 | // Set dropdown width and event handler |
138 | 141 | // NOTE: Setting width using width(), then css() because width() only can return a float, |
139 | 142 | // which can result in a missing right border when there is a scrollbar. |
140 | | - $items.width(nWidth).css('width', $items.css('width')).click(function() { |
| 143 | + $items.width(nWidth).css('width', $items.css('width')); |
| 144 | + if (oOptions.width) { |
| 145 | + $dropdown.parent().css('min-width', $items.css('width')); |
| 146 | + $dropdown.css('width', '100%'); |
| 147 | + $items.css('width', '100%'); |
| 148 | + } |
| 149 | + $items.click(function() { |
141 | 150 | var $li = $(this), |
142 | 151 | $selected = $dropdown.children('.selected'); |
143 | 152 | // Ignore disabled menu |
|
230 | 239 | // Put focus on menu when user clicks on label |
231 | 240 | if (sLabelId) $('#' + sLabelId).off('click', handleFocus).click(handleFocus); |
232 | 241 | // Done with everything! |
233 | | - $dropdown.parent().width(nOuterWidth||$dropdown.outerWidth(true)).removeClass('loading'); |
| 242 | + $dropdown.parent().width(oOptions.width||nOuterWidth||$dropdown.outerWidth(true)).removeClass('loading'); |
234 | 243 | oOptions.afterLoad(); |
235 | 244 | }, |
236 | 245 |
|
|
386 | 395 | ++nCount; |
387 | 396 | return '<li id="item' + nTimestamp + '-' + nCount + '"' |
388 | 397 | + (sGroup ? ' data-group="' + sGroup + '"' : '') |
389 | | - + (elOpt && elOpt.value ? ' data-value="' + elOpt.value + '"' : '') |
| 398 | + + (elOpt && (elOpt.value||oOptions.classic) ? ' data-value="' + elOpt.value + '"' : '') |
390 | 399 | + (elOpt && elOpt.nodeName==='OPTION' ? ' role="option"' : '') |
391 | 400 | + (sTitle ? ' title="' + sTitle + '" aria-label="' + sTitle + '"' : '') |
392 | 401 | + (sClass ? ' class="' + $.trim(sClass) + '"' : '') |
|
0 commit comments