raspberry-pi-absensi/assets/plugin/multiselect/multiselect.min.js

11 lines
11 KiB
JavaScript
Raw Permalink Normal View History

/*
* @license
*
* Multiselect v2.3.1
* http://crlcu.github.io/multiselect/
*
* Copyright (c) 2016 Adrian Crisan
* Licensed under the MIT license (https://github.com/crlcu/multiselect/blob/master/LICENSE)
*/
if("undefined"==typeof jQuery)throw Error("multiselect requires jQuery");(function($){"use strict";var version=$.fn.jquery.split(" ")[0].split(".");if(2>version[0]&&7>version[1])throw Error("multiselect requires jQuery version 1.7 or higher")})(jQuery),function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):factory(jQuery)}(function($){"use strict";var Multiselect=function($){function Multiselect($select,settings){var id=$select.prop("id");this.$left=$select,this.$right=$(settings.right).length?$(settings.right):$("#"+id+"_to"),this.actions={$leftAll:$(settings.leftAll).length?$(settings.leftAll):$("#"+id+"_leftAll"),$rightAll:$(settings.rightAll).length?$(settings.rightAll):$("#"+id+"_rightAll"),$leftSelected:$(settings.leftSelected).length?$(settings.leftSelected):$("#"+id+"_leftSelected"),$rightSelected:$(settings.rightSelected).length?$(settings.rightSelected):$("#"+id+"_rightSelected"),$undo:$(settings.undo).length?$(settings.undo):$("#"+id+"_undo"),$redo:$(settings.redo).length?$(settings.redo):$("#"+id+"_redo"),$moveUp:$(settings.moveUp).length?$(settings.moveUp):$("#"+id+"_move_up"),$moveDown:$(settings.moveDown).length?$(settings.moveDown):$("#"+id+"_move_down")},delete settings.leftAll,delete settings.leftSelected,delete settings.right,delete settings.rightAll,delete settings.rightSelected,delete settings.undo,delete settings.redo,delete settings.moveUp,delete settings.moveDown,this.options={keepRenderingSort:settings.keepRenderingSort,submitAllLeft:void 0!==settings.submitAllLeft?settings.submitAllLeft:!0,submitAllRight:void 0!==settings.submitAllRight?settings.submitAllRight:!0,search:settings.search,ignoreDisabled:void 0!==settings.ignoreDisabled?settings.ignoreDisabled:!1},delete settings.keepRenderingSort,settings.submitAllLeft,settings.submitAllRight,settings.search,settings.ignoreDisabled,this.callbacks=settings,this.init()}return Multiselect.prototype={init:function(){var self=this;self.undoStack=[],self.redoStack=[],(self.$left.find("optgroup").length||self.$right.find("optgroup").length)&&(self.callbacks.sort=!1),self.options.keepRenderingSort&&(self.skipInitSort=!0,self.callbacks.sort!==!1&&(self.callbacks.sort=function(a,b){return $(a).data("position")>$(b).data("position")?1:-1}),self.$left.find("option").each(function(index,option){$(option).data("position",index)}),self.$right.find("option").each(function(index,option){$(option).data("position",index)})),"function"==typeof self.callbacks.startUp&&self.callbacks.startUp(self.$left,self.$right),self.skipInitSort||"function"!=typeof self.callbacks.sort||(self.$left.mSort(self.callbacks.sort),self.$right.each(function(i,select){$(select).mSort(self.callbacks.sort)})),self.options.search&&self.options.search.left&&(self.options.search.$left=$(self.options.search.left),self.$left.before(self.options.search.$left)),self.options.search&&self.options.search.right&&(self.options.search.$right=$(self.options.search.right),self.$right.before($(self.options.search.$right))),self.events()},events:function(){var self=this;self.options.search&&self.options.search.$left&&self.options.search.$left.on("keyup",function(){this.value?(self.$left.find('option:search("'+this.value+'")').mShow(),self.$left.find('option:not(:search("'+this.value+'"))').mHide(),self.$left.find("option.hidden").parent("optgroup").not($(":visible").parent()).mHide(),self.$left.find("option:not(.hidden)").parent("optgroup").mShow()):self.$left.find("option, optgroup").mShow()}),self.options.search&&self.options.search.$right&&self.options.search.$right.on("keyup",function(){this.value?(self.$right.find('option:search("'+this.value+'")').mShow(),self.$right.find('option:not(:search("'+this.value+'"))').mHide(),self.$right.find("option.hidden").parent("optgroup").not($(":visible").parent()).mHide(),self.$right.find("option:not(.hidden)").parent("optgroup").mShow()):self.$right.find("option, optgroup").mShow()}),self.$right.closest("form").on("submit",function(){self.$left.find("option").prop("selected",self.options.submitAllLeft),self.$right.find("option").prop("sele