index of
/
home
/
thefkyzp
/
hulmvisaadvisor.com
/
wp-content
/
plugins
/
chaty
/
admin
/
assets
/
js
/
File: /home/thefkyzp/hulmvisaadvisor.com/wp-content/plugins/chaty/admin/assets/js/sumoselect.js
/*! * jquery.sumoselect * http://hemantnegi.github.io/jquery.sumoselect * 2016-12-12 * * Copyright 2015 Hemant Negi * Email : hemant.frnz@gmail.com * Compressor http://refresh-sf.com/ */ !function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"undefined"!=typeof exports?module.exports=a(require("jquery")):a(jQuery)}($=>{$.fn.SumoSelect=function(b){let c=(c,b)=>{let a=null;"function"==typeof Event?a=new Event(b,{bubbles:!0}):(a=document.createEvent("Event")).initEvent(b,!0,!0),c.dispatchEvent(a)};window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);let d={placeholder:"Select Here",csvDispCount:3,captionFormat:"{0} Selected",captionFormatAllSelected:"{0} all selected!",floatWidth:400,forceCustomRendering:!1,nativeOnDevice:["Android","BlackBerry","iPhone","iPad","iPod","Opera Mini","IEMobile","Silk"],outputAsCSV:!1,csvSepChar:",",okCancelInMulti:!1,isClickAwayOk:!1,triggerChangeCombined:!0,selectAll:!1,search:!1,searchText:"Search...",searchFn:(a,b)=>0>a.toLowerCase().indexOf(b.toLowerCase()),noMatch:'No matches for "{0}"',prefix:"",locale:["OK","Cancel","Select All"],up:!1,showTitle:!0,max:null,renderLi:(a,b)=>a},a=this.each(function(){let a=this;if(this.sumo||!$(this).is("select"))return;let e=$.extend({},d,b,$(this).data());this.sumo={E:$(a),is_multi:$(a).attr("multiple"),select:"",caption:"",placeholder:"",optDiv:"",CaptionCont:"",ul:"",is_floating:!1,is_opened:!1,mob:!1,Pstate:[],lastUnselected:null,selectedCount:0,createElems(){let a=this,b=a.E.find("option:checked");if(a.E.wrap('<div class="SumoSelect" tabindex="0" role="button" aria-expanded="false">'),b.each((_,a)=>{a.selected=!0}),a.select=a.E.parent(),a.caption=$("<span>"),a.CaptionCont=$(`<p class="CaptionCont SelectBox ${a.E.attr("class")}" ><label><i></i></label></p>`).attr("style",a.E.attr("style")).prepend(a.caption),a.select.append(a.CaptionCont),a.is_multi||(e.okCancelInMulti=!1),a.E.attr("disabled")&&a.select.addClass("disabled").removeAttr("tabindex"),e.outputAsCSV&&a.is_multi&&a.E.attr("name")&&(a.select.append($('<input class="HEMANT123" type="hidden" />').attr("name",a.E.attr("name")).val(a.getSelStr())),a.E.removeAttr("name")),a.isMobile()&&!e.forceCustomRendering){a.setNativeMobile();return}a.E.attr("name")&&a.select.addClass(`sumo_${a.E.attr("name").replace(/\[\]/,"")}`),a.E.addClass("SumoUnder").attr("tabindex","-1"),a.optDiv=$(`<div class="optWrapper ${e.up?"up":""}">`),a.floatingList(),a.ul=$('<ul class="options">'),a.optDiv.append(a.ul),e.selectAll&&a.is_multi&&!e.max&&a.SelAll(),e.search&&a.Search(),a.ul.append(a.prepItems(a.E.children())),a.is_multi&&a.multiSelelect(),a.select.append(a.optDiv),a._handleMax(),a.basicEvents(),a.selAllState()},prepItems(a,c){let b=[],d=this;return $(a).each((f,e)=>{let a=$(e);b.push(a.is("optgroup")?$(`<li class="group ${e.disabled?"disabled":""}"><label></label><ul></ul></li>`).find("label").text(a.attr("label")).end().find("ul").append(d.prepItems(a.children(),e.disabled)).end():d.createLi(a,c))}),b},createLi(a,d){let c=this;a.attr("value")||a.attr("value",a.val());let b=$(`<li class="opt"><label>${a.html()}</label></li>`);return b.data("opt",a),a.data("li",b),c.is_multi&&b.prepend("<span><i></i></span>"),(a[0].disabled||d)&&b.addClass("disabled"),c.onOptClick(b),a[0].selected&&(b.addClass("selected"),c.selectedCount++),a.attr("class")&&b.addClass(a.attr("class")),a.attr("title")&&b.attr("title",a.attr("title")),e.renderLi(b,a)},getSelStr(){let a=[];return this.E.find("option:checked").each(function(){a.push($(this).val())}),a.join(e.csvSepChar)},multiSelelect(){let a=this;a.optDiv.addClass("multiple"),a.okbtn=$('<p tabindex="0" class="btnOk"></p>').click(()=>{a._okbtn(),a.hideOpts()}),[a.okbtn[0].innerText]=e.locale,a.cancelBtn=$('<p tabindex="0" class="btnCancel"></p>').click(()=>{a._cnbtn(),a.hideOpts()}),[,a.cancelBtn[0].innerText]=e.locale;let b=a.okbtn.add(a.cancelBtn);a.optDiv.append($('<div class="MultiControls">').append(b)),b.on("keydown.sumo",function(b){let c=$(this);switch(b.which){case 32:case 13:c.trigger("click");break;case 9:if(c.hasClass("btnOk"))return;break;case 27:a._cnbtn(),a.hideOpts();return}b.stopPropagation(),b.preventDefault()})},_okbtn(){let a=this,b=0;e.triggerChangeCombined&&(a.E.find("option:checked").length!==a.Pstate.length?b=1:a.E.find("option").each((c,d)=>{d.selected&&0>a.Pstate.indexOf(c)&&(b=1)}),b&&(a.callChange(),a.setText()))},_cnbtn(){let a=this;a.E.find("option:checked").each(function(){this.selected=!1}),a.optDiv.find("li.selected").removeClass("selected");for(let b=0;b<a.Pstate.length;b++)a.E.find("option")[a.Pstate[b]].selected=!0,a.ul.find("li.opt").eq(a.Pstate[b]).addClass("selected");a.selAllState()},_handleMax(){e.max&&(this.selectedCount>= +e.max?this.optDiv.find("li.opt").not(".hidden").each((b,a)=>{$(a).hasClass("selected")||$(a).addClass("temporary-disabled disabled")}):this.optDiv.find("li.opt").not(".hidden").each((b,a)=>{$(a).hasClass("temporary-disabled")&&$(a).removeClass("temporary-disabled disabled")}))},SelAll(){let a=this;a.is_multi&&(a.selAll=$('<p class="select-all"><span><i></i></span><label></label></p>'),[,,a.selAll.find("label")[0].innerText]=e.locale,a.optDiv.addClass("selall"),a.selAll.on("click",()=>{a.selAll.toggleClass("selected"),a.toggSelAll(a.selAll.hasClass("selected"),1)}),a.optDiv.prepend(a.selAll))},Search(){let a=this,c=a.CaptionCont.addClass("search"),d=$('<p class="no-match">'),f=b.searchFn&&"function"==typeof b.searchFn?b.searchFn:e.searchFn;a.ftxt=$('<input type="text" class="search-txt" value="" autocomplete="off">').on("click",a=>{a.stopPropagation()}),a.ftxt[0].placeholder=e.searchText,c.append(a.ftxt),a.optDiv.children("ul").after(d),a.ftxt.on("keyup.sumo",()=>{let b=a.optDiv.find("ul.options li.opt").each((e,d)=>{let b=$(d),{0:c}=b.data("opt");c.hidden=f(b.text(),a.ftxt.val(),b),b.toggleClass("hidden",c.hidden)}).not(".hidden");a.optDiv[0].querySelectorAll("li.group").forEach(a=>{a.querySelector("li:not(.hidden)")?a.classList.remove("hidden"):a.classList.add("hidden")}),d.html(e.noMatch.replace(/\{0\}/g,"<em></em>")).toggle(!b.length),d.find("em").text(a.ftxt.val()),a.selAllState()})},selAllState(){let a=this;if(e.selectAll&&a.is_multi){let b=0,c=0;a.optDiv.find("li.opt").not(".hidden .disabled").each((d,a)=>{$(a).hasClass("selected")&&b++,c++}),b===c?a.selAll.removeClass("partial").addClass("selected"):0===b?a.selAll.removeClass("selected partial"):a.selAll.addClass("partial")}},showOpts(){let a=this;if(!a.E.attr("disabled")){if(a.E.trigger("sumo:opening",a),a.is_opened=!0,a.select.addClass("open").attr("aria-expanded","true"),a.E.trigger("sumo:opened",a),a.ftxt?a.ftxt.focus():a.select.focus(),$(document).on("click.sumo",b=>{!a.select.is(b.target)&&0===a.select.has(b.target).length&&a.is_opened&&(a.hideOpts(),e.okCancelInMulti&&(e.isClickAwayOk?a._okbtn():a._cnbtn()))}),a.is_floating){let b=a.optDiv.children("ul").outerHeight()+2;a.is_multi&&(b+=+a.optDiv.css("padding-bottom")),a.optDiv.css("height",b),$("body").addClass("sumoStopScroll")}a.setPstate()}},setPstate(){let a=this;a.is_multi&&(a.is_floating||e.okCancelInMulti)&&(a.Pstate=[],a.E.find("option").each((b,c)=>{c.selected&&a.Pstate.push(b)}))},callChange(){this.E.get().forEach(a=>{c(a,"change"),c(a,"click")})},hideOpts(){let a=this;a.is_opened&&(a.E.trigger("sumo:closing",a),a.is_opened=!1,a.select.removeClass("open").attr("aria-expanded","false").find("ul li.sel").removeClass("sel"),a.E.trigger("sumo:closed",a),$(document).off("click.sumo"),$("body").removeClass("sumoStopScroll"),e.search&&(a.ftxt.val(""),a.ftxt.trigger("keyup.sumo")))},setOnOpen(){let a=this,b=a.optDiv.find("li.opt:not(.hidden)").eq(e.search?0:a.E[0].selectedIndex);(!b.hasClass("disabled")||(b=b.next(":not(disabled)")).length)&&(a.optDiv.find("li.sel").removeClass("sel"),b.addClass("sel"),a.showOpts())},nav(i){let b=this,g=null,a=b.ul.find("li.opt.sel:not(.hidden)"),e=b.ul.find("li.opt:not(.disabled):not(.hidden)"),c=e.index(a);if(b.is_opened&&a.length){if(i&&c>0)g=e.eq(c-1);else{if(i||!(c<e.length-1)||!(c> -1))return;g=e.eq(c+1)}a.removeClass("sel"),a=g.addClass("sel");let{ul:d}=b,h=d.scrollTop(),f=a.position().top+h;f>=h+d.height()-a.outerHeight()&&d.scrollTop(f-d.height()+a.outerHeight()),f<h&&d.scrollTop(f)}else b.setOnOpen()},basicEvents(){let a=this;a.CaptionCont.click(b=>{a.E.trigger("click"),a.is_opened?a.hideOpts():a.showOpts(),b.stopPropagation()}),a.select.on("keydown.sumo",b=>{switch(b.which){case 38:a.nav(!0);break;case 40:a.nav(!1);break;case 65:if(!a.is_multi||e.max||!b.ctrlKey)return;a.toggSelAll(!b.shiftKey,1);break;case 32:if(e.search&&a.ftxt.is(b.target))return;break;case 13:a.is_opened?a.optDiv.find("ul li.sel").trigger("click"):a.setOnOpen();break;case 9:e.okCancelInMulti||a.hideOpts();return;case 27:e.okCancelInMulti&&a._cnbtn(),a.hideOpts();return;default:return}b.preventDefault()}),$(window).on("resize.sumo",()=>{a.floatingList()})},onOptClick(a){let b=this;a.click(function(){let a=$(this);a.hasClass("disabled")||(b.is_multi?(a.toggleClass("selected"),a.data("opt")[0].selected=a.hasClass("selected"),!1===a.data("opt")[0].selected?(b.lastUnselected=a.data("opt")[0].textContent,b.selectedCount--):b.selectedCount++,e.max&&b._handleMax(),b.selAllState()):(a.parent().find("li.selected").removeClass("selected"),a.toggleClass("selected"),a.data("opt")[0].selected=!0,b.selectedCount=1),b.is_multi&&e.triggerChangeCombined&&(b.is_floating||e.okCancelInMulti)||(b.setText(),b.callChange()),b.is_multi||b.hideOpts())})},setText(){let a=this;if(a.placeholder="",a.is_multi){let b=a.E.find(":checked").not(":disabled");e.csvDispCount&&b.length>e.csvDispCount?b.length===a.E.find("option").length&&e.captionFormatAllSelected?a.placeholder=e.captionFormatAllSelected.replace(/\{0\}/g,b.length):a.placeholder=e.captionFormat.replace(/\{0\}/g,b.length):a.placeholder=b.toArray().map(a=>a.innerText).join(", ")}else a.placeholder=a.E.find(":checked").not(":disabled").text();let c=!1;a.placeholder||(c=!0,a.placeholder=a.E.attr("placeholder"),a.placeholder||(a.placeholder=a.E.find("option:disabled:checked").text())),a.placeholder=a.placeholder?`${e.prefix} ${a.placeholder}`:e.placeholder,a.caption.text(a.placeholder),e.showTitle&&a.CaptionCont.attr("title",a.placeholder);let d=a.select.find("input.HEMANT123");return d.length&&d.val(a.getSelStr()),c?a.caption.addClass("placeholder"):a.caption.removeClass("placeholder"),a.placeholder},isMobile(){let b=navigator.userAgent||navigator.vendor||window.opera;for(let a=0;a<e.nativeOnDevice.length;a++)if(b.toString().toLowerCase().indexOf(e.nativeOnDevice[a].toLowerCase())>0)return e.nativeOnDevice[a];return!1},setNativeMobile(){let a=this;a.E.addClass("SelectClass"),a.mob=!0,a.E.change(()=>{a.setText()})},floatingList(){let a=this;a.is_floating=$(window).width()<=e.floatWidth,a.optDiv.toggleClass("isFloating",a.is_floating),a.is_floating||a.optDiv.css("height",""),a.optDiv.toggleClass("okCancelInMulti",e.okCancelInMulti&&!a.is_floating)},vRange(a){let b=this,c=b.E.find("option");if(c.length<=a||a<0)throw new Error("index out of bounds");return b},toggSel(d,c){let b=this,a=null;"number"==typeof c?(b.vRange(c),a=b.E.find("option")[c]):a=b.E.find(`option[value="${c}"]`)[0]||0,a&&!a.disabled&&a.selected!==d&&(e.max&&!a.selected&&b.selectedCount<e.max||a.selected|| !e.max&&!a.selected)&&(a.selected=d,b.mob||$(a).data("li").toggleClass("selected",d),b.callChange(),b.setPstate(),b.setText(),b.selAllState())},toggDis(c,b){let a=this.vRange(b);a.E.find("option")[b].disabled=c,c&&(a.E.find("option")[b].selected=!1),a.mob||a.optDiv.find("ul.options li.opt").eq(b).toggleClass("disabled",c).removeClass("selected"),a.setText()},toggSumo(b){let a=this;return a.enabled=b,a.select.toggleClass("disabled",b),b?(a.E.attr("disabled","disabled"),a.select.removeAttr("tabindex")):(a.E.removeAttr("disabled"),a.select.attr("tabindex","0")),a},toggSelAll(b,c){let a=this,d=$.extend(!0,{},$._data(a.E.get(0),"events"));a.E.off(),a.is_multi?b?a.E.find("option:not(:checked):not(:disabled):not(:hidden)").toArray().forEach(a=>{$(a).data("li").hasClass("hidden")||(a.selected=!0,$(a).data("li").toggleClass("selected",!0))}):a.E.find("option:checked:not(:disabled):not(:hidden)").toArray().forEach(a=>{$(a).data("li").hasClass("hidden")||(a.selected=!1,$(a).data("li").toggleClass("selected",!1))}):b?console.warn("You called `SelectAll` on a non-multiple select"):a.E[0].selectedIndex=-1,$.each(d,(_,b)=>{$.each(b,(c,b)=>{a.E.on(b.type,b.handler)})}),(!a.is_multi||e.okCancelInMulti)&&a.is_multi||(a.callChange(),a.setText()),c||(!a.mob&&a.selAll&&a.selAll.removeClass("partial").toggleClass("selected",!!b),a.setText(),a.setPstate())},reload(){let a=this.unload();return $(a).SumoSelect(e)},unload(){let b=this;return b.select.before(b.E),b.E.show(),b.E[0].classList.remove("SumoUnder"),e.outputAsCSV&&b.is_multi&&b.select.find("input.HEMANT123").length&&b.E.attr("name",b.select.find("input.HEMANT123").attr("name")),b.select.remove(),delete a.sumo,b.E.trigger("sumo:unloaded",b),a},add(d,e,j,g){if(void 0===d)throw new Error("No value to add");let b=this,h=b.E.find("option"),k=d,i=e,c=j;"number"==typeof e?(c=e,i=d):void 0===e&&(i=d);let f=$("<option></option>").val(k).html(i);if(g&&"object"==typeof g&&$.each(g,(a,b)=>{f.attr(a,b)}),h.length<c)throw new Error("index out of bounds");return void 0===c||h.length===c?(b.E.append(f),b.mob||b.ul.append(b.createLi(f))):(h.eq(c).before(f),b.mob||b.ul.find("li.opt").eq(c).before(b.createLi(f))),a},remove(b){let a=this.vRange(b);a.E.find("option").eq(b).remove(),a.mob||a.optDiv.find("ul.options li.opt").eq(b).remove(),a.setText()},removeAll(){let b=this,c=b.E.find("option");for(let a=c.length-1;a>=0;a--)!0!==c[a].selected&&b.remove(a)},find(c){let d=this,a=d.E.find("option");for(let b in a)if(a[b].value===c)return+b;return -1},selectItem(a){this.toggSel(!0,a)},unSelectItem(a){this.toggSel(!1,a)},selectAll(){this.toggSelAll(!0)},unSelectAll(){this.toggSelAll(!1)},disableItem(a){this.toggDis(!0,a)},enableItem(a){this.toggDis(!1,a)},enabled:!0,enable(){return this.toggSumo(!1)},disable(){return this.toggSumo(!0)},init(){let a=this;return a.createElems(),a.setText(),a.E.trigger("sumo:initialized",a),a}},a.sumo.init()});return 1===a.length?a[0]:a}})