bnbweb/back/assets/js/bootstrap-multiselect.min.js

44 lines
21 KiB
JavaScript
Raw Permalink Normal View History

2022-11-14 15:49:28 +00:00
/**
* Bootstrap Multiselect (https://github.com/davidstutz/bootstrap-multiselect)
*
* Apache License, Version 2.0:
* Copyright (c) 2012 - 2015 David Stutz
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* BSD 3-Clause License:
* Copyright (c) 2012 - 2015 David Stutz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of David Stutz nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
!function(a){"use strict";function b(a,b){for(var c=0;c<a.length;++c)b(a[c],c)}function c(b,c){this.$select=a(b),this.$select.attr("data-placeholder")&&(c.nonSelectedText=this.$select.data("placeholder")),this.options=this.mergeOptions(a.extend({},c,this.$select.data())),this.originalOptions=this.$select.clone()[0].options,this.query="",this.searchTimeout=null,this.lastToggledInput=null,this.options.multiple="multiple"===this.$select.attr("multiple"),this.options.onChange=a.proxy(this.options.onChange,this),this.options.onDropdownShow=a.proxy(this.options.onDropdownShow,this),this.options.onDropdownHide=a.proxy(this.options.onDropdownHide,this),this.options.onDropdownShown=a.proxy(this.options.onDropdownShown,this),this.options.onDropdownHidden=a.proxy(this.options.onDropdownHidden,this),this.buildContainer(),this.buildButton(),this.buildDropdown(),this.buildSelectAll(),this.buildDropdownOptions(),this.buildFilter(),this.updateButtonText(),this.updateSelectAll(),this.options.disableIfEmpty&&a("option",this.$select).length<=0&&this.disable(),this.$select.hide().after(this.$container)}"undefined"!=typeof ko&&ko.bindingHandlers&&!ko.bindingHandlers.multiselect&&(ko.bindingHandlers.multiselect={after:["options","value","selectedOptions"],init:function(b,c,d,e,f){var g=a(b),h=ko.toJS(c());if(g.multiselect(h),d.has("options")){var i=d.get("options");ko.isObservable(i)&&ko.computed({read:function(){i(),setTimeout(function(){var a=g.data("multiselect");a&&a.updateOriginalOptions(),g.multiselect("rebuild")},1)},disposeWhenNodeIsRemoved:b})}if(d.has("value")){var j=d.get("value");ko.isObservable(j)&&ko.computed({read:function(){j(),setTimeout(function(){g.multiselect("refresh")},1)},disposeWhenNodeIsRemoved:b}).extend({rateLimit:100,notifyWhenChangesStop:!0})}if(d.has("selectedOptions")){var k=d.get("selectedOptions");ko.isObservable(k)&&ko.computed({read:function(){k(),setTimeout(function(){g.multiselect("refresh")},1)},disposeWhenNodeIsRemoved:b}).extend({rateLimit:100,notifyWhenChangesStop:!0})}ko.utils.domNodeDisposal.addDisposeCallback(b,function(){g.multiselect("destroy")})},update:function(b,c,d,e,f){var g=a(b),h=ko.toJS(c());g.multiselect("setOptions",h),g.multiselect("rebuild")}}),c.prototype={defaults:{buttonText:function(b,c){if(0===b.length)return this.nonSelectedText;if(this.allSelectedText&&b.length===a("option",a(c)).length&&1!==a("option",a(c)).length&&this.multiple)return this.selectAllNumber?this.allSelectedText+" ("+b.length+")":this.allSelectedText;if(b.length>this.numberDisplayed)return b.length+" "+this.nSelectedText;var d="",e=this.delimiterText;return b.each(function(){var b=void 0!==a(this).attr("label")?a(this).attr("label"):a(this).text();d+=b+e}),d.substr(0,d.length-2)},buttonTitle:function(b,c){if(0===b.length)return this.nonSelectedText;var d="",e=this.delimiterText;return b.each(function(){var b=void 0!==a(this).attr("label")?a(this).attr("label"):a(this).text();d+=b+e}),d.substr(0,d.length-2)},optionLabel:function(b){return a(b).attr("label")||a(b).text()},onChange:function(a,b){},onDropdownShow:function(a){},onDropdownHide:function(a){},onDropdownShown:function(a){},onDropdownHidden:function(a){},onSelectAll:function(){},enableHTML:!1,buttonClass:"btn btn-default",inheritClass:!1,buttonWidth:"auto",buttonContainer:'<div class="btn-group" />',dropRight:!1,selectedClass:"active",maxHeight:!1,checkboxName:!1,includeSelectAllOption:!1,includeSelectAllIfMoreThan:0,selectAllText:" Select all",selectAllValue:"multiselect-all",selectAllName:!1,selectAllNumber:!0,enableFiltering:!1,enableCaseInsensitiveFiltering:!1,enableClickableOptGroups:!1,filterPlaceholder:"Search",filterBehavior:"text",includeFilterClearBtn:!0,preventInputChangeEvent:!1,nonSelectedText:"None selected",nSelectedText:"selected",allSelectedText:"All selected",numberDisplayed:3,disableIfEmpty:!1,delimiterText:", ",templates:{button:'<button type="button" class="multiselect dropdown-toggle" data-toggle="dropdown"><span class="multiselect-selected-text"></span> <b class="caret"></b></button>',ul:'<ul class="multiselect-container dropdown-me