phcthemes_admin_panel_pack 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/common/backstretch/jquery.backstretch.js +1602 -0
  3. data/app/assets/javascripts/common/bootstrap-datepicker/bootstrap-datepicker.js +2039 -0
  4. data/app/assets/javascripts/common/bootstrap-markdown/bootstrap-markdown.js +1390 -0
  5. data/app/assets/javascripts/common/bootstrap-select/bootstrap-select.js +3139 -0
  6. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-am_ET.js +46 -0
  7. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-am_ET.js.map +1 -0
  8. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-am_ET.min.js +8 -0
  9. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ar_AR.js +51 -0
  10. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ar_AR.js.map +1 -0
  11. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ar_AR.min.js +8 -0
  12. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-bg_BG.js +46 -0
  13. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-bg_BG.js.map +1 -0
  14. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-bg_BG.min.js +8 -0
  15. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-cs_CZ.js +39 -0
  16. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-cs_CZ.js.map +1 -0
  17. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-cs_CZ.min.js +8 -0
  18. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-da_DK.js +46 -0
  19. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-da_DK.js.map +1 -0
  20. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-da_DK.min.js +8 -0
  21. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-de_DE.js +46 -0
  22. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-de_DE.js.map +1 -0
  23. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-de_DE.min.js +8 -0
  24. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-en_US.js +46 -0
  25. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-en_US.js.map +1 -0
  26. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-en_US.min.js +8 -0
  27. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_CL.js +39 -0
  28. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_CL.js.map +1 -0
  29. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_CL.min.js +8 -0
  30. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_ES.js +39 -0
  31. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_ES.js.map +1 -0
  32. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-es_ES.min.js +8 -0
  33. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-et_EE.js +46 -0
  34. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-et_EE.js.map +1 -0
  35. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-et_EE.min.js +8 -0
  36. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-eu.js +39 -0
  37. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-eu.js.map +1 -0
  38. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-eu.min.js +8 -0
  39. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fa_IR.js +39 -0
  40. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fa_IR.js.map +1 -0
  41. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fa_IR.min.js +8 -0
  42. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fi_FI.js +46 -0
  43. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fi_FI.js.map +1 -0
  44. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fi_FI.min.js +8 -0
  45. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fr_FR.js +46 -0
  46. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fr_FR.js.map +1 -0
  47. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-fr_FR.min.js +8 -0
  48. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hr_HR.js +46 -0
  49. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hr_HR.js.map +1 -0
  50. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hr_HR.min.js +8 -0
  51. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hu_HU.js +46 -0
  52. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hu_HU.js.map +1 -0
  53. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-hu_HU.min.js +8 -0
  54. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-id_ID.js +39 -0
  55. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-id_ID.js.map +1 -0
  56. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-id_ID.min.js +8 -0
  57. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-it_IT.js +41 -0
  58. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-it_IT.js.map +1 -0
  59. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-it_IT.min.js +8 -0
  60. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ja_JP.js +39 -0
  61. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ja_JP.js.map +1 -0
  62. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ja_JP.min.js +8 -0
  63. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-kh_KM.js +46 -0
  64. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-kh_KM.js.map +1 -0
  65. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-kh_KM.min.js +8 -0
  66. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ko_KR.js +46 -0
  67. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ko_KR.js.map +1 -0
  68. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ko_KR.min.js +8 -0
  69. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lt_LT.js +46 -0
  70. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lt_LT.js.map +1 -0
  71. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lt_LT.min.js +8 -0
  72. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lv_LV.js +46 -0
  73. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lv_LV.js.map +1 -0
  74. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-lv_LV.min.js +8 -0
  75. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nb_NO.js +46 -0
  76. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nb_NO.js.map +1 -0
  77. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nb_NO.min.js +8 -0
  78. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nl_NL.js +39 -0
  79. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nl_NL.js.map +1 -0
  80. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-nl_NL.min.js +8 -0
  81. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pl_PL.js +39 -0
  82. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pl_PL.js.map +1 -0
  83. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pl_PL.min.js +8 -0
  84. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_BR.js +39 -0
  85. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_BR.js.map +1 -0
  86. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_BR.min.js +8 -0
  87. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_PT.js +39 -0
  88. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_PT.js.map +1 -0
  89. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-pt_PT.min.js +8 -0
  90. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ro_RO.js +40 -0
  91. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ro_RO.js.map +1 -0
  92. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ro_RO.min.js +8 -0
  93. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ru_RU.js +40 -0
  94. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ru_RU.js.map +1 -0
  95. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ru_RU.min.js +8 -0
  96. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sk_SK.js +39 -0
  97. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sk_SK.js.map +1 -0
  98. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sk_SK.min.js +8 -0
  99. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sl_SI.js +44 -0
  100. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sl_SI.js.map +1 -0
  101. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sl_SI.min.js +8 -0
  102. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sv_SE.js +46 -0
  103. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sv_SE.js.map +1 -0
  104. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-sv_SE.min.js +8 -0
  105. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-tr_TR.js +46 -0
  106. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-tr_TR.js.map +1 -0
  107. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-tr_TR.min.js +8 -0
  108. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ua_UA.js +39 -0
  109. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ua_UA.js.map +1 -0
  110. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-ua_UA.min.js +8 -0
  111. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-vi_VN.js +46 -0
  112. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-vi_VN.js.map +1 -0
  113. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-vi_VN.min.js +8 -0
  114. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_CN.js +39 -0
  115. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_CN.js.map +1 -0
  116. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_CN.min.js +8 -0
  117. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_TW.js +39 -0
  118. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_TW.js.map +1 -0
  119. data/app/assets/javascripts/common/bootstrap-select/i18n/defaults-zh_TW.min.js +8 -0
  120. data/app/assets/javascripts/common/bootstrap/bootstrap.bundle.js +7013 -0
  121. data/app/assets/javascripts/common/bootstrap/bootstrap.three.js +2377 -0
  122. data/app/assets/javascripts/common/chartjs/chart.js +14680 -0
  123. data/app/assets/javascripts/common/custom/custom.js +0 -0
  124. data/app/assets/javascripts/common/datatables/datatables.js +15310 -0
  125. data/app/assets/javascripts/common/daterangepicker/daterangepicker.js +1565 -0
  126. data/app/assets/javascripts/common/fastclick/fastclick.js +841 -0
  127. data/app/assets/javascripts/common/flexslider/jquery.flexslider.js +1252 -0
  128. data/app/assets/javascripts/common/greenstock/greensock.js +36 -0
  129. data/app/assets/javascripts/common/icheck/icheck.js +509 -0
  130. data/app/assets/javascripts/common/imagesloaded/imagesloaded.pkgd.js +497 -0
  131. data/app/assets/javascripts/common/isotope/isotope.pkgd.js +3563 -0
  132. data/app/assets/javascripts/common/jquery-countdown/jquery.countdown.js +246 -0
  133. data/app/assets/javascripts/common/jquery-filterizer/jquery.filterizr.min.js +1 -0
  134. data/app/assets/javascripts/common/jquery-jvectormap/jquery-jvectormap.js +44 -0
  135. data/app/assets/javascripts/common/jquery-placeholder/jquery.placeholder.js +281 -0
  136. data/app/assets/javascripts/common/jquery-slimscroll/jquery.slimscroll.js +474 -0
  137. data/app/assets/javascripts/common/jquery-sparkline/jquery.sparkline.js +3054 -0
  138. data/app/assets/javascripts/common/jquery-ui/jquery-ui.js +18706 -0
  139. data/app/assets/javascripts/common/jquery-validation/jquery.validate.js +1650 -0
  140. data/app/assets/javascripts/common/jquery/jquery-3.4.1.js +10598 -0
  141. data/app/assets/javascripts/common/jqvmap/jquery.vmap.js +1281 -0
  142. data/app/assets/javascripts/common/jqvmap/jquery.vmap.min.js +10 -0
  143. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.africa.js +2 -0
  144. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.asia.js +2 -0
  145. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.australia.js +2 -0
  146. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.europe.js +2 -0
  147. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.north-america.js +2 -0
  148. data/app/assets/javascripts/common/jqvmap/maps/continents/jquery.vmap.south-america.js +2 -0
  149. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.algeria.js +2 -0
  150. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.argentina.js +1 -0
  151. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.brazil.js +2 -0
  152. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.canada.js +2 -0
  153. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.europe.js +2 -0
  154. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.france.js +1 -0
  155. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.germany.js +2 -0
  156. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.greece.js +1 -0
  157. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.iran.js +6 -0
  158. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.iraq.js +1 -0
  159. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.russia.js +2 -0
  160. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.tunisia.js +2 -0
  161. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.turkey.js +11 -0
  162. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.usa.js +2 -0
  163. data/app/assets/javascripts/common/jqvmap/maps/jquery.vmap.world.js +2 -0
  164. data/app/assets/javascripts/common/js-cookie/js.cookie.js +165 -0
  165. data/app/assets/javascripts/common/layerslider/layerslider.kreaturamedia.jquery.js +13 -0
  166. data/app/assets/javascripts/common/layerslider/layerslider.origami.js +13 -0
  167. data/app/assets/javascripts/common/layerslider/layerslider.timeline.js +13 -0
  168. data/app/assets/javascripts/common/layerslider/layerslider.transitions.js +13 -0
  169. data/app/assets/javascripts/common/leaflet/leaflet.js +5 -0
  170. data/app/assets/javascripts/common/magnific-popup/jquery.magnific-popup.js +1860 -0
  171. data/app/assets/javascripts/common/mapbox/mapbox.js +51 -0
  172. data/app/assets/javascripts/common/metismenu/metisMenu.js +340 -0
  173. data/app/assets/javascripts/common/moderizer/modernizr.js +11 -0
  174. data/app/assets/javascripts/common/owl-carousel/owl.carousel.js +3448 -0
  175. data/app/assets/javascripts/common/pace/pace.js +935 -0
  176. data/app/assets/javascripts/common/paroller/jquery.paroller.js +228 -0
  177. data/app/assets/javascripts/common/particlejs/particles.js +1541 -0
  178. data/app/assets/javascripts/common/perfect-scrollbar/perfect-scrollbar.common.js +1318 -0
  179. data/app/assets/javascripts/common/perfect-scrollbar/perfect-scrollbar.esm.js +1316 -0
  180. data/app/assets/javascripts/common/perfect-scrollbar/perfect-scrollbar.js +1324 -0
  181. data/app/assets/javascripts/common/plyr/plyr.js +9137 -0
  182. data/app/assets/javascripts/common/rangeslider/rangeslider.js +498 -0
  183. data/app/assets/javascripts/common/retina/retina.js +100 -0
  184. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.actions.js +386 -0
  185. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.carousel.js +365 -0
  186. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.kenburn.js +199 -0
  187. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.layeranimation.js +2524 -0
  188. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.migration.js +260 -0
  189. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.navigation.js +1156 -0
  190. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.parallax.js +465 -0
  191. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.slideanims.js +1447 -0
  192. data/app/assets/javascripts/common/rev-slider/extensions/revolution.extension.video.js +1464 -0
  193. data/app/assets/javascripts/common/rev-slider/jquery.themepunch.revolution.js +3286 -0
  194. data/app/assets/javascripts/common/rev-slider/jquery.themepunch.tools.min.js +8710 -0
  195. data/app/assets/javascripts/common/scrollup/jquery.scrollUp.js +168 -0
  196. data/app/assets/javascripts/common/select2/select2.full.js +6597 -0
  197. data/app/assets/javascripts/common/selectbox/jquery.selectBox.js +1092 -0
  198. data/app/assets/javascripts/common/smooth-scroll/SmoothScroll.js +788 -0
  199. data/app/assets/javascripts/common/spectrum/spectrum.js +2323 -0
  200. data/app/assets/javascripts/common/stepper/jquery.fs.stepper.js +339 -0
  201. data/app/assets/javascripts/common/swiper/swiper.js +8124 -0
  202. data/app/assets/javascripts/common/toaster/toastr.js +476 -0
  203. data/app/assets/javascripts/common/typed/typed.js +1045 -0
  204. data/app/assets/javascripts/common/visable/jquery.visible.js +68 -0
  205. data/app/assets/javascripts/common/waypoints/jquery.waypoints.js +662 -0
  206. data/app/assets/javascripts/phcthemes_admin_panel_pack_adminlte.js +12 -0
  207. data/app/assets/javascripts/phcthemes_admin_panel_pack_basic.js +5 -0
  208. data/app/assets/javascripts/phcthemes_admin_panel_pack_boomerang.js +0 -0
  209. data/app/assets/javascripts/phcthemes_admin_panel_pack_coloradmin.js +10 -0
  210. data/app/assets/javascripts/phcthemes_admin_panel_pack_inspinia.js +10 -0
  211. data/app/assets/javascripts/phcthemes_admin_panel_pack_metronic.js +4 -0
  212. data/app/assets/javascripts/phcthemes_admin_panel_pack_quilpro.js +5 -0
  213. data/app/assets/javascripts/phcthemes_admin_panel_pack_starlight.js +5 -0
  214. data/app/assets/javascripts/themes/adminlte/custom/custom.js +0 -0
  215. data/app/assets/javascripts/themes/adminlte/theme/adminlte.js +1141 -0
  216. data/app/assets/javascripts/themes/boomerang/custom/custom.1.js +0 -0
  217. data/app/assets/javascripts/themes/boomerang/custom/custom.js +0 -0
  218. data/app/assets/javascripts/themes/coloradmin/theme/apps.js +1650 -0
  219. data/app/assets/javascripts/themes/coloradmin/theme/default.js +152 -0
  220. data/app/assets/javascripts/themes/inspinia/custom/custom.js +0 -0
  221. data/app/assets/javascripts/themes/inspinia/theme/inspinia.js +279 -0
  222. data/app/assets/javascripts/themes/metronic/theme/scripts.bundle.js +9916 -0
  223. data/app/assets/javascripts/themes/metronic/theme/vendors.bundle.js +91352 -0
  224. data/app/assets/stylesheets/phcthemes_admin_panel_pack_adminlte.scss +13 -0
  225. data/app/assets/stylesheets/phcthemes_admin_panel_pack_basic.scss +6 -0
  226. data/app/assets/stylesheets/phcthemes_admin_panel_pack_boomerang.scss +24 -0
  227. data/app/assets/stylesheets/phcthemes_admin_panel_pack_coloradmin.scss +15 -0
  228. data/app/assets/stylesheets/phcthemes_admin_panel_pack_inspinia.scss +15 -0
  229. data/app/assets/stylesheets/phcthemes_admin_panel_pack_metronic.scss +7 -0
  230. data/app/assets/stylesheets/phcthemes_admin_panel_pack_quilpro.scss +16 -0
  231. data/app/assets/stylesheets/phcthemes_admin_panel_pack_starlight.scss +12 -0
  232. data/lib/phcthemes_admin_panel_pack/engine.rb +7 -5
  233. data/lib/phcthemes_admin_panel_pack/version.rb +1 -1
  234. metadata +234 -18
@@ -0,0 +1,3139 @@
1
+ /*!
2
+ * Bootstrap-select v1.13.10 (https://developer.snapappointments.com/bootstrap-select)
3
+ *
4
+ * Copyright 2012-2019 SnapAppointments, LLC
5
+ * Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
6
+ */
7
+
8
+ (function (root, factory) {
9
+ if (root === undefined && window !== undefined) root = window;
10
+ if (typeof define === 'function' && define.amd) {
11
+ // AMD. Register as an anonymous module unless amdModuleId is set
12
+ define(["jquery"], function (a0) {
13
+ return (factory(a0));
14
+ });
15
+ } else if (typeof module === 'object' && module.exports) {
16
+ // Node. Does not work with strict CommonJS, but
17
+ // only CommonJS-like environments that support module.exports,
18
+ // like Node.
19
+ module.exports = factory(require("jquery"));
20
+ } else {
21
+ factory(root["jQuery"]);
22
+ }
23
+ }(this, function (jQuery) {
24
+
25
+ (function ($) {
26
+ 'use strict';
27
+
28
+ var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
29
+
30
+ var uriAttrs = [
31
+ 'background',
32
+ 'cite',
33
+ 'href',
34
+ 'itemtype',
35
+ 'longdesc',
36
+ 'poster',
37
+ 'src',
38
+ 'xlink:href'
39
+ ];
40
+
41
+ var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
42
+
43
+ var DefaultWhitelist = {
44
+ // Global attributes allowed on any supplied element below.
45
+ '*': ['class', 'dir', 'id', 'lang', 'role', 'tabindex', 'style', ARIA_ATTRIBUTE_PATTERN],
46
+ a: ['target', 'href', 'title', 'rel'],
47
+ area: [],
48
+ b: [],
49
+ br: [],
50
+ col: [],
51
+ code: [],
52
+ div: [],
53
+ em: [],
54
+ hr: [],
55
+ h1: [],
56
+ h2: [],
57
+ h3: [],
58
+ h4: [],
59
+ h5: [],
60
+ h6: [],
61
+ i: [],
62
+ img: ['src', 'alt', 'title', 'width', 'height'],
63
+ li: [],
64
+ ol: [],
65
+ p: [],
66
+ pre: [],
67
+ s: [],
68
+ small: [],
69
+ span: [],
70
+ sub: [],
71
+ sup: [],
72
+ strong: [],
73
+ u: [],
74
+ ul: []
75
+ }
76
+
77
+ /**
78
+ * A pattern that recognizes a commonly useful subset of URLs that are safe.
79
+ *
80
+ * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
81
+ */
82
+ var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
83
+
84
+ /**
85
+ * A pattern that matches safe data URLs. Only matches image, video and audio types.
86
+ *
87
+ * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
88
+ */
89
+ var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;
90
+
91
+ function allowedAttribute (attr, allowedAttributeList) {
92
+ var attrName = attr.nodeName.toLowerCase()
93
+
94
+ if ($.inArray(attrName, allowedAttributeList) !== -1) {
95
+ if ($.inArray(attrName, uriAttrs) !== -1) {
96
+ return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN))
97
+ }
98
+
99
+ return true
100
+ }
101
+
102
+ var regExp = $(allowedAttributeList).filter(function (index, value) {
103
+ return value instanceof RegExp
104
+ })
105
+
106
+ // Check if a regular expression validates the attribute.
107
+ for (var i = 0, l = regExp.length; i < l; i++) {
108
+ if (attrName.match(regExp[i])) {
109
+ return true
110
+ }
111
+ }
112
+
113
+ return false
114
+ }
115
+
116
+ function sanitizeHtml (unsafeElements, whiteList, sanitizeFn) {
117
+ if (sanitizeFn && typeof sanitizeFn === 'function') {
118
+ return sanitizeFn(unsafeElements);
119
+ }
120
+
121
+ var whitelistKeys = Object.keys(whiteList);
122
+
123
+ for (var i = 0, len = unsafeElements.length; i < len; i++) {
124
+ var elements = unsafeElements[i].querySelectorAll('*');
125
+
126
+ for (var j = 0, len2 = elements.length; j < len2; j++) {
127
+ var el = elements[j];
128
+ var elName = el.nodeName.toLowerCase();
129
+
130
+ if (whitelistKeys.indexOf(elName) === -1) {
131
+ el.parentNode.removeChild(el);
132
+
133
+ continue;
134
+ }
135
+
136
+ var attributeList = [].slice.call(el.attributes);
137
+ var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
138
+
139
+ for (var k = 0, len3 = attributeList.length; k < len3; k++) {
140
+ var attr = attributeList[k];
141
+
142
+ if (!allowedAttribute(attr, whitelistedAttributes)) {
143
+ el.removeAttribute(attr.nodeName);
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ // Polyfill for browsers with no classList support
151
+ // Remove in v2
152
+ if (!('classList' in document.createElement('_'))) {
153
+ (function (view) {
154
+ if (!('Element' in view)) return;
155
+
156
+ var classListProp = 'classList',
157
+ protoProp = 'prototype',
158
+ elemCtrProto = view.Element[protoProp],
159
+ objCtr = Object,
160
+ classListGetter = function () {
161
+ var $elem = $(this);
162
+
163
+ return {
164
+ add: function (classes) {
165
+ classes = Array.prototype.slice.call(arguments).join(' ');
166
+ return $elem.addClass(classes);
167
+ },
168
+ remove: function (classes) {
169
+ classes = Array.prototype.slice.call(arguments).join(' ');
170
+ return $elem.removeClass(classes);
171
+ },
172
+ toggle: function (classes, force) {
173
+ return $elem.toggleClass(classes, force);
174
+ },
175
+ contains: function (classes) {
176
+ return $elem.hasClass(classes);
177
+ }
178
+ }
179
+ };
180
+
181
+ if (objCtr.defineProperty) {
182
+ var classListPropDesc = {
183
+ get: classListGetter,
184
+ enumerable: true,
185
+ configurable: true
186
+ };
187
+ try {
188
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
189
+ } catch (ex) { // IE 8 doesn't support enumerable:true
190
+ // adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
191
+ // modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
192
+ if (ex.number === undefined || ex.number === -0x7FF5EC54) {
193
+ classListPropDesc.enumerable = false;
194
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
195
+ }
196
+ }
197
+ } else if (objCtr[protoProp].__defineGetter__) {
198
+ elemCtrProto.__defineGetter__(classListProp, classListGetter);
199
+ }
200
+ }(window));
201
+ }
202
+
203
+ var testElement = document.createElement('_');
204
+
205
+ testElement.classList.add('c1', 'c2');
206
+
207
+ if (!testElement.classList.contains('c2')) {
208
+ var _add = DOMTokenList.prototype.add,
209
+ _remove = DOMTokenList.prototype.remove;
210
+
211
+ DOMTokenList.prototype.add = function () {
212
+ Array.prototype.forEach.call(arguments, _add.bind(this));
213
+ }
214
+
215
+ DOMTokenList.prototype.remove = function () {
216
+ Array.prototype.forEach.call(arguments, _remove.bind(this));
217
+ }
218
+ }
219
+
220
+ testElement.classList.toggle('c3', false);
221
+
222
+ // Polyfill for IE 10 and Firefox <24, where classList.toggle does not
223
+ // support the second argument.
224
+ if (testElement.classList.contains('c3')) {
225
+ var _toggle = DOMTokenList.prototype.toggle;
226
+
227
+ DOMTokenList.prototype.toggle = function (token, force) {
228
+ if (1 in arguments && !this.contains(token) === !force) {
229
+ return force;
230
+ } else {
231
+ return _toggle.call(this, token);
232
+ }
233
+ };
234
+ }
235
+
236
+ testElement = null;
237
+
238
+ // shallow array comparison
239
+ function isEqual (array1, array2) {
240
+ return array1.length === array2.length && array1.every(function (element, index) {
241
+ return element === array2[index];
242
+ });
243
+ };
244
+
245
+ // <editor-fold desc="Shims">
246
+ if (!String.prototype.startsWith) {
247
+ (function () {
248
+ 'use strict'; // needed to support `apply`/`call` with `undefined`/`null`
249
+ var defineProperty = (function () {
250
+ // IE 8 only supports `Object.defineProperty` on DOM elements
251
+ try {
252
+ var object = {};
253
+ var $defineProperty = Object.defineProperty;
254
+ var result = $defineProperty(object, object, object) && $defineProperty;
255
+ } catch (error) {
256
+ }
257
+ return result;
258
+ }());
259
+ var toString = {}.toString;
260
+ var startsWith = function (search) {
261
+ if (this == null) {
262
+ throw new TypeError();
263
+ }
264
+ var string = String(this);
265
+ if (search && toString.call(search) == '[object RegExp]') {
266
+ throw new TypeError();
267
+ }
268
+ var stringLength = string.length;
269
+ var searchString = String(search);
270
+ var searchLength = searchString.length;
271
+ var position = arguments.length > 1 ? arguments[1] : undefined;
272
+ // `ToInteger`
273
+ var pos = position ? Number(position) : 0;
274
+ if (pos != pos) { // better `isNaN`
275
+ pos = 0;
276
+ }
277
+ var start = Math.min(Math.max(pos, 0), stringLength);
278
+ // Avoid the `indexOf` call if no match is possible
279
+ if (searchLength + start > stringLength) {
280
+ return false;
281
+ }
282
+ var index = -1;
283
+ while (++index < searchLength) {
284
+ if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
285
+ return false;
286
+ }
287
+ }
288
+ return true;
289
+ };
290
+ if (defineProperty) {
291
+ defineProperty(String.prototype, 'startsWith', {
292
+ 'value': startsWith,
293
+ 'configurable': true,
294
+ 'writable': true
295
+ });
296
+ } else {
297
+ String.prototype.startsWith = startsWith;
298
+ }
299
+ }());
300
+ }
301
+
302
+ if (!Object.keys) {
303
+ Object.keys = function (
304
+ o, // object
305
+ k, // key
306
+ r // result array
307
+ ) {
308
+ // initialize object and result
309
+ r = [];
310
+ // iterate over object keys
311
+ for (k in o) {
312
+ // fill result array with non-prototypical keys
313
+ r.hasOwnProperty.call(o, k) && r.push(k);
314
+ }
315
+ // return result
316
+ return r;
317
+ };
318
+ }
319
+
320
+ if (HTMLSelectElement && !HTMLSelectElement.prototype.hasOwnProperty('selectedOptions')) {
321
+ Object.defineProperty(HTMLSelectElement.prototype, 'selectedOptions', {
322
+ get: function () {
323
+ return this.querySelectorAll(':checked');
324
+ }
325
+ });
326
+ }
327
+
328
+ function getSelectedOptions (select, ignoreDisabled) {
329
+ var selectedOptions = select.selectedOptions,
330
+ options = [],
331
+ opt;
332
+
333
+ if (ignoreDisabled) {
334
+ for (var i = 0, len = selectedOptions.length; i < len; i++) {
335
+ opt = selectedOptions[i];
336
+
337
+ if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
338
+ options.push(opt);
339
+ }
340
+ }
341
+
342
+ return options;
343
+ }
344
+
345
+ return selectedOptions;
346
+ }
347
+
348
+ // much faster than $.val()
349
+ function getSelectValues (select, selectedOptions) {
350
+ var value = [],
351
+ options = selectedOptions || select.selectedOptions,
352
+ opt;
353
+
354
+ for (var i = 0, len = options.length; i < len; i++) {
355
+ opt = options[i];
356
+
357
+ if (!(opt.disabled || opt.parentNode.tagName === 'OPTGROUP' && opt.parentNode.disabled)) {
358
+ value.push(opt.value || opt.text);
359
+ }
360
+ }
361
+
362
+ if (!select.multiple) {
363
+ return !value.length ? null : value[0];
364
+ }
365
+
366
+ return value;
367
+ }
368
+
369
+ // set data-selected on select element if the value has been programmatically selected
370
+ // prior to initialization of bootstrap-select
371
+ // * consider removing or replacing an alternative method *
372
+ var valHooks = {
373
+ useDefault: false,
374
+ _set: $.valHooks.select.set
375
+ };
376
+
377
+ $.valHooks.select.set = function (elem, value) {
378
+ if (value && !valHooks.useDefault) $(elem).data('selected', true);
379
+
380
+ return valHooks._set.apply(this, arguments);
381
+ };
382
+
383
+ var changedArguments = null;
384
+
385
+ var EventIsSupported = (function () {
386
+ try {
387
+ new Event('change');
388
+ return true;
389
+ } catch (e) {
390
+ return false;
391
+ }
392
+ })();
393
+
394
+ $.fn.triggerNative = function (eventName) {
395
+ var el = this[0],
396
+ event;
397
+
398
+ if (el.dispatchEvent) { // for modern browsers & IE9+
399
+ if (EventIsSupported) {
400
+ // For modern browsers
401
+ event = new Event(eventName, {
402
+ bubbles: true
403
+ });
404
+ } else {
405
+ // For IE since it doesn't support Event constructor
406
+ event = document.createEvent('Event');
407
+ event.initEvent(eventName, true, false);
408
+ }
409
+
410
+ el.dispatchEvent(event);
411
+ } else if (el.fireEvent) { // for IE8
412
+ event = document.createEventObject();
413
+ event.eventType = eventName;
414
+ el.fireEvent('on' + eventName, event);
415
+ } else {
416
+ // fall back to jQuery.trigger
417
+ this.trigger(eventName);
418
+ }
419
+ };
420
+ // </editor-fold>
421
+
422
+ function stringSearch (li, searchString, method, normalize) {
423
+ var stringTypes = [
424
+ 'display',
425
+ 'subtext',
426
+ 'tokens'
427
+ ],
428
+ searchSuccess = false;
429
+
430
+ for (var i = 0; i < stringTypes.length; i++) {
431
+ var stringType = stringTypes[i],
432
+ string = li[stringType];
433
+
434
+ if (string) {
435
+ string = string.toString();
436
+
437
+ // Strip HTML tags. This isn't perfect, but it's much faster than any other method
438
+ if (stringType === 'display') {
439
+ string = string.replace(/<[^>]+>/g, '');
440
+ }
441
+
442
+ if (normalize) string = normalizeToBase(string);
443
+ string = string.toUpperCase();
444
+
445
+ if (method === 'contains') {
446
+ searchSuccess = string.indexOf(searchString) >= 0;
447
+ } else {
448
+ searchSuccess = string.startsWith(searchString);
449
+ }
450
+
451
+ if (searchSuccess) break;
452
+ }
453
+ }
454
+
455
+ return searchSuccess;
456
+ }
457
+
458
+ function toInteger (value) {
459
+ return parseInt(value, 10) || 0;
460
+ }
461
+
462
+ // Borrowed from Lodash (_.deburr)
463
+ /** Used to map Latin Unicode letters to basic Latin letters. */
464
+ var deburredLetters = {
465
+ // Latin-1 Supplement block.
466
+ '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
467
+ '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
468
+ '\xc7': 'C', '\xe7': 'c',
469
+ '\xd0': 'D', '\xf0': 'd',
470
+ '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
471
+ '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
472
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
473
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
474
+ '\xd1': 'N', '\xf1': 'n',
475
+ '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
476
+ '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
477
+ '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
478
+ '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
479
+ '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
480
+ '\xc6': 'Ae', '\xe6': 'ae',
481
+ '\xde': 'Th', '\xfe': 'th',
482
+ '\xdf': 'ss',
483
+ // Latin Extended-A block.
484
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
485
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
486
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
487
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
488
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
489
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
490
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
491
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
492
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
493
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
494
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
495
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
496
+ '\u0134': 'J', '\u0135': 'j',
497
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
498
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
499
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
500
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
501
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
502
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
503
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
504
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
505
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
506
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
507
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
508
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
509
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
510
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
511
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
512
+ '\u0174': 'W', '\u0175': 'w',
513
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
514
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
515
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
516
+ '\u0132': 'IJ', '\u0133': 'ij',
517
+ '\u0152': 'Oe', '\u0153': 'oe',
518
+ '\u0149': "'n", '\u017f': 's'
519
+ };
520
+
521
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
522
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
523
+
524
+ /** Used to compose unicode character classes. */
525
+ var rsComboMarksRange = '\\u0300-\\u036f',
526
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
527
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
528
+ rsComboMarksExtendedRange = '\\u1ab0-\\u1aff',
529
+ rsComboMarksSupplementRange = '\\u1dc0-\\u1dff',
530
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;
531
+
532
+ /** Used to compose unicode capture groups. */
533
+ var rsCombo = '[' + rsComboRange + ']';
534
+
535
+ /**
536
+ * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
537
+ * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
538
+ */
539
+ var reComboMark = RegExp(rsCombo, 'g');
540
+
541
+ function deburrLetter (key) {
542
+ return deburredLetters[key];
543
+ };
544
+
545
+ function normalizeToBase (string) {
546
+ string = string.toString();
547
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
548
+ }
549
+
550
+ // List of HTML entities for escaping.
551
+ var escapeMap = {
552
+ '&': '&amp;',
553
+ '<': '&lt;',
554
+ '>': '&gt;',
555
+ '"': '&quot;',
556
+ "'": '&#x27;',
557
+ '`': '&#x60;'
558
+ };
559
+
560
+ // Functions for escaping and unescaping strings to/from HTML interpolation.
561
+ var createEscaper = function (map) {
562
+ var escaper = function (match) {
563
+ return map[match];
564
+ };
565
+ // Regexes for identifying a key that needs to be escaped.
566
+ var source = '(?:' + Object.keys(map).join('|') + ')';
567
+ var testRegexp = RegExp(source);
568
+ var replaceRegexp = RegExp(source, 'g');
569
+ return function (string) {
570
+ string = string == null ? '' : '' + string;
571
+ return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
572
+ };
573
+ };
574
+
575
+ var htmlEscape = createEscaper(escapeMap);
576
+
577
+ /**
578
+ * ------------------------------------------------------------------------
579
+ * Constants
580
+ * ------------------------------------------------------------------------
581
+ */
582
+
583
+ var keyCodeMap = {
584
+ 32: ' ',
585
+ 48: '0',
586
+ 49: '1',
587
+ 50: '2',
588
+ 51: '3',
589
+ 52: '4',
590
+ 53: '5',
591
+ 54: '6',
592
+ 55: '7',
593
+ 56: '8',
594
+ 57: '9',
595
+ 59: ';',
596
+ 65: 'A',
597
+ 66: 'B',
598
+ 67: 'C',
599
+ 68: 'D',
600
+ 69: 'E',
601
+ 70: 'F',
602
+ 71: 'G',
603
+ 72: 'H',
604
+ 73: 'I',
605
+ 74: 'J',
606
+ 75: 'K',
607
+ 76: 'L',
608
+ 77: 'M',
609
+ 78: 'N',
610
+ 79: 'O',
611
+ 80: 'P',
612
+ 81: 'Q',
613
+ 82: 'R',
614
+ 83: 'S',
615
+ 84: 'T',
616
+ 85: 'U',
617
+ 86: 'V',
618
+ 87: 'W',
619
+ 88: 'X',
620
+ 89: 'Y',
621
+ 90: 'Z',
622
+ 96: '0',
623
+ 97: '1',
624
+ 98: '2',
625
+ 99: '3',
626
+ 100: '4',
627
+ 101: '5',
628
+ 102: '6',
629
+ 103: '7',
630
+ 104: '8',
631
+ 105: '9'
632
+ };
633
+
634
+ var keyCodes = {
635
+ ESCAPE: 27, // KeyboardEvent.which value for Escape (Esc) key
636
+ ENTER: 13, // KeyboardEvent.which value for Enter key
637
+ SPACE: 32, // KeyboardEvent.which value for space key
638
+ TAB: 9, // KeyboardEvent.which value for tab key
639
+ ARROW_UP: 38, // KeyboardEvent.which value for up arrow key
640
+ ARROW_DOWN: 40 // KeyboardEvent.which value for down arrow key
641
+ }
642
+
643
+ var version = {
644
+ success: false,
645
+ major: '3'
646
+ };
647
+
648
+ try {
649
+ version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
650
+ version.major = version.full[0];
651
+ version.success = true;
652
+ } catch (err) {
653
+ // do nothing
654
+ }
655
+
656
+ var selectId = 0;
657
+
658
+ var EVENT_KEY = '.bs.select';
659
+
660
+ var classNames = {
661
+ DISABLED: 'disabled',
662
+ DIVIDER: 'divider',
663
+ SHOW: 'open',
664
+ DROPUP: 'dropup',
665
+ MENU: 'dropdown-menu',
666
+ MENURIGHT: 'dropdown-menu-right',
667
+ MENULEFT: 'dropdown-menu-left',
668
+ // to-do: replace with more advanced template/customization options
669
+ BUTTONCLASS: 'btn-default',
670
+ POPOVERHEADER: 'popover-title',
671
+ ICONBASE: 'glyphicon',
672
+ TICKICON: 'glyphicon-ok'
673
+ }
674
+
675
+ var Selector = {
676
+ MENU: '.' + classNames.MENU
677
+ }
678
+
679
+ var elementTemplates = {
680
+ span: document.createElement('span'),
681
+ i: document.createElement('i'),
682
+ subtext: document.createElement('small'),
683
+ a: document.createElement('a'),
684
+ li: document.createElement('li'),
685
+ whitespace: document.createTextNode('\u00A0'),
686
+ fragment: document.createDocumentFragment()
687
+ }
688
+
689
+ elementTemplates.a.setAttribute('role', 'option');
690
+ elementTemplates.subtext.className = 'text-muted';
691
+
692
+ elementTemplates.text = elementTemplates.span.cloneNode(false);
693
+ elementTemplates.text.className = 'text';
694
+
695
+ elementTemplates.checkMark = elementTemplates.span.cloneNode(false);
696
+
697
+ var REGEXP_ARROW = new RegExp(keyCodes.ARROW_UP + '|' + keyCodes.ARROW_DOWN);
698
+ var REGEXP_TAB_OR_ESCAPE = new RegExp('^' + keyCodes.TAB + '$|' + keyCodes.ESCAPE);
699
+
700
+ var generateOption = {
701
+ li: function (content, classes, optgroup) {
702
+ var li = elementTemplates.li.cloneNode(false);
703
+
704
+ if (content) {
705
+ if (content.nodeType === 1 || content.nodeType === 11) {
706
+ li.appendChild(content);
707
+ } else {
708
+ li.innerHTML = content;
709
+ }
710
+ }
711
+
712
+ if (typeof classes !== 'undefined' && classes !== '') li.className = classes;
713
+ if (typeof optgroup !== 'undefined' && optgroup !== null) li.classList.add('optgroup-' + optgroup);
714
+
715
+ return li;
716
+ },
717
+
718
+ a: function (text, classes, inline) {
719
+ var a = elementTemplates.a.cloneNode(true);
720
+
721
+ if (text) {
722
+ if (text.nodeType === 11) {
723
+ a.appendChild(text);
724
+ } else {
725
+ a.insertAdjacentHTML('beforeend', text);
726
+ }
727
+ }
728
+
729
+ if (typeof classes !== 'undefined' && classes !== '') a.className = classes;
730
+ if (version.major === '4') a.classList.add('dropdown-item');
731
+ if (inline) a.setAttribute('style', inline);
732
+
733
+ return a;
734
+ },
735
+
736
+ text: function (options, useFragment) {
737
+ var textElement = elementTemplates.text.cloneNode(false),
738
+ subtextElement,
739
+ iconElement;
740
+
741
+ if (options.content) {
742
+ textElement.innerHTML = options.content;
743
+ } else {
744
+ textElement.textContent = options.text;
745
+
746
+ if (options.icon) {
747
+ var whitespace = elementTemplates.whitespace.cloneNode(false);
748
+
749
+ // need to use <i> for icons in the button to prevent a breaking change
750
+ // note: switch to span in next major release
751
+ iconElement = (useFragment === true ? elementTemplates.i : elementTemplates.span).cloneNode(false);
752
+ iconElement.className = options.iconBase + ' ' + options.icon;
753
+
754
+ elementTemplates.fragment.appendChild(iconElement);
755
+ elementTemplates.fragment.appendChild(whitespace);
756
+ }
757
+
758
+ if (options.subtext) {
759
+ subtextElement = elementTemplates.subtext.cloneNode(false);
760
+ subtextElement.textContent = options.subtext;
761
+ textElement.appendChild(subtextElement);
762
+ }
763
+ }
764
+
765
+ if (useFragment === true) {
766
+ while (textElement.childNodes.length > 0) {
767
+ elementTemplates.fragment.appendChild(textElement.childNodes[0]);
768
+ }
769
+ } else {
770
+ elementTemplates.fragment.appendChild(textElement);
771
+ }
772
+
773
+ return elementTemplates.fragment;
774
+ },
775
+
776
+ label: function (options) {
777
+ var textElement = elementTemplates.text.cloneNode(false),
778
+ subtextElement,
779
+ iconElement;
780
+
781
+ textElement.innerHTML = options.label;
782
+
783
+ if (options.icon) {
784
+ var whitespace = elementTemplates.whitespace.cloneNode(false);
785
+
786
+ iconElement = elementTemplates.span.cloneNode(false);
787
+ iconElement.className = options.iconBase + ' ' + options.icon;
788
+
789
+ elementTemplates.fragment.appendChild(iconElement);
790
+ elementTemplates.fragment.appendChild(whitespace);
791
+ }
792
+
793
+ if (options.subtext) {
794
+ subtextElement = elementTemplates.subtext.cloneNode(false);
795
+ subtextElement.textContent = options.subtext;
796
+ textElement.appendChild(subtextElement);
797
+ }
798
+
799
+ elementTemplates.fragment.appendChild(textElement);
800
+
801
+ return elementTemplates.fragment;
802
+ }
803
+ }
804
+
805
+ var Selectpicker = function (element, options) {
806
+ var that = this;
807
+
808
+ // bootstrap-select has been initialized - revert valHooks.select.set back to its original function
809
+ if (!valHooks.useDefault) {
810
+ $.valHooks.select.set = valHooks._set;
811
+ valHooks.useDefault = true;
812
+ }
813
+
814
+ this.$element = $(element);
815
+ this.$newElement = null;
816
+ this.$button = null;
817
+ this.$menu = null;
818
+ this.options = options;
819
+ this.selectpicker = {
820
+ main: {},
821
+ search: {},
822
+ current: {}, // current changes if a search is in progress
823
+ view: {},
824
+ keydown: {
825
+ keyHistory: '',
826
+ resetKeyHistory: {
827
+ start: function () {
828
+ return setTimeout(function () {
829
+ that.selectpicker.keydown.keyHistory = '';
830
+ }, 800);
831
+ }
832
+ }
833
+ }
834
+ };
835
+ // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a
836
+ // data-attribute)
837
+ if (this.options.title === null) {
838
+ this.options.title = this.$element.attr('title');
839
+ }
840
+
841
+ // Format window padding
842
+ var winPad = this.options.windowPadding;
843
+ if (typeof winPad === 'number') {
844
+ this.options.windowPadding = [winPad, winPad, winPad, winPad];
845
+ }
846
+
847
+ // Expose public methods
848
+ this.val = Selectpicker.prototype.val;
849
+ this.render = Selectpicker.prototype.render;
850
+ this.refresh = Selectpicker.prototype.refresh;
851
+ this.setStyle = Selectpicker.prototype.setStyle;
852
+ this.selectAll = Selectpicker.prototype.selectAll;
853
+ this.deselectAll = Selectpicker.prototype.deselectAll;
854
+ this.destroy = Selectpicker.prototype.destroy;
855
+ this.remove = Selectpicker.prototype.remove;
856
+ this.show = Selectpicker.prototype.show;
857
+ this.hide = Selectpicker.prototype.hide;
858
+
859
+ this.init();
860
+ };
861
+
862
+ Selectpicker.VERSION = '1.13.10';
863
+
864
+ // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both.
865
+ Selectpicker.DEFAULTS = {
866
+ noneSelectedText: 'Nothing selected',
867
+ noneResultsText: 'No results matched {0}',
868
+ countSelectedText: function (numSelected, numTotal) {
869
+ return (numSelected == 1) ? '{0} item selected' : '{0} items selected';
870
+ },
871
+ maxOptionsText: function (numAll, numGroup) {
872
+ return [
873
+ (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)',
874
+ (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)'
875
+ ];
876
+ },
877
+ selectAllText: 'Select All',
878
+ deselectAllText: 'Deselect All',
879
+ doneButton: false,
880
+ doneButtonText: 'Close',
881
+ multipleSeparator: ', ',
882
+ styleBase: 'btn',
883
+ style: classNames.BUTTONCLASS,
884
+ size: 'auto',
885
+ title: null,
886
+ selectedTextFormat: 'values',
887
+ width: false,
888
+ container: false,
889
+ hideDisabled: false,
890
+ showSubtext: false,
891
+ showIcon: true,
892
+ showContent: true,
893
+ dropupAuto: true,
894
+ header: false,
895
+ liveSearch: false,
896
+ liveSearchPlaceholder: null,
897
+ liveSearchNormalize: false,
898
+ liveSearchStyle: 'contains',
899
+ actionsBox: false,
900
+ iconBase: classNames.ICONBASE,
901
+ tickIcon: classNames.TICKICON,
902
+ showTick: false,
903
+ template: {
904
+ caret: '<span class="caret"></span>'
905
+ },
906
+ maxOptions: false,
907
+ mobile: false,
908
+ selectOnTab: false,
909
+ dropdownAlignRight: false,
910
+ windowPadding: 0,
911
+ virtualScroll: 600,
912
+ display: false,
913
+ sanitize: true,
914
+ sanitizeFn: null,
915
+ whiteList: DefaultWhitelist
916
+ };
917
+
918
+ Selectpicker.prototype = {
919
+
920
+ constructor: Selectpicker,
921
+
922
+ init: function () {
923
+ var that = this,
924
+ id = this.$element.attr('id');
925
+
926
+ selectId++;
927
+ this.selectId = 'bs-select-' + selectId;
928
+
929
+ this.$element[0].classList.add('bs-select-hidden');
930
+
931
+ this.multiple = this.$element.prop('multiple');
932
+ this.autofocus = this.$element.prop('autofocus');
933
+
934
+ if (this.$element[0].classList.contains('show-tick')) {
935
+ this.options.showTick = true;
936
+ }
937
+
938
+ this.$newElement = this.createDropdown();
939
+ this.$element
940
+ .after(this.$newElement)
941
+ .prependTo(this.$newElement);
942
+
943
+ this.$button = this.$newElement.children('button');
944
+ this.$menu = this.$newElement.children(Selector.MENU);
945
+ this.$menuInner = this.$menu.children('.inner');
946
+ this.$searchbox = this.$menu.find('input');
947
+
948
+ this.$element[0].classList.remove('bs-select-hidden');
949
+
950
+ if (this.options.dropdownAlignRight === true) this.$menu[0].classList.add(classNames.MENURIGHT);
951
+
952
+ if (typeof id !== 'undefined') {
953
+ this.$button.attr('data-id', id);
954
+ }
955
+
956
+ this.checkDisabled();
957
+ this.clickListener();
958
+
959
+ if (this.options.liveSearch) {
960
+ this.liveSearchListener();
961
+ this.focusedParent = this.$searchbox[0];
962
+ } else {
963
+ this.focusedParent = this.$menuInner[0];
964
+ }
965
+
966
+ this.setStyle();
967
+ this.render();
968
+ this.setWidth();
969
+ if (this.options.container) {
970
+ this.selectPosition();
971
+ } else {
972
+ this.$element.on('hide' + EVENT_KEY, function () {
973
+ if (that.isVirtual()) {
974
+ // empty menu on close
975
+ var menuInner = that.$menuInner[0],
976
+ emptyMenu = menuInner.firstChild.cloneNode(false);
977
+
978
+ // replace the existing UL with an empty one - this is faster than $.empty() or innerHTML = ''
979
+ menuInner.replaceChild(emptyMenu, menuInner.firstChild);
980
+ menuInner.scrollTop = 0;
981
+ }
982
+ });
983
+ }
984
+ this.$menu.data('this', this);
985
+ this.$newElement.data('this', this);
986
+ if (this.options.mobile) this.mobile();
987
+
988
+ this.$newElement.on({
989
+ 'hide.bs.dropdown': function (e) {
990
+ that.$element.trigger('hide' + EVENT_KEY, e);
991
+ },
992
+ 'hidden.bs.dropdown': function (e) {
993
+ that.$element.trigger('hidden' + EVENT_KEY, e);
994
+ },
995
+ 'show.bs.dropdown': function (e) {
996
+ that.$element.trigger('show' + EVENT_KEY, e);
997
+ },
998
+ 'shown.bs.dropdown': function (e) {
999
+ that.$element.trigger('shown' + EVENT_KEY, e);
1000
+ }
1001
+ });
1002
+
1003
+ if (that.$element[0].hasAttribute('required')) {
1004
+ this.$element.on('invalid' + EVENT_KEY, function () {
1005
+ that.$button[0].classList.add('bs-invalid');
1006
+
1007
+ that.$element
1008
+ .on('shown' + EVENT_KEY + '.invalid', function () {
1009
+ that.$element
1010
+ .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened
1011
+ .off('shown' + EVENT_KEY + '.invalid');
1012
+ })
1013
+ .on('rendered' + EVENT_KEY, function () {
1014
+ // if select is no longer invalid, remove the bs-invalid class
1015
+ if (this.validity.valid) that.$button[0].classList.remove('bs-invalid');
1016
+ that.$element.off('rendered' + EVENT_KEY);
1017
+ });
1018
+
1019
+ that.$button.on('blur' + EVENT_KEY, function () {
1020
+ that.$element.trigger('focus').trigger('blur');
1021
+ that.$button.off('blur' + EVENT_KEY);
1022
+ });
1023
+ });
1024
+ }
1025
+
1026
+ setTimeout(function () {
1027
+ that.createLi();
1028
+ that.$element.trigger('loaded' + EVENT_KEY);
1029
+ });
1030
+ },
1031
+
1032
+ createDropdown: function () {
1033
+ // Options
1034
+ // If we are multiple or showTick option is set, then add the show-tick class
1035
+ var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '',
1036
+ multiselectable = this.multiple ? ' aria-multiselectable="true"' : '',
1037
+ inputGroup = '',
1038
+ autofocus = this.autofocus ? ' autofocus' : '';
1039
+
1040
+ if (version.major < 4 && this.$element.parent().hasClass('input-group')) {
1041
+ inputGroup = ' input-group-btn';
1042
+ }
1043
+
1044
+ // Elements
1045
+ var drop,
1046
+ header = '',
1047
+ searchbox = '',
1048
+ actionsbox = '',
1049
+ donebutton = '';
1050
+
1051
+ if (this.options.header) {
1052
+ header =
1053
+ '<div class="' + classNames.POPOVERHEADER + '">' +
1054
+ '<button type="button" class="close" aria-hidden="true">&times;</button>' +
1055
+ this.options.header +
1056
+ '</div>';
1057
+ }
1058
+
1059
+ if (this.options.liveSearch) {
1060
+ searchbox =
1061
+ '<div class="bs-searchbox">' +
1062
+ '<input type="text" class="form-control" autocomplete="off"' +
1063
+ (
1064
+ this.options.liveSearchPlaceholder === null ? ''
1065
+ :
1066
+ ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"'
1067
+ ) +
1068
+ ' role="combobox" aria-label="Search" aria-controls="' + this.selectId + '" aria-autocomplete="list">' +
1069
+ '</div>';
1070
+ }
1071
+
1072
+ if (this.multiple && this.options.actionsBox) {
1073
+ actionsbox =
1074
+ '<div class="bs-actionsbox">' +
1075
+ '<div class="btn-group btn-group-sm btn-block">' +
1076
+ '<button type="button" class="actions-btn bs-select-all btn ' + classNames.BUTTONCLASS + '">' +
1077
+ this.options.selectAllText +
1078
+ '</button>' +
1079
+ '<button type="button" class="actions-btn bs-deselect-all btn ' + classNames.BUTTONCLASS + '">' +
1080
+ this.options.deselectAllText +
1081
+ '</button>' +
1082
+ '</div>' +
1083
+ '</div>';
1084
+ }
1085
+
1086
+ if (this.multiple && this.options.doneButton) {
1087
+ donebutton =
1088
+ '<div class="bs-donebutton">' +
1089
+ '<div class="btn-group btn-block">' +
1090
+ '<button type="button" class="btn btn-sm ' + classNames.BUTTONCLASS + '">' +
1091
+ this.options.doneButtonText +
1092
+ '</button>' +
1093
+ '</div>' +
1094
+ '</div>';
1095
+ }
1096
+
1097
+ drop =
1098
+ '<div class="dropdown bootstrap-select' + showTick + inputGroup + '">' +
1099
+ '<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" ' + (this.options.display === 'static' ? 'data-display="static"' : '') + 'data-toggle="dropdown"' + autofocus + ' role="combobox" aria-owns="' + this.selectId + '" aria-haspopup="listbox" aria-expanded="false">' +
1100
+ '<div class="filter-option">' +
1101
+ '<div class="filter-option-inner">' +
1102
+ '<div class="filter-option-inner-inner"></div>' +
1103
+ '</div> ' +
1104
+ '</div>' +
1105
+ (
1106
+ version.major === '4' ? ''
1107
+ :
1108
+ '<span class="bs-caret">' +
1109
+ this.options.template.caret +
1110
+ '</span>'
1111
+ ) +
1112
+ '</button>' +
1113
+ '<div class="' + classNames.MENU + ' ' + (version.major === '4' ? '' : classNames.SHOW) + '">' +
1114
+ header +
1115
+ searchbox +
1116
+ actionsbox +
1117
+ '<div class="inner ' + classNames.SHOW + '" role="listbox" id="' + this.selectId + '" tabindex="-1" ' + multiselectable + '>' +
1118
+ '<ul class="' + classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '') + '" role="presentation">' +
1119
+ '</ul>' +
1120
+ '</div>' +
1121
+ donebutton +
1122
+ '</div>' +
1123
+ '</div>';
1124
+
1125
+ return $(drop);
1126
+ },
1127
+
1128
+ setPositionData: function () {
1129
+ this.selectpicker.view.canHighlight = [];
1130
+ this.selectpicker.view.size = 0;
1131
+
1132
+ for (var i = 0; i < this.selectpicker.current.data.length; i++) {
1133
+ var li = this.selectpicker.current.data[i],
1134
+ canHighlight = true;
1135
+
1136
+ if (li.type === 'divider') {
1137
+ canHighlight = false;
1138
+ li.height = this.sizeInfo.dividerHeight;
1139
+ } else if (li.type === 'optgroup-label') {
1140
+ canHighlight = false;
1141
+ li.height = this.sizeInfo.dropdownHeaderHeight;
1142
+ } else {
1143
+ li.height = this.sizeInfo.liHeight;
1144
+ }
1145
+
1146
+ if (li.disabled) canHighlight = false;
1147
+
1148
+ this.selectpicker.view.canHighlight.push(canHighlight);
1149
+
1150
+ if (canHighlight) {
1151
+ this.selectpicker.view.size++;
1152
+ li.posinset = this.selectpicker.view.size;
1153
+ }
1154
+
1155
+ li.position = (i === 0 ? 0 : this.selectpicker.current.data[i - 1].position) + li.height;
1156
+ }
1157
+ },
1158
+
1159
+ isVirtual: function () {
1160
+ return (this.options.virtualScroll !== false) && (this.selectpicker.main.elements.length >= this.options.virtualScroll) || this.options.virtualScroll === true;
1161
+ },
1162
+
1163
+ createView: function (isSearching, setSize, refresh) {
1164
+ var that = this,
1165
+ scrollTop = 0,
1166
+ active = [],
1167
+ selected,
1168
+ prevActive;
1169
+
1170
+ this.selectpicker.current = isSearching ? this.selectpicker.search : this.selectpicker.main;
1171
+
1172
+ this.setPositionData();
1173
+
1174
+ if (setSize) {
1175
+ if (refresh) {
1176
+ scrollTop = this.$menuInner[0].scrollTop;
1177
+ } else if (!that.multiple) {
1178
+ var element = that.$element[0],
1179
+ selectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
1180
+
1181
+ if (typeof selectedIndex === 'number' && that.options.size !== false) {
1182
+ var selectedData = that.selectpicker.main.data[selectedIndex],
1183
+ position = selectedData && selectedData.position;
1184
+
1185
+ if (position) {
1186
+ scrollTop = position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2);
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+
1192
+ scroll(scrollTop, true);
1193
+
1194
+ this.$menuInner.off('scroll.createView').on('scroll.createView', function (e, updateValue) {
1195
+ if (!that.noScroll) scroll(this.scrollTop, updateValue);
1196
+ that.noScroll = false;
1197
+ });
1198
+
1199
+ function scroll (scrollTop, init) {
1200
+ var size = that.selectpicker.current.elements.length,
1201
+ chunks = [],
1202
+ chunkSize,
1203
+ chunkCount,
1204
+ firstChunk,
1205
+ lastChunk,
1206
+ currentChunk,
1207
+ prevPositions,
1208
+ positionIsDifferent,
1209
+ previousElements,
1210
+ menuIsDifferent = true,
1211
+ isVirtual = that.isVirtual();
1212
+
1213
+ that.selectpicker.view.scrollTop = scrollTop;
1214
+
1215
+ if (isVirtual === true) {
1216
+ // if an option that is encountered that is wider than the current menu width, update the menu width accordingly
1217
+ if (that.sizeInfo.hasScrollBar && that.$menu[0].offsetWidth > that.sizeInfo.totalMenuWidth) {
1218
+ that.sizeInfo.menuWidth = that.$menu[0].offsetWidth;
1219
+ that.sizeInfo.totalMenuWidth = that.sizeInfo.menuWidth + that.sizeInfo.scrollBarWidth;
1220
+ that.$menu.css('min-width', that.sizeInfo.menuWidth);
1221
+ }
1222
+ }
1223
+
1224
+ chunkSize = Math.ceil(that.sizeInfo.menuInnerHeight / that.sizeInfo.liHeight * 1.5); // number of options in a chunk
1225
+ chunkCount = Math.round(size / chunkSize) || 1; // number of chunks
1226
+
1227
+ for (var i = 0; i < chunkCount; i++) {
1228
+ var endOfChunk = (i + 1) * chunkSize;
1229
+
1230
+ if (i === chunkCount - 1) {
1231
+ endOfChunk = size;
1232
+ }
1233
+
1234
+ chunks[i] = [
1235
+ (i) * chunkSize + (!i ? 0 : 1),
1236
+ endOfChunk
1237
+ ];
1238
+
1239
+ if (!size) break;
1240
+
1241
+ if (currentChunk === undefined && scrollTop <= that.selectpicker.current.data[endOfChunk - 1].position - that.sizeInfo.menuInnerHeight) {
1242
+ currentChunk = i;
1243
+ }
1244
+ }
1245
+
1246
+ if (currentChunk === undefined) currentChunk = 0;
1247
+
1248
+ prevPositions = [that.selectpicker.view.position0, that.selectpicker.view.position1];
1249
+
1250
+ // always display previous, current, and next chunks
1251
+ firstChunk = Math.max(0, currentChunk - 1);
1252
+ lastChunk = Math.min(chunkCount - 1, currentChunk + 1);
1253
+
1254
+ that.selectpicker.view.position0 = isVirtual === false ? 0 : (Math.max(0, chunks[firstChunk][0]) || 0);
1255
+ that.selectpicker.view.position1 = isVirtual === false ? size : (Math.min(size, chunks[lastChunk][1]) || 0);
1256
+
1257
+ positionIsDifferent = prevPositions[0] !== that.selectpicker.view.position0 || prevPositions[1] !== that.selectpicker.view.position1;
1258
+
1259
+ if (that.activeIndex !== undefined) {
1260
+ prevActive = that.selectpicker.main.elements[that.prevActiveIndex];
1261
+ active = that.selectpicker.main.elements[that.activeIndex];
1262
+ selected = that.selectpicker.main.elements[that.selectedIndex];
1263
+
1264
+ if (init) {
1265
+ if (that.activeIndex !== that.selectedIndex) {
1266
+ that.defocusItem(active);
1267
+ }
1268
+ that.activeIndex = undefined;
1269
+ }
1270
+
1271
+ if (that.activeIndex && that.activeIndex !== that.selectedIndex) {
1272
+ that.defocusItem(selected);
1273
+ }
1274
+ }
1275
+
1276
+ if (that.prevActiveIndex !== undefined && that.prevActiveIndex !== that.activeIndex && that.prevActiveIndex !== that.selectedIndex) {
1277
+ that.defocusItem(prevActive);
1278
+ }
1279
+
1280
+ if (init || positionIsDifferent) {
1281
+ previousElements = that.selectpicker.view.visibleElements ? that.selectpicker.view.visibleElements.slice() : [];
1282
+
1283
+ if (isVirtual === false) {
1284
+ that.selectpicker.view.visibleElements = that.selectpicker.current.elements;
1285
+ } else {
1286
+ that.selectpicker.view.visibleElements = that.selectpicker.current.elements.slice(that.selectpicker.view.position0, that.selectpicker.view.position1);
1287
+ }
1288
+
1289
+ that.setOptionStatus();
1290
+
1291
+ // if searching, check to make sure the list has actually been updated before updating DOM
1292
+ // this prevents unnecessary repaints
1293
+ if (isSearching || (isVirtual === false && init)) menuIsDifferent = !isEqual(previousElements, that.selectpicker.view.visibleElements);
1294
+
1295
+ // if virtual scroll is disabled and not searching,
1296
+ // menu should never need to be updated more than once
1297
+ if ((init || isVirtual === true) && menuIsDifferent) {
1298
+ var menuInner = that.$menuInner[0],
1299
+ menuFragment = document.createDocumentFragment(),
1300
+ emptyMenu = menuInner.firstChild.cloneNode(false),
1301
+ marginTop,
1302
+ marginBottom,
1303
+ elements = that.selectpicker.view.visibleElements,
1304
+ toSanitize = [];
1305
+
1306
+ // replace the existing UL with an empty one - this is faster than $.empty()
1307
+ menuInner.replaceChild(emptyMenu, menuInner.firstChild);
1308
+
1309
+ for (var i = 0, visibleElementsLen = elements.length; i < visibleElementsLen; i++) {
1310
+ var element = elements[i],
1311
+ elText,
1312
+ elementData;
1313
+
1314
+ if (that.options.sanitize) {
1315
+ elText = element.lastChild;
1316
+
1317
+ if (elText) {
1318
+ elementData = that.selectpicker.current.data[i + that.selectpicker.view.position0];
1319
+
1320
+ if (elementData && elementData.content && !elementData.sanitized) {
1321
+ toSanitize.push(elText);
1322
+ elementData.sanitized = true;
1323
+ }
1324
+ }
1325
+ }
1326
+
1327
+ menuFragment.appendChild(element);
1328
+ }
1329
+
1330
+ if (that.options.sanitize && toSanitize.length) {
1331
+ sanitizeHtml(toSanitize, that.options.whiteList, that.options.sanitizeFn);
1332
+ }
1333
+
1334
+ if (isVirtual === true) {
1335
+ marginTop = (that.selectpicker.view.position0 === 0 ? 0 : that.selectpicker.current.data[that.selectpicker.view.position0 - 1].position);
1336
+ marginBottom = (that.selectpicker.view.position1 > size - 1 ? 0 : that.selectpicker.current.data[size - 1].position - that.selectpicker.current.data[that.selectpicker.view.position1 - 1].position);
1337
+
1338
+ menuInner.firstChild.style.marginTop = marginTop + 'px';
1339
+ menuInner.firstChild.style.marginBottom = marginBottom + 'px';
1340
+ } else {
1341
+ menuInner.firstChild.style.marginTop = 0;
1342
+ menuInner.firstChild.style.marginBottom = 0;
1343
+ }
1344
+
1345
+ menuInner.firstChild.appendChild(menuFragment);
1346
+ }
1347
+ }
1348
+
1349
+ that.prevActiveIndex = that.activeIndex;
1350
+
1351
+ if (!that.options.liveSearch) {
1352
+ that.$menuInner.trigger('focus');
1353
+ } else if (isSearching && init) {
1354
+ var index = 0,
1355
+ newActive;
1356
+
1357
+ if (!that.selectpicker.view.canHighlight[index]) {
1358
+ index = 1 + that.selectpicker.view.canHighlight.slice(1).indexOf(true);
1359
+ }
1360
+
1361
+ newActive = that.selectpicker.view.visibleElements[index];
1362
+
1363
+ that.defocusItem(that.selectpicker.view.currentActive);
1364
+
1365
+ that.activeIndex = (that.selectpicker.current.data[index] || {}).index;
1366
+
1367
+ that.focusItem(newActive);
1368
+ }
1369
+ }
1370
+
1371
+ $(window)
1372
+ .off('resize' + EVENT_KEY + '.' + this.selectId + '.createView')
1373
+ .on('resize' + EVENT_KEY + '.' + this.selectId + '.createView', function () {
1374
+ var isActive = that.$newElement.hasClass(classNames.SHOW);
1375
+
1376
+ if (isActive) scroll(that.$menuInner[0].scrollTop);
1377
+ });
1378
+ },
1379
+
1380
+ focusItem: function (li, liData, noStyle) {
1381
+ if (li) {
1382
+ liData = liData || this.selectpicker.main.data[this.activeIndex];
1383
+ var a = li.firstChild;
1384
+
1385
+ if (a) {
1386
+ a.setAttribute('aria-setsize', this.selectpicker.view.size);
1387
+ a.setAttribute('aria-posinset', liData.posinset);
1388
+
1389
+ if (noStyle !== true) {
1390
+ this.focusedParent.setAttribute('aria-activedescendant', a.id);
1391
+ li.classList.add('active');
1392
+ a.classList.add('active');
1393
+ }
1394
+ }
1395
+ }
1396
+ },
1397
+
1398
+ defocusItem: function (li) {
1399
+ if (li) {
1400
+ li.classList.remove('active');
1401
+ if (li.firstChild) li.firstChild.classList.remove('active');
1402
+ }
1403
+ },
1404
+
1405
+ setPlaceholder: function () {
1406
+ var updateIndex = false;
1407
+
1408
+ if (this.options.title && !this.multiple) {
1409
+ if (!this.selectpicker.view.titleOption) this.selectpicker.view.titleOption = document.createElement('option');
1410
+
1411
+ // this option doesn't create a new <li> element, but does add a new option at the start,
1412
+ // so startIndex should increase to prevent having to check every option for the bs-title-option class
1413
+ updateIndex = true;
1414
+
1415
+ var element = this.$element[0],
1416
+ isSelected = false,
1417
+ titleNotAppended = !this.selectpicker.view.titleOption.parentNode;
1418
+
1419
+ if (titleNotAppended) {
1420
+ // Use native JS to prepend option (faster)
1421
+ this.selectpicker.view.titleOption.className = 'bs-title-option';
1422
+ this.selectpicker.view.titleOption.value = '';
1423
+
1424
+ // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option.
1425
+ // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs,
1426
+ // if so, the select will have the data-selected attribute
1427
+ var $opt = $(element.options[element.selectedIndex]);
1428
+ isSelected = $opt.attr('selected') === undefined && this.$element.data('selected') === undefined;
1429
+ }
1430
+
1431
+ if (titleNotAppended || this.selectpicker.view.titleOption.index !== 0) {
1432
+ element.insertBefore(this.selectpicker.view.titleOption, element.firstChild);
1433
+ }
1434
+
1435
+ // Set selected *after* appending to select,
1436
+ // otherwise the option doesn't get selected in IE
1437
+ // set using selectedIndex, as setting the selected attr to true here doesn't work in IE11
1438
+ if (isSelected) element.selectedIndex = 0;
1439
+ }
1440
+
1441
+ return updateIndex;
1442
+ },
1443
+
1444
+ createLi: function () {
1445
+ var that = this,
1446
+ iconBase = this.options.iconBase,
1447
+ optionSelector = ':not([hidden]):not([data-hidden="true"])',
1448
+ mainElements = [],
1449
+ mainData = [],
1450
+ widestOptionLength = 0,
1451
+ optID = 0,
1452
+ startIndex = this.setPlaceholder() ? 1 : 0; // append the titleOption if necessary and skip the first option in the loop
1453
+
1454
+ if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
1455
+
1456
+ if ((that.options.showTick || that.multiple) && !elementTemplates.checkMark.parentNode) {
1457
+ elementTemplates.checkMark.className = iconBase + ' ' + that.options.tickIcon + ' check-mark';
1458
+ elementTemplates.a.appendChild(elementTemplates.checkMark);
1459
+ }
1460
+
1461
+ var selectOptions = this.$element[0].querySelectorAll('select > *' + optionSelector);
1462
+
1463
+ function addDivider (config) {
1464
+ var previousData = mainData[mainData.length - 1];
1465
+
1466
+ // ensure optgroup doesn't create back-to-back dividers
1467
+ if (
1468
+ previousData &&
1469
+ previousData.type === 'divider' &&
1470
+ (previousData.optID || config.optID)
1471
+ ) {
1472
+ return;
1473
+ }
1474
+
1475
+ config = config || {};
1476
+ config.type = 'divider';
1477
+
1478
+ mainElements.push(
1479
+ generateOption.li(
1480
+ false,
1481
+ classNames.DIVIDER,
1482
+ (config.optID ? config.optID + 'div' : undefined)
1483
+ )
1484
+ );
1485
+
1486
+ mainData.push(config);
1487
+ }
1488
+
1489
+ function addOption (option, config) {
1490
+ config = config || {};
1491
+
1492
+ config.divider = option.getAttribute('data-divider') === 'true';
1493
+
1494
+ if (config.divider) {
1495
+ addDivider({
1496
+ optID: config.optID
1497
+ });
1498
+ } else {
1499
+ var liIndex = mainData.length,
1500
+ cssText = option.style.cssText,
1501
+ inlineStyle = cssText ? htmlEscape(cssText) : '',
1502
+ optionClass = (option.className || '') + (config.optgroupClass || '');
1503
+
1504
+ if (config.optID) optionClass = 'opt ' + optionClass;
1505
+
1506
+ config.text = option.textContent;
1507
+
1508
+ config.content = option.getAttribute('data-content');
1509
+ config.tokens = option.getAttribute('data-tokens');
1510
+ config.subtext = option.getAttribute('data-subtext');
1511
+ config.icon = option.getAttribute('data-icon');
1512
+ config.iconBase = iconBase;
1513
+
1514
+ var textElement = generateOption.text(config);
1515
+ var liElement = generateOption.li(
1516
+ generateOption.a(
1517
+ textElement,
1518
+ optionClass,
1519
+ inlineStyle
1520
+ ),
1521
+ '',
1522
+ config.optID
1523
+ );
1524
+
1525
+ if (liElement.firstChild) {
1526
+ liElement.firstChild.id = that.selectId + '-' + liIndex;
1527
+ }
1528
+
1529
+ mainElements.push(liElement);
1530
+
1531
+ option.liIndex = liIndex;
1532
+
1533
+ config.display = config.content || config.text;
1534
+ config.type = 'option';
1535
+ config.index = liIndex;
1536
+ config.option = option;
1537
+ config.disabled = config.disabled || option.disabled;
1538
+
1539
+ mainData.push(config);
1540
+
1541
+ var combinedLength = 0;
1542
+
1543
+ // count the number of characters in the option - not perfect, but should work in most cases
1544
+ if (config.display) combinedLength += config.display.length;
1545
+ if (config.subtext) combinedLength += config.subtext.length;
1546
+ // if there is an icon, ensure this option's width is checked
1547
+ if (config.icon) combinedLength += 1;
1548
+
1549
+ if (combinedLength > widestOptionLength) {
1550
+ widestOptionLength = combinedLength;
1551
+
1552
+ // guess which option is the widest
1553
+ // use this when calculating menu width
1554
+ // not perfect, but it's fast, and the width will be updating accordingly when scrolling
1555
+ that.selectpicker.view.widestOption = mainElements[mainElements.length - 1];
1556
+ }
1557
+ }
1558
+ }
1559
+
1560
+ function addOptgroup (index, selectOptions) {
1561
+ var optgroup = selectOptions[index],
1562
+ previous = selectOptions[index - 1],
1563
+ next = selectOptions[index + 1],
1564
+ options = optgroup.querySelectorAll('option' + optionSelector);
1565
+
1566
+ if (!options.length) return;
1567
+
1568
+ var config = {
1569
+ label: htmlEscape(optgroup.label),
1570
+ subtext: optgroup.getAttribute('data-subtext'),
1571
+ icon: optgroup.getAttribute('data-icon'),
1572
+ iconBase: iconBase
1573
+ },
1574
+ optgroupClass = ' ' + (optgroup.className || ''),
1575
+ headerIndex,
1576
+ lastIndex;
1577
+
1578
+ optID++;
1579
+
1580
+ if (previous) {
1581
+ addDivider({ optID: optID });
1582
+ }
1583
+
1584
+ var labelElement = generateOption.label(config);
1585
+
1586
+ mainElements.push(
1587
+ generateOption.li(labelElement, 'dropdown-header' + optgroupClass, optID)
1588
+ );
1589
+
1590
+ mainData.push({
1591
+ display: config.label,
1592
+ subtext: config.subtext,
1593
+ type: 'optgroup-label',
1594
+ optID: optID
1595
+ });
1596
+
1597
+ for (var j = 0, len = options.length; j < len; j++) {
1598
+ var option = options[j];
1599
+
1600
+ if (j === 0) {
1601
+ headerIndex = mainData.length - 1;
1602
+ lastIndex = headerIndex + len;
1603
+ }
1604
+
1605
+ addOption(option, {
1606
+ headerIndex: headerIndex,
1607
+ lastIndex: lastIndex,
1608
+ optID: optID,
1609
+ optgroupClass: optgroupClass,
1610
+ disabled: optgroup.disabled
1611
+ });
1612
+ }
1613
+
1614
+ if (next) {
1615
+ addDivider({ optID: optID });
1616
+ }
1617
+ }
1618
+
1619
+ for (var len = selectOptions.length; startIndex < len; startIndex++) {
1620
+ var item = selectOptions[startIndex];
1621
+
1622
+ if (item.tagName !== 'OPTGROUP') {
1623
+ addOption(item, {});
1624
+ } else {
1625
+ addOptgroup(startIndex, selectOptions);
1626
+ }
1627
+ }
1628
+
1629
+ this.selectpicker.main.elements = mainElements;
1630
+ this.selectpicker.main.data = mainData;
1631
+
1632
+ this.selectpicker.current = this.selectpicker.main;
1633
+ },
1634
+
1635
+ findLis: function () {
1636
+ return this.$menuInner.find('.inner > li');
1637
+ },
1638
+
1639
+ render: function () {
1640
+ // ensure titleOption is appended and selected (if necessary) before getting selectedOptions
1641
+ this.setPlaceholder();
1642
+
1643
+ var that = this,
1644
+ element = this.$element[0],
1645
+ selectedOptions = getSelectedOptions(element, this.options.hideDisabled),
1646
+ selectedCount = selectedOptions.length,
1647
+ button = this.$button[0],
1648
+ buttonInner = button.querySelector('.filter-option-inner-inner'),
1649
+ multipleSeparator = document.createTextNode(this.options.multipleSeparator),
1650
+ titleFragment = elementTemplates.fragment.cloneNode(false),
1651
+ showCount,
1652
+ countMax,
1653
+ hasContent = false;
1654
+
1655
+ button.classList.toggle('bs-placeholder', that.multiple ? !selectedCount : !getSelectValues(element, selectedOptions));
1656
+
1657
+ this.tabIndex();
1658
+
1659
+ if (this.options.selectedTextFormat === 'static') {
1660
+ titleFragment = generateOption.text({ text: this.options.title }, true);
1661
+ } else {
1662
+ showCount = this.multiple && this.options.selectedTextFormat.indexOf('count') !== -1 && selectedCount > 1;
1663
+
1664
+ // determine if the number of selected options will be shown (showCount === true)
1665
+ if (showCount) {
1666
+ countMax = this.options.selectedTextFormat.split('>');
1667
+ showCount = (countMax.length > 1 && selectedCount > countMax[1]) || (countMax.length === 1 && selectedCount >= 2);
1668
+ }
1669
+
1670
+ // only loop through all selected options if the count won't be shown
1671
+ if (showCount === false) {
1672
+ for (var selectedIndex = 0; selectedIndex < selectedCount; selectedIndex++) {
1673
+ if (selectedIndex < 50) {
1674
+ var option = selectedOptions[selectedIndex],
1675
+ titleOptions = {},
1676
+ thisData = {
1677
+ content: option.getAttribute('data-content'),
1678
+ subtext: option.getAttribute('data-subtext'),
1679
+ icon: option.getAttribute('data-icon')
1680
+ };
1681
+
1682
+ if (this.multiple && selectedIndex > 0) {
1683
+ titleFragment.appendChild(multipleSeparator.cloneNode(false));
1684
+ }
1685
+
1686
+ if (option.title) {
1687
+ titleOptions.text = option.title;
1688
+ } else if (thisData.content && that.options.showContent) {
1689
+ titleOptions.content = thisData.content.toString();
1690
+ hasContent = true;
1691
+ } else {
1692
+ if (that.options.showIcon) {
1693
+ titleOptions.icon = thisData.icon;
1694
+ titleOptions.iconBase = this.options.iconBase;
1695
+ }
1696
+ if (that.options.showSubtext && !that.multiple && thisData.subtext) titleOptions.subtext = ' ' + thisData.subtext;
1697
+ titleOptions.text = option.textContent.trim();
1698
+ }
1699
+
1700
+ titleFragment.appendChild(generateOption.text(titleOptions, true));
1701
+ } else {
1702
+ break;
1703
+ }
1704
+ }
1705
+
1706
+ // add ellipsis
1707
+ if (selectedCount > 49) {
1708
+ titleFragment.appendChild(document.createTextNode('...'));
1709
+ }
1710
+ } else {
1711
+ var optionSelector = ':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';
1712
+ if (this.options.hideDisabled) optionSelector += ':not(:disabled)';
1713
+
1714
+ // If this is a multiselect, and selectedTextFormat is count, then show 1 of 2 selected, etc.
1715
+ var totalCount = this.$element[0].querySelectorAll('select > option' + optionSelector + ', optgroup' + optionSelector + ' option' + optionSelector).length,
1716
+ tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedCount, totalCount) : this.options.countSelectedText;
1717
+
1718
+ titleFragment = generateOption.text({
1719
+ text: tr8nText.replace('{0}', selectedCount.toString()).replace('{1}', totalCount.toString())
1720
+ }, true);
1721
+ }
1722
+ }
1723
+
1724
+ if (this.options.title == undefined) {
1725
+ // use .attr to ensure undefined is returned if title attribute is not set
1726
+ this.options.title = this.$element.attr('title');
1727
+ }
1728
+
1729
+ // If the select doesn't have a title, then use the default, or if nothing is set at all, use noneSelectedText
1730
+ if (!titleFragment.childNodes.length) {
1731
+ titleFragment = generateOption.text({
1732
+ text: typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText
1733
+ }, true);
1734
+ }
1735
+
1736
+ // strip all HTML tags and trim the result, then unescape any escaped tags
1737
+ button.title = titleFragment.textContent.replace(/<[^>]*>?/g, '').trim();
1738
+
1739
+ if (this.options.sanitize && hasContent) {
1740
+ sanitizeHtml([titleFragment], that.options.whiteList, that.options.sanitizeFn);
1741
+ }
1742
+
1743
+ buttonInner.innerHTML = '';
1744
+ buttonInner.appendChild(titleFragment);
1745
+
1746
+ if (version.major < 4 && this.$newElement[0].classList.contains('bs3-has-addon')) {
1747
+ var filterExpand = button.querySelector('.filter-expand'),
1748
+ clone = buttonInner.cloneNode(true);
1749
+
1750
+ clone.className = 'filter-expand';
1751
+
1752
+ if (filterExpand) {
1753
+ button.replaceChild(clone, filterExpand);
1754
+ } else {
1755
+ button.appendChild(clone);
1756
+ }
1757
+ }
1758
+
1759
+ this.$element.trigger('rendered' + EVENT_KEY);
1760
+ },
1761
+
1762
+ /**
1763
+ * @param [style]
1764
+ * @param [status]
1765
+ */
1766
+ setStyle: function (newStyle, status) {
1767
+ var button = this.$button[0],
1768
+ newElement = this.$newElement[0],
1769
+ style = this.options.style.trim(),
1770
+ buttonClass;
1771
+
1772
+ if (this.$element.attr('class')) {
1773
+ this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, ''));
1774
+ }
1775
+
1776
+ if (version.major < 4) {
1777
+ newElement.classList.add('bs3');
1778
+
1779
+ if (newElement.parentNode.classList.contains('input-group') &&
1780
+ (newElement.previousElementSibling || newElement.nextElementSibling) &&
1781
+ (newElement.previousElementSibling || newElement.nextElementSibling).classList.contains('input-group-addon')
1782
+ ) {
1783
+ newElement.classList.add('bs3-has-addon');
1784
+ }
1785
+ }
1786
+
1787
+ if (newStyle) {
1788
+ buttonClass = newStyle.trim();
1789
+ } else {
1790
+ buttonClass = style;
1791
+ }
1792
+
1793
+ if (status == 'add') {
1794
+ if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
1795
+ } else if (status == 'remove') {
1796
+ if (buttonClass) button.classList.remove.apply(button.classList, buttonClass.split(' '));
1797
+ } else {
1798
+ if (style) button.classList.remove.apply(button.classList, style.split(' '));
1799
+ if (buttonClass) button.classList.add.apply(button.classList, buttonClass.split(' '));
1800
+ }
1801
+ },
1802
+
1803
+ liHeight: function (refresh) {
1804
+ if (!refresh && (this.options.size === false || this.sizeInfo)) return;
1805
+
1806
+ if (!this.sizeInfo) this.sizeInfo = {};
1807
+
1808
+ var newElement = document.createElement('div'),
1809
+ menu = document.createElement('div'),
1810
+ menuInner = document.createElement('div'),
1811
+ menuInnerInner = document.createElement('ul'),
1812
+ divider = document.createElement('li'),
1813
+ dropdownHeader = document.createElement('li'),
1814
+ li = document.createElement('li'),
1815
+ a = document.createElement('a'),
1816
+ text = document.createElement('span'),
1817
+ header = this.options.header && this.$menu.find('.' + classNames.POPOVERHEADER).length > 0 ? this.$menu.find('.' + classNames.POPOVERHEADER)[0].cloneNode(true) : null,
1818
+ search = this.options.liveSearch ? document.createElement('div') : null,
1819
+ actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null,
1820
+ doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null,
1821
+ firstOption = this.$element.find('option')[0];
1822
+
1823
+ this.sizeInfo.selectWidth = this.$newElement[0].offsetWidth;
1824
+
1825
+ text.className = 'text';
1826
+ a.className = 'dropdown-item ' + (firstOption ? firstOption.className : '');
1827
+ newElement.className = this.$menu[0].parentNode.className + ' ' + classNames.SHOW;
1828
+ newElement.style.width = this.sizeInfo.selectWidth + 'px';
1829
+ if (this.options.width === 'auto') menu.style.minWidth = 0;
1830
+ menu.className = classNames.MENU + ' ' + classNames.SHOW;
1831
+ menuInner.className = 'inner ' + classNames.SHOW;
1832
+ menuInnerInner.className = classNames.MENU + ' inner ' + (version.major === '4' ? classNames.SHOW : '');
1833
+ divider.className = classNames.DIVIDER;
1834
+ dropdownHeader.className = 'dropdown-header';
1835
+
1836
+ text.appendChild(document.createTextNode('\u200b'));
1837
+ a.appendChild(text);
1838
+ li.appendChild(a);
1839
+ dropdownHeader.appendChild(text.cloneNode(true));
1840
+
1841
+ if (this.selectpicker.view.widestOption) {
1842
+ menuInnerInner.appendChild(this.selectpicker.view.widestOption.cloneNode(true));
1843
+ }
1844
+
1845
+ menuInnerInner.appendChild(li);
1846
+ menuInnerInner.appendChild(divider);
1847
+ menuInnerInner.appendChild(dropdownHeader);
1848
+ if (header) menu.appendChild(header);
1849
+ if (search) {
1850
+ var input = document.createElement('input');
1851
+ search.className = 'bs-searchbox';
1852
+ input.className = 'form-control';
1853
+ search.appendChild(input);
1854
+ menu.appendChild(search);
1855
+ }
1856
+ if (actions) menu.appendChild(actions);
1857
+ menuInner.appendChild(menuInnerInner);
1858
+ menu.appendChild(menuInner);
1859
+ if (doneButton) menu.appendChild(doneButton);
1860
+ newElement.appendChild(menu);
1861
+
1862
+ document.body.appendChild(newElement);
1863
+
1864
+ var liHeight = li.offsetHeight,
1865
+ dropdownHeaderHeight = dropdownHeader ? dropdownHeader.offsetHeight : 0,
1866
+ headerHeight = header ? header.offsetHeight : 0,
1867
+ searchHeight = search ? search.offsetHeight : 0,
1868
+ actionsHeight = actions ? actions.offsetHeight : 0,
1869
+ doneButtonHeight = doneButton ? doneButton.offsetHeight : 0,
1870
+ dividerHeight = $(divider).outerHeight(true),
1871
+ // fall back to jQuery if getComputedStyle is not supported
1872
+ menuStyle = window.getComputedStyle ? window.getComputedStyle(menu) : false,
1873
+ menuWidth = menu.offsetWidth,
1874
+ $menu = menuStyle ? null : $(menu),
1875
+ menuPadding = {
1876
+ vert: toInteger(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) +
1877
+ toInteger(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) +
1878
+ toInteger(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) +
1879
+ toInteger(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')),
1880
+ horiz: toInteger(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) +
1881
+ toInteger(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) +
1882
+ toInteger(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) +
1883
+ toInteger(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth'))
1884
+ },
1885
+ menuExtras = {
1886
+ vert: menuPadding.vert +
1887
+ toInteger(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) +
1888
+ toInteger(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2,
1889
+ horiz: menuPadding.horiz +
1890
+ toInteger(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) +
1891
+ toInteger(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2
1892
+ },
1893
+ scrollBarWidth;
1894
+
1895
+ menuInner.style.overflowY = 'scroll';
1896
+
1897
+ scrollBarWidth = menu.offsetWidth - menuWidth;
1898
+
1899
+ document.body.removeChild(newElement);
1900
+
1901
+ this.sizeInfo.liHeight = liHeight;
1902
+ this.sizeInfo.dropdownHeaderHeight = dropdownHeaderHeight;
1903
+ this.sizeInfo.headerHeight = headerHeight;
1904
+ this.sizeInfo.searchHeight = searchHeight;
1905
+ this.sizeInfo.actionsHeight = actionsHeight;
1906
+ this.sizeInfo.doneButtonHeight = doneButtonHeight;
1907
+ this.sizeInfo.dividerHeight = dividerHeight;
1908
+ this.sizeInfo.menuPadding = menuPadding;
1909
+ this.sizeInfo.menuExtras = menuExtras;
1910
+ this.sizeInfo.menuWidth = menuWidth;
1911
+ this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth;
1912
+ this.sizeInfo.scrollBarWidth = scrollBarWidth;
1913
+ this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight;
1914
+
1915
+ this.setPositionData();
1916
+ },
1917
+
1918
+ getSelectPosition: function () {
1919
+ var that = this,
1920
+ $window = $(window),
1921
+ pos = that.$newElement.offset(),
1922
+ $container = $(that.options.container),
1923
+ containerPos;
1924
+
1925
+ if (that.options.container && $container.length && !$container.is('body')) {
1926
+ containerPos = $container.offset();
1927
+ containerPos.top += parseInt($container.css('borderTopWidth'));
1928
+ containerPos.left += parseInt($container.css('borderLeftWidth'));
1929
+ } else {
1930
+ containerPos = { top: 0, left: 0 };
1931
+ }
1932
+
1933
+ var winPad = that.options.windowPadding;
1934
+
1935
+ this.sizeInfo.selectOffsetTop = pos.top - containerPos.top - $window.scrollTop();
1936
+ this.sizeInfo.selectOffsetBot = $window.height() - this.sizeInfo.selectOffsetTop - this.sizeInfo.selectHeight - containerPos.top - winPad[2];
1937
+ this.sizeInfo.selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft();
1938
+ this.sizeInfo.selectOffsetRight = $window.width() - this.sizeInfo.selectOffsetLeft - this.sizeInfo.selectWidth - containerPos.left - winPad[1];
1939
+ this.sizeInfo.selectOffsetTop -= winPad[0];
1940
+ this.sizeInfo.selectOffsetLeft -= winPad[3];
1941
+ },
1942
+
1943
+ setMenuSize: function (isAuto) {
1944
+ this.getSelectPosition();
1945
+
1946
+ var selectWidth = this.sizeInfo.selectWidth,
1947
+ liHeight = this.sizeInfo.liHeight,
1948
+ headerHeight = this.sizeInfo.headerHeight,
1949
+ searchHeight = this.sizeInfo.searchHeight,
1950
+ actionsHeight = this.sizeInfo.actionsHeight,
1951
+ doneButtonHeight = this.sizeInfo.doneButtonHeight,
1952
+ divHeight = this.sizeInfo.dividerHeight,
1953
+ menuPadding = this.sizeInfo.menuPadding,
1954
+ menuInnerHeight,
1955
+ menuHeight,
1956
+ divLength = 0,
1957
+ minHeight,
1958
+ _minHeight,
1959
+ maxHeight,
1960
+ menuInnerMinHeight,
1961
+ estimate;
1962
+
1963
+ if (this.options.dropupAuto) {
1964
+ // Get the estimated height of the menu without scrollbars.
1965
+ // This is useful for smaller menus, where there might be plenty of room
1966
+ // below the button without setting dropup, but we can't know
1967
+ // the exact height of the menu until createView is called later
1968
+ estimate = liHeight * this.selectpicker.current.elements.length + menuPadding.vert;
1969
+ this.$newElement.toggleClass(classNames.DROPUP, this.sizeInfo.selectOffsetTop - this.sizeInfo.selectOffsetBot > this.sizeInfo.menuExtras.vert && estimate + this.sizeInfo.menuExtras.vert + 50 > this.sizeInfo.selectOffsetBot);
1970
+ }
1971
+
1972
+ if (this.options.size === 'auto') {
1973
+ _minHeight = this.selectpicker.current.elements.length > 3 ? this.sizeInfo.liHeight * 3 + this.sizeInfo.menuExtras.vert - 2 : 0;
1974
+ menuHeight = this.sizeInfo.selectOffsetBot - this.sizeInfo.menuExtras.vert;
1975
+ minHeight = _minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
1976
+ menuInnerMinHeight = Math.max(_minHeight - menuPadding.vert, 0);
1977
+
1978
+ if (this.$newElement.hasClass(classNames.DROPUP)) {
1979
+ menuHeight = this.sizeInfo.selectOffsetTop - this.sizeInfo.menuExtras.vert;
1980
+ }
1981
+
1982
+ maxHeight = menuHeight;
1983
+ menuInnerHeight = menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert;
1984
+ } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
1985
+ for (var i = 0; i < this.options.size; i++) {
1986
+ if (this.selectpicker.current.data[i].type === 'divider') divLength++;
1987
+ }
1988
+
1989
+ menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert;
1990
+ menuInnerHeight = menuHeight - menuPadding.vert;
1991
+ maxHeight = menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight;
1992
+ minHeight = menuInnerMinHeight = '';
1993
+ }
1994
+
1995
+ if (this.options.dropdownAlignRight === 'auto') {
1996
+ this.$menu.toggleClass(classNames.MENURIGHT, this.sizeInfo.selectOffsetLeft > this.sizeInfo.selectOffsetRight && this.sizeInfo.selectOffsetRight < (this.sizeInfo.totalMenuWidth - selectWidth));
1997
+ }
1998
+
1999
+ this.$menu.css({
2000
+ 'max-height': maxHeight + 'px',
2001
+ 'overflow': 'hidden',
2002
+ 'min-height': minHeight + 'px'
2003
+ });
2004
+
2005
+ this.$menuInner.css({
2006
+ 'max-height': menuInnerHeight + 'px',
2007
+ 'overflow-y': 'auto',
2008
+ 'min-height': menuInnerMinHeight + 'px'
2009
+ });
2010
+
2011
+ // ensure menuInnerHeight is always a positive number to prevent issues calculating chunkSize in createView
2012
+ this.sizeInfo.menuInnerHeight = Math.max(menuInnerHeight, 1);
2013
+
2014
+ if (this.selectpicker.current.data.length && this.selectpicker.current.data[this.selectpicker.current.data.length - 1].position > this.sizeInfo.menuInnerHeight) {
2015
+ this.sizeInfo.hasScrollBar = true;
2016
+ this.sizeInfo.totalMenuWidth = this.sizeInfo.menuWidth + this.sizeInfo.scrollBarWidth;
2017
+
2018
+ this.$menu.css('min-width', this.sizeInfo.totalMenuWidth);
2019
+ }
2020
+
2021
+ if (this.dropdown && this.dropdown._popper) this.dropdown._popper.update();
2022
+ },
2023
+
2024
+ setSize: function (refresh) {
2025
+ this.liHeight(refresh);
2026
+
2027
+ if (this.options.header) this.$menu.css('padding-top', 0);
2028
+ if (this.options.size === false) return;
2029
+
2030
+ var that = this,
2031
+ $window = $(window);
2032
+
2033
+ this.setMenuSize();
2034
+
2035
+ if (this.options.liveSearch) {
2036
+ this.$searchbox
2037
+ .off('input.setMenuSize propertychange.setMenuSize')
2038
+ .on('input.setMenuSize propertychange.setMenuSize', function () {
2039
+ return that.setMenuSize();
2040
+ });
2041
+ }
2042
+
2043
+ if (this.options.size === 'auto') {
2044
+ $window
2045
+ .off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize')
2046
+ .on('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize', function () {
2047
+ return that.setMenuSize();
2048
+ });
2049
+ } else if (this.options.size && this.options.size != 'auto' && this.selectpicker.current.elements.length > this.options.size) {
2050
+ $window.off('resize' + EVENT_KEY + '.' + this.selectId + '.setMenuSize' + ' scroll' + EVENT_KEY + '.' + this.selectId + '.setMenuSize');
2051
+ }
2052
+
2053
+ that.createView(false, true, refresh);
2054
+ },
2055
+
2056
+ setWidth: function () {
2057
+ var that = this;
2058
+
2059
+ if (this.options.width === 'auto') {
2060
+ requestAnimationFrame(function () {
2061
+ that.$menu.css('min-width', '0');
2062
+
2063
+ that.$element.on('loaded' + EVENT_KEY, function () {
2064
+ that.liHeight();
2065
+ that.setMenuSize();
2066
+
2067
+ // Get correct width if element is hidden
2068
+ var $selectClone = that.$newElement.clone().appendTo('body'),
2069
+ btnWidth = $selectClone.css('width', 'auto').children('button').outerWidth();
2070
+
2071
+ $selectClone.remove();
2072
+
2073
+ // Set width to whatever's larger, button title or longest option
2074
+ that.sizeInfo.selectWidth = Math.max(that.sizeInfo.totalMenuWidth, btnWidth);
2075
+ that.$newElement.css('width', that.sizeInfo.selectWidth + 'px');
2076
+ });
2077
+ });
2078
+ } else if (this.options.width === 'fit') {
2079
+ // Remove inline min-width so width can be changed from 'auto'
2080
+ this.$menu.css('min-width', '');
2081
+ this.$newElement.css('width', '').addClass('fit-width');
2082
+ } else if (this.options.width) {
2083
+ // Remove inline min-width so width can be changed from 'auto'
2084
+ this.$menu.css('min-width', '');
2085
+ this.$newElement.css('width', this.options.width);
2086
+ } else {
2087
+ // Remove inline min-width/width so width can be changed
2088
+ this.$menu.css('min-width', '');
2089
+ this.$newElement.css('width', '');
2090
+ }
2091
+ // Remove fit-width class if width is changed programmatically
2092
+ if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
2093
+ this.$newElement[0].classList.remove('fit-width');
2094
+ }
2095
+ },
2096
+
2097
+ selectPosition: function () {
2098
+ this.$bsContainer = $('<div class="bs-container" />');
2099
+
2100
+ var that = this,
2101
+ $container = $(this.options.container),
2102
+ pos,
2103
+ containerPos,
2104
+ actualHeight,
2105
+ getPlacement = function ($element) {
2106
+ var containerPosition = {},
2107
+ // fall back to dropdown's default display setting if display is not manually set
2108
+ display = that.options.display || (
2109
+ // Bootstrap 3 doesn't have $.fn.dropdown.Constructor.Default
2110
+ $.fn.dropdown.Constructor.Default ? $.fn.dropdown.Constructor.Default.display
2111
+ : false
2112
+ );
2113
+
2114
+ that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass(classNames.DROPUP, $element.hasClass(classNames.DROPUP));
2115
+ pos = $element.offset();
2116
+
2117
+ if (!$container.is('body')) {
2118
+ containerPos = $container.offset();
2119
+ containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop();
2120
+ containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft();
2121
+ } else {
2122
+ containerPos = { top: 0, left: 0 };
2123
+ }
2124
+
2125
+ actualHeight = $element.hasClass(classNames.DROPUP) ? 0 : $element[0].offsetHeight;
2126
+
2127
+ // Bootstrap 4+ uses Popper for menu positioning
2128
+ if (version.major < 4 || display === 'static') {
2129
+ containerPosition.top = pos.top - containerPos.top + actualHeight;
2130
+ containerPosition.left = pos.left - containerPos.left;
2131
+ }
2132
+
2133
+ containerPosition.width = $element[0].offsetWidth;
2134
+
2135
+ that.$bsContainer.css(containerPosition);
2136
+ };
2137
+
2138
+ this.$button.on('click.bs.dropdown.data-api', function () {
2139
+ if (that.isDisabled()) {
2140
+ return;
2141
+ }
2142
+
2143
+ getPlacement(that.$newElement);
2144
+
2145
+ that.$bsContainer
2146
+ .appendTo(that.options.container)
2147
+ .toggleClass(classNames.SHOW, !that.$button.hasClass(classNames.SHOW))
2148
+ .append(that.$menu);
2149
+ });
2150
+
2151
+ $(window)
2152
+ .off('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId)
2153
+ .on('resize' + EVENT_KEY + '.' + this.selectId + ' scroll' + EVENT_KEY + '.' + this.selectId, function () {
2154
+ var isActive = that.$newElement.hasClass(classNames.SHOW);
2155
+
2156
+ if (isActive) getPlacement(that.$newElement);
2157
+ });
2158
+
2159
+ this.$element.on('hide' + EVENT_KEY, function () {
2160
+ that.$menu.data('height', that.$menu.height());
2161
+ that.$bsContainer.detach();
2162
+ });
2163
+ },
2164
+
2165
+ setOptionStatus: function (selectedOnly) {
2166
+ var that = this;
2167
+
2168
+ that.noScroll = false;
2169
+
2170
+ if (that.selectpicker.view.visibleElements && that.selectpicker.view.visibleElements.length) {
2171
+ for (var i = 0; i < that.selectpicker.view.visibleElements.length; i++) {
2172
+ var liData = that.selectpicker.current.data[i + that.selectpicker.view.position0],
2173
+ option = liData.option;
2174
+
2175
+ if (option) {
2176
+ if (selectedOnly !== true) {
2177
+ that.setDisabled(
2178
+ liData.index,
2179
+ liData.disabled
2180
+ );
2181
+ }
2182
+
2183
+ that.setSelected(
2184
+ liData.index,
2185
+ option.selected
2186
+ );
2187
+ }
2188
+ }
2189
+ }
2190
+ },
2191
+
2192
+ /**
2193
+ * @param {number} index - the index of the option that is being changed
2194
+ * @param {boolean} selected - true if the option is being selected, false if being deselected
2195
+ */
2196
+ setSelected: function (index, selected) {
2197
+ var li = this.selectpicker.main.elements[index],
2198
+ liData = this.selectpicker.main.data[index],
2199
+ activeIndexIsSet = this.activeIndex !== undefined,
2200
+ thisIsActive = this.activeIndex === index,
2201
+ prevActive,
2202
+ a,
2203
+ // if current option is already active
2204
+ // OR
2205
+ // if the current option is being selected, it's NOT multiple, and
2206
+ // activeIndex is undefined:
2207
+ // - when the menu is first being opened, OR
2208
+ // - after a search has been performed, OR
2209
+ // - when retainActive is false when selecting a new option (i.e. index of the newly selected option is not the same as the current activeIndex)
2210
+ keepActive = thisIsActive || (selected && !this.multiple && !activeIndexIsSet);
2211
+
2212
+ liData.selected = selected;
2213
+
2214
+ a = li.firstChild;
2215
+
2216
+ if (selected) {
2217
+ this.selectedIndex = index;
2218
+ }
2219
+
2220
+ li.classList.toggle('selected', selected);
2221
+
2222
+ if (keepActive) {
2223
+ this.focusItem(li, liData);
2224
+ this.selectpicker.view.currentActive = li;
2225
+ this.activeIndex = index;
2226
+ } else {
2227
+ this.defocusItem(li);
2228
+ }
2229
+
2230
+ if (a) {
2231
+ a.classList.toggle('selected', selected);
2232
+
2233
+ if (selected) {
2234
+ a.setAttribute('aria-selected', true);
2235
+ } else {
2236
+ if (this.multiple) {
2237
+ a.setAttribute('aria-selected', false);
2238
+ } else {
2239
+ a.removeAttribute('aria-selected');
2240
+ }
2241
+ }
2242
+ }
2243
+
2244
+ if (!keepActive && !activeIndexIsSet && selected && this.prevActiveIndex !== undefined) {
2245
+ prevActive = this.selectpicker.main.elements[this.prevActiveIndex];
2246
+
2247
+ this.defocusItem(prevActive);
2248
+ }
2249
+ },
2250
+
2251
+ /**
2252
+ * @param {number} index - the index of the option that is being disabled
2253
+ * @param {boolean} disabled - true if the option is being disabled, false if being enabled
2254
+ */
2255
+ setDisabled: function (index, disabled) {
2256
+ var li = this.selectpicker.main.elements[index],
2257
+ a;
2258
+
2259
+ this.selectpicker.main.data[index].disabled = disabled;
2260
+
2261
+ a = li.firstChild;
2262
+
2263
+ li.classList.toggle(classNames.DISABLED, disabled);
2264
+
2265
+ if (a) {
2266
+ if (version.major === '4') a.classList.toggle(classNames.DISABLED, disabled);
2267
+
2268
+ if (disabled) {
2269
+ a.setAttribute('aria-disabled', disabled);
2270
+ a.setAttribute('tabindex', -1);
2271
+ } else {
2272
+ a.removeAttribute('aria-disabled');
2273
+ a.setAttribute('tabindex', 0);
2274
+ }
2275
+ }
2276
+ },
2277
+
2278
+ isDisabled: function () {
2279
+ return this.$element[0].disabled;
2280
+ },
2281
+
2282
+ checkDisabled: function () {
2283
+ var that = this;
2284
+
2285
+ if (this.isDisabled()) {
2286
+ this.$newElement[0].classList.add(classNames.DISABLED);
2287
+ this.$button.addClass(classNames.DISABLED).attr('tabindex', -1).attr('aria-disabled', true);
2288
+ } else {
2289
+ if (this.$button[0].classList.contains(classNames.DISABLED)) {
2290
+ this.$newElement[0].classList.remove(classNames.DISABLED);
2291
+ this.$button.removeClass(classNames.DISABLED).attr('aria-disabled', false);
2292
+ }
2293
+
2294
+ if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) {
2295
+ this.$button.removeAttr('tabindex');
2296
+ }
2297
+ }
2298
+
2299
+ this.$button.on('click', function () {
2300
+ return !that.isDisabled();
2301
+ });
2302
+ },
2303
+
2304
+ tabIndex: function () {
2305
+ if (this.$element.data('tabindex') !== this.$element.attr('tabindex') &&
2306
+ (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) {
2307
+ this.$element.data('tabindex', this.$element.attr('tabindex'));
2308
+ this.$button.attr('tabindex', this.$element.data('tabindex'));
2309
+ }
2310
+
2311
+ this.$element.attr('tabindex', -98);
2312
+ },
2313
+
2314
+ clickListener: function () {
2315
+ var that = this,
2316
+ $document = $(document);
2317
+
2318
+ $document.data('spaceSelect', false);
2319
+
2320
+ this.$button.on('keyup', function (e) {
2321
+ if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) {
2322
+ e.preventDefault();
2323
+ $document.data('spaceSelect', false);
2324
+ }
2325
+ });
2326
+
2327
+ this.$newElement.on('show.bs.dropdown', function () {
2328
+ if (version.major > 3 && !that.dropdown) {
2329
+ that.dropdown = that.$button.data('bs.dropdown');
2330
+ that.dropdown._menu = that.$menu[0];
2331
+ }
2332
+ });
2333
+
2334
+ this.$button.on('click.bs.dropdown.data-api', function () {
2335
+ if (!that.$newElement.hasClass(classNames.SHOW)) {
2336
+ that.setSize();
2337
+ }
2338
+ });
2339
+
2340
+ function setFocus () {
2341
+ if (that.options.liveSearch) {
2342
+ that.$searchbox.trigger('focus');
2343
+ } else {
2344
+ that.$menuInner.trigger('focus');
2345
+ }
2346
+ }
2347
+
2348
+ function checkPopperExists () {
2349
+ if (that.dropdown && that.dropdown._popper && that.dropdown._popper.state.isCreated) {
2350
+ setFocus();
2351
+ } else {
2352
+ requestAnimationFrame(checkPopperExists);
2353
+ }
2354
+ }
2355
+
2356
+ this.$element.on('shown' + EVENT_KEY, function () {
2357
+ if (that.$menuInner[0].scrollTop !== that.selectpicker.view.scrollTop) {
2358
+ that.$menuInner[0].scrollTop = that.selectpicker.view.scrollTop;
2359
+ }
2360
+
2361
+ if (version.major > 3) {
2362
+ requestAnimationFrame(checkPopperExists);
2363
+ } else {
2364
+ setFocus();
2365
+ }
2366
+ });
2367
+
2368
+ // ensure posinset and setsize are correct before selecting an option via a click
2369
+ this.$menuInner.on('mouseenter', 'li a', function (e) {
2370
+ var hoverLi = this.parentElement,
2371
+ position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
2372
+ index = Array.prototype.indexOf.call(hoverLi.parentElement.children, hoverLi),
2373
+ hoverData = that.selectpicker.current.data[index + position0];
2374
+
2375
+ that.focusItem(hoverLi, hoverData, true);
2376
+ });
2377
+
2378
+ this.$menuInner.on('click', 'li a', function (e, retainActive) {
2379
+ var $this = $(this),
2380
+ element = that.$element[0],
2381
+ position0 = that.isVirtual() ? that.selectpicker.view.position0 : 0,
2382
+ clickedData = that.selectpicker.current.data[$this.parent().index() + position0],
2383
+ clickedIndex = clickedData.index,
2384
+ prevValue = getSelectValues(element),
2385
+ prevIndex = element.selectedIndex,
2386
+ prevOption = element.options[prevIndex],
2387
+ triggerChange = true;
2388
+
2389
+ // Don't close on multi choice menu
2390
+ if (that.multiple && that.options.maxOptions !== 1) {
2391
+ e.stopPropagation();
2392
+ }
2393
+
2394
+ e.preventDefault();
2395
+
2396
+ // Don't run if the select is disabled
2397
+ if (!that.isDisabled() && !$this.parent().hasClass(classNames.DISABLED)) {
2398
+ var $options = that.$element.find('option'),
2399
+ option = clickedData.option,
2400
+ $option = $(option),
2401
+ state = option.selected,
2402
+ $optgroup = $option.parent('optgroup'),
2403
+ $optgroupOptions = $optgroup.find('option'),
2404
+ maxOptions = that.options.maxOptions,
2405
+ maxOptionsGrp = $optgroup.data('maxOptions') || false;
2406
+
2407
+ if (clickedIndex === that.activeIndex) retainActive = true;
2408
+
2409
+ if (!retainActive) {
2410
+ that.prevActiveIndex = that.activeIndex;
2411
+ that.activeIndex = undefined;
2412
+ }
2413
+
2414
+ if (!that.multiple) { // Deselect all others if not multi select box
2415
+ prevOption.selected = false;
2416
+ option.selected = true;
2417
+ that.setSelected(clickedIndex, true);
2418
+ } else { // Toggle the one we have chosen if we are multi select.
2419
+ option.selected = !state;
2420
+
2421
+ that.setSelected(clickedIndex, !state);
2422
+ $this.trigger('blur');
2423
+
2424
+ if (maxOptions !== false || maxOptionsGrp !== false) {
2425
+ var maxReached = maxOptions < $options.filter(':selected').length,
2426
+ maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length;
2427
+
2428
+ if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) {
2429
+ if (maxOptions && maxOptions == 1) {
2430
+ $options.prop('selected', false);
2431
+ $option.prop('selected', true);
2432
+
2433
+ for (var i = 0; i < $options.length; i++) {
2434
+ that.setSelected(i, false);
2435
+ }
2436
+
2437
+ that.setSelected(clickedIndex, true);
2438
+ } else if (maxOptionsGrp && maxOptionsGrp == 1) {
2439
+ $optgroup.find('option:selected').prop('selected', false);
2440
+ $option.prop('selected', true);
2441
+
2442
+ for (var i = 0; i < $optgroupOptions.length; i++) {
2443
+ var option = $optgroupOptions[i];
2444
+ that.setSelected($options.index(option), false);
2445
+ }
2446
+
2447
+ that.setSelected(clickedIndex, true);
2448
+ } else {
2449
+ var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText,
2450
+ maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText,
2451
+ maxTxt = maxOptionsArr[0].replace('{n}', maxOptions),
2452
+ maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp),
2453
+ $notify = $('<div class="notify"></div>');
2454
+ // If {var} is set in array, replace it
2455
+ /** @deprecated */
2456
+ if (maxOptionsArr[2]) {
2457
+ maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]);
2458
+ maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]);
2459
+ }
2460
+
2461
+ $option.prop('selected', false);
2462
+
2463
+ that.$menu.append($notify);
2464
+
2465
+ if (maxOptions && maxReached) {
2466
+ $notify.append($('<div>' + maxTxt + '</div>'));
2467
+ triggerChange = false;
2468
+ that.$element.trigger('maxReached' + EVENT_KEY);
2469
+ }
2470
+
2471
+ if (maxOptionsGrp && maxReachedGrp) {
2472
+ $notify.append($('<div>' + maxTxtGrp + '</div>'));
2473
+ triggerChange = false;
2474
+ that.$element.trigger('maxReachedGrp' + EVENT_KEY);
2475
+ }
2476
+
2477
+ setTimeout(function () {
2478
+ that.setSelected(clickedIndex, false);
2479
+ }, 10);
2480
+
2481
+ $notify.delay(750).fadeOut(300, function () {
2482
+ $(this).remove();
2483
+ });
2484
+ }
2485
+ }
2486
+ }
2487
+ }
2488
+
2489
+ if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) {
2490
+ that.$button.trigger('focus');
2491
+ } else if (that.options.liveSearch) {
2492
+ that.$searchbox.trigger('focus');
2493
+ }
2494
+
2495
+ // Trigger select 'change'
2496
+ if (triggerChange) {
2497
+ if (that.multiple || prevIndex !== element.selectedIndex) {
2498
+ // $option.prop('selected') is current option state (selected/unselected). prevValue is the value of the select prior to being changed.
2499
+ changedArguments = [option.index, $option.prop('selected'), prevValue];
2500
+ that.$element
2501
+ .triggerNative('change');
2502
+ }
2503
+ }
2504
+ }
2505
+ });
2506
+
2507
+ this.$menu.on('click', 'li.' + classNames.DISABLED + ' a, .' + classNames.POPOVERHEADER + ', .' + classNames.POPOVERHEADER + ' :not(.close)', function (e) {
2508
+ if (e.currentTarget == this) {
2509
+ e.preventDefault();
2510
+ e.stopPropagation();
2511
+ if (that.options.liveSearch && !$(e.target).hasClass('close')) {
2512
+ that.$searchbox.trigger('focus');
2513
+ } else {
2514
+ that.$button.trigger('focus');
2515
+ }
2516
+ }
2517
+ });
2518
+
2519
+ this.$menuInner.on('click', '.divider, .dropdown-header', function (e) {
2520
+ e.preventDefault();
2521
+ e.stopPropagation();
2522
+ if (that.options.liveSearch) {
2523
+ that.$searchbox.trigger('focus');
2524
+ } else {
2525
+ that.$button.trigger('focus');
2526
+ }
2527
+ });
2528
+
2529
+ this.$menu.on('click', '.' + classNames.POPOVERHEADER + ' .close', function () {
2530
+ that.$button.trigger('click');
2531
+ });
2532
+
2533
+ this.$searchbox.on('click', function (e) {
2534
+ e.stopPropagation();
2535
+ });
2536
+
2537
+ this.$menu.on('click', '.actions-btn', function (e) {
2538
+ if (that.options.liveSearch) {
2539
+ that.$searchbox.trigger('focus');
2540
+ } else {
2541
+ that.$button.trigger('focus');
2542
+ }
2543
+
2544
+ e.preventDefault();
2545
+ e.stopPropagation();
2546
+
2547
+ if ($(this).hasClass('bs-select-all')) {
2548
+ that.selectAll();
2549
+ } else {
2550
+ that.deselectAll();
2551
+ }
2552
+ });
2553
+
2554
+ this.$element
2555
+ .on('change' + EVENT_KEY, function () {
2556
+ that.render();
2557
+ that.$element.trigger('changed' + EVENT_KEY, changedArguments);
2558
+ changedArguments = null;
2559
+ })
2560
+ .on('focus' + EVENT_KEY, function () {
2561
+ if (!that.options.mobile) that.$button.trigger('focus');
2562
+ });
2563
+ },
2564
+
2565
+ liveSearchListener: function () {
2566
+ var that = this,
2567
+ noResults = document.createElement('li');
2568
+
2569
+ this.$button.on('click.bs.dropdown.data-api', function () {
2570
+ if (!!that.$searchbox.val()) {
2571
+ that.$searchbox.val('');
2572
+ }
2573
+ });
2574
+
2575
+ this.$searchbox.on('click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api', function (e) {
2576
+ e.stopPropagation();
2577
+ });
2578
+
2579
+ this.$searchbox.on('input propertychange', function () {
2580
+ var searchValue = that.$searchbox.val();
2581
+
2582
+ that.selectpicker.search.elements = [];
2583
+ that.selectpicker.search.data = [];
2584
+
2585
+ if (searchValue) {
2586
+ var i,
2587
+ searchMatch = [],
2588
+ q = searchValue.toUpperCase(),
2589
+ cache = {},
2590
+ cacheArr = [],
2591
+ searchStyle = that._searchStyle(),
2592
+ normalizeSearch = that.options.liveSearchNormalize;
2593
+
2594
+ if (normalizeSearch) q = normalizeToBase(q);
2595
+
2596
+ that._$lisSelected = that.$menuInner.find('.selected');
2597
+
2598
+ for (var i = 0; i < that.selectpicker.main.data.length; i++) {
2599
+ var li = that.selectpicker.main.data[i];
2600
+
2601
+ if (!cache[i]) {
2602
+ cache[i] = stringSearch(li, q, searchStyle, normalizeSearch);
2603
+ }
2604
+
2605
+ if (cache[i] && li.headerIndex !== undefined && cacheArr.indexOf(li.headerIndex) === -1) {
2606
+ if (li.headerIndex > 0) {
2607
+ cache[li.headerIndex - 1] = true;
2608
+ cacheArr.push(li.headerIndex - 1);
2609
+ }
2610
+
2611
+ cache[li.headerIndex] = true;
2612
+ cacheArr.push(li.headerIndex);
2613
+
2614
+ cache[li.lastIndex + 1] = true;
2615
+ }
2616
+
2617
+ if (cache[i] && li.type !== 'optgroup-label') cacheArr.push(i);
2618
+ }
2619
+
2620
+ for (var i = 0, cacheLen = cacheArr.length; i < cacheLen; i++) {
2621
+ var index = cacheArr[i],
2622
+ prevIndex = cacheArr[i - 1],
2623
+ li = that.selectpicker.main.data[index],
2624
+ liPrev = that.selectpicker.main.data[prevIndex];
2625
+
2626
+ if (li.type !== 'divider' || (li.type === 'divider' && liPrev && liPrev.type !== 'divider' && cacheLen - 1 !== i)) {
2627
+ that.selectpicker.search.data.push(li);
2628
+ searchMatch.push(that.selectpicker.main.elements[index]);
2629
+ }
2630
+ }
2631
+
2632
+ that.activeIndex = undefined;
2633
+ that.noScroll = true;
2634
+ that.$menuInner.scrollTop(0);
2635
+ that.selectpicker.search.elements = searchMatch;
2636
+ that.createView(true);
2637
+
2638
+ if (!searchMatch.length) {
2639
+ noResults.className = 'no-results';
2640
+ noResults.innerHTML = that.options.noneResultsText.replace('{0}', '"' + htmlEscape(searchValue) + '"');
2641
+ that.$menuInner[0].firstChild.appendChild(noResults);
2642
+ }
2643
+ } else {
2644
+ that.$menuInner.scrollTop(0);
2645
+ that.createView(false);
2646
+ }
2647
+ });
2648
+ },
2649
+
2650
+ _searchStyle: function () {
2651
+ return this.options.liveSearchStyle || 'contains';
2652
+ },
2653
+
2654
+ val: function (value) {
2655
+ var element = this.$element[0];
2656
+
2657
+ if (typeof value !== 'undefined') {
2658
+ var prevValue = getSelectValues(element);
2659
+
2660
+ changedArguments = [null, null, prevValue];
2661
+
2662
+ this.$element
2663
+ .val(value)
2664
+ .trigger('changed' + EVENT_KEY, changedArguments);
2665
+
2666
+ if (this.$newElement.hasClass(classNames.SHOW)) {
2667
+ if (this.multiple) {
2668
+ this.setOptionStatus(true);
2669
+ } else {
2670
+ var liSelectedIndex = (element.options[element.selectedIndex] || {}).liIndex;
2671
+
2672
+ if (typeof liSelectedIndex === 'number') {
2673
+ this.setSelected(this.selectedIndex, false);
2674
+ this.setSelected(liSelectedIndex, true);
2675
+ }
2676
+ }
2677
+ }
2678
+
2679
+ this.render();
2680
+
2681
+ changedArguments = null;
2682
+
2683
+ return this.$element;
2684
+ } else {
2685
+ return this.$element.val();
2686
+ }
2687
+ },
2688
+
2689
+ changeAll: function (status) {
2690
+ if (!this.multiple) return;
2691
+ if (typeof status === 'undefined') status = true;
2692
+
2693
+ var element = this.$element[0],
2694
+ previousSelected = 0,
2695
+ currentSelected = 0,
2696
+ prevValue = getSelectValues(element);
2697
+
2698
+ element.classList.add('bs-select-hidden');
2699
+
2700
+ for (var i = 0, len = this.selectpicker.current.elements.length; i < len; i++) {
2701
+ var liData = this.selectpicker.current.data[i],
2702
+ option = liData.option;
2703
+
2704
+ if (option && !liData.disabled && liData.type !== 'divider') {
2705
+ if (liData.selected) previousSelected++;
2706
+ option.selected = status;
2707
+ if (status) currentSelected++;
2708
+ }
2709
+ }
2710
+
2711
+ element.classList.remove('bs-select-hidden');
2712
+
2713
+ if (previousSelected === currentSelected) return;
2714
+
2715
+ this.setOptionStatus();
2716
+
2717
+ changedArguments = [null, null, prevValue];
2718
+
2719
+ this.$element
2720
+ .triggerNative('change');
2721
+ },
2722
+
2723
+ selectAll: function () {
2724
+ return this.changeAll(true);
2725
+ },
2726
+
2727
+ deselectAll: function () {
2728
+ return this.changeAll(false);
2729
+ },
2730
+
2731
+ toggle: function (e) {
2732
+ e = e || window.event;
2733
+
2734
+ if (e) e.stopPropagation();
2735
+
2736
+ this.$button.trigger('click.bs.dropdown.data-api');
2737
+ },
2738
+
2739
+ keydown: function (e) {
2740
+ var $this = $(this),
2741
+ isToggle = $this.hasClass('dropdown-toggle'),
2742
+ $parent = isToggle ? $this.closest('.dropdown') : $this.closest(Selector.MENU),
2743
+ that = $parent.data('this'),
2744
+ $items = that.findLis(),
2745
+ index,
2746
+ isActive,
2747
+ liActive,
2748
+ activeLi,
2749
+ offset,
2750
+ updateScroll = false,
2751
+ downOnTab = e.which === keyCodes.TAB && !isToggle && !that.options.selectOnTab,
2752
+ isArrowKey = REGEXP_ARROW.test(e.which) || downOnTab,
2753
+ scrollTop = that.$menuInner[0].scrollTop,
2754
+ isVirtual = that.isVirtual(),
2755
+ position0 = isVirtual === true ? that.selectpicker.view.position0 : 0;
2756
+
2757
+ isActive = that.$newElement.hasClass(classNames.SHOW);
2758
+
2759
+ if (
2760
+ !isActive &&
2761
+ (
2762
+ isArrowKey ||
2763
+ (e.which >= 48 && e.which <= 57) ||
2764
+ (e.which >= 96 && e.which <= 105) ||
2765
+ (e.which >= 65 && e.which <= 90)
2766
+ )
2767
+ ) {
2768
+ that.$button.trigger('click.bs.dropdown.data-api');
2769
+
2770
+ if (that.options.liveSearch) {
2771
+ that.$searchbox.trigger('focus');
2772
+ return;
2773
+ }
2774
+ }
2775
+
2776
+ if (e.which === keyCodes.ESCAPE && isActive) {
2777
+ e.preventDefault();
2778
+ that.$button.trigger('click.bs.dropdown.data-api').trigger('focus');
2779
+ }
2780
+
2781
+ if (isArrowKey) { // if up or down
2782
+ if (!$items.length) return;
2783
+
2784
+ liActive = that.selectpicker.main.elements[that.activeIndex];
2785
+ index = liActive ? Array.prototype.indexOf.call(liActive.parentElement.children, liActive) : -1;
2786
+
2787
+ if (index !== -1) {
2788
+ that.defocusItem(liActive);
2789
+ }
2790
+
2791
+ if (e.which === keyCodes.ARROW_UP) { // up
2792
+ if (index !== -1) index--;
2793
+ if (index + position0 < 0) index += $items.length;
2794
+
2795
+ if (!that.selectpicker.view.canHighlight[index + position0]) {
2796
+ index = that.selectpicker.view.canHighlight.slice(0, index + position0).lastIndexOf(true) - position0;
2797
+ if (index === -1) index = $items.length - 1;
2798
+ }
2799
+ } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
2800
+ index++;
2801
+ if (index + position0 >= that.selectpicker.view.canHighlight.length) index = 0;
2802
+
2803
+ if (!that.selectpicker.view.canHighlight[index + position0]) {
2804
+ index = index + 1 + that.selectpicker.view.canHighlight.slice(index + position0 + 1).indexOf(true);
2805
+ }
2806
+ }
2807
+
2808
+ e.preventDefault();
2809
+
2810
+ var liActiveIndex = position0 + index;
2811
+
2812
+ if (e.which === keyCodes.ARROW_UP) { // up
2813
+ // scroll to bottom and highlight last option
2814
+ if (position0 === 0 && index === $items.length - 1) {
2815
+ that.$menuInner[0].scrollTop = that.$menuInner[0].scrollHeight;
2816
+
2817
+ liActiveIndex = that.selectpicker.current.elements.length - 1;
2818
+ } else {
2819
+ activeLi = that.selectpicker.current.data[liActiveIndex];
2820
+ offset = activeLi.position - activeLi.height;
2821
+
2822
+ updateScroll = offset < scrollTop;
2823
+ }
2824
+ } else if (e.which === keyCodes.ARROW_DOWN || downOnTab) { // down
2825
+ // scroll to top and highlight first option
2826
+ if (index === 0) {
2827
+ that.$menuInner[0].scrollTop = 0;
2828
+
2829
+ liActiveIndex = 0;
2830
+ } else {
2831
+ activeLi = that.selectpicker.current.data[liActiveIndex];
2832
+ offset = activeLi.position - that.sizeInfo.menuInnerHeight;
2833
+
2834
+ updateScroll = offset > scrollTop;
2835
+ }
2836
+ }
2837
+
2838
+ liActive = that.selectpicker.current.elements[liActiveIndex];
2839
+
2840
+ that.activeIndex = that.selectpicker.current.data[liActiveIndex].index;
2841
+
2842
+ that.focusItem(liActive);
2843
+
2844
+ that.selectpicker.view.currentActive = liActive;
2845
+
2846
+ if (updateScroll) that.$menuInner[0].scrollTop = offset;
2847
+
2848
+ if (that.options.liveSearch) {
2849
+ that.$searchbox.trigger('focus');
2850
+ } else {
2851
+ $this.trigger('focus');
2852
+ }
2853
+ } else if (
2854
+ (!$this.is('input') && !REGEXP_TAB_OR_ESCAPE.test(e.which)) ||
2855
+ (e.which === keyCodes.SPACE && that.selectpicker.keydown.keyHistory)
2856
+ ) {
2857
+ var searchMatch,
2858
+ matches = [],
2859
+ keyHistory;
2860
+
2861
+ e.preventDefault();
2862
+
2863
+ that.selectpicker.keydown.keyHistory += keyCodeMap[e.which];
2864
+
2865
+ if (that.selectpicker.keydown.resetKeyHistory.cancel) clearTimeout(that.selectpicker.keydown.resetKeyHistory.cancel);
2866
+ that.selectpicker.keydown.resetKeyHistory.cancel = that.selectpicker.keydown.resetKeyHistory.start();
2867
+
2868
+ keyHistory = that.selectpicker.keydown.keyHistory;
2869
+
2870
+ // if all letters are the same, set keyHistory to just the first character when searching
2871
+ if (/^(.)\1+$/.test(keyHistory)) {
2872
+ keyHistory = keyHistory.charAt(0);
2873
+ }
2874
+
2875
+ // find matches
2876
+ for (var i = 0; i < that.selectpicker.current.data.length; i++) {
2877
+ var li = that.selectpicker.current.data[i],
2878
+ hasMatch;
2879
+
2880
+ hasMatch = stringSearch(li, keyHistory, 'startsWith', true);
2881
+
2882
+ if (hasMatch && that.selectpicker.view.canHighlight[i]) {
2883
+ matches.push(li.index);
2884
+ }
2885
+ }
2886
+
2887
+ if (matches.length) {
2888
+ var matchIndex = 0;
2889
+
2890
+ $items.removeClass('active').find('a').removeClass('active');
2891
+
2892
+ // either only one key has been pressed or they are all the same key
2893
+ if (keyHistory.length === 1) {
2894
+ matchIndex = matches.indexOf(that.activeIndex);
2895
+
2896
+ if (matchIndex === -1 || matchIndex === matches.length - 1) {
2897
+ matchIndex = 0;
2898
+ } else {
2899
+ matchIndex++;
2900
+ }
2901
+ }
2902
+
2903
+ searchMatch = matches[matchIndex];
2904
+
2905
+ activeLi = that.selectpicker.main.data[searchMatch];
2906
+
2907
+ if (scrollTop - activeLi.position > 0) {
2908
+ offset = activeLi.position - activeLi.height;
2909
+ updateScroll = true;
2910
+ } else {
2911
+ offset = activeLi.position - that.sizeInfo.menuInnerHeight;
2912
+ // if the option is already visible at the current scroll position, just keep it the same
2913
+ updateScroll = activeLi.position > scrollTop + that.sizeInfo.menuInnerHeight;
2914
+ }
2915
+
2916
+ liActive = that.selectpicker.main.elements[searchMatch];
2917
+
2918
+ that.activeIndex = matches[matchIndex];
2919
+
2920
+ that.focusItem(liActive);
2921
+
2922
+ if (liActive) liActive.firstChild.focus();
2923
+
2924
+ if (updateScroll) that.$menuInner[0].scrollTop = offset;
2925
+
2926
+ $this.trigger('focus');
2927
+ }
2928
+ }
2929
+
2930
+ // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu.
2931
+ if (
2932
+ isActive &&
2933
+ (
2934
+ (e.which === keyCodes.SPACE && !that.selectpicker.keydown.keyHistory) ||
2935
+ e.which === keyCodes.ENTER ||
2936
+ (e.which === keyCodes.TAB && that.options.selectOnTab)
2937
+ )
2938
+ ) {
2939
+ if (e.which !== keyCodes.SPACE) e.preventDefault();
2940
+
2941
+ if (!that.options.liveSearch || e.which !== keyCodes.SPACE) {
2942
+ that.$menuInner.find('.active a').trigger('click', true); // retain active class
2943
+ $this.trigger('focus');
2944
+
2945
+ if (!that.options.liveSearch) {
2946
+ // Prevent screen from scrolling if the user hits the spacebar
2947
+ e.preventDefault();
2948
+ // Fixes spacebar selection of dropdown items in FF & IE
2949
+ $(document).data('spaceSelect', true);
2950
+ }
2951
+ }
2952
+ }
2953
+ },
2954
+
2955
+ mobile: function () {
2956
+ this.$element[0].classList.add('mobile-device');
2957
+ },
2958
+
2959
+ refresh: function () {
2960
+ // update options if data attributes have been changed
2961
+ var config = $.extend({}, this.options, this.$element.data());
2962
+ this.options = config;
2963
+
2964
+ this.checkDisabled();
2965
+ this.setStyle();
2966
+ this.render();
2967
+ this.createLi();
2968
+ this.setWidth();
2969
+
2970
+ this.setSize(true);
2971
+
2972
+ this.$element.trigger('refreshed' + EVENT_KEY);
2973
+ },
2974
+
2975
+ hide: function () {
2976
+ this.$newElement.hide();
2977
+ },
2978
+
2979
+ show: function () {
2980
+ this.$newElement.show();
2981
+ },
2982
+
2983
+ remove: function () {
2984
+ this.$newElement.remove();
2985
+ this.$element.remove();
2986
+ },
2987
+
2988
+ destroy: function () {
2989
+ this.$newElement.before(this.$element).remove();
2990
+
2991
+ if (this.$bsContainer) {
2992
+ this.$bsContainer.remove();
2993
+ } else {
2994
+ this.$menu.remove();
2995
+ }
2996
+
2997
+ this.$element
2998
+ .off(EVENT_KEY)
2999
+ .removeData('selectpicker')
3000
+ .removeClass('bs-select-hidden selectpicker');
3001
+
3002
+ $(window).off(EVENT_KEY + '.' + this.selectId);
3003
+ }
3004
+ };
3005
+
3006
+ // SELECTPICKER PLUGIN DEFINITION
3007
+ // ==============================
3008
+ function Plugin (option) {
3009
+ // get the args of the outer function..
3010
+ var args = arguments;
3011
+ // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them
3012
+ // to get lost/corrupted in android 2.3 and IE9 #715 #775
3013
+ var _option = option;
3014
+
3015
+ [].shift.apply(args);
3016
+
3017
+ // if the version was not set successfully
3018
+ if (!version.success) {
3019
+ // try to retreive it again
3020
+ try {
3021
+ version.full = ($.fn.dropdown.Constructor.VERSION || '').split(' ')[0].split('.');
3022
+ } catch (err) {
3023
+ // fall back to use BootstrapVersion if set
3024
+ if (Selectpicker.BootstrapVersion) {
3025
+ version.full = Selectpicker.BootstrapVersion.split(' ')[0].split('.');
3026
+ } else {
3027
+ version.full = [version.major, '0', '0'];
3028
+
3029
+ console.warn(
3030
+ 'There was an issue retrieving Bootstrap\'s version. ' +
3031
+ 'Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. ' +
3032
+ 'If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.',
3033
+ err
3034
+ );
3035
+ }
3036
+ }
3037
+
3038
+ version.major = version.full[0];
3039
+ version.success = true;
3040
+ }
3041
+
3042
+ if (version.major === '4') {
3043
+ // some defaults need to be changed if using Bootstrap 4
3044
+ // check to see if they have already been manually changed before forcing them to update
3045
+ var toUpdate = [];
3046
+
3047
+ if (Selectpicker.DEFAULTS.style === classNames.BUTTONCLASS) toUpdate.push({ name: 'style', className: 'BUTTONCLASS' });
3048
+ if (Selectpicker.DEFAULTS.iconBase === classNames.ICONBASE) toUpdate.push({ name: 'iconBase', className: 'ICONBASE' });
3049
+ if (Selectpicker.DEFAULTS.tickIcon === classNames.TICKICON) toUpdate.push({ name: 'tickIcon', className: 'TICKICON' });
3050
+
3051
+ classNames.DIVIDER = 'dropdown-divider';
3052
+ classNames.SHOW = 'show';
3053
+ classNames.BUTTONCLASS = 'btn-light';
3054
+ classNames.POPOVERHEADER = 'popover-header';
3055
+ classNames.ICONBASE = '';
3056
+ classNames.TICKICON = 'bs-ok-default';
3057
+
3058
+ for (var i = 0; i < toUpdate.length; i++) {
3059
+ var option = toUpdate[i];
3060
+ Selectpicker.DEFAULTS[option.name] = classNames[option.className];
3061
+ }
3062
+ }
3063
+
3064
+ var value;
3065
+ var chain = this.each(function () {
3066
+ var $this = $(this);
3067
+ if ($this.is('select')) {
3068
+ var data = $this.data('selectpicker'),
3069
+ options = typeof _option == 'object' && _option;
3070
+
3071
+ if (!data) {
3072
+ var dataAttributes = $this.data();
3073
+
3074
+ for (var dataAttr in dataAttributes) {
3075
+ if (dataAttributes.hasOwnProperty(dataAttr) && $.inArray(dataAttr, DISALLOWED_ATTRIBUTES) !== -1) {
3076
+ delete dataAttributes[dataAttr];
3077
+ }
3078
+ }
3079
+
3080
+ var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, dataAttributes, options);
3081
+ config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), dataAttributes.template, options.template);
3082
+ $this.data('selectpicker', (data = new Selectpicker(this, config)));
3083
+ } else if (options) {
3084
+ for (var i in options) {
3085
+ if (options.hasOwnProperty(i)) {
3086
+ data.options[i] = options[i];
3087
+ }
3088
+ }
3089
+ }
3090
+
3091
+ if (typeof _option == 'string') {
3092
+ if (data[_option] instanceof Function) {
3093
+ value = data[_option].apply(data, args);
3094
+ } else {
3095
+ value = data.options[_option];
3096
+ }
3097
+ }
3098
+ }
3099
+ });
3100
+
3101
+ if (typeof value !== 'undefined') {
3102
+ // noinspection JSUnusedAssignment
3103
+ return value;
3104
+ } else {
3105
+ return chain;
3106
+ }
3107
+ }
3108
+
3109
+ var old = $.fn.selectpicker;
3110
+ $.fn.selectpicker = Plugin;
3111
+ $.fn.selectpicker.Constructor = Selectpicker;
3112
+
3113
+ // SELECTPICKER NO CONFLICT
3114
+ // ========================
3115
+ $.fn.selectpicker.noConflict = function () {
3116
+ $.fn.selectpicker = old;
3117
+ return this;
3118
+ };
3119
+
3120
+ $(document)
3121
+ .off('keydown.bs.dropdown.data-api')
3122
+ .on('keydown' + EVENT_KEY, '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', Selectpicker.prototype.keydown)
3123
+ .on('focusin.modal', '.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input', function (e) {
3124
+ e.stopPropagation();
3125
+ });
3126
+
3127
+ // SELECTPICKER DATA-API
3128
+ // =====================
3129
+ $(window).on('load' + EVENT_KEY + '.data-api', function () {
3130
+ $('.selectpicker').each(function () {
3131
+ var $selectpicker = $(this);
3132
+ Plugin.call($selectpicker, $selectpicker.data());
3133
+ })
3134
+ });
3135
+ })(jQuery);
3136
+
3137
+
3138
+ }));
3139
+ //# sourceMappingURL=bootstrap-select.js.map