{"size": 11972, "ext": "js", "max_stars_repo_path": "docs/assets/jquery.fs.selecter.min.js", "max_stars_repo_name": "shakrmedia/petal", "max_stars_repo_stars_event_min_datetime": "2016-12-16T02:19:19.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-26T05:57:26.000Z", "max_issues_repo_path": "docs/assets/jquery.fs.selecter.min.js", "max_issues_repo_name": "shakrmedia/petal", "max_issues_repo_issues_event_min_datetime": "2016-12-16T20:22:50.000Z", "max_issues_repo_issues_event_max_datetime": "2020-12-28T05:17:59.000Z", "max_forks_repo_path": "dist/jquery.fs.selecter.min.js", "max_forks_repo_name": "shakrmedia/petal", "max_forks_repo_forks_event_min_datetime": "2016-12-17T10:56:44.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-02T20:32:52.000Z"}
{"max_stars_count": 144, "max_issues_count": 14, "max_forks_count": 14, "avg_line_length": 1496.5, "max_line_length": 11761, "alphanum_fraction": 0.7400601403}
/* 
 * Selecter v3.2.4 - 2015-01-07 
 * A jQuery plugin for replacing default select elements. Part of the Formstone Library. 
 * http://formstone.it/selecter/ 
 * 
 * Copyright 2015 Ben Plum; MIT Licensed 
 */
!function($,window){"use strict";function _init(opts){opts=$.extend({},options,opts||{}),null===$body&&($body=$("body"));for(var $items=$(this),i=0,count=$items.length;i<count;i++)_build($items.eq(i),opts);return $items}function _build($select,opts){if(!$select.hasClass("selecter-element")){opts=$.extend({},opts,$select.data("selecter-options")),opts.multiple=$select.prop("multiple"),opts.disabled=$select.is(":disabled"),opts.external&&(opts.links=!0);var $originalOption=$select.find("[selected]").not(":disabled"),originalOptionIndex=$select.find("option").index($originalOption);opts.multiple||""===opts.label?opts.label="":($select.prepend('<option value="" class="selecter-placeholder" selected>'+opts.label+"</option>"),originalOptionIndex>-1&&originalOptionIndex++);var $allOptions=$select.find("option, optgroup"),$options=$allOptions.filter("option");$originalOption.length||($originalOption=$options.eq(0));var originalIndex=originalOptionIndex>-1?originalOptionIndex:0,originalLabel=""!==opts.label?opts.label:$originalOption.text(),wrapperTag="div";opts.tabIndex=$select[0].tabIndex,$select[0].tabIndex=-1;var inner="",wrapper="";wrapper+="<"+wrapperTag+' class="selecter '+opts.customClass,isMobile?wrapper+=" mobile":opts.cover&&(wrapper+=" cover"),wrapper+=opts.multiple?" multiple":" closed",opts.disabled&&(wrapper+=" disabled"),wrapper+='" tabindex="'+opts.tabIndex+'">',wrapper+="</"+wrapperTag+">",opts.multiple||(inner+='<span class="selecter-selected">',inner+=$("<span></span>").text(_trim(originalLabel,opts.trim)).html(),inner+="</span>"),inner+='<div class="selecter-options">',inner+="</div>",$select.addClass("selecter-element").wrap(wrapper).after(inner);var $selecter=$select.parent(".selecter"),data=$.extend({$select:$select,$allOptions:$allOptions,$options:$options,$selecter:$selecter,$selected:$selecter.find(".selecter-selected"),$itemsWrapper:$selecter.find(".selecter-options"),index:-1,guid:guid++},opts);_buildOptions(data),data.multiple||_update(originalIndex,data),void 0!==$.fn.scroller&&data.$itemsWrapper.scroller(),data.$selecter.on("touchstart.selecter",".selecter-selected",data,_onTouchStart).on("click.selecter",".selecter-selected",data,_onClick).on("click.selecter",".selecter-item",data,_onSelect).on("close.selecter",data,_onClose).data("selecter",data),data.$select.on("change.selecter",data,_onChange),isMobile||(data.$selecter.on("focusin.selecter",data,_onFocus).on("blur.selecter",data,_onBlur),data.$select.on("focusin.selecter",data,function(e){e.data.$selecter.trigger("focus")}))}}function _buildOptions(data){for(var html="",itemTag=data.links?"a":"span",j=0,i=0,count=data.$allOptions.length;i<count;i++){var $op=data.$allOptions.eq(i);if("OPTGROUP"===$op[0].tagName)html+='<span class="selecter-group',$op.is(":disabled")&&(html+=" disabled"),html+='">'+$op.attr("label")+"</span>";else{var opVal=$op.val();$op.attr("value")||$op.attr("value",opVal),html+="<"+itemTag+' class="selecter-item',$op.hasClass("selecter-placeholder")&&(html+=" placeholder"),$op.is(":selected")&&(html+=" selected"),$op.is(":disabled")&&(html+=" disabled"),html+='" ',html+=data.links?'href="'+opVal+'"':'data-value="'+opVal+'"',html+=">"+$("<span></span>").text(_trim($op.text(),data.trim)).html()+"</"+itemTag+">",j++}}data.$itemsWrapper.html(html),data.$items=data.$selecter.find(".selecter-item")}function _onTouchStart(e){e.stopPropagation();var data=e.data;data.touchStartEvent=e.originalEvent,data.touchStartX=data.touchStartEvent.touches[0].clientX,data.touchStartY=data.touchStartEvent.touches[0].clientY,data.$selecter.on("touchmove.selecter",".selecter-selected",data,_onTouchMove).on("touchend.selecter",".selecter-selected",data,_onTouchEnd)}function _onTouchMove(e){var data=e.data,oe=e.originalEvent;(Math.abs(oe.touches[0].clientX-data.touchStartX)>10||Math.abs(oe.touches[0].clientY-data.touchStartY)>10)&&data.$selecter.off("touchmove.selecter touchend.selecter")}function _onTouchEnd(e){var data=e.data;data.touchStartEvent.preventDefault(),data.$selecter.off("touchmove.selecter touchend.selecter"),_onClick(e)}function _onClick(e){e.preventDefault(),e.stopPropagation();var data=e.data;if(!data.$select.is(":disabled"))if($(".selecter").not(data.$selecter).trigger("close.selecter",[data]),data.mobile||!isMobile||isFirefoxMobile)data.$selecter.hasClass("closed")?_onOpen(e):data.$selecter.hasClass("open")&&_onClose(e);else{var el=data.$select[0];if(window.document.createEvent){var evt=window.document.createEvent("MouseEvents");evt.initMouseEvent("mousedown",!1,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),el.dispatchEvent(evt)}else el.fireEvent&&el.fireEvent("onmousedown")}}function _onOpen(e){e.preventDefault(),e.stopPropagation();var data=e.data;if(!data.$selecter.hasClass("open")){var offset=data.$selecter.offset(),optionsHeight=data.$itemsWrapper.outerHeight(!0);data.index>=0?data.$items.eq(data.index).position():{left:0,top:0};(offset.top+optionsHeight>window.innerHeight+Math.max(window.scrollY,document.documentElement.scrollTop)||data.bottom)&&data.$selecter.addClass("bottom"),data.$itemsWrapper.show(),data.$selecter.removeClass("closed").addClass("open"),$body.on("click.selecter-"+data.guid,":not(.selecter-options)",data,_onCloseHelper),_scrollOptions(data)}}function _onCloseHelper(e){e.preventDefault(),e.stopPropagation(),0===$(e.currentTarget).parents(".selecter").length&&_onClose(e)}function _onClose(e){e.preventDefault(),e.stopPropagation();var data=e.data;data.$selecter.hasClass("open")&&(data.$itemsWrapper.hide(),data.$selecter.removeClass("open").addClass("closed"),data.bottom||data.$selecter.removeClass("bottom"),$body.off(".selecter-"+data.guid))}function _onSelect(e){e.preventDefault(),e.stopPropagation();var $target=$(this),data=e.data;if(!data.$select.is(":disabled")){if(data.$itemsWrapper.is(":visible")){var index=data.$items.index($target);index!==data.index&&(_update(index,data),_handleChange(data))}data.multiple||_onClose(e)}}function _onChange(e,internal){var $target=$(this),data=e.data;if(!internal&&!data.multiple){var index=data.$options.index(data.$options.filter("[value='"+_escape($target.val())+"']"));_update(index,data),_handleChange(data)}}function _onFocus(e){e.preventDefault(),e.stopPropagation();var data=e.data;data.$select.is(":disabled")||data.multiple||(data.$selecter.addClass("focus").on("keydown.selecter-"+data.guid,data,_onKeypress),$(".selecter").not(data.$selecter).trigger("close.selecter",[data]))}function _onBlur(e,internal,two){e.preventDefault(),e.stopPropagation();var data=e.data;data.$selecter.removeClass("focus").off("keydown.selecter-"+data.guid),$(".selecter").not(data.$selecter).trigger("close.selecter",[data])}function _onKeypress(e){var data=e.data;if(13===e.keyCode)data.$selecter.hasClass("open")&&(_onClose(e),_update(data.index,data)),_handleChange(data);else if(!(9===e.keyCode||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)){e.preventDefault(),e.stopPropagation();var total=data.$items.length-1,index=data.index<0?0:data.index;if($.inArray(e.keyCode,isFirefox?[38,40,37,39]:[38,40])>-1)index+=38===e.keyCode||isFirefox&&37===e.keyCode?-1:1,index<0&&(index=0),index>total&&(index=total);else{var letter,i,input=String.fromCharCode(e.keyCode).toUpperCase();for(i=data.index+1;i<=total;i++)if(letter=data.$options.eq(i).text().charAt(0).toUpperCase(),letter===input){index=i;break}if(index<0||index===data.index)for(i=0;i<=total;i++)if(letter=data.$options.eq(i).text().charAt(0).toUpperCase(),letter===input){index=i;break}}index>=0&&(_update(index,data),_scrollOptions(data))}}function _update(index,data){var $item=data.$items.eq(index),isSelected=$item.hasClass("selected"),isDisabled=$item.hasClass("disabled");if(!isDisabled)if(data.multiple)isSelected?(data.$options.eq(index).prop("selected",null),$item.removeClass("selected")):(data.$options.eq(index).prop("selected",!0),$item.addClass("selected"));else if(index>-1&&index<data.$items.length){var newLabel=$item.html();$item.data("value");data.$selected.html(newLabel).removeClass("placeholder"),data.$items.filter(".selected").removeClass("selected"),data.$select[0].selectedIndex=index,$item.addClass("selected"),data.index=index}else""!==data.label&&data.$selected.html(data.label)}function _scrollOptions(data){var $selected=data.$items.eq(data.index),selectedOffset=data.index>=0&&!$selected.hasClass("placeholder")?$selected.position():{left:0,top:0};void 0!==$.fn.scroller?data.$itemsWrapper.scroller("scroll",data.$itemsWrapper.find(".scroller-content").scrollTop()+selectedOffset.top,0).scroller("reset"):data.$itemsWrapper.scrollTop(data.$itemsWrapper.scrollTop()+selectedOffset.top)}function _handleChange(data){data.links?_launch(data):(data.callback.call(data.$selecter,data.$select.val(),data.index),data.$select.trigger("change",[!0]))}function _launch(data){var url=data.$select.val();data.external?window.open(url):window.location.href=url}function _trim(text,length){return 0===length?text:text.length>length?text.substring(0,length)+"...":text}function _escape(text){return"string"==typeof text?text.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"):text}var guid=0,userAgent=window.navigator.userAgent||window.navigator.vendor||window.opera,isFirefox=/Firefox/i.test(userAgent),isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(userAgent),isFirefoxMobile=isFirefox&&isMobile,$body=null,options={callback:$.noop,cover:!1,bottom:!1,customClass:"",label:"",external:!1,links:!1,mobile:!1,trim:0},pub={defaults:function(opts){return options=$.extend(options,opts||{}),"object"!=typeof this||$(this)},disable:function(option){return $(this).each(function(i,input){var data=$(input).parent(".selecter").data("selecter");if(data)if("undefined"!=typeof option){var index=data.$items.index(data.$items.filter("[data-value="+option+"]"));data.$items.eq(index).addClass("disabled"),data.$options.eq(index).prop("disabled",!0)}else data.$selecter.hasClass("open")&&data.$selecter.find(".selecter-selected").trigger("click.selecter"),data.$selecter.addClass("disabled"),data.$select.prop("disabled",!0)})},destroy:function(){return $(this).each(function(i,input){var data=$(input).parent(".selecter").data("selecter");data&&(data.$selecter.hasClass("open")&&data.$selecter.find(".selecter-selected").trigger("click.selecter"),void 0!==$.fn.scroller&&data.$selecter.find(".selecter-options").scroller("destroy"),data.$select[0].tabIndex=data.tabIndex,data.$select.find(".selecter-placeholder").remove(),data.$selected.remove(),data.$itemsWrapper.remove(),data.$selecter.off(".selecter"),data.$select.off(".selecter").removeClass("selecter-element").show().unwrap())})},enable:function(option){return $(this).each(function(i,input){var data=$(input).parent(".selecter").data("selecter");if(data)if("undefined"!=typeof option){var index=data.$items.index(data.$items.filter("[data-value="+option+"]"));data.$items.eq(index).removeClass("disabled"),data.$options.eq(index).prop("disabled",!1)}else data.$selecter.removeClass("disabled"),data.$select.prop("disabled",!1)})},refresh:function(){return pub.update.apply($(this))},update:function(){return $(this).each(function(i,input){var data=$(input).parent(".selecter").data("selecter");if(data){var index=data.index;data.$allOptions=data.$select.find("option, optgroup"),data.$options=data.$allOptions.filter("option"),data.index=-1,index=data.$options.index(data.$options.filter(":selected")),_buildOptions(data),data.multiple||_update(index,data)}})}};$.fn.selecter=function(method){return pub[method]?pub[method].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof method&&method?this:_init.apply(this,arguments)},$.selecter=function(method){"defaults"===method&&pub.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,window);