1/*! 2 * bootstrap-select v1.3.5 3 * http://silviomoreto.github.io/bootstrap-select/ 4 * 5 * Copyright 2013 bootstrap-select 6 * Licensed under the MIT license 7 */ 8 9!function($) { 10 11 "use strict"; 12 13 $.expr[":"].icontains = function(obj, index, meta) { 14 return $(obj).text().toUpperCase().indexOf(meta[3].toUpperCase()) >= 0; 15 }; 16 17 var Selectpicker = function(element, options, e) { 18 if (e) { 19 e.stopPropagation(); 20 e.preventDefault(); 21 } 22 this.$element = $(element); 23 this.$newElement = null; 24 this.$button = null; 25 this.$menu = null; 26 27 //Merge defaults, options and data-attributes to make our options 28 this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options); 29 30 //If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute 31 if (this.options.title == null) { 32 this.options.title = this.$element.attr('title'); 33 } 34 35 //Expose public methods 36 this.val = Selectpicker.prototype.val; 37 this.render = Selectpicker.prototype.render; 38 this.refresh = Selectpicker.prototype.refresh; 39 this.setStyle = Selectpicker.prototype.setStyle; 40 this.selectAll = Selectpicker.prototype.selectAll; 41 this.deselectAll = Selectpicker.prototype.deselectAll; 42 this.init(); 43 }; 44 45 Selectpicker.prototype = { 46 47 constructor: Selectpicker, 48 49 init: function() { 50 this.$element.hide(); 51 this.multiple = this.$element.prop('multiple'); 52 var id = this.$element.attr('id'); 53 this.$newElement = this.createView(); 54 this.$element.after(this.$newElement); 55 this.$menu = this.$newElement.find('> .dropdown-menu'); 56 this.$button = this.$newElement.find('> button'); 57 this.$searchbox = this.$newElement.find('input'); 58 59 if (id !== undefined) { 60 var that = this; 61 this.$button.attr('data-id', id); 62 $('label[for="' + id + '"]').click(function(e) { 63 e.preventDefault(); 64 that.$button.focus(); 65 }); 66 } 67 68 this.checkDisabled(); 69 this.clickListener(); 70 this.liveSearchListener(); 71 this.render(); 72 this.liHeight(); 73 this.setStyle(); 74 this.setWidth(); 75 if (this.options.container) { 76 this.selectPosition(); 77 } 78 this.$menu.data('this', this); 79 this.$newElement.data('this', this); 80 }, 81 82 createDropdown: function() { 83 //If we are multiple, then add the show-tick class by default 84 var multiple = this.multiple ? ' show-tick' : ''; 85 var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>' + this.options.header + '</div>' : ''; 86 var searchbox = this.options.liveSearch ? '<div class="bootstrap-select-searchbox"><input type="text" class="input-block-level form-control" /></div>' : ''; 87 var drop = 88 "<div class='btn-group bootstrap-select" + multiple + "'>" + 89 "<button type='button' class='btn dropdown-toggle selectpicker' data-toggle='dropdown'>" + 90 "<div class='filter-option pull-left'></div> " + 91 "<div class='caret'></div>" + 92 "</button>" + 93 "<div class='dropdown-menu open'>" + 94 header + 95 searchbox + 96 "<ul class='dropdown-menu inner selectpicker' role='menu'>" + 97 "</ul>" + 98 "</div>" + 99 "</div>"; 100 101 return $(drop); 102 }, 103 104 createView: function() { 105 var $drop = this.createDropdown(); 106 var $li = this.createLi(); 107 $drop.find('ul').append($li); 108 return $drop; 109 }, 110 111 reloadLi: function() { 112 //Remove all children. 113 this.destroyLi(); 114 //Re build 115 var $li = this.createLi(); 116 this.$menu.find('ul').append( $li ); 117 }, 118 119 destroyLi: function() { 120 this.$menu.find('li').remove(); 121 }, 122 123 createLi: function() { 124 var that = this, 125 _liA = [], 126 _liHtml = ''; 127 128 this.$element.find('option').each(function() { 129 var $this = $(this); 130 131 //Get the class and text for the option 132 var optionClass = $this.attr("class") || ''; 133 var inline = $this.attr("style") || ''; 134 var text = $this.data('content') ? $this.data('content') : $this.html(); 135 var subtext = $this.data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.data('subtext') + '</small>' : ''; 136 var icon = $this.data('icon') !== undefined ? '<i class="glyphicon '+$this.data('icon')+'"></i> ' : ''; 137 if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) { 138 icon = '<span>'+icon+'</span>'; 139 } 140 141 if (!$this.data('content')) { 142 //Prepend any icon and append any subtext to the main text. 143 text = icon + '<span class="text">
143' + text + subtext + '</span>'; 144 } 145 146 if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) { 147 _liA.push('<a style="min-height: 0; padding: 0"></a>'); 148 } else if ($this.parent().is('optgroup') && $this.data('divider') !== true) { 149 if ($this.index() == 0) { 150 //Get the opt group label 151 var label = $this.parent().attr('label'); 152 var labelSubtext = $this.parent().data('subtext') !== undefined ? '<small class="muted text-muted">'+$this.parent().data('subtext')+'</small>' : ''; 153 var labelIcon = $this.parent().data('icon') ? '<i class="'+$this.parent().data('icon')+'"></i> ' : ''; 154 label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>'; 155 156 if ($this[0].index != 0) { 157 _liA.push( 158 '<div class="div-contain"><div class="divider"></div></div>'+ 159 '<dt>'+label+'</dt>'+ 160 that.createA(text, "opt " + optionClass, inline ) 161 ); 162 } else { 163 _liA.push( 164 '<dt>'+label+'</dt>'+ 165 that.createA(text, "opt " + optionClass, inline )); 166 } 167 } else { 168 _liA.push(that.createA(text, "opt " + optionClass, inline )); 169 } 170 } else if ($this.data('divider') === true) { 171 _liA.push('<div class="div-contain"><div class="divider"></div></div>'); 172 } else if ($(this).data('hidden') === true) { 173 _liA.push(''); 174 } else { 175 _liA.push(that.createA(text, optionClass, inline )); 176 } 177 }); 178 179 $.each(_liA, function(i, item) { 180 _liHtml += "<li rel=" + i + ">" + item + "</li>"; 181 }); 182 183 //If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button 184 if (!this.multiple && this.$element.find('option:selected').length==0 && !this.options.title) { 185 this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected'); 186 } 187 188 return $(_liHtml); 189 }, 190 191 createA: function(text, classes, inline) { 192 return '<a tabindex="0" class="'+classes+'" style="'+inline+'">' + 193 text + 194 '<i class="glyphicon glyphicon-ok icon-ok check-mark"></i>' + 195 '</a>'; 196 }, 197 198 render: function() { 199 var that = this; 200 201 //Update the LI to match the SELECT 202 this.$element.find('option').each(function(index) { 203 that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') ); 204 that.setSelected(index, $(this).is(':selected') ); 205 }); 206 207 this.tabIndex(); 208 209 var selectedItems = this.$element.find('option:selected').map(function() { 210 var $this = $(this); 211 var icon = $this.data('icon') && that.options.showIcon ? '<i class="glyphicon ' + $this.data('icon') + '"></i> ' : ''; 212 var subtext; 213 if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) { 214 subtext = ' <small class="muted text-muted">'+$this.data('subtext') +'</small>'; 215 } else { 216 subtext = ''; 217 } 218 if ($this.data('content') && that.options.showContent) { 219 return $this.data('content'); 220 } else if ($this.attr('title') != undefined) { 221 return $this.attr('title'); 222 } else { 223 return icon + $this.html() + subtext; 224 } 225 }).toArray(); 226 227 //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled 228 //Convert all the values into a comma delimited string 229 var title = !this.multiple ? selectedItems[0] : selectedItems.join(", "); 230 231 //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc.. 232 if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) { 233 var max = this.options.selectedTextFormat.split(">"); 234 var notDisabled = this.options.hideDisabled ? ':not([disabled])' : ''; 235 if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) { 236 title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length); 237 } 238 } 239 240 //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text 241 if (!title) { 242 title = this.options.title != undefined ? this.options.title : this.options.noneSelectedText; 243 } 244 245 this.$newElement.find('.filter-option').html(title); 246 }, 247 248 setStyle: function(style, status) { 249 if (this.$element.attr('class')) { 250 this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device/gi, '')); 251 } 252 253 var buttonClass = style ? style : this.options.style; 254 255 if (status == 'add') { 256 this.$button.addClass(buttonClass); 257 } else if (status == 'remove') { 258 this.$button.removeClass(buttonClass); 259 } else { 260 this.$button.removeClass(this.options.style); 261 this.$button.addClass(buttonClass); 262 } 263 }, 264 265 liHeight: function() { 266 var selectClone = this.$newElement.clone(); 267 selectClone.appendTo('body'); 268 var $menuClone = selectClone.addClass('open').find('> .dropdown-menu'); 269 var liHeight = $menuClone.find('li > a').outerHeight(); 270 var headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0; 271 var searchHeight = this.options.liveSearch ? $menuClone.find('.bootstrap-select-searchbox').outerHeight() : 0; 272 selectClone.remove(); 273 this.$newElement.data('liHeight', liHeight).data('headerHeight', headerHeight).data('searchHeight', searchHeight); 274 }, 275 276 setSize: function() { 277 var that = this, 278 menu = this.$menu, 279 menuInner = menu.find('.inner'), 280 selectHeight = this.$newElement.outerHeight(), 281 liHeight = this.$newElement.data('liHeight'), 282 headerHeight = this.$newElement.data('headerHeight'), 283 searchHeight = this.$newElement.data('searchHeight'), 284 divHeight = menu.find('li .divider').outerHeight(true), 285 menuPadding = parseInt(menu.css('padding-top')) + 286 parseInt(menu.css('padding-bottom')) + 287 parseInt(menu.css('border-top-width')) + 288 parseInt(menu.css('border-bottom-width')), 289 notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '', 290 $window = $(window), 291 menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2, 292 menuHeight, 293 selectOffsetTop, 294 selectOffsetBot, 295 posVert = function() { 296 selectOffsetTop = that.$newElement.offset().top - $window.scrollTop(); 297 selectOffsetBot = $window.height() - selectOffsetTop - selectHeight; 298 }; 299 posVert(); 300 if (this.options.header) menu.css('padding-top', 0); 301 302 if (this.options.size == 'auto') { 303 var getSize = function() { 304 var minHeight; 305 posVert(); 306 menuHeight = selectOffsetBot - menuExtras; 307 that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight - menuExtras) < menu.height() && that.options.dropupAuto); 308 if (that.$newElement.hasClass('dropup')) { 309 menuHeight = selectOffsetTop - menuExtras; 310 } 311 if ((menu.find('li').length + menu.find('dt').length) > 3) { 312 minHeight = liHeight*3 + menuExtras - 2; 313 } else { 314 minHeight = 0; 315 } 316 menu.css({'max-height' : menuHeight + 'px', 'overflow' : 'hidden', 'min-height' : minHeight + 'px'}); 317 menuInner.css({'max-height' : menuHeight - headerHeight - searchHeight- menuPadding + 'px', 'overflow-y' : 'auto', 'min-height' : minHeight - menuPadding + 'px'}); 318 }; 319 getSize(); 320 $(window).resize(getSize); 321 $(window).scroll(getSize); 322 } else if (this.options.size && this.options.size != 'auto' && menu.find('li'+notDisabled).length > this.options.size) { 323 var optIndex = menu.find("li"+notDisabled+" > *").filter(':not(.div-contain)').slice(0,this.options.size).last().parent().index(); 324 var divLength = menu.find("li").slice(0,optIndex + 1).find('.div-contain').length; 325 menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding; 326 this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && menuHeight < menu.height() && this.options.dropupAuto); 327 menu.css({'max-height' : menuHeight + headerHeight + searchHeight + 'px', 'overflow' : 'hidden'}); 328 menuInner.css({'max-height' : menuHeight - menuPadding + 'px', 'overflow-y' : 'auto'}); 329 } 330 }, 331 332 setWidth: function() { 333 if (this.options.width == 'auto') { 334 this.$menu.css('min-width', '0'); 335 336 // Get correct width if element hidden 337 var selectClone = this.$newElement.clone().appendTo('body'); 338 var ulWidth = selectClone.find('> .dropdown-menu').css('width'); 339 selectClone.remove(); 340 341 this.$newElement.css('width', ulWidth); 342 } else if (this.options.width == 'fit') { 343 // Remove inline min-width so width can be changed from 'auto' 344 this.$menu.css('min-width', ''); 345 this.$newElement.css('width', '').addClass('fit-width'); 346 } else if (this.options.width) { 347 // Remove inline min-width so width can be changed from 'auto' 348 this.$menu.css('min-width', ''); 349 this.$newElement.css('width', this.options.width); 350 } else { 351 // Remove inline min-width/width so width can be changed 352 this.$menu.css('min-width', ''); 353 this.$newElement.css('width', ''); 354 } 355 // Remove fit-width class if width is changed programmatically 356 if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { 357 this.$newElement.removeClass('fit-width'); 358 } 359 }, 360 361 selectPosition: function() { 362 var that = this, 363 drop = "<div />", 364 $drop = $(drop), 365 pos, 366 actualHeight, 367 getPlacement = function($element) { 368 $drop.addClass($element.attr('class')).toggleClass('dropup', $element.hasClass('dropup')); 369 pos = $element.offset(); 370 actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight; 371 $drop.css({'top' : pos.top + actualHeight, 'left' : pos.left, 'width' : $element[0].offsetWidth, 'position' : 'absolute'}); 372 }; 373 this.$newElement.on('click', function() { 374 getPlacement($(this)); 375 $drop.appendTo(that.options.container); 376 $drop.toggleClass('open', !$(this).hasClass('open')); 377 $drop.append(that.$menu); 378 }); 379 $(window).resize(function() { 380 getPlacement(that.$newElement); 381 }); 382 $(window).on('scroll', function() { 383 getPlacement(that.$newElement); 384 }); 385 $('html').on('click', function(e) { 386 if ($(e.target).closest(that.$newElement).length < 1) { 387 $drop.removeClass('open'); 388 } 389 }); 390 }, 391 392 mobile: function() { 393 this.$element.addClass('mobile-device').appendTo(this.$newElement); 394 if (this.options.container) this.$menu.hide(); 395 }, 396 397 refresh: function() { 398 this.reloadLi(); 399 this.render(); 400 this.setWidth(); 401 this.setStyle(); 402 this.checkDisabled(); 403 this.liHeight(); 404 }, 405 406 update: function() { 407 this.reloadLi(); 408 this.setWidth(); 409 this.setStyle(); 410 this.checkDisabled(); 411 this.liHeight(); 412 }, 413 414 setSelected: function(index, selected) { 415 this.$menu.find('li').eq(index).toggleClass('selected', selected); 416 }, 417 418 setDisabled: function(index, disabled) { 419 if (disabled) { 420 this.$menu.find('li').eq(index).addClass('disabled').find('a').attr('href','#').attr('tabindex',-1); 421 } else { 422 this.$menu.find('li').eq(index).removeClass('disabled').find('a').removeAttr('href').attr('tabindex',0); 423 } 424 }, 425 426 isDisabled: function() { 427 return this.$element.is(':disabled'); 428 }, 429 430 checkDisabled: function() { 431 var that = this; 432 433 if (this.isDisabled()) { 434 this.$button.addClass('disabled').attr('tabindex', -1); 435 } else { 436 if (this.$button.hasClass('disabled')) { 437 this.$button.removeClass('disabled'); 438 } 439 440 if (this.$button.attr('tabindex') == -1) { 441 if (!this.$element.data('tabindex')) this.$button.removeAttr('tabindex'); 442 } 443 } 444 445 this.$button.click(function() { 446 return !that.isDisabled(); 447 }); 448 }, 449 450 tabIndex: function() { 451 if (this.$element.is('[tabindex]')) { 452 this.$element.data('tabindex', this.$element.attr("tabindex")); 453 this.$button.attr('tabindex', this.$element.data('tabindex')); 454 } 455 }, 456 457 clickListener: function() { 458 var that = this; 459 460 $('body').on('touchstart.dropdown', '.dropdown-menu', function(e) { 461 e.stopPropagation(); 462 }); 463 464 this.$newElement.on('click', function() { 465 that.setSize(); 466 }); 467 468 this.$menu.on('click', 'li a', function(e) { 469 var clickedIndex = $(this).parent().index(), 470 prevValue = that.$element.val(); 471 472 //Dont close on multi choice menu 473 if (that.multiple) { 474 e.stopPropagation(); 475 } 476 477 e.preventDefault(); 478 479 //Dont run if we have been disabled 480 if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) { 481 var $options = that.$element.find('option'); 482 var $option = $options.eq(clickedIndex); 483 484 //Deselect all others if not multi select box 485 if (!that.multiple) { 486 $options.prop('selected', false); 487 $option.prop('selected', true); 488 } 489 //Else toggle the one we have chosen if we are multi sel
489ect. 490 else { 491 var state = $option.prop('selected'); 492 493 $option.prop('selected', !state); 494 } 495 496 that.$button.focus(); 497 498 // Trigger select 'change' 499 if (prevValue != that.$element.val()) { 500 that.$element.change(); 501 } 502 } 503 }); 504 505 this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, h3.popover-title', function(e) { 506 if (e.target == this) { 507 e.preventDefault(); 508 e.stopPropagation(); 509 that.$button.focus(); 510 } 511 }); 512 513 this.$searchbox.on('click', function(e) { 514 e.stopPropagation(); 515 }); 516 517 this.$element.change(function() { 518 that.render(); 519 }); 520 }, 521 522 liveSearchListener: function() { 523 var that = this; 524 525 this.$newElement.on('click.dropdown.data-api', function(){ 526 if(that.options.liveSearch) { 527 setTimeout(function() { 528 that.$searchbox.focus(); 529 }, 10); 530 } 531 }); 532 533 this.$searchbox.on('keyup', function(e) { 534 if(e.keyCode == 40) { 535 // Down-arrow should go to the first visible item. 536 that.$menu.find('li:not(.divider):visible a').first().focus(); 537 } 538 else if(e.keyCode == 38) { 539 // Up-arrow should go to the last visible item. 540 that.$menu.find('li:not(.divider):visible a').last().focus(); 541 } 542 else if (that.$searchbox.val()) { 543 that.$menu.find('li').show().not(':icontains(' + that.$searchbox.val() + ')').hide(); 544 } else { 545 that.$menu.find('li').show(); 546 } 547 }).on('keydown', function(e) { 548 if(e.keyCode == 13) { 549 // Prevent return from submitting any form here (needs to be in keydown instead of keyup). 550 // Closes the dropdown and focuses it. 551 that.$button.click().focus(); 552 e.preventDefault(); 553 return false; 554 } 555 }); 556 }, 557 558 val: function(value) { 559 560 if (value != undefined) { 561 this.$element.val( value ); 562 563 this.$element.change(); 564 return this.$element; 565 } else { 566 return this.$element.val(); 567 } 568 }, 569 570 selectAll: function() { 571 this.$element.find('option').prop('selected', true).attr('selected', 'selected'); 572 this.render(); 573 }, 574 575 deselectAll: function() { 576 this.$element.find('option').prop('selected', false).removeAttr('selected'); 577 this.render(); 578 }, 579 580 keydown: function(e) { 581 var that = $(this).parent().data('this'); 582 // If the dropdown is closed, open it and move focus to the search box, if there is one. 583 if(that.$searchbox && that.$searchbox.is(':not(:visible)') && e.keyCode >= 48 && e.keyCode <= 90) { 584 $(':focus').click(); 585 that.$searchbox.focus(); 586 } 587 }, 588 589 keyup: function(e) { 590 var $this, 591 $items, 592 $parent, 593 that; 594 595 $this = $(this); 596 597 $parent = $this.parent(); 598 599 that = $parent.data('this'); 600 601 if (that.options.container) $parent = that.$menu; 602 603 $items = $('[role=menu] li:not(.divider):visible a', $parent); 604 605 if (!$items.length) return; 606 607 if (/(38|40)/.test(e.keyCode) && that.$searchbox) { 608 // Since we bind on keyup, the focus will have already changed here. Keep track of the last focused item and the current, 609 // and if they match (and are at the top or bottom of the list), move the focus to the searchbox. 610 var index = $items.index($(':focus')); 611 var last = $this.data('lastIndex'); 612 $this.data('lastIndex', index); 613 if(index == last) { 614 if(index == 0 || index == $items.length - 1) that.$searchbox.focus(); 615 } 616 } 617 else { 618 var keyCodeMap = { 619 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", 59:";", 620 65:"a", 66:"b", 67:"c", 68:"d", 69:"e", 70:"f", 71:"g", 72:"h", 73:"i", 74:"j", 75:"k", 76:"l", 621 77:"m", 78:"n", 79:"o", 80:"p", 81:"q", 82:"r", 83:"s", 84:"t", 85:"u", 86:"v", 87:"w", 88:"x", 89:"y", 90:"z", 622 96:"0", 97:"1", 98:"2", 99:"3", 100:"4", 101:"5", 102:"6", 103:"7", 104:"8", 105:"9" 623 }; 624 625 var keyIndex = []; 626 627 $items.each(function() { 628 if ($(this).parent().is(':not(.disabled)')) { 629 if ($.trim($(this).text().toLowerCase()).substring(0,1) == keyCodeMap[e.keyCode]) { 630 keyIndex.push($(this).parent().index()); 631 } 632 } 633 }); 634 635 var count = $(document).data('keycount'); 636 count++; 637 $(document).data('keycount',count); 638 639 var prevKey = $.trim($(':focus').text().toLowerCase()).substring(0,1); 640 641 if (prevKey != keyCodeMap[e.keyCode]) { 642 count = 1; 643 $(document).data('keycount',count); 644 } else if (count >= keyIndex.length) { 645 $(document).data('keycount',0); 646 } 647 648 $items.eq(keyIndex[count - 1]).focus(); 649 } 650 651 // Select focused option if "Enter" or "Spacebar" are pressed inside the menu. 652 if (/(13|32)/.test(e.keyCode) && $this.is('[role=menu]')) { 653 e.preventDefault(); 654 $(':focus').click(); 655 $(document).data('keycount',0); 656 } 657 }, 658 659 hide: function() { 660 this.$newElement.hide(); 661 }, 662 663 show: function() { 664 this.$newElement.show(); 665 }, 666 667 destroy: function() { 668 this.$newElement.remove(); 669 this.$element.remove(); 670 } 671 }; 672 673 $.fn.selectpicker = function(option, event) { 674 //get the args of the outer function.. 675 var args = arguments; 676 var value; 677 var chain = this.each(function() { 678 if ($(this).is('select')) { 679 var $this = $(this), 680 data = $this.data('selectpicker'), 681 options = typeof option == 'object' && option; 682 683 if (!data) { 684 $this.data('selectpicker', (data = new Selectpicker(this, options, event))); 685 } else if (options) { 686 for(var i in options) { 687 data.options[i] = options[i]; 688 } 689 } 690 691 if (typeof option == 'string') { 692 //Copy the value of option, as once we shift the arguments 693 //it also shifts the value of option. 694 var property = option; 695 if (data[property] instanceof Function) { 696 [].shift.apply(args); 697 value = data[property].apply(data, args); 698 } else { 699 value = data.options[property]; 700 } 701 } 702 } 703 }); 704 705 if (value != undefined) { 706 return value; 707 } else { 708 return chain; 709 } 710 }; 711 712 $.fn.selectpicker.defaults = { 713 style: 'btn-default', 714 size: 'auto', 715 title: null, 716 selectedTextFormat : 'values', 717 noneSelectedText : 'Nothing selected', 718 countSelectedText: '{0} of {1} selected', 719 width: false, 720 container: false, 721 hideDisabled: false, 722 showSubtext: false, 723 showIcon: true, 724 showContent: true, 725 dropupAuto: true, 726 header: false, 727 liveSearch: false 728 }; 729 730 $(document) 731 .data('keycount', 0) 732 .on('keydown', '.selectpicker[data-toggle=dropdown], .selectpicker[role=menu]' , Selectpicker.prototype.keydown) 733 .on('keyup', '.selectpicker[data-toggle=dropdown], .selectpicker[role=menu]' , Selectpicker.prototype.keyup); 734 735}(window.jQuery);
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.