Brak opisu

bootstrap-multiselect-collapsible-groups.js 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. ! function(e) {
  2. "use strict";
  3. jQuery.fn.multiselect.Constructor.prototype.selectAll = (function() {
  4. var cached_function = jQuery.fn.multiselect.Constructor.prototype.selectAll;
  5. return function() {
  6. var args = Array.prototype.slice.call( arguments );
  7. args[0] = (this.options.enableCollapsibleOptGroups && this.options.multiple) ? false : args[0];
  8. cached_function.apply(this, args);
  9. };
  10. }());
  11. jQuery.fn.multiselect.Constructor.prototype.deselectAll = (function() {
  12. var cached_function = jQuery.fn.multiselect.Constructor.prototype.deselectAll;
  13. return function() {
  14. var args = Array.prototype.slice.call( arguments );
  15. args[0] = (this.options.enableCollapsibleOptGroups && this.options.multiple) ? false : args[0];
  16. cached_function.apply(this, args);
  17. };
  18. }());
  19. jQuery.fn.multiselect.Constructor.prototype.createOptgroup = (function() {
  20. var cached_function = jQuery.fn.multiselect.Constructor.prototype.createOptgroup;
  21. return function() {
  22. var args = Array.prototype.slice.call( arguments );
  23. var t = args[0];
  24. if (this.options.enableCollapsibleOptGroups && this.options.multiple) {
  25. var n = e(t).attr("label");
  26. var v = e(t).attr("value");
  27. var r = e('<li class="multiselect-item multiselect-group"><a href="javascript:void(0);"><input type="checkbox" value="' + v + '"/><b> ' + n + '<b class="caret"></b></b></a></li>');
  28. if (this.options.enableClickableOptGroups) {
  29. r.addClass("multiselect-group-clickable")
  30. }
  31. this.$ul.append(r);
  32. if (e(t).is(":disabled")) {
  33. r.addClass("disabled")
  34. }
  35. e("option", t).each(e.proxy(function(e, t) {
  36. this.createOptionValue(t)
  37. }, this))
  38. } else {
  39. cached_function.apply(this, arguments);
  40. }
  41. };
  42. }());
  43. jQuery.fn.multiselect.Constructor.prototype.buildDropdownOptions = (function() {
  44. var cached_function = jQuery.fn.multiselect.Constructor.prototype.buildDropdownOptions;
  45. return function() {
  46. cached_function.apply(this, arguments);
  47. if (this.options.enableCollapsibleOptGroups && this.options.multiple) {
  48. e("li.multiselect-group input", this.$ul).off();
  49. e("li.multiselect-group", this.$ul).siblings().not("li.multiselect-group, li.multiselect-all", this.$ul).each( function () {
  50. $(this).toggleClass('hidden', true);
  51. });
  52. e("li.multiselect-group", this.$ul).on("click", e.proxy(function(t) {
  53. t.stopPropagation();
  54. }, this));
  55. e("li.multiselect-group > a > b", this.$ul).on("click", e.proxy(function(t) {
  56. t.stopPropagation();
  57. var n = e(t.target).closest('li');
  58. var r = n.nextUntil("li.multiselect-group");
  59. var i = true;
  60. r.each(function() {
  61. i = i && e(this).hasClass('hidden');
  62. });
  63. r.toggleClass('hidden', !i);
  64. }, this));
  65. e("li.multiselect-group > a > input", this.$ul).on("change", e.proxy(function(t) {
  66. t.stopPropagation();
  67. var n = e(t.target).closest('li');
  68. var r = n.nextUntil("li.multiselect-group");
  69. var i = true;
  70. var s = r.find("input");
  71. s.each(function() {
  72. i = i && e(this).prop("checked")
  73. });
  74. s.prop("checked", !i).trigger("change")
  75. }, this));
  76. e("li.multiselect-all", this.$ul).css('background', '#f3f3f3').css('border-bottom', '1px solid #eaeaea');
  77. e("li.multiselect-group > a, li.multiselect-all > a > label.checkbox", this.$ul).css('padding', '3px 20px 3px 35px');
  78. e("li.multiselect-group > a > input", this.$ul).css('margin', '4px 0px 5px -20px');
  79. }
  80. };
  81. }());
  82. }(window.jQuery)