jekyll-theme-mdui 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/assets/js/chips.js CHANGED
@@ -1,2 +1,2 @@
1
- Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){var materialChipsDefaults={data:[],placeholder:"",secondaryPlaceholder:"",autocompleteOptions:{},};$(document).ready(function(){$(document).on("click",".chip .close",function(e){var $chips=$(this).closest(".chips");if($chips.attr("data-initialized")){return}$(this).closest(".chip").remove()})});$.fn.material_chip=function(options){var self=this;this.$el=$(this);this.$document=$(document);this.SELS={CHIPS:".chips",CHIP:".chip",INPUT:"input",DELETE:".material-icons",SELECTED_CHIP:".selected",};if("data"===options){return this.$el.data("chips")}var curr_options=$.extend({},materialChipsDefaults,options);self.hasAutocomplete=!$.isEmptyObject(curr_options.autocompleteOptions.data);this.init=function(){var i=0;var chips;self.$el.each(function(){var $chips=$(this);var chipId=Materialize.guid();self.chipId=chipId;if(!curr_options.data||!(curr_options.data instanceof Array)){curr_options.data=[]}$chips.data("chips",curr_options.data);$chips.attr("data-index",i);$chips.attr("data-initialized",true);if(!$chips.hasClass(self.SELS.CHIPS)){$chips.addClass("chips")}self.chips($chips,chipId);i++})};this.handleEvents=function(){var SELS=self.SELS;self.$document.off("click.chips-focus",SELS.CHIPS).on("click.chips-focus",SELS.CHIPS,function(e){$(e.target).find(SELS.INPUT).focus()});self.$document.off("click.chips-select",SELS.CHIP).on("click.chips-select",SELS.CHIP,function(e){var $chip=$(e.target);if($chip.length){var wasSelected=$chip.hasClass("selected");var $chips=$chip.closest(SELS.CHIPS);$(SELS.CHIP).removeClass("selected");if(!wasSelected){self.selectChip($chip.index(),$chips)}}});self.$document.off("keydown.chips").on("keydown.chips",function(e){if($(e.target).is("input, textarea")){return}var $chip=self.$document.find(SELS.CHIP+SELS.SELECTED_CHIP);var $chips=$chip.closest(SELS.CHIPS);var length=$chip.siblings(SELS.CHIP).length;var index;if(!$chip.length){return}if(e.which===8||e.which===46){e.preventDefault();index=$chip.index();self.deleteChip(index,$chips);var selectIndex=null;if((index+1)<length){selectIndex=index}else{if(index===length||(index+1)===length){selectIndex=length-1}}if(selectIndex<0){selectIndex=null}if(null!==selectIndex){self.selectChip(selectIndex,$chips)}if(!length){$chips.find("input").focus()}}else{if(e.which===37){index=$chip.index()-1;if(index<0){return}$(SELS.CHIP).removeClass("selected");self.selectChip(index,$chips)}else{if(e.which===39){index=$chip.index()+1;$(SELS.CHIP).removeClass("selected");if(index>length){$chips.find("input").focus();return}self.selectChip(index,$chips)}}}});self.$document.off("focusin.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusin.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.addClass("focus");$currChips.siblings("label, .prefix").addClass("active");$(SELS.CHIP).removeClass("selected")});self.$document.off("focusout.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusout.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.removeClass("focus");if($currChips.data("chips")===undefined||!$currChips.data("chips").length){$currChips.siblings("label").removeClass("active")}$currChips.siblings(".prefix").removeClass("active")});self.$document.off("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT).on("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var chipsLength=$chips.children(SELS.CHIP).length;if(13===e.which){if(self.hasAutocomplete&&$chips.find(".autocomplete-content.dropdown-content").length&&$chips.find(".autocomplete-content.dropdown-content").children().length){return}e.preventDefault();self.addChip({tag:$target.val()},$chips);$target.val("");return}if((8===e.keyCode||37===e.keyCode)&&""===$target.val()&&chipsLength){e.preventDefault();self.selectChip(chipsLength-1,$chips);$target.blur();return}});self.$document.off("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE).on("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var $chip=$target.closest(SELS.CHIP);e.stopPropagation();self.deleteChip($chip.index(),$chips);$chips.find("input").focus()})};this.chips=function($chips,chipId){$chips.empty();$chips.data("chips").forEach(function(elem){$chips.append(self.renderChip(elem))});$chips.append($('<input id="'+chipId+'" class="input mdui-textfield-input" placeholder="">'));self.setPlaceholder($chips);var label=$chips.next("label");if(label.length){label.attr("for",chipId);if($chips.data("chips")!==undefined&&$chips.data("chips").length){label.addClass("active")}}var input=$("#"+chipId);if(self.hasAutocomplete){curr_options.autocompleteOptions.onAutocomplete=function(val){self.addChip({tag:val},$chips);input.val("");input.focus()
1
+ Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){var materialChipsDefaults={data:[],placeholder:"",secondaryPlaceholder:"",autocompleteOptions:{},};$(document).ready(function(){$(document).on("click",".chip .close",function(e){var $chips=$(this).closest(".chips");if($chips.attr("data-initialized")){return}$(this).closest(".chip").remove()})});$.fn.material_chip=function(options){var self=this;this.$el=$(this);this.$document=$(document);this.SELS={CHIPS:".chips",CHIP:".chip",INPUT:"input",DELETE:".material-icons",SELECTED_CHIP:".selected",};if("data"===options){return this.$el.data("chips")}var curr_options=$.extend({},materialChipsDefaults,options);self.hasAutocomplete=!$.isEmptyObject(curr_options.autocompleteOptions.data);this.init=function(){var i=0;var chips;self.$el.each(function(){var $chips=$(this);var chipId=Materialize.guid();self.chipId=chipId;if(!curr_options.data||!(curr_options.data instanceof Array)){curr_options.data=[]}$chips.data("chips",curr_options.data);$chips.attr("data-index",i);$chips.attr("data-initialized",true);if(!$chips.hasClass(self.SELS.CHIPS)){$chips.addClass("chips")}self.chips($chips,chipId);i++})};this.handleEvents=function(){var SELS=self.SELS;self.$document.off("click.chips-focus",SELS.CHIPS).on("click.chips-focus",SELS.CHIPS,function(e){$(e.target).find(SELS.INPUT).focus()});self.$document.off("click.chips-select",SELS.CHIP).on("click.chips-select",SELS.CHIP,function(e){var $chip=$(e.target);if($chip.length){var wasSelected=$chip.hasClass("selected");var $chips=$chip.closest(SELS.CHIPS);$(SELS.CHIP).removeClass("selected");if(!wasSelected){self.selectChip($chip.index(),$chips)}}});self.$document.off("keydown.chips").on("keydown.chips",function(e){if($(e.target).is("input, textarea")){return}var $chip=self.$document.find(SELS.CHIP+SELS.SELECTED_CHIP);var $chips=$chip.closest(SELS.CHIPS);var length=$chip.siblings(SELS.CHIP).length;var index;if(!$chip.length){return}if(e.which===8||e.which===46){e.preventDefault();index=$chip.index();self.deleteChip(index,$chips);var selectIndex=null;if((index+1)<length){selectIndex=index}else{if(index===length||(index+1)===length){selectIndex=length-1}}if(selectIndex<0){selectIndex=null}if(null!==selectIndex){self.selectChip(selectIndex,$chips)}if(!length){$chips.find("input").focus()}}else{if(e.which===37){index=$chip.index()-1;if(index<0){return}$(SELS.CHIP).removeClass("selected");self.selectChip(index,$chips)}else{if(e.which===39){index=$chip.index()+1;$(SELS.CHIP).removeClass("selected");if(index>length){$chips.find("input").focus();return}self.selectChip(index,$chips)}}}});self.$document.off("focusin.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusin.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.addClass("focus");$currChips.siblings("label, .prefix").addClass("active");$(SELS.CHIP).removeClass("selected")});self.$document.off("focusout.chips",SELS.CHIPS+" "+SELS.INPUT).on("focusout.chips",SELS.CHIPS+" "+SELS.INPUT,function(e){var $currChips=$(e.target).closest(SELS.CHIPS);$currChips.removeClass("focus");if($currChips.data("chips")===undefined||!$currChips.data("chips").length){$currChips.siblings("label").removeClass("active")}$currChips.siblings(".prefix").removeClass("active")});self.$document.off("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT).on("keydown.chips-add",SELS.CHIPS+" "+SELS.INPUT,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var chipsLength=$chips.children(SELS.CHIP).length;if(13===e.which){if(self.hasAutocomplete&&$chips.find(".autocomplete-content.dropdown-content").length&&$chips.find(".autocomplete-content.dropdown-content").children().length){return}e.preventDefault();self.addChip({tag:$target.val()},$chips);$target.val("");return}if((8===e.keyCode||37===e.keyCode)&&""===$target.val()&&chipsLength){e.preventDefault();self.selectChip(chipsLength-1,$chips);$target.blur();return}});self.$document.off("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE).on("click.chips-delete",SELS.CHIPS+" "+SELS.DELETE,function(e){var $target=$(e.target);var $chips=$target.closest(SELS.CHIPS);var $chip=$target.closest(SELS.CHIP);e.stopPropagation();self.deleteChip($chip.index(),$chips);$chips.find("input").focus()})};this.chips=function($chips,chipId){$chips.empty();$chips.data("chips").forEach(function(elem){$chips.append(self.renderChip(elem))});$chips.append($('<input id="'+chipId+'" class="input mdui-textfield-input" placeholder="">'));self.setPlaceholder($chips);var label=$chips.next("label");if(label.length){label.attr("for",chipId);if($chips.data("chips")!==undefined&&$chips.data("chips").length){label.addClass("active")}}var input=$("#"+chipId);if(self.hasAutocomplete){curr_options.autocompleteOptions.onAutocomplete=function(val){self.addChip({tag:val},$chips);input.val("");input.focus()
2
2
  };input.autocomplete(curr_options.autocompleteOptions)}};this.renderChip=function(elem){if(!elem.tag){return}var $renderedChip=$('<div class="mdui-chip chip mdui-chip-title"></div>');$renderedChip.text(elem.tag);if(elem.image){$renderedChip.prepend($("<img />").attr("src",elem.image))}$renderedChip.append($('<i class="material-icons mdui-icon close">close</i>'));return $renderedChip};this.setPlaceholder=function($chips){if($chips.data("chips")!==undefined&&$chips.data("chips").length&&curr_options.placeholder){$chips.find("input").prop("placeholder",curr_options.placeholder)}else{if(($chips.data("chips")===undefined||!$chips.data("chips").length)&&curr_options.secondaryPlaceholder){$chips.find("input").prop("placeholder",curr_options.secondaryPlaceholder)}}};this.isValid=function($chips,elem){var chips=$chips.data("chips");var exists=false;for(var i=0;i<chips.length;i++){if(chips[i].tag===elem.tag){exists=true;return}}return""!==elem.tag&&!exists};this.addChip=function(elem,$chips){if(!self.isValid($chips,elem)){return}var $renderedChip=self.renderChip(elem);var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){newData.push(oldData[i])}newData.push(elem);$chips.data("chips",newData);$renderedChip.insertBefore($chips.find("input"));$chips.trigger("chip.add",elem);self.setPlaceholder($chips)};this.deleteChip=function(chipIndex,$chips){var chip=$chips.data("chips")[chipIndex];$chips.find(".chip").eq(chipIndex).remove();var newData=[];var oldData=$chips.data("chips");for(var i=0;i<oldData.length;i++){if(i!==chipIndex){newData.push(oldData[i])}}$chips.data("chips",newData);$chips.trigger("chip.delete",chip);self.setPlaceholder($chips)};this.selectChip=function(chipIndex,$chips){var $chip=$chips.find(".chip").eq(chipIndex);if($chip&&false===$chip.hasClass("selected")){$chip.addClass("selected");$chips.trigger("chip.select",$chips.data("chips")[chipIndex])}};this.getChipsElement=function(index,$chips){return $chips.eq(index)};this.init();this.handleEvents()}}(jQuery));
@@ -1,11 +1,11 @@
1
- /*!
2
- * jQuery Typeahead
3
- * Copyright (C) 2017 RunningCoder.org
4
- * Licensed under the MIT license
5
- *
6
- * @author Tom Bertrand
7
- * @version 2.8.0 (2017-3-1)
8
- * @link http://www.runningcoder.org/jquerytypeahead/
9
- */
10
- !function(t){"function"==typeof define&&define.amd?define("jquery-typeahead",["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=function(e,i){return void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(i)),t(e)}():t(jQuery)}(function(t){"use strict";window.Typeahead={version:"2.8.0"};var e={input:null,minLength:2,maxLength:!1,maxItem:8,dynamic:!1,delay:300,order:null,offset:!1,hint:!1,accent:!1,highlight:!0,group:!1,groupOrder:null,maxItemPerGroup:null,dropdownFilter:!1,dynamicFilter:null,backdrop:!1,backdropOnFocus:!1,cache:!1,ttl:36e5,compression:!1,searchOnFocus:!1,blurOnTab:!0,resultContainer:null,generateOnLoad:null,mustSelectItem:!1,href:null,display:["display"],template:null,templateValue:null,groupTemplate:null,correlativeTemplate:!1,emptyTemplate:!1,cancelButton:!0,loadingAnimation:!0,filter:!0,matcher:null,source:null,callback:{onInit:null,onReady:null,onShowLayout:null,onHideLayout:null,onSearch:null,onResult:null,onLayoutBuiltBefore:null,onLayoutBuiltAfter:null,onNavigateBefore:null,onNavigateAfter:null,onMouseEnter:null,onMouseLeave:null,onClickBefore:null,onClickAfter:null,onDropdownFilter:null,onSendRequest:null,onReceiveRequest:null,onPopulateSource:null,onCacheSave:null,onSubmit:null,onCancel:null},selector:{container:"typeahead__container",result:"typeahead__result",list:"typeahead__list",group:"typeahead__group",item:"typeahead__item",empty:"typeahead__empty",display:"typeahead__display",query:"typeahead__query",filter:"typeahead__filter",filterButton:"typeahead__filter-button",dropdown:"typeahead__dropdown",dropdownItem:"typeahead__dropdown-item",button:"typeahead__button",backdrop:"typeahead__backdrop",hint:"typeahead__hint",cancelButton:"typeahead__cancel-button"},debug:!1},i=".typeahead",o={from:"ãàáäâẽèéëêìíïîõòóöôùúüûñç",to:"aaaaaeeeeeiiiiooooouuuunc"},s=~window.navigator.appVersion.indexOf("MSIE 9."),n=~window.navigator.appVersion.indexOf("MSIE 10"),r=~window.navigator.userAgent.indexOf("Trident")&&~window.navigator.userAgent.indexOf("rv:11"),a=function(t,e){this.rawQuery=t.val()||"",this.query=t.val()||"",this.selector=t[0].selector,this.deferred=null,this.tmpSource={},this.source={},this.dynamicGroups=[],this.hasDynamicGroups=!1,this.generatedGroupCount=0,this.groupBy="group",this.groups=[],this.searchGroups=[],this.generateGroups=[],this.requestGroups=[],this.result={},this.groupTemplate="",this.resultHtml=null,this.resultCount=0,this.resultCountPerGroup={},this.options=e,this.node=t,this.namespace="."+this.helper.slugify.call(this,this.selector)+i,this.container=null,this.resultContainer=null,this.item=null,this.xhr={},this.hintIndex=null,this.filters={dropdown:{},dynamic:{}},this.dropdownFilter={"static":[],dynamic:[]},this.dropdownFilterAll=null,this.isDropdownEvent=!1,this.requests={},this.backdrop={},this.hint={},this.hasDragged=!1,this.focusOnly=!1,this.__construct()};a.prototype={_validateCacheMethod:function(t){var e,i=["localStorage","sessionStorage"];if(t===!0)t="localStorage";else if("string"==typeof t&&!~i.indexOf(t))return!1;e="undefined"!=typeof window[t];try{window[t].setItem("typeahead","typeahead"),window[t].removeItem("typeahead")}catch(o){e=!1}return e&&t||!1},extendOptions:function(){if(this.options.cache=this._validateCacheMethod(this.options.cache),this.options.compression&&("object"==typeof LZString&&this.options.cache||(this.options.compression=!1)),(!this.options.maxLength||isNaN(this.options.maxLength))&&(this.options.maxLength=1/0),"undefined"!=typeof this.options.maxItem&&~[0,!1].indexOf(this.options.maxItem)&&(this.options.maxItem=1/0),this.options.maxItemPerGroup&&!/^\d+$/.test(this.options.maxItemPerGroup)&&(this.options.maxItemPerGroup=null),this.options.display&&!Array.isArray(this.options.display)&&(this.options.display=[this.options.display]),this.options.group&&(Array.isArray(this.options.group)||("string"==typeof this.options.group?this.options.group={key:this.options.group}:"boolean"==typeof this.options.group&&(this.options.group={key:"group"}),this.options.group.key=this.options.group.key||"group")),this.options.highlight&&!~["any",!0].indexOf(this.options.highlight)&&(this.options.highlight=!1),this.options.dropdownFilter&&this.options.dropdownFilter instanceof Object){Array.isArray(this.options.dropdownFilter)||(this.options.dropdownFilter=[this.options.dropdownFilter]);for(var i=0,s=this.options.dropdownFilter.length;s>i;++i)this.dropdownFilter[this.options.dropdownFilter[i].value?"static":"dynamic"].push(this.options.dropdownFilter[i])}this.options.dynamicFilter&&!Array.isArray(this.options.dynamicFilter)&&(this.options.dynamicFilter=[this.options.dynamicFilter]),this.options.accent&&("object"==typeof this.options.accent?this.options.accent.from&&this.options.accent.to&&this.options.accent.from.length===this.options.accent.to.length:this.options.accent=o),this.options.groupTemplate&&(this.groupTemplate=this.options.groupTemplate),this.options.resultContainer&&("string"==typeof this.options.resultContainer&&(this.options.resultContainer=t(this.options.resultContainer)),this.options.resultContainer instanceof t&&this.options.resultContainer[0]&&(this.resultContainer=this.options.resultContainer)),this.options.maxItemPerGroup&&this.options.group&&this.options.group.key&&(this.groupBy=this.options.group.key),this.options.callback&&this.options.callback.onClick&&(this.options.callback.onClickBefore=this.options.callback.onClick,delete this.options.callback.onClick),this.options.callback&&this.options.callback.onNavigate&&(this.options.callback.onNavigateBefore=this.options.callback.onNavigate,delete this.options.callback.onNavigate),this.options=t.extend(!0,{},e,this.options)},unifySourceFormat:function(){this.dynamicGroups=[],Array.isArray(this.options.source)&&(this.options.source={group:{data:this.options.source}}),"string"==typeof this.options.source&&(this.options.source={group:{ajax:{url:this.options.source}}}),this.options.source.ajax&&(this.options.source={group:{ajax:this.options.source.ajax}}),(this.options.source.url||this.options.source.data)&&(this.options.source={group:this.options.source});var t,e,i;for(t in this.options.source)if(this.options.source.hasOwnProperty(t)){if(e=this.options.source[t],"string"==typeof e&&(e={ajax:{url:e}}),i=e.url||e.ajax,Array.isArray(i)?(e.ajax="string"==typeof i[0]?{url:i[0]}:i[0],e.ajax.path=e.ajax.path||i[1]||null,delete e.url):("object"==typeof e.url?e.ajax=e.url:"string"==typeof e.url&&(e.ajax={url:e.url}),delete e.url),!e.data&&!e.ajax)return!1;e.display&&!Array.isArray(e.display)&&(e.display=[e.display]),e.minLength="number"==typeof e.minLength?e.minLength:this.options.minLength,e.maxLength="number"==typeof e.maxLength?e.maxLength:this.options.maxLength,e.dynamic="boolean"==typeof e.dynamic||this.options.dynamic,e.minLength>e.maxLength&&(e.minLength=e.maxLength),this.options.source[t]=e,this.options.source[t].dynamic&&this.dynamicGroups.push(t),e.cache="undefined"!=typeof e.cache?this._validateCacheMethod(e.cache):this.options.cache,e.compression&&("object"==typeof LZString&&e.cache||(e.compression=!1))}return this.hasDynamicGroups=this.options.dynamic||!!this.dynamicGroups.length,!0},init:function(){this.helper.executeCallback.call(this,this.options.callback.onInit,[this.node]),this.container=this.node.closest("."+this.options.selector.container)},delegateEvents:function(){var e=this,i=["focus"+this.namespace,"input"+this.namespace,"propertychange"+this.namespace,"keydown"+this.namespace,"keyup"+this.namespace,"search"+this.namespace,"generate"+this.namespace];t("html").on("touchmove",function(){e.hasDragged=!0}).on("touchstart",function(){e.hasDragged=!1}),this.node.closest("form").on("submit",function(t){return e.options.mustSelectItem&&e.helper.isEmpty(e.item)?void t.preventDefault():(e.options.backdropOnFocus||e.hideLayout(),e.options.callback.onSubmit?e.helper.executeCallback.call(e,e.options.callback.onSubmit,[e.node,this,e.item,t]):void 0)}).on("reset",function(){setTimeout(function(){e.node.trigger("input"+e.namespace),e.hideLayout()})});var o=!1;if(this.node.attr("placeholder")&&(n||r)){var a=!0;this.node.on("focusin focusout",function(){a=!(this.value||!this.placeholder)}),this.node.on("input",function(t){a&&(t.stopImmediatePropagation(),a=!1)})}this.node.off(this.namespace).on(i.join(" "),function(i,n){switch(i.type){case"generate":e.generateSource(Object.keys(e.options.source));break;case"focus":if(e.focusOnly){e.focusOnly=!1;break}e.options.backdropOnFocus&&(e.buildBackdropLayout(),e.showLayout()),e.options.searchOnFocus&&(e.deferred=t.Deferred(),e.generateSource());break;case"keydown":i.keyCode&&~[9,13,27,38,39,40].indexOf(i.keyCode)&&(o=!0,e.navigate(i));break;case"keyup":s&&e.node[0].value.replace(/^\s+/,"").toString().length<e.query.length&&e.node.trigger("input"+e.namespace);break;case"propertychange":if(o){o=!1;break}case"input":e.deferred=t.Deferred(),e.rawQuery=e.node[0].value.toString(),e.query=e.rawQuery.replace(/^\s+/,""),""===e.rawQuery&&""===e.query&&(i.originalEvent=n||{},e.helper.executeCallback.call(e,e.options.callback.onCancel,[e.node,i])),e.options.cancelButton&&e.toggleCancelButtonVisibility(),e.options.hint&&e.hint.container&&""!==e.hint.container.val()&&0!==e.hint.container.val().indexOf(e.rawQuery)&&e.hint.container.val(""),e.hasDynamicGroups?e.helper.typeWatch(function(){e.generateSource()},e.options.delay):e.generateSource();break;case"search":e.searchResult(),e.buildLayout(),e.result.length||e.searchGroups.length&&e.options.emptyTemplate&&e.query.length?e.showLayout():e.hideLayout(),e.deferred&&e.deferred.resolve()}return e.deferred&&e.deferred.promise()}),this.options.generateOnLoad&&this.node.trigger("generate"+this.namespace)},filterGenerateSource:function(){this.searchGroups=[],this.generateGroups=[];for(var t in this.options.source)if(this.options.source.hasOwnProperty(t)&&this.query.length>=this.options.source[t].minLength&&this.query.length<=this.options.source[t].maxLength){if(this.searchGroups.push(t),!this.options.source[t].dynamic&&this.source[t])continue;this.generateGroups.push(t)}},generateSource:function(e){if(this.filterGenerateSource(),Array.isArray(e)&&e.length)this.generateGroups=e;else if(!this.generateGroups.length)return void this.node.trigger("search"+this.namespace);if(this.requestGroups=[],this.generatedGroupCount=0,this.options.loadingAnimation&&this.container.addClass("loading"),!this.helper.isEmpty(this.xhr)){for(var i in this.xhr)this.xhr.hasOwnProperty(i)&&this.xhr[i].abort();this.xhr={}}for(var o,s,n,r,a,l,h,c=this,i=0,u=this.generateGroups.length;u>i;++i){if(o=this.generateGroups[i],n=this.options.source[o],r=n.cache,a=n.compression,r&&(l=window[r].getItem("TYPEAHEAD_"+this.selector+":"+o))){a&&(l=LZString.decompressFromUTF16(l)),h=!1;try{l=JSON.parse(l+""),l.data&&l.ttl>(new Date).getTime()?(this.populateSource(l.data,o),h=!0):window[r].removeItem("TYPEAHEAD_"+this.selector+":"+o)}catch(p){}if(h)continue}!n.data||n.ajax?n.ajax&&(this.requests[o]||(this.requests[o]=this.generateRequestObject(o)),this.requestGroups.push(o)):"function"==typeof n.data?(s=n.data.call(this),Array.isArray(s)?c.populateSource(s,o):"function"==typeof s.promise&&!function(e){t.when(s).then(function(t){t&&Array.isArray(t)&&c.populateSource(t,e)})}(o)):this.populateSource(t.extend(!0,[],n.data),o)}return this.requestGroups.length&&this.handleRequests(),!!this.generateGroups.length},generateRequestObject:function(t){var e=this,i=this.options.source[t],o={request:{url:i.ajax.url||null,dataType:"json",beforeSend:function(o,s){e.xhr[t]=o;var n=e.requests[t].callback.beforeSend||i.ajax.beforeSend;"function"==typeof n&&n.apply(null,arguments)}},callback:{beforeSend:null,done:null,fail:null,then:null,always:null},extra:{path:i.ajax.path||null,group:t},validForGroup:[t]};if("function"!=typeof i.ajax&&(i.ajax instanceof Object&&(o=this.extendXhrObject(o,i.ajax)),Object.keys(this.options.source).length>1))for(var s in this.requests)this.requests.hasOwnProperty(s)&&(this.requests[s].isDuplicated||o.request.url&&o.request.url===this.requests[s].request.url&&(this.requests[s].validForGroup.push(t),o.isDuplicated=!0,delete o.validForGroup));return o},extendXhrObject:function(e,i){return"object"==typeof i.callback&&(e.callback=i.callback,delete i.callback),"function"==typeof i.beforeSend&&(e.callback.beforeSend=i.beforeSend,delete i.beforeSend),e.request=t.extend(!0,e.request,i),"jsonp"!==e.request.dataType.toLowerCase()||e.request.jsonpCallback||(e.request.jsonpCallback="callback_"+e.extra.group),e},handleRequests:function(){var e,i=this,o=this.requestGroups.length;if(this.helper.executeCallback.call(this,this.options.callback.onSendRequest,[this.node,this.query])!==!1)for(var s=0,n=this.requestGroups.length;n>s;++s)e=this.requestGroups[s],this.requests[e].isDuplicated||!function(e,s){if("function"==typeof i.options.source[e].ajax){var n=i.options.source[e].ajax.call(i,i.query);if(s=i.extendXhrObject(i.generateRequestObject(e),"object"==typeof n?n:{}),"object"!=typeof s.request||!s.request.url)return void i.populateSource([],e);i.requests[e]=s}var r,a,l=!1;if(~s.request.url.indexOf("{{query}}")&&(l||(s=t.extend(!0,{},s),l=!0),s.request.url=s.request.url.replace("{{query}}",encodeURIComponent(i.query))),s.request.data)for(var h in s.request.data)if(s.request.data.hasOwnProperty(h)&&~String(s.request.data[h]).indexOf("{{query}}")){l||(s=t.extend(!0,{},s),l=!0),s.request.data[h]=s.request.data[h].replace("{{query}}",i.query);break}t.ajax(s.request).done(function(t,e,o){a=null;for(var n=0,l=s.validForGroup.length;l>n;n++)r=i.requests[s.validForGroup[n]],r.callback.done instanceof Function&&(a=r.callback.done.call(i,t,e,o))}).fail(function(t,e,o){for(var n=0,a=s.validForGroup.length;a>n;n++)r=i.requests[s.validForGroup[n]],r.callback.fail instanceof Function&&r.callback.fail.call(i,t,e,o)}).always(function(t,e,n){for(var l=0,h=s.validForGroup.length;h>l;l++){if(r=i.requests[s.validForGroup[l]],r.callback.always instanceof Function&&r.callback.always.call(i,t,e,n),"object"!=typeof n)return;i.populateSource("function"==typeof t.promise&&[]||a||t,r.extra.group,r.extra.path||r.request.path),o-=1,0===o&&i.helper.executeCallback.call(i,i.options.callback.onReceiveRequest,[i.node,i.query])}}).then(function(t,e){for(var o=0,n=s.validForGroup.length;n>o;o++)r=i.requests[s.validForGroup[o]],r.callback.then instanceof Function&&r.callback.then.call(i,t,e)})}(e,this.requests[e])},populateSource:function(t,e,i){var o=this,s=this.options.source[e],n=s.ajax&&s.data;i&&"string"==typeof i&&(t=this.helper.namespace.call(this,i,t)),Array.isArray(t)||(t=[]),n&&("function"==typeof n&&(n=n()),Array.isArray(n)&&(t=t.concat(n)));for(var r,a=s.display?"compiled"===s.display[0]?s.display[1]:s.display[0]:"compiled"===this.options.display[0]?this.options.display[1]:this.options.display[0],l=0,h=t.length;h>l;l++)null!==t[l]&&"boolean"!=typeof t[l]&&("string"==typeof t[l]&&(r={},r[a]=t[l],t[l]=r),t[l].group=e);if(!this.hasDynamicGroups&&this.dropdownFilter.dynamic.length)for(var c,u,p={},l=0,h=t.length;h>l;l++)for(var d=0,f=this.dropdownFilter.dynamic.length;f>d;d++)c=this.dropdownFilter.dynamic[d].key,u=t[l][c],u&&(this.dropdownFilter.dynamic[d].value||(this.dropdownFilter.dynamic[d].value=[]),p[c]||(p[c]=[]),~p[c].indexOf(u.toLowerCase())||(p[c].push(u.toLowerCase()),this.dropdownFilter.dynamic[d].value.push(u)));if(this.options.correlativeTemplate){var y=s.template||this.options.template,g="";if("function"==typeof y&&(y=y.call(this,"",{})),y){if(Array.isArray(this.options.correlativeTemplate))for(var l=0,h=this.options.correlativeTemplate.length;h>l;l++)g+="{{"+this.options.correlativeTemplate[l]+"}} ";else g=y.replace(/<.+?>/g,"");for(var l=0,h=t.length;h>l;l++)t[l].compiled=g.replace(/\{\{([\w\-\.]+)(?:\|(\w+))?}}/g,function(e,i){return o.helper.namespace.call(o,i,t[l],"get","")}).trim();s.display?~s.display.indexOf("compiled")||s.display.unshift("compiled"):~this.options.display.indexOf("compiled")||this.options.display.unshift("compiled")}else;}this.options.callback.onPopulateSource&&(t=this.helper.executeCallback.call(this,this.options.callback.onPopulateSource,[this.node,t,e,i])),this.tmpSource[e]=Array.isArray(t)&&t||[];var m=this.options.source[e].cache,v=this.options.source[e].compression,b=this.options.source[e].ttl||this.options.ttl;if(m&&!window[m].getItem("TYPEAHEAD_"+this.selector+":"+e)){this.options.callback.onCacheSave&&(t=this.helper.executeCallback.call(this,this.options.callback.onCacheSave,[this.node,t,e,i]));var k=JSON.stringify({data:t,ttl:(new Date).getTime()+b});v&&(k=LZString.compressToUTF16(k)),window[m].setItem("TYPEAHEAD_"+this.selector+":"+e,k)}this.incrementGeneratedGroup()},incrementGeneratedGroup:function(){if(this.generatedGroupCount++,this.generatedGroupCount===this.generateGroups.length){this.xhr={};for(var t=0,e=this.generateGroups.length;e>t;t++)this.source[this.generateGroups[t]]=this.tmpSource[this.generateGroups[t]];this.hasDynamicGroups||this.buildDropdownItemLayout("dynamic"),this.options.loadingAnimation&&this.container.removeClass("loading"),this.node.trigger("search"+this.namespace)}},navigate:function(t){if(this.helper.executeCallback.call(this,this.options.callback.onNavigateBefore,[this.node,this.query,t]),27===t.keyCode)return t.preventDefault(),void(this.query.length?(this.resetInput(),this.node.trigger("input"+this.namespace,[t])):(this.node.blur(),this.hideLayout()));if(this.options.blurOnTab&&9===t.keyCode)return this.node.blur(),void this.hideLayout();if(this.result.length){var e=this.resultContainer.find("."+this.options.selector.item),i=e.filter(".active"),o=i[0]&&e.index(i)||null,s=null;if(13===t.keyCode)return void(i.length>0&&(t.preventDefault(),i.find("a:first").trigger("click",t)));if(39===t.keyCode)return void(o?e.eq(o).find("a:first")[0].click():this.options.hint&&""!==this.hint.container.val()&&this.helper.getCaret(this.node[0])>=this.query.length&&e.find('a[data-index="'+this.hintIndex+'"]')[0].click());e.length>0&&i.removeClass("active"),38===t.keyCode?(t.preventDefault(),i.length>0?o-1>=0&&(s=o-1,e.eq(s).addClass("active")):(s=e.length-1,e.last().addClass("active"))):40===t.keyCode&&(t.preventDefault(),i.length>0?o+1<e.length&&(s=o+1,e.eq(s).addClass("active")):(s=0,e.first().addClass("active"))),t.preventInputChange&&~[38,40].indexOf(t.keyCode)&&this.buildHintLayout(null!==s&&s<this.result.length?[this.result[s]]:null),this.options.hint&&this.hint.container&&this.hint.container.css("color",t.preventInputChange?this.hint.css.color:null===s&&this.hint.css.color||this.hint.container.css("background-color")||"fff"),this.node.val(null===s||t.preventInputChange?this.rawQuery:this.result[s][this.result[s].matchedKey]),this.helper.executeCallback.call(this,this.options.callback.onNavigateAfter,[this.node,e,null!==s&&e.eq(s).find("a:first")||void 0,null!==s&&this.result[s]||void 0,this.query,t])}},searchResult:function(t){t||(this.item={}),this.resetLayout(),this.helper.executeCallback.call(this,this.options.callback.onSearch,[this.node,this.query])!==!1&&(this.searchGroups.length&&this.searchResultData(),this.helper.executeCallback.call(this,this.options.callback.onResult,[this.node,this.query,this.result,this.resultCount,this.resultCountPerGroup]),this.isDropdownEvent&&(this.helper.executeCallback.call(this,this.options.callback.onDropdownFilter,[this.node,this.query,this.filters.dropdown,this.result]),this.isDropdownEvent=!1))},searchResultData:function(){var e,i,o,s,n,r,a,l,h,c,u,p,d,f=this,y=this.groupBy,g=null,m=this.query.toLowerCase(),v=this.options.maxItem,b=this.options.maxItemPerGroup,k=this.filters.dynamic&&!this.helper.isEmpty(this.filters.dynamic),w="function"==typeof this.options.matcher&&this.options.matcher;this.options.accent&&(m=this.helper.removeAccent.call(this,m));for(var x=0,C=this.searchGroups.length;C>x;++x)if(e=this.searchGroups[x],!this.filters.dropdown||"group"!==this.filters.dropdown.key||this.filters.dropdown.value===e){a="undefined"!=typeof this.options.source[e].filter?this.options.source[e].filter:this.options.filter,h="function"==typeof this.options.source[e].matcher&&this.options.source[e].matcher||w;for(var q=0,O=this.source[e].length;O>q&&(!(this.resultItemCount>=v)||this.options.callback.onResult);q++)if((!k||this.dynamicFilter.validate.apply(this,[this.source[e][q]]))&&(i=this.source[e][q],null!==i&&"boolean"!=typeof i&&(!this.filters.dropdown||(i[this.filters.dropdown.key]||"").toLowerCase()===(this.filters.dropdown.value||"").toLowerCase()))){if(g="group"===y?e:i[y]?i[y]:i.group,g&&!this.result[g]&&(this.result[g]=[],this.resultCountPerGroup[g]=0),b&&"group"===y&&this.result[g].length>=b&&!this.options.callback.onResult)break;n=this.options.source[e].display||this.options.display;for(var S=0,F=n.length;F>S;++S){if(a!==!1){if(r=/\./.test(n[S])?this.helper.namespace.call(this,n[S],i):i[n[S]],"undefined"==typeof r||""===r)continue;r=this.helper.cleanStringFromScript(r)}if("function"==typeof a){if(l=a.call(this,i,r),void 0===l)break;if(!l)continue;"object"==typeof l&&(i=l)}if(~[void 0,!0].indexOf(a)){if(s=r,s=s.toString().toLowerCase(),this.options.accent&&(s=this.helper.removeAccent.call(this,s)),o=s.indexOf(m),this.options.correlativeTemplate&&"compiled"===n[S]&&0>o&&/\s/.test(m)){u=!0,p=m.split(" "),d=s;for(var L=0,A=p.length;A>L;L++)if(""!==p[L]){if(!~d.indexOf(p[L])){u=!1;break}d=d.replace(p[L],"")}}if(0>o&&!u)continue;if(this.options.offset&&0!==o)continue;if(h){if(c=h.call(this,i,r),void 0===c)break;if(!c)continue;"object"==typeof c&&(i=c)}}if(this.resultCount++,this.resultCountPerGroup[g]++,this.resultItemCount<v){if(b&&this.result[g].length>=b)break;this.result[g].push(t.extend(!0,{matchedKey:n[S]},i)),this.resultItemCount++}break}if(!this.options.callback.onResult){if(this.resultItemCount>=v)break;if(b&&this.result[g].length>=b&&"group"===y)break}}}if(this.options.order){var j,n=[];for(var e in this.result)if(this.result.hasOwnProperty(e)){for(var x=0,C=this.result[e].length;C>x;x++)j=this.options.source[this.result[e][x].group].display||this.options.display,~n.indexOf(j[0])||n.push(j[0]);this.result[e].sort(f.helper.sort(n,"asc"===f.options.order,function(t){return t.toString().toUpperCase()}))}}var G=[],T=[];T="function"==typeof this.options.groupOrder?this.options.groupOrder.apply(this,[this.node,this.query,this.result,this.resultCount,this.resultCountPerGroup]):Array.isArray(this.options.groupOrder)?this.options.groupOrder:"string"==typeof this.options.groupOrder&&~["asc","desc"].indexOf(this.options.groupOrder)?Object.keys(this.result).sort(f.helper.sort([],"asc"===f.options.groupOrder,function(t){return t.toString().toUpperCase()})):Object.keys(this.result);for(var x=0,C=T.length;C>x;x++)G=G.concat(this.result[T[x]]||[]);this.groups=JSON.parse(JSON.stringify(T)),this.result=G},buildLayout:function(){if(this.buildHtmlLayout(),this.buildBackdropLayout(),this.buildHintLayout(),this.options.callback.onLayoutBuiltBefore){var e=this.helper.executeCallback.call(this,this.options.callback.onLayoutBuiltBefore,[this.node,this.query,this.result,this.resultHtml]);e instanceof t&&(this.resultHtml=e)}this.resultHtml&&this.resultContainer.html(this.resultHtml),this.options.callback.onLayoutBuiltAfter&&this.helper.executeCallback.call(this,this.options.callback.onLayoutBuiltAfter,[this.node,this.query,this.result])},buildHtmlLayout:function(){if(this.options.resultContainer!==!1){this.resultContainer||(this.resultContainer=t("<div/>",{"class":this.options.selector.result}),this.container.append(this.resultContainer));var e;if(!this.result.length){if(!this.options.emptyTemplate||""===this.query)return;e="function"==typeof this.options.emptyTemplate?this.options.emptyTemplate.call(this,this.query):this.options.emptyTemplate.replace(/\{\{query}}/gi,this.helper.cleanStringFromScript(this.query))}var i=this.query.toLowerCase();this.options.accent&&(i=this.helper.removeAccent.call(this,i));var o=this,s=this.groupTemplate||"<ul></ul>",n=!1;this.groupTemplate?s=t(s.replace(/<([^>]+)>\{\{(.+?)}}<\/[^>]+>/g,function(t,i,s,r,a){var l="",h="group"===s?o.groups:[s];if(!o.result.length)return n===!0?"":(n=!0,"<"+i+' class="'+o.options.selector.empty+'"><a href="javascript:;">'+e+"</a></"+i+">");for(var c=0,u=h.length;u>c;++c)l+="<"+i+' data-group-template="'+h[c]+'"><ul></ul></'+i+">";return l})):(s=t(s),this.result.length||s.append(e instanceof t?e:'<li class="'+o.options.selector.empty+'"><a href="javascript:;">'+e+"</a></li>")),s.addClass(this.options.selector.list+(this.helper.isEmpty(this.result)?" empty":""));for(var r,a,l,h,c,u,p,d,f,y,g,m,v=this.groupTemplate&&this.result.length&&o.groups||[],b=0,k=this.result.length;k>b;++b)l=this.result[b],r=l.group,h=this.options.source[l.group].href||this.options.href,f=[],y=this.options.source[l.group].display||this.options.display,this.options.group&&(r=l[this.options.group.key],this.options.group.template&&("function"==typeof this.options.group.template?a=this.options.group.template(l):"string"==typeof this.options.template&&(a=this.options.group.template.replace(/\{\{([\w\-\.]+)}}/gi,function(t,e){return o.helper.namespace.call(o,e,l,"get","")}))),s.find('[data-search-group="'+r+'"]')[0]||(this.groupTemplate?s.find('[data-group-template="'+r+'"] ul'):s).append(t("<li/>",{"class":o.options.selector.group,html:t("<a/>",{href:"javascript:;",html:a||r,tabindex:-1}),"data-search-group":r}))),this.groupTemplate&&v.length&&(m=v.indexOf(r||l.group),~m&&v.splice(m,1)),c=t("<li/>",{"class":o.options.selector.item+" "+o.options.selector.group+"-"+this.helper.slugify.call(this,r),html:t("<a/>",{href:function(){return h&&("string"==typeof h?h=h.replace(/\{\{([^\|}]+)(?:\|([^}]+))*}}/gi,function(t,e,i){var s=o.helper.namespace.call(o,e,l,"get","");return i=i&&i.split("|")||[],~i.indexOf("slugify")&&(s=o.helper.slugify.call(o,s)),s}):"function"==typeof h&&(h=h(l)),l.href=h),h||"javascript:;"}(),"data-group":r,"data-index":b,html:function(){if(u=l.group&&o.options.source[l.group].template||o.options.template)"function"==typeof u&&(u=u.call(o,o.query,l)),d=u.replace(/\{\{([^\|}]+)(?:\|([^}]+))*}}/gi,function(t,e,s){var n=o.helper.cleanStringFromScript(String(o.helper.namespace.call(o,e,l,"get","")));return s=s&&s.split("|")||[],~s.indexOf("slugify")&&(n=o.helper.slugify.call(o,n)),~s.indexOf("raw")||o.options.highlight===!0&&i&&~y.indexOf(e)&&(n=o.helper.highlight.call(o,n,i.split(" "),o.options.accent)),n});else{for(var e=0,s=y.length;s>e;e++)g=/\./.test(y[e])?o.helper.namespace.call(o,y[e],l,"get",""):l[y[e]],"undefined"!=typeof g&&""!==g&&f.push(g);d='<span class="'+o.options.selector.display+'">'+o.helper.cleanStringFromScript(String(f.join(" ")))+"</span>"}(o.options.highlight===!0&&i&&!u||"any"===o.options.highlight)&&(d=o.helper.highlight.call(o,d,i.split(" "),o.options.accent)),t(this).append(d)}})}),function(e,i,s){s.on("click",function(e,s){return s&&"object"==typeof s&&(e.originalEvent=s),o.options.mustSelectItem&&o.helper.isEmpty(i)?void e.preventDefault():(o.item=i,void(o.helper.executeCallback.call(o,o.options.callback.onClickBefore,[o.node,t(this),i,e])!==!1&&(e.originalEvent&&e.originalEvent.defaultPrevented||e.isDefaultPrevented()||(p=i.group&&o.options.source[i.group].templateValue||o.options.templateValue,"function"==typeof p&&(p=p.call(o)),o.query=o.rawQuery=p?p.replace(/\{\{([\w\-\.]+)}}/gi,function(t,e){return o.helper.namespace.call(o,e,i,"get","")}):o.helper.namespace.call(o,i.matchedKey,i).toString(),o.focusOnly=!0,o.node.val(o.query).focus(),o.searchResult(!0),o.buildLayout(),o.hideLayout(),o.helper.executeCallback.call(o,o.options.callback.onClickAfter,[o.node,t(this),i,e])))))}),s.on("mouseenter",function(e){o.helper.executeCallback.call(o,o.options.callback.onMouseEnter,[o.node,t(this),i,e])}),s.on("mouseleave",function(e){o.helper.executeCallback.call(o,o.options.callback.onMouseLeave,[o.node,t(this),i,e])})}(b,l,c),(this.groupTemplate?s.find('[data-group-template="'+r+'"] ul'):s).append(c);if(this.result.length&&v.length)for(var b=0,k=v.length;k>b;++b)s.find('[data-group-template="'+v[b]+'"]').remove();this.resultHtml=s}},buildBackdropLayout:function(){this.options.backdrop&&(this.backdrop.container||(this.backdrop.css=t.extend({opacity:.6,filter:"alpha(opacity=60)",position:"fixed",top:0,right:0,bottom:0,left:0,"z-index":1040,"background-color":"#000"},this.options.backdrop),this.backdrop.container=t("<div/>",{"class":this.options.selector.backdrop,css:this.backdrop.css}).insertAfter(this.container)),this.container.addClass("backdrop").css({"z-index":this.backdrop.css["z-index"]+1,position:"relative"}))},buildHintLayout:function(e){if(this.options.hint){if(this.node[0].scrollWidth>Math.ceil(this.node.innerWidth()))return void(this.hint.container&&this.hint.container.val(""));var i=this,o="",e=e||this.result,s=this.query.toLowerCase();if(this.options.accent&&(s=this.helper.removeAccent.call(this,s)),this.hintIndex=null,this.searchGroups.length){if(this.hint.container||(this.hint.css=t.extend({"border-color":"transparent",position:"absolute",top:0,display:"inline","z-index":-1,"float":"none",color:"silver","box-shadow":"none",cursor:"default","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"},this.options.hint),this.hint.container=t("<input/>",{type:this.node.attr("type"),"class":this.node.attr("class"),readonly:!0,unselectable:"on","aria-hidden":"true",tabindex:-1,click:function(){i.node.focus()}}).addClass(this.options.selector.hint).css(this.hint.css).insertAfter(this.node),this.node.parent().css({position:"relative"})),this.hint.container.css("color",this.hint.css.color),s)for(var n,r,a,l=0,h=e.length;h>l;l++){r=e[l].group,n=this.options.source[r].display||this.options.display;for(var c=0,u=n.length;u>c;c++)if(a=String(e[l][n[c]]).toLowerCase(),this.options.accent&&(a=this.helper.removeAccent.call(this,a)),0===a.indexOf(s)){o=String(e[l][n[c]]),this.hintIndex=l;break}if(null!==this.hintIndex)break}this.hint.container.val(o.length>0&&this.rawQuery+o.substring(this.query.length)||"")}}},buildDropdownLayout:function(){if(this.options.dropdownFilter){var e=this;t("<span/>",{"class":this.options.selector.filter,html:function(){t(this).append(t("<button/>",{type:"button","class":e.options.selector.filterButton,style:"display: none;",click:function(i){i.stopPropagation(),e.container.toggleClass("filter");var o=e.namespace+"-dropdown-filter";t("html").off(o),e.container.hasClass("filter")&&t("html").on("click"+o+" touchend"+o,function(i){t(i.target).closest("."+e.options.selector.filter)[0]||e.hasDragged||e.container.removeClass("filter")})}})),t(this).append(t("<ul/>",{"class":e.options.selector.dropdown}))}}).insertAfter(e.container.find("."+e.options.selector.query))}},buildDropdownItemLayout:function(e){function i(t){"*"===t.value?delete this.filters.dropdown:this.filters.dropdown=t,this.container.removeClass("filter").find("."+this.options.selector.filterButton).html(t.template),this.isDropdownEvent=!0,this.node.trigger("search"+this.namespace),this.node.focus()}if(this.options.dropdownFilter){var o,s,n=this,r="string"==typeof this.options.dropdownFilter&&this.options.dropdownFilter||"All",a=this.container.find("."+this.options.selector.dropdown);"static"!==e||this.options.dropdownFilter!==!0&&"string"!=typeof this.options.dropdownFilter||this.dropdownFilter["static"].push({key:"group",template:"{{group}}",all:r,value:Object.keys(this.options.source)});for(var l=0,h=this.dropdownFilter[e].length;h>l;l++){s=this.dropdownFilter[e][l],Array.isArray(s.value)||(s.value=[s.value]),s.all&&(this.dropdownFilterAll=s.all);for(var c=0,u=s.value.length;u>=c;c++)(c!==u||l===h-1)&&(c===u&&l===h-1&&"static"===e&&this.dropdownFilter.dynamic.length||(o=this.dropdownFilterAll||r,s.value[c]?o=s.template?s.template.replace(new RegExp("{{"+s.key+"}}","gi"),s.value[c]):s.value[c]:this.container.find("."+n.options.selector.filterButton).html(o),function(e,o,s){a.append(t("<li/>",{"class":n.options.selector.dropdownItem+" "+n.helper.slugify.call(n,o.key+"-"+(o.value[e]||r)),
1
+ /*!
2
+ * jQuery Typeahead
3
+ * Copyright (C) 2017 RunningCoder.org
4
+ * Licensed under the MIT license
5
+ *
6
+ * @author Tom Bertrand
7
+ * @version 2.8.0 (2017-3-1)
8
+ * @link http://www.runningcoder.org/jquerytypeahead/
9
+ */
10
+ !function(t){"function"==typeof define&&define.amd?define("jquery-typeahead",["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=function(e,i){return void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(i)),t(e)}():t(jQuery)}(function(t){"use strict";window.Typeahead={version:"2.8.0"};var e={input:null,minLength:2,maxLength:!1,maxItem:8,dynamic:!1,delay:300,order:null,offset:!1,hint:!1,accent:!1,highlight:!0,group:!1,groupOrder:null,maxItemPerGroup:null,dropdownFilter:!1,dynamicFilter:null,backdrop:!1,backdropOnFocus:!1,cache:!1,ttl:36e5,compression:!1,searchOnFocus:!1,blurOnTab:!0,resultContainer:null,generateOnLoad:null,mustSelectItem:!1,href:null,display:["display"],template:null,templateValue:null,groupTemplate:null,correlativeTemplate:!1,emptyTemplate:!1,cancelButton:!0,loadingAnimation:!0,filter:!0,matcher:null,source:null,callback:{onInit:null,onReady:null,onShowLayout:null,onHideLayout:null,onSearch:null,onResult:null,onLayoutBuiltBefore:null,onLayoutBuiltAfter:null,onNavigateBefore:null,onNavigateAfter:null,onMouseEnter:null,onMouseLeave:null,onClickBefore:null,onClickAfter:null,onDropdownFilter:null,onSendRequest:null,onReceiveRequest:null,onPopulateSource:null,onCacheSave:null,onSubmit:null,onCancel:null},selector:{container:"typeahead__container",result:"typeahead__result",list:"typeahead__list",group:"typeahead__group",item:"typeahead__item",empty:"typeahead__empty",display:"typeahead__display",query:"typeahead__query",filter:"typeahead__filter",filterButton:"typeahead__filter-button",dropdown:"typeahead__dropdown",dropdownItem:"typeahead__dropdown-item",button:"typeahead__button",backdrop:"typeahead__backdrop",hint:"typeahead__hint",cancelButton:"typeahead__cancel-button"},debug:!1},i=".typeahead",o={from:"ãàáäâẽèéëêìíïîõòóöôùúüûñç",to:"aaaaaeeeeeiiiiooooouuuunc"},s=~window.navigator.appVersion.indexOf("MSIE 9."),n=~window.navigator.appVersion.indexOf("MSIE 10"),r=~window.navigator.userAgent.indexOf("Trident")&&~window.navigator.userAgent.indexOf("rv:11"),a=function(t,e){this.rawQuery=t.val()||"",this.query=t.val()||"",this.selector=t[0].selector,this.deferred=null,this.tmpSource={},this.source={},this.dynamicGroups=[],this.hasDynamicGroups=!1,this.generatedGroupCount=0,this.groupBy="group",this.groups=[],this.searchGroups=[],this.generateGroups=[],this.requestGroups=[],this.result={},this.groupTemplate="",this.resultHtml=null,this.resultCount=0,this.resultCountPerGroup={},this.options=e,this.node=t,this.namespace="."+this.helper.slugify.call(this,this.selector)+i,this.container=null,this.resultContainer=null,this.item=null,this.xhr={},this.hintIndex=null,this.filters={dropdown:{},dynamic:{}},this.dropdownFilter={"static":[],dynamic:[]},this.dropdownFilterAll=null,this.isDropdownEvent=!1,this.requests={},this.backdrop={},this.hint={},this.hasDragged=!1,this.focusOnly=!1,this.__construct()};a.prototype={_validateCacheMethod:function(t){var e,i=["localStorage","sessionStorage"];if(t===!0)t="localStorage";else if("string"==typeof t&&!~i.indexOf(t))return!1;e="undefined"!=typeof window[t];try{window[t].setItem("typeahead","typeahead"),window[t].removeItem("typeahead")}catch(o){e=!1}return e&&t||!1},extendOptions:function(){if(this.options.cache=this._validateCacheMethod(this.options.cache),this.options.compression&&("object"==typeof LZString&&this.options.cache||(this.options.compression=!1)),(!this.options.maxLength||isNaN(this.options.maxLength))&&(this.options.maxLength=1/0),"undefined"!=typeof this.options.maxItem&&~[0,!1].indexOf(this.options.maxItem)&&(this.options.maxItem=1/0),this.options.maxItemPerGroup&&!/^\d+$/.test(this.options.maxItemPerGroup)&&(this.options.maxItemPerGroup=null),this.options.display&&!Array.isArray(this.options.display)&&(this.options.display=[this.options.display]),this.options.group&&(Array.isArray(this.options.group)||("string"==typeof this.options.group?this.options.group={key:this.options.group}:"boolean"==typeof this.options.group&&(this.options.group={key:"group"}),this.options.group.key=this.options.group.key||"group")),this.options.highlight&&!~["any",!0].indexOf(this.options.highlight)&&(this.options.highlight=!1),this.options.dropdownFilter&&this.options.dropdownFilter instanceof Object){Array.isArray(this.options.dropdownFilter)||(this.options.dropdownFilter=[this.options.dropdownFilter]);for(var i=0,s=this.options.dropdownFilter.length;s>i;++i)this.dropdownFilter[this.options.dropdownFilter[i].value?"static":"dynamic"].push(this.options.dropdownFilter[i])}this.options.dynamicFilter&&!Array.isArray(this.options.dynamicFilter)&&(this.options.dynamicFilter=[this.options.dynamicFilter]),this.options.accent&&("object"==typeof this.options.accent?this.options.accent.from&&this.options.accent.to&&this.options.accent.from.length===this.options.accent.to.length:this.options.accent=o),this.options.groupTemplate&&(this.groupTemplate=this.options.groupTemplate),this.options.resultContainer&&("string"==typeof this.options.resultContainer&&(this.options.resultContainer=t(this.options.resultContainer)),this.options.resultContainer instanceof t&&this.options.resultContainer[0]&&(this.resultContainer=this.options.resultContainer)),this.options.maxItemPerGroup&&this.options.group&&this.options.group.key&&(this.groupBy=this.options.group.key),this.options.callback&&this.options.callback.onClick&&(this.options.callback.onClickBefore=this.options.callback.onClick,delete this.options.callback.onClick),this.options.callback&&this.options.callback.onNavigate&&(this.options.callback.onNavigateBefore=this.options.callback.onNavigate,delete this.options.callback.onNavigate),this.options=t.extend(!0,{},e,this.options)},unifySourceFormat:function(){this.dynamicGroups=[],Array.isArray(this.options.source)&&(this.options.source={group:{data:this.options.source}}),"string"==typeof this.options.source&&(this.options.source={group:{ajax:{url:this.options.source}}}),this.options.source.ajax&&(this.options.source={group:{ajax:this.options.source.ajax}}),(this.options.source.url||this.options.source.data)&&(this.options.source={group:this.options.source});var t,e,i;for(t in this.options.source)if(this.options.source.hasOwnProperty(t)){if(e=this.options.source[t],"string"==typeof e&&(e={ajax:{url:e}}),i=e.url||e.ajax,Array.isArray(i)?(e.ajax="string"==typeof i[0]?{url:i[0]}:i[0],e.ajax.path=e.ajax.path||i[1]||null,delete e.url):("object"==typeof e.url?e.ajax=e.url:"string"==typeof e.url&&(e.ajax={url:e.url}),delete e.url),!e.data&&!e.ajax)return!1;e.display&&!Array.isArray(e.display)&&(e.display=[e.display]),e.minLength="number"==typeof e.minLength?e.minLength:this.options.minLength,e.maxLength="number"==typeof e.maxLength?e.maxLength:this.options.maxLength,e.dynamic="boolean"==typeof e.dynamic||this.options.dynamic,e.minLength>e.maxLength&&(e.minLength=e.maxLength),this.options.source[t]=e,this.options.source[t].dynamic&&this.dynamicGroups.push(t),e.cache="undefined"!=typeof e.cache?this._validateCacheMethod(e.cache):this.options.cache,e.compression&&("object"==typeof LZString&&e.cache||(e.compression=!1))}return this.hasDynamicGroups=this.options.dynamic||!!this.dynamicGroups.length,!0},init:function(){this.helper.executeCallback.call(this,this.options.callback.onInit,[this.node]),this.container=this.node.closest("."+this.options.selector.container)},delegateEvents:function(){var e=this,i=["focus"+this.namespace,"input"+this.namespace,"propertychange"+this.namespace,"keydown"+this.namespace,"keyup"+this.namespace,"search"+this.namespace,"generate"+this.namespace];t("html").on("touchmove",function(){e.hasDragged=!0}).on("touchstart",function(){e.hasDragged=!1}),this.node.closest("form").on("submit",function(t){return e.options.mustSelectItem&&e.helper.isEmpty(e.item)?void t.preventDefault():(e.options.backdropOnFocus||e.hideLayout(),e.options.callback.onSubmit?e.helper.executeCallback.call(e,e.options.callback.onSubmit,[e.node,this,e.item,t]):void 0)}).on("reset",function(){setTimeout(function(){e.node.trigger("input"+e.namespace),e.hideLayout()})});var o=!1;if(this.node.attr("placeholder")&&(n||r)){var a=!0;this.node.on("focusin focusout",function(){a=!(this.value||!this.placeholder)}),this.node.on("input",function(t){a&&(t.stopImmediatePropagation(),a=!1)})}this.node.off(this.namespace).on(i.join(" "),function(i,n){switch(i.type){case"generate":e.generateSource(Object.keys(e.options.source));break;case"focus":if(e.focusOnly){e.focusOnly=!1;break}e.options.backdropOnFocus&&(e.buildBackdropLayout(),e.showLayout()),e.options.searchOnFocus&&(e.deferred=t.Deferred(),e.generateSource());break;case"keydown":i.keyCode&&~[9,13,27,38,39,40].indexOf(i.keyCode)&&(o=!0,e.navigate(i));break;case"keyup":s&&e.node[0].value.replace(/^\s+/,"").toString().length<e.query.length&&e.node.trigger("input"+e.namespace);break;case"propertychange":if(o){o=!1;break}case"input":e.deferred=t.Deferred(),e.rawQuery=e.node[0].value.toString(),e.query=e.rawQuery.replace(/^\s+/,""),""===e.rawQuery&&""===e.query&&(i.originalEvent=n||{},e.helper.executeCallback.call(e,e.options.callback.onCancel,[e.node,i])),e.options.cancelButton&&e.toggleCancelButtonVisibility(),e.options.hint&&e.hint.container&&""!==e.hint.container.val()&&0!==e.hint.container.val().indexOf(e.rawQuery)&&e.hint.container.val(""),e.hasDynamicGroups?e.helper.typeWatch(function(){e.generateSource()},e.options.delay):e.generateSource();break;case"search":e.searchResult(),e.buildLayout(),e.result.length||e.searchGroups.length&&e.options.emptyTemplate&&e.query.length?e.showLayout():e.hideLayout(),e.deferred&&e.deferred.resolve()}return e.deferred&&e.deferred.promise()}),this.options.generateOnLoad&&this.node.trigger("generate"+this.namespace)},filterGenerateSource:function(){this.searchGroups=[],this.generateGroups=[];for(var t in this.options.source)if(this.options.source.hasOwnProperty(t)&&this.query.length>=this.options.source[t].minLength&&this.query.length<=this.options.source[t].maxLength){if(this.searchGroups.push(t),!this.options.source[t].dynamic&&this.source[t])continue;this.generateGroups.push(t)}},generateSource:function(e){if(this.filterGenerateSource(),Array.isArray(e)&&e.length)this.generateGroups=e;else if(!this.generateGroups.length)return void this.node.trigger("search"+this.namespace);if(this.requestGroups=[],this.generatedGroupCount=0,this.options.loadingAnimation&&this.container.addClass("loading"),!this.helper.isEmpty(this.xhr)){for(var i in this.xhr)this.xhr.hasOwnProperty(i)&&this.xhr[i].abort();this.xhr={}}for(var o,s,n,r,a,l,h,c=this,i=0,u=this.generateGroups.length;u>i;++i){if(o=this.generateGroups[i],n=this.options.source[o],r=n.cache,a=n.compression,r&&(l=window[r].getItem("TYPEAHEAD_"+this.selector+":"+o))){a&&(l=LZString.decompressFromUTF16(l)),h=!1;try{l=JSON.parse(l+""),l.data&&l.ttl>(new Date).getTime()?(this.populateSource(l.data,o),h=!0):window[r].removeItem("TYPEAHEAD_"+this.selector+":"+o)}catch(p){}if(h)continue}!n.data||n.ajax?n.ajax&&(this.requests[o]||(this.requests[o]=this.generateRequestObject(o)),this.requestGroups.push(o)):"function"==typeof n.data?(s=n.data.call(this),Array.isArray(s)?c.populateSource(s,o):"function"==typeof s.promise&&!function(e){t.when(s).then(function(t){t&&Array.isArray(t)&&c.populateSource(t,e)})}(o)):this.populateSource(t.extend(!0,[],n.data),o)}return this.requestGroups.length&&this.handleRequests(),!!this.generateGroups.length},generateRequestObject:function(t){var e=this,i=this.options.source[t],o={request:{url:i.ajax.url||null,dataType:"json",beforeSend:function(o,s){e.xhr[t]=o;var n=e.requests[t].callback.beforeSend||i.ajax.beforeSend;"function"==typeof n&&n.apply(null,arguments)}},callback:{beforeSend:null,done:null,fail:null,then:null,always:null},extra:{path:i.ajax.path||null,group:t},validForGroup:[t]};if("function"!=typeof i.ajax&&(i.ajax instanceof Object&&(o=this.extendXhrObject(o,i.ajax)),Object.keys(this.options.source).length>1))for(var s in this.requests)this.requests.hasOwnProperty(s)&&(this.requests[s].isDuplicated||o.request.url&&o.request.url===this.requests[s].request.url&&(this.requests[s].validForGroup.push(t),o.isDuplicated=!0,delete o.validForGroup));return o},extendXhrObject:function(e,i){return"object"==typeof i.callback&&(e.callback=i.callback,delete i.callback),"function"==typeof i.beforeSend&&(e.callback.beforeSend=i.beforeSend,delete i.beforeSend),e.request=t.extend(!0,e.request,i),"jsonp"!==e.request.dataType.toLowerCase()||e.request.jsonpCallback||(e.request.jsonpCallback="callback_"+e.extra.group),e},handleRequests:function(){var e,i=this,o=this.requestGroups.length;if(this.helper.executeCallback.call(this,this.options.callback.onSendRequest,[this.node,this.query])!==!1)for(var s=0,n=this.requestGroups.length;n>s;++s)e=this.requestGroups[s],this.requests[e].isDuplicated||!function(e,s){if("function"==typeof i.options.source[e].ajax){var n=i.options.source[e].ajax.call(i,i.query);if(s=i.extendXhrObject(i.generateRequestObject(e),"object"==typeof n?n:{}),"object"!=typeof s.request||!s.request.url)return void i.populateSource([],e);i.requests[e]=s}var r,a,l=!1;if(~s.request.url.indexOf("{{query}}")&&(l||(s=t.extend(!0,{},s),l=!0),s.request.url=s.request.url.replace("{{query}}",encodeURIComponent(i.query))),s.request.data)for(var h in s.request.data)if(s.request.data.hasOwnProperty(h)&&~String(s.request.data[h]).indexOf("{{query}}")){l||(s=t.extend(!0,{},s),l=!0),s.request.data[h]=s.request.data[h].replace("{{query}}",i.query);break}t.ajax(s.request).done(function(t,e,o){a=null;for(var n=0,l=s.validForGroup.length;l>n;n++)r=i.requests[s.validForGroup[n]],r.callback.done instanceof Function&&(a=r.callback.done.call(i,t,e,o))}).fail(function(t,e,o){for(var n=0,a=s.validForGroup.length;a>n;n++)r=i.requests[s.validForGroup[n]],r.callback.fail instanceof Function&&r.callback.fail.call(i,t,e,o)}).always(function(t,e,n){for(var l=0,h=s.validForGroup.length;h>l;l++){if(r=i.requests[s.validForGroup[l]],r.callback.always instanceof Function&&r.callback.always.call(i,t,e,n),"object"!=typeof n)return;i.populateSource("function"==typeof t.promise&&[]||a||t,r.extra.group,r.extra.path||r.request.path),o-=1,0===o&&i.helper.executeCallback.call(i,i.options.callback.onReceiveRequest,[i.node,i.query])}}).then(function(t,e){for(var o=0,n=s.validForGroup.length;n>o;o++)r=i.requests[s.validForGroup[o]],r.callback.then instanceof Function&&r.callback.then.call(i,t,e)})}(e,this.requests[e])},populateSource:function(t,e,i){var o=this,s=this.options.source[e],n=s.ajax&&s.data;i&&"string"==typeof i&&(t=this.helper.namespace.call(this,i,t)),Array.isArray(t)||(t=[]),n&&("function"==typeof n&&(n=n()),Array.isArray(n)&&(t=t.concat(n)));for(var r,a=s.display?"compiled"===s.display[0]?s.display[1]:s.display[0]:"compiled"===this.options.display[0]?this.options.display[1]:this.options.display[0],l=0,h=t.length;h>l;l++)null!==t[l]&&"boolean"!=typeof t[l]&&("string"==typeof t[l]&&(r={},r[a]=t[l],t[l]=r),t[l].group=e);if(!this.hasDynamicGroups&&this.dropdownFilter.dynamic.length)for(var c,u,p={},l=0,h=t.length;h>l;l++)for(var d=0,f=this.dropdownFilter.dynamic.length;f>d;d++)c=this.dropdownFilter.dynamic[d].key,u=t[l][c],u&&(this.dropdownFilter.dynamic[d].value||(this.dropdownFilter.dynamic[d].value=[]),p[c]||(p[c]=[]),~p[c].indexOf(u.toLowerCase())||(p[c].push(u.toLowerCase()),this.dropdownFilter.dynamic[d].value.push(u)));if(this.options.correlativeTemplate){var y=s.template||this.options.template,g="";if("function"==typeof y&&(y=y.call(this,"",{})),y){if(Array.isArray(this.options.correlativeTemplate))for(var l=0,h=this.options.correlativeTemplate.length;h>l;l++)g+="{{"+this.options.correlativeTemplate[l]+"}} ";else g=y.replace(/<.+?>/g,"");for(var l=0,h=t.length;h>l;l++)t[l].compiled=g.replace(/\{\{([\w\-\.]+)(?:\|(\w+))?}}/g,function(e,i){return o.helper.namespace.call(o,i,t[l],"get","")}).trim();s.display?~s.display.indexOf("compiled")||s.display.unshift("compiled"):~this.options.display.indexOf("compiled")||this.options.display.unshift("compiled")}else;}this.options.callback.onPopulateSource&&(t=this.helper.executeCallback.call(this,this.options.callback.onPopulateSource,[this.node,t,e,i])),this.tmpSource[e]=Array.isArray(t)&&t||[];var m=this.options.source[e].cache,v=this.options.source[e].compression,b=this.options.source[e].ttl||this.options.ttl;if(m&&!window[m].getItem("TYPEAHEAD_"+this.selector+":"+e)){this.options.callback.onCacheSave&&(t=this.helper.executeCallback.call(this,this.options.callback.onCacheSave,[this.node,t,e,i]));var k=JSON.stringify({data:t,ttl:(new Date).getTime()+b});v&&(k=LZString.compressToUTF16(k)),window[m].setItem("TYPEAHEAD_"+this.selector+":"+e,k)}this.incrementGeneratedGroup()},incrementGeneratedGroup:function(){if(this.generatedGroupCount++,this.generatedGroupCount===this.generateGroups.length){this.xhr={};for(var t=0,e=this.generateGroups.length;e>t;t++)this.source[this.generateGroups[t]]=this.tmpSource[this.generateGroups[t]];this.hasDynamicGroups||this.buildDropdownItemLayout("dynamic"),this.options.loadingAnimation&&this.container.removeClass("loading"),this.node.trigger("search"+this.namespace)}},navigate:function(t){if(this.helper.executeCallback.call(this,this.options.callback.onNavigateBefore,[this.node,this.query,t]),27===t.keyCode)return t.preventDefault(),void(this.query.length?(this.resetInput(),this.node.trigger("input"+this.namespace,[t])):(this.node.blur(),this.hideLayout()));if(this.options.blurOnTab&&9===t.keyCode)return this.node.blur(),void this.hideLayout();if(this.result.length){var e=this.resultContainer.find("."+this.options.selector.item),i=e.filter(".active"),o=i[0]&&e.index(i)||null,s=null;if(13===t.keyCode)return void(i.length>0&&(t.preventDefault(),i.find("a:first").trigger("click",t)));if(39===t.keyCode)return void(o?e.eq(o).find("a:first")[0].click():this.options.hint&&""!==this.hint.container.val()&&this.helper.getCaret(this.node[0])>=this.query.length&&e.find('a[data-index="'+this.hintIndex+'"]')[0].click());e.length>0&&i.removeClass("active"),38===t.keyCode?(t.preventDefault(),i.length>0?o-1>=0&&(s=o-1,e.eq(s).addClass("active")):(s=e.length-1,e.last().addClass("active"))):40===t.keyCode&&(t.preventDefault(),i.length>0?o+1<e.length&&(s=o+1,e.eq(s).addClass("active")):(s=0,e.first().addClass("active"))),t.preventInputChange&&~[38,40].indexOf(t.keyCode)&&this.buildHintLayout(null!==s&&s<this.result.length?[this.result[s]]:null),this.options.hint&&this.hint.container&&this.hint.container.css("color",t.preventInputChange?this.hint.css.color:null===s&&this.hint.css.color||this.hint.container.css("background-color")||"fff"),this.node.val(null===s||t.preventInputChange?this.rawQuery:this.result[s][this.result[s].matchedKey]),this.helper.executeCallback.call(this,this.options.callback.onNavigateAfter,[this.node,e,null!==s&&e.eq(s).find("a:first")||void 0,null!==s&&this.result[s]||void 0,this.query,t])}},searchResult:function(t){t||(this.item={}),this.resetLayout(),this.helper.executeCallback.call(this,this.options.callback.onSearch,[this.node,this.query])!==!1&&(this.searchGroups.length&&this.searchResultData(),this.helper.executeCallback.call(this,this.options.callback.onResult,[this.node,this.query,this.result,this.resultCount,this.resultCountPerGroup]),this.isDropdownEvent&&(this.helper.executeCallback.call(this,this.options.callback.onDropdownFilter,[this.node,this.query,this.filters.dropdown,this.result]),this.isDropdownEvent=!1))},searchResultData:function(){var e,i,o,s,n,r,a,l,h,c,u,p,d,f=this,y=this.groupBy,g=null,m=this.query.toLowerCase(),v=this.options.maxItem,b=this.options.maxItemPerGroup,k=this.filters.dynamic&&!this.helper.isEmpty(this.filters.dynamic),w="function"==typeof this.options.matcher&&this.options.matcher;this.options.accent&&(m=this.helper.removeAccent.call(this,m));for(var x=0,C=this.searchGroups.length;C>x;++x)if(e=this.searchGroups[x],!this.filters.dropdown||"group"!==this.filters.dropdown.key||this.filters.dropdown.value===e){a="undefined"!=typeof this.options.source[e].filter?this.options.source[e].filter:this.options.filter,h="function"==typeof this.options.source[e].matcher&&this.options.source[e].matcher||w;for(var q=0,O=this.source[e].length;O>q&&(!(this.resultItemCount>=v)||this.options.callback.onResult);q++)if((!k||this.dynamicFilter.validate.apply(this,[this.source[e][q]]))&&(i=this.source[e][q],null!==i&&"boolean"!=typeof i&&(!this.filters.dropdown||(i[this.filters.dropdown.key]||"").toLowerCase()===(this.filters.dropdown.value||"").toLowerCase()))){if(g="group"===y?e:i[y]?i[y]:i.group,g&&!this.result[g]&&(this.result[g]=[],this.resultCountPerGroup[g]=0),b&&"group"===y&&this.result[g].length>=b&&!this.options.callback.onResult)break;n=this.options.source[e].display||this.options.display;for(var S=0,F=n.length;F>S;++S){if(a!==!1){if(r=/\./.test(n[S])?this.helper.namespace.call(this,n[S],i):i[n[S]],"undefined"==typeof r||""===r)continue;r=this.helper.cleanStringFromScript(r)}if("function"==typeof a){if(l=a.call(this,i,r),void 0===l)break;if(!l)continue;"object"==typeof l&&(i=l)}if(~[void 0,!0].indexOf(a)){if(s=r,s=s.toString().toLowerCase(),this.options.accent&&(s=this.helper.removeAccent.call(this,s)),o=s.indexOf(m),this.options.correlativeTemplate&&"compiled"===n[S]&&0>o&&/\s/.test(m)){u=!0,p=m.split(" "),d=s;for(var L=0,A=p.length;A>L;L++)if(""!==p[L]){if(!~d.indexOf(p[L])){u=!1;break}d=d.replace(p[L],"")}}if(0>o&&!u)continue;if(this.options.offset&&0!==o)continue;if(h){if(c=h.call(this,i,r),void 0===c)break;if(!c)continue;"object"==typeof c&&(i=c)}}if(this.resultCount++,this.resultCountPerGroup[g]++,this.resultItemCount<v){if(b&&this.result[g].length>=b)break;this.result[g].push(t.extend(!0,{matchedKey:n[S]},i)),this.resultItemCount++}break}if(!this.options.callback.onResult){if(this.resultItemCount>=v)break;if(b&&this.result[g].length>=b&&"group"===y)break}}}if(this.options.order){var j,n=[];for(var e in this.result)if(this.result.hasOwnProperty(e)){for(var x=0,C=this.result[e].length;C>x;x++)j=this.options.source[this.result[e][x].group].display||this.options.display,~n.indexOf(j[0])||n.push(j[0]);this.result[e].sort(f.helper.sort(n,"asc"===f.options.order,function(t){return t.toString().toUpperCase()}))}}var G=[],T=[];T="function"==typeof this.options.groupOrder?this.options.groupOrder.apply(this,[this.node,this.query,this.result,this.resultCount,this.resultCountPerGroup]):Array.isArray(this.options.groupOrder)?this.options.groupOrder:"string"==typeof this.options.groupOrder&&~["asc","desc"].indexOf(this.options.groupOrder)?Object.keys(this.result).sort(f.helper.sort([],"asc"===f.options.groupOrder,function(t){return t.toString().toUpperCase()})):Object.keys(this.result);for(var x=0,C=T.length;C>x;x++)G=G.concat(this.result[T[x]]||[]);this.groups=JSON.parse(JSON.stringify(T)),this.result=G},buildLayout:function(){if(this.buildHtmlLayout(),this.buildBackdropLayout(),this.buildHintLayout(),this.options.callback.onLayoutBuiltBefore){var e=this.helper.executeCallback.call(this,this.options.callback.onLayoutBuiltBefore,[this.node,this.query,this.result,this.resultHtml]);e instanceof t&&(this.resultHtml=e)}this.resultHtml&&this.resultContainer.html(this.resultHtml),this.options.callback.onLayoutBuiltAfter&&this.helper.executeCallback.call(this,this.options.callback.onLayoutBuiltAfter,[this.node,this.query,this.result])},buildHtmlLayout:function(){if(this.options.resultContainer!==!1){this.resultContainer||(this.resultContainer=t("<div/>",{"class":this.options.selector.result}),this.container.append(this.resultContainer));var e;if(!this.result.length){if(!this.options.emptyTemplate||""===this.query)return;e="function"==typeof this.options.emptyTemplate?this.options.emptyTemplate.call(this,this.query):this.options.emptyTemplate.replace(/\{\{query}}/gi,this.helper.cleanStringFromScript(this.query))}var i=this.query.toLowerCase();this.options.accent&&(i=this.helper.removeAccent.call(this,i));var o=this,s=this.groupTemplate||"<ul></ul>",n=!1;this.groupTemplate?s=t(s.replace(/<([^>]+)>\{\{(.+?)}}<\/[^>]+>/g,function(t,i,s,r,a){var l="",h="group"===s?o.groups:[s];if(!o.result.length)return n===!0?"":(n=!0,"<"+i+' class="'+o.options.selector.empty+'"><a href="javascript:;">'+e+"</a></"+i+">");for(var c=0,u=h.length;u>c;++c)l+="<"+i+' data-group-template="'+h[c]+'"><ul></ul></'+i+">";return l})):(s=t(s),this.result.length||s.append(e instanceof t?e:'<li class="'+o.options.selector.empty+'"><a href="javascript:;">'+e+"</a></li>")),s.addClass(this.options.selector.list+(this.helper.isEmpty(this.result)?" empty":""));for(var r,a,l,h,c,u,p,d,f,y,g,m,v=this.groupTemplate&&this.result.length&&o.groups||[],b=0,k=this.result.length;k>b;++b)l=this.result[b],r=l.group,h=this.options.source[l.group].href||this.options.href,f=[],y=this.options.source[l.group].display||this.options.display,this.options.group&&(r=l[this.options.group.key],this.options.group.template&&("function"==typeof this.options.group.template?a=this.options.group.template(l):"string"==typeof this.options.template&&(a=this.options.group.template.replace(/\{\{([\w\-\.]+)}}/gi,function(t,e){return o.helper.namespace.call(o,e,l,"get","")}))),s.find('[data-search-group="'+r+'"]')[0]||(this.groupTemplate?s.find('[data-group-template="'+r+'"] ul'):s).append(t("<li/>",{"class":o.options.selector.group,html:t("<a/>",{href:"javascript:;",html:a||r,tabindex:-1}),"data-search-group":r}))),this.groupTemplate&&v.length&&(m=v.indexOf(r||l.group),~m&&v.splice(m,1)),c=t("<li/>",{"class":o.options.selector.item+" "+o.options.selector.group+"-"+this.helper.slugify.call(this,r),html:t("<a/>",{href:function(){return h&&("string"==typeof h?h=h.replace(/\{\{([^\|}]+)(?:\|([^}]+))*}}/gi,function(t,e,i){var s=o.helper.namespace.call(o,e,l,"get","");return i=i&&i.split("|")||[],~i.indexOf("slugify")&&(s=o.helper.slugify.call(o,s)),s}):"function"==typeof h&&(h=h(l)),l.href=h),h||"javascript:;"}(),"data-group":r,"data-index":b,html:function(){if(u=l.group&&o.options.source[l.group].template||o.options.template)"function"==typeof u&&(u=u.call(o,o.query,l)),d=u.replace(/\{\{([^\|}]+)(?:\|([^}]+))*}}/gi,function(t,e,s){var n=o.helper.cleanStringFromScript(String(o.helper.namespace.call(o,e,l,"get","")));return s=s&&s.split("|")||[],~s.indexOf("slugify")&&(n=o.helper.slugify.call(o,n)),~s.indexOf("raw")||o.options.highlight===!0&&i&&~y.indexOf(e)&&(n=o.helper.highlight.call(o,n,i.split(" "),o.options.accent)),n});else{for(var e=0,s=y.length;s>e;e++)g=/\./.test(y[e])?o.helper.namespace.call(o,y[e],l,"get",""):l[y[e]],"undefined"!=typeof g&&""!==g&&f.push(g);d='<span class="'+o.options.selector.display+'">'+o.helper.cleanStringFromScript(String(f.join(" ")))+"</span>"}(o.options.highlight===!0&&i&&!u||"any"===o.options.highlight)&&(d=o.helper.highlight.call(o,d,i.split(" "),o.options.accent)),t(this).append(d)}})}),function(e,i,s){s.on("click",function(e,s){return s&&"object"==typeof s&&(e.originalEvent=s),o.options.mustSelectItem&&o.helper.isEmpty(i)?void e.preventDefault():(o.item=i,void(o.helper.executeCallback.call(o,o.options.callback.onClickBefore,[o.node,t(this),i,e])!==!1&&(e.originalEvent&&e.originalEvent.defaultPrevented||e.isDefaultPrevented()||(p=i.group&&o.options.source[i.group].templateValue||o.options.templateValue,"function"==typeof p&&(p=p.call(o)),o.query=o.rawQuery=p?p.replace(/\{\{([\w\-\.]+)}}/gi,function(t,e){return o.helper.namespace.call(o,e,i,"get","")}):o.helper.namespace.call(o,i.matchedKey,i).toString(),o.focusOnly=!0,o.node.val(o.query).focus(),o.searchResult(!0),o.buildLayout(),o.hideLayout(),o.helper.executeCallback.call(o,o.options.callback.onClickAfter,[o.node,t(this),i,e])))))}),s.on("mouseenter",function(e){o.helper.executeCallback.call(o,o.options.callback.onMouseEnter,[o.node,t(this),i,e])}),s.on("mouseleave",function(e){o.helper.executeCallback.call(o,o.options.callback.onMouseLeave,[o.node,t(this),i,e])})}(b,l,c),(this.groupTemplate?s.find('[data-group-template="'+r+'"] ul'):s).append(c);if(this.result.length&&v.length)for(var b=0,k=v.length;k>b;++b)s.find('[data-group-template="'+v[b]+'"]').remove();this.resultHtml=s}},buildBackdropLayout:function(){this.options.backdrop&&(this.backdrop.container||(this.backdrop.css=t.extend({opacity:.6,filter:"alpha(opacity=60)",position:"fixed",top:0,right:0,bottom:0,left:0,"z-index":1040,"background-color":"#000"},this.options.backdrop),this.backdrop.container=t("<div/>",{"class":this.options.selector.backdrop,css:this.backdrop.css}).insertAfter(this.container)),this.container.addClass("backdrop").css({"z-index":this.backdrop.css["z-index"]+1,position:"relative"}))},buildHintLayout:function(e){if(this.options.hint){if(this.node[0].scrollWidth>Math.ceil(this.node.innerWidth()))return void(this.hint.container&&this.hint.container.val(""));var i=this,o="",e=e||this.result,s=this.query.toLowerCase();if(this.options.accent&&(s=this.helper.removeAccent.call(this,s)),this.hintIndex=null,this.searchGroups.length){if(this.hint.container||(this.hint.css=t.extend({"border-color":"transparent",position:"absolute",top:0,display:"inline","z-index":-1,"float":"none",color:"silver","box-shadow":"none",cursor:"default","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"},this.options.hint),this.hint.container=t("<input/>",{type:this.node.attr("type"),"class":this.node.attr("class"),readonly:!0,unselectable:"on","aria-hidden":"true",tabindex:-1,click:function(){i.node.focus()}}).addClass(this.options.selector.hint).css(this.hint.css).insertAfter(this.node),this.node.parent().css({position:"relative"})),this.hint.container.css("color",this.hint.css.color),s)for(var n,r,a,l=0,h=e.length;h>l;l++){r=e[l].group,n=this.options.source[r].display||this.options.display;for(var c=0,u=n.length;u>c;c++)if(a=String(e[l][n[c]]).toLowerCase(),this.options.accent&&(a=this.helper.removeAccent.call(this,a)),0===a.indexOf(s)){o=String(e[l][n[c]]),this.hintIndex=l;break}if(null!==this.hintIndex)break}this.hint.container.val(o.length>0&&this.rawQuery+o.substring(this.query.length)||"")}}},buildDropdownLayout:function(){if(this.options.dropdownFilter){var e=this;t("<span/>",{"class":this.options.selector.filter,html:function(){t(this).append(t("<button/>",{type:"button","class":e.options.selector.filterButton,style:"display: none;",click:function(i){i.stopPropagation(),e.container.toggleClass("filter");var o=e.namespace+"-dropdown-filter";t("html").off(o),e.container.hasClass("filter")&&t("html").on("click"+o+" touchend"+o,function(i){t(i.target).closest("."+e.options.selector.filter)[0]||e.hasDragged||e.container.removeClass("filter")})}})),t(this).append(t("<ul/>",{"class":e.options.selector.dropdown}))}}).insertAfter(e.container.find("."+e.options.selector.query))}},buildDropdownItemLayout:function(e){function i(t){"*"===t.value?delete this.filters.dropdown:this.filters.dropdown=t,this.container.removeClass("filter").find("."+this.options.selector.filterButton).html(t.template),this.isDropdownEvent=!0,this.node.trigger("search"+this.namespace),this.node.focus()}if(this.options.dropdownFilter){var o,s,n=this,r="string"==typeof this.options.dropdownFilter&&this.options.dropdownFilter||"All",a=this.container.find("."+this.options.selector.dropdown);"static"!==e||this.options.dropdownFilter!==!0&&"string"!=typeof this.options.dropdownFilter||this.dropdownFilter["static"].push({key:"group",template:"{{group}}",all:r,value:Object.keys(this.options.source)});for(var l=0,h=this.dropdownFilter[e].length;h>l;l++){s=this.dropdownFilter[e][l],Array.isArray(s.value)||(s.value=[s.value]),s.all&&(this.dropdownFilterAll=s.all);for(var c=0,u=s.value.length;u>=c;c++)(c!==u||l===h-1)&&(c===u&&l===h-1&&"static"===e&&this.dropdownFilter.dynamic.length||(o=this.dropdownFilterAll||r,s.value[c]?o=s.template?s.template.replace(new RegExp("{{"+s.key+"}}","gi"),s.value[c]):s.value[c]:this.container.find("."+n.options.selector.filterButton).html(o),function(e,o,s){a.append(t("<li/>",{"class":n.options.selector.dropdownItem+" "+n.helper.slugify.call(n,o.key+"-"+(o.value[e]||r)),
11
11
  html:t("<a/>",{href:"javascript:;",html:s,click:function(t){t.preventDefault(),i.call(n,{key:o.key,value:o.value[e]||"*",template:s})}})}))}(c,s,o)))}this.dropdownFilter[e].length&&this.container.find("."+n.options.selector.filterButton).removeAttr("style")}},dynamicFilter:{isEnabled:!1,init:function(){this.options.dynamicFilter&&(this.dynamicFilter.bind.call(this),this.dynamicFilter.isEnabled=!0)},validate:function(t){var e,i,o=null,s=null;for(var n in this.filters.dynamic)if(this.filters.dynamic.hasOwnProperty(n)&&(i=~n.indexOf(".")?this.helper.namespace.call(this,n,t,"get"):t[n],"|"!==this.filters.dynamic[n].modifier||o||(o=i==this.filters.dynamic[n].value||!1),"&"===this.filters.dynamic[n].modifier)){if(i!=this.filters.dynamic[n].value){s=!1;break}s=!0}return e=o,null!==s&&(e=s,s===!0&&null!==o&&(e=o)),!!e},set:function(t,e){var i=t.match(/^([|&])?(.+)/);e?this.filters.dynamic[i[2]]={modifier:i[1]||"|",value:e}:delete this.filters.dynamic[i[2]],this.dynamicFilter.isEnabled&&this.generateSource()},bind:function(){for(var e,i=this,o=0,s=this.options.dynamicFilter.length;s>o;o++)e=this.options.dynamicFilter[o],"string"==typeof e.selector&&(e.selector=t(e.selector)),e.selector instanceof t&&e.selector[0]&&e.key&&!function(t){t.selector.off(i.namespace).on("change"+i.namespace,function(){i.dynamicFilter.set.apply(i,[t.key,i.dynamicFilter.getValue(this)])}).trigger("change"+i.namespace)}(e)},getValue:function(t){var e;return"SELECT"===t.tagName?e=t.value:"INPUT"===t.tagName&&("checkbox"===t.type?e=t.checked&&t.getAttribute("value")||t.checked||null:"radio"===t.type&&t.checked&&(e=t.value)),e}},showLayout:function(){function e(){var e=this;t("html").off("keydown"+this.namespace).on("keydown"+this.namespace,function(i){i.keyCode&&9===i.keyCode&&setTimeout(function(){t(":focus").closest(e.container).find(e.node)[0]||e.hideLayout()},0)}),t("html").off("click"+this.namespace+" touchend"+this.namespace).on("click"+this.namespace+" touchend"+this.namespace,function(i){t(i.target).closest(e.container)[0]||e.hasDragged||e.hideLayout()})}this.container.hasClass("result")||(this.result.length||this.options.emptyTemplate||this.options.backdropOnFocus)&&(e.call(this),this.container.addClass([this.result.length||this.searchGroups.length&&this.options.emptyTemplate&&this.query.length?"result ":"",this.options.hint&&this.searchGroups.length?"hint":"",this.options.backdrop||this.options.backdropOnFocus?"backdrop":""].join(" ")),this.helper.executeCallback.call(this,this.options.callback.onShowLayout,[this.node,this.query]))},hideLayout:function(){(this.container.hasClass("result")||this.container.hasClass("backdrop"))&&(this.container.removeClass("result hint filter"+(this.options.backdropOnFocus&&t(this.node).is(":focus")?"":" backdrop")),this.options.backdropOnFocus&&this.container.hasClass("backdrop")||(t("html").off(this.namespace),this.helper.executeCallback.call(this,this.options.callback.onHideLayout,[this.node,this.query])))},resetLayout:function(){this.result={},this.groups=[],this.resultCount=0,this.resultCountPerGroup={},this.resultItemCount=0,this.resultHtml=null,this.options.hint&&this.hint.container&&this.hint.container.val("")},resetInput:function(){this.node.val(""),this.item=null,this.query="",this.rawQuery=""},buildCancelButtonLayout:function(){if(this.options.cancelButton){var e=this;t("<span/>",{"class":this.options.selector.cancelButton,mousedown:function(t){t.stopImmediatePropagation(),t.preventDefault(),e.resetInput(),e.node.trigger("input"+e.namespace,[t])}}).insertBefore(this.node)}},toggleCancelButtonVisibility:function(){this.container.toggleClass("cancel",!!this.query.length)},__construct:function(){this.extendOptions(),this.unifySourceFormat()&&(this.dynamicFilter.init.apply(this),this.init(),this.buildDropdownLayout(),this.buildDropdownItemLayout("static"),this.delegateEvents(),this.buildCancelButtonLayout(),this.helper.executeCallback.call(this,this.options.callback.onReady,[this.node]))},helper:{isEmpty:function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0},removeAccent:function(t){if("string"==typeof t){var e=o;return"object"==typeof this.options.accent&&(e=this.options.accent),t=t.toLowerCase().replace(new RegExp("["+e.from+"]","g"),function(t){return e.to[e.from.indexOf(t)]})}},slugify:function(t){return t=String(t),""!==t&&(t=this.helper.removeAccent.call(this,t),t=t.replace(/[^-a-z0-9]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")),t},sort:function(t,e,i){var o=function(e){for(var o=0,s=t.length;s>o;o++)if("undefined"!=typeof e[t[o]])return i(e[t[o]]);return e};return e=[-1,1][+!!e],function(t,i){return t=o(t),i=o(i),e*((t>i)-(i>t))}},replaceAt:function(t,e,i,o){return t.substring(0,e)+o+t.substring(e+i)},highlight:function(t,e,i){t=String(t);var o=i&&this.helper.removeAccent.call(this,t)||t,s=[];Array.isArray(e)||(e=[e]),e.sort(function(t,e){return e.length-t.length});for(var n=e.length-1;n>=0;n--)""!==e[n].trim()?e[n]=e[n].replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):e.splice(n,1);o.replace(new RegExp("(?:"+e.join("|")+")(?!([^<]+)?>)","gi"),function(t,e,i){s.push({offset:i,length:t.length})});for(var n=s.length-1;n>=0;n--)t=this.helper.replaceAt(t,s[n].offset,s[n].length,"<strong>"+t.substr(s[n].offset,s[n].length)+"</strong>");return t},getCaret:function(t){if(t.selectionStart)return t.selectionStart;if(document.selection){t.focus();var e=document.selection.createRange();if(null===e)return 0;var i=t.createTextRange(),o=i.duplicate();return i.moveToBookmark(e.getBookmark()),o.setEndPoint("EndToStart",i),o.text.length}return 0},cleanStringFromScript:function(t){return"string"==typeof t&&t.replace(/<\/?(?:script|iframe)\b[^>]*>/gm,"")||t},executeCallback:function(t,e){if(t){var i;if("function"==typeof t)i=t;else if(("string"==typeof t||Array.isArray(t))&&("string"==typeof t&&(t=[t,[]]),i=this.helper.namespace.call(this,t[0],window),"function"!=typeof i))return;return i.apply(this,(t[1]||[]).concat(e?e:[]))}},namespace:function(t,e,i,o){if("string"!=typeof t||""===t)return!1;var s="undefined"!=typeof o?o:void 0;if(!~t.indexOf("."))return e[t]||s;for(var n=t.split("."),r=e||window,i=i||"get",a="",l=0,h=n.length;h>l;l++){if(a=n[l],"undefined"==typeof r[a]){if(~["get","delete"].indexOf(i))return"undefined"!=typeof o?o:void 0;r[a]={}}if(~["set","create","delete"].indexOf(i)&&l===h-1){if("set"!==i&&"create"!==i)return delete r[a],!0;r[a]=s}r=r[a]}return r},typeWatch:function(){var t=0;return function(e,i){clearTimeout(t),t=setTimeout(e,i)}}()}},t.fn.typeahead=t.typeahead=function(t){return l.typeahead(this,t)};var l={typeahead:function(e,i){if(i&&i.source&&"object"==typeof i.source){if("function"==typeof e){if(!i.input)return;e=t(i.input)}if(e.length&&"INPUT"===e[0].nodeName){if(1===e.length)return e[0].selector=e.selector||i.input||e[0].nodeName.toLowerCase(),window.Typeahead[e[0].selector]=new a(e,i);for(var o,s={},n=0,r=e.length;r>n;++n)o=e[n].nodeName.toLowerCase(),"undefined"!=typeof s[o]&&(o+=n),e[n].selector=o,window.Typeahead[o]=s[o]=new a(e.eq(n),i);return s}}}};return window.console=window.console||{log:function(){}},Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),"trim"in String.prototype||(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),"indexOf"in Array.prototype||(Array.prototype.indexOf=function(t,e){void 0===e&&(e=0),0>e&&(e+=this.length),0>e&&(e=0);for(var i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1}),Object.keys||(Object.keys=function(t){var e,i=[];for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&i.push(e);return i}),a});
@@ -1,9 +1,9 @@
1
- (function(factory){if(typeof define=="function"&&define.amd){define("picker",["jquery"],factory)}else{if(typeof exports=="object"){module.exports=factory(require("jquery"))}else{this.Picker=factory(jQuery)}}}(function($){var $window=$(window);var $document=$(document);var $html=$(document.documentElement);function PickerConstructor(ELEMENT,NAME,COMPONENT,OPTIONS){if(!ELEMENT){return PickerConstructor}var IS_DEFAULT_THEME=false,STATE={id:ELEMENT.id||"P"+Math.abs(~~(Math.random()*new Date()))},SETTINGS=COMPONENT?$.extend(true,{},COMPONENT.defaults,OPTIONS):OPTIONS||{},CLASSES=$.extend({},PickerConstructor.klasses(),SETTINGS.klass),$ELEMENT=$(ELEMENT),PickerInstance=function(){return this.start()},P=PickerInstance.prototype={constructor:PickerInstance,$node:$ELEMENT,start:function(){if(STATE&&STATE.start){return P}STATE.methods={};STATE.start=true;STATE.open=false;STATE.type=ELEMENT.type;ELEMENT.autofocus=ELEMENT==getActiveElement();ELEMENT.readOnly=!SETTINGS.editable;ELEMENT.id=ELEMENT.id||STATE.id;if(ELEMENT.type!="text"){ELEMENT.type="text"}P.component=new COMPONENT(P,SETTINGS);P.$root=$(PickerConstructor._.node("div",createWrappedComponent(),CLASSES.picker,'id="'+ELEMENT.id+'_root" tabindex="0"'));prepareElementRoot();if(SETTINGS.formatSubmit){prepareElementHidden()}prepareElement();if(SETTINGS.container){$(SETTINGS.container).append(P.$root)}else{$ELEMENT.after(P.$root)}P.on({start:P.component.onStart,render:P.component.onRender,stop:P.component.onStop,open:P.component.onOpen,close:P.component.onClose,set:P.component.onSet}).on({start:SETTINGS.onStart,render:SETTINGS.onRender,stop:SETTINGS.onStop,open:SETTINGS.onOpen,close:SETTINGS.onClose,set:SETTINGS.onSet});IS_DEFAULT_THEME=isUsingDefaultTheme(P.$root.children()[0]);if(ELEMENT.autofocus){P.open()}return P.trigger("start").trigger("render")},render:function(entireComponent){if(entireComponent){P.$root.html(createWrappedComponent())}else{P.$root.find("."+CLASSES.box).html(P.component.nodes(STATE.open))}return P.trigger("render")},stop:function(){if(!STATE.start){return P}P.close();if(P._hidden){P._hidden.parentNode.removeChild(P._hidden)}P.$root.remove();$ELEMENT.removeClass(CLASSES.input).removeData(NAME);setTimeout(function(){$ELEMENT.off("."+STATE.id)},0);ELEMENT.type=STATE.type;ELEMENT.readOnly=false;P.trigger("stop");STATE.methods={};STATE.start=false;return P},open:function(dontGiveFocus){if(STATE.open){return P}$ELEMENT.addClass(CLASSES.active);aria(ELEMENT,"expanded",true);setTimeout(function(){P.$root.addClass(CLASSES.opened);aria(P.$root[0],"hidden",false)},0);if(dontGiveFocus!==false){STATE.open=true;if(IS_DEFAULT_THEME){$html.css("overflow","hidden").css("padding-right","+="+getScrollbarWidth())}P.$root.eq(0).focus();$document.on("click."+STATE.id+" focusin."+STATE.id,function(event){var target=event.target;if(target!=ELEMENT&&target!=document&&event.which!=3){P.close(target===P.$root.children()[0])}}).on("keydown."+STATE.id,function(event){var keycode=event.keyCode,keycodeToMove=P.component.key[keycode],target=event.target;if(keycode==27){P.close(true)}else{if(target==P.$root[0]&&(keycodeToMove||keycode==13)){event.preventDefault();if(keycodeToMove){PickerConstructor._.trigger(P.component.key.go,P,[PickerConstructor._.trigger(keycodeToMove)])}else{if(!P.$root.find("."+CLASSES.highlighted).hasClass(CLASSES.disabled)){P.set("select",P.component.item.highlight).close()}}}else{if($.contains(P.$root[0],target)&&keycode==13){event.preventDefault();target.click()}}}})}return P.trigger("open")},close:function(giveFocus){if(giveFocus){P.$root.off("focus.toOpen").eq(0).focus();setTimeout(function(){P.$root.on("focus.toOpen",handleFocusToOpenEvent)},0)}$ELEMENT.removeClass(CLASSES.active);aria(ELEMENT,"expanded",false);setTimeout(function(){P.$root.removeClass(CLASSES.opened+" "+CLASSES.focused);aria(P.$root[0],"hidden",true)},0);if(!STATE.open){return P}STATE.open=false;if(IS_DEFAULT_THEME){$html.css("overflow","").css("padding-right","-="+getScrollbarWidth())}$document.off("."+STATE.id);return P.trigger("close")},clear:function(options){return P.set("clear",null,options)},set:function(thing,value,options){var thingItem,thingValue,thingIsObject=$.isPlainObject(thing),thingObject=thingIsObject?thing:{};options=thingIsObject&&$.isPlainObject(value)?value:options||{};if(thing){if(!thingIsObject){thingObject[thing]=value}for(thingItem in thingObject){thingValue=thingObject[thingItem];if(thingItem in P.component.item){if(thingValue===undefined){thingValue=null}P.component.set(thingItem,thingValue,options)}if(thingItem=="select"||thingItem=="clear"){$ELEMENT.val(thingItem=="clear"?"":P.get(thingItem,SETTINGS.format)).trigger("change")}}P.render()}return options.muted?P:P.trigger("set",thingObject)},get:function(thing,format){thing=thing||"value";if(STATE[thing]!=null){return STATE[thing]}if(thing=="valueSubmit"){if(P._hidden){return P._hidden.value}thing="value"}if(thing=="value"){return ELEMENT.value}if(thing in P.component.item){if(typeof format=="string"){var thingValue=P.component.get(thing);
2
- return thingValue?PickerConstructor._.trigger(P.component.formats.toString,P.component,[format,thingValue]):""}return P.component.get(thing)}},on:function(thing,method,internal){var thingName,thingMethod,thingIsObject=$.isPlainObject(thing),thingObject=thingIsObject?thing:{};if(thing){if(!thingIsObject){thingObject[thing]=method}for(thingName in thingObject){thingMethod=thingObject[thingName];if(internal){thingName="_"+thingName}STATE.methods[thingName]=STATE.methods[thingName]||[];STATE.methods[thingName].push(thingMethod)}}return P},off:function(){var i,thingName,names=arguments;for(i=0,namesCount=names.length;i<namesCount;i+=1){thingName=names[i];if(thingName in STATE.methods){delete STATE.methods[thingName]}}return P},trigger:function(name,data){var _trigger=function(name){var methodList=STATE.methods[name];if(methodList){methodList.map(function(method){PickerConstructor._.trigger(method,P,[data])})}};_trigger("_"+name);_trigger(name);return P}};function createWrappedComponent(){return PickerConstructor._.node("div",PickerConstructor._.node("div",PickerConstructor._.node("div",PickerConstructor._.node("div",P.component.nodes(STATE.open),CLASSES.box),CLASSES.wrap),CLASSES.frame),CLASSES.holder)}function prepareElement(){$ELEMENT.data(NAME,P).addClass(CLASSES.input).attr("tabindex",-1).val($ELEMENT.data("value")?P.get("select",SETTINGS.format):ELEMENT.value);if(!SETTINGS.editable){$ELEMENT.on("focus."+STATE.id+" click."+STATE.id,function(event){event.preventDefault();P.$root.eq(0).focus()}).on("keydown."+STATE.id,handleKeydownEvent)}aria(ELEMENT,{haspopup:true,expanded:false,readonly:false,owns:ELEMENT.id+"_root"})}function prepareElementRoot(){P.$root.on({keydown:handleKeydownEvent,focusin:function(event){P.$root.removeClass(CLASSES.focused);event.stopPropagation()},"mousedown click":function(event){var target=event.target;if(target!=P.$root.children()[0]){event.stopPropagation();if(event.type=="mousedown"&&!$(target).is("input, select, textarea, button, option")){event.preventDefault();P.$root.eq(0).focus()}}}}).on({focus:function(){$ELEMENT.addClass(CLASSES.target)},blur:function(){$ELEMENT.removeClass(CLASSES.target)}}).on("focus.toOpen",handleFocusToOpenEvent).on("click","[data-pick], [data-nav], [data-clear], [data-close]",function(){var $target=$(this),targetData=$target.data(),targetDisabled=$target.hasClass(CLASSES.navDisabled)||$target.hasClass(CLASSES.disabled),activeElement=getActiveElement();activeElement=activeElement&&(activeElement.type||activeElement.href);if(targetDisabled||activeElement&&!$.contains(P.$root[0],activeElement)){P.$root.eq(0).focus()}if(!targetDisabled&&targetData.nav){P.set("highlight",P.component.item.highlight,{nav:targetData.nav})}else{if(!targetDisabled&&"pick" in targetData){P.set("select",targetData.pick)}else{if(targetData.clear){P.clear().close(true)}else{if(targetData.close){P.close(true)}}}}});aria(P.$root[0],"hidden",true)}function prepareElementHidden(){var name;if(SETTINGS.hiddenName===true){name=ELEMENT.name;ELEMENT.name=""}else{name=[typeof SETTINGS.hiddenPrefix=="string"?SETTINGS.hiddenPrefix:"",typeof SETTINGS.hiddenSuffix=="string"?SETTINGS.hiddenSuffix:"_submit"];name=name[0]+ELEMENT.name+name[1]}P._hidden=$("<input "+"type=hidden "+'name="'+name+'"'+($ELEMENT.data("value")||ELEMENT.value?' value="'+P.get("select",SETTINGS.formatSubmit)+'"':"")+">")[0];$ELEMENT.on("change."+STATE.id,function(){P._hidden.value=ELEMENT.value?P.get("select",SETTINGS.formatSubmit):""});if(SETTINGS.container){$(SETTINGS.container).append(P._hidden)}else{$ELEMENT.after(P._hidden)}}function handleKeydownEvent(event){var keycode=event.keyCode,isKeycodeDelete=/^(8|46)$/.test(keycode);if(keycode==27){P.close();return false}if(keycode==32||isKeycodeDelete||!STATE.open&&P.component.key[keycode]){event.preventDefault();event.stopPropagation();if(isKeycodeDelete){P.clear().close()}else{P.open()}}}function handleFocusToOpenEvent(event){event.stopPropagation();if(event.type=="focus"){P.$root.addClass(CLASSES.focused)}P.open()}return new PickerInstance()}PickerConstructor.klasses=function(prefix){prefix=prefix||"picker";return{picker:prefix,opened:prefix+"--opened",focused:prefix+"--focused",input:prefix+"__input",active:prefix+"__input--active",target:prefix+"__input--target",holder:prefix+"__holder",frame:prefix+"__frame",wrap:prefix+"__wrap",box:prefix+"__box"}};function isUsingDefaultTheme(element){var theme,prop="position";if(element.currentStyle){theme=element.currentStyle[prop]}else{if(window.getComputedStyle){theme=getComputedStyle(element)[prop]}}return theme=="fixed"}function getScrollbarWidth(){if($html.height()<=$window.height()){return 0}var $outer=$('<div style="visibility:hidden;width:100px" />').appendTo("body");var widthWithoutScroll=$outer[0].offsetWidth;$outer.css("overflow","scroll");var $inner=$('<div style="width:100%" />').appendTo($outer);var widthWithScroll=$inner[0].offsetWidth;$outer.remove();return widthWithoutScroll-widthWithScroll}PickerConstructor._={group:function(groupObject){var loopObjectScope,nodesList="",counter=PickerConstructor._.trigger(groupObject.min,groupObject);
3
- for(;counter<=PickerConstructor._.trigger(groupObject.max,groupObject,[counter]);counter+=groupObject.i){loopObjectScope=PickerConstructor._.trigger(groupObject.item,groupObject,[counter]);nodesList+=PickerConstructor._.node(groupObject.node,loopObjectScope[0],loopObjectScope[1],loopObjectScope[2])}return nodesList},node:function(wrapper,item,klass,attribute){if(!item){return""}item=$.isArray(item)?item.join(""):item;klass=klass?' class="'+klass+'"':"";attribute=attribute?" "+attribute:"";return"<"+wrapper+klass+attribute+">"+item+"</"+wrapper+">"},lead:function(number){return(number<10?"0":"")+number},trigger:function(callback,scope,args){return typeof callback=="function"?callback.apply(scope,args||[]):callback},digits:function(string){return(/\d/).test(string[1])?2:1},isDate:function(value){return{}.toString.call(value).indexOf("Date")>-1&&this.isInteger(value.getDate())},isInteger:function(value){return{}.toString.call(value).indexOf("Number")>-1&&value%1===0},ariaAttr:ariaAttr};PickerConstructor.extend=function(name,Component){$.fn[name]=function(options,action){var componentData=this.data(name);if(options=="picker"){return componentData}if(componentData&&typeof options=="string"){return PickerConstructor._.trigger(componentData[options],componentData,[action])}return this.each(function(){var $this=$(this);if(!$this.data(name)){new PickerConstructor(this,name,Component,options)}})};$.fn[name].defaults=Component.defaults};function aria(element,attribute,value){if($.isPlainObject(attribute)){for(var key in attribute){ariaSet(element,key,attribute[key])}}else{ariaSet(element,attribute,value)}}function ariaSet(element,attribute,value){element.setAttribute((attribute=="role"?"":"aria-")+attribute,value)}function ariaAttr(attribute,data){if(!$.isPlainObject(attribute)){attribute={attribute:data}}data="";for(var key in attribute){var attr=(key=="role"?"":"aria-")+key,attrVal=attribute[key];data+=attrVal==null?"":attr+'="'+attribute[key]+'"'}return data}function getActiveElement(){try{return document.activeElement}catch(err){}}return PickerConstructor}));
4
-
5
- (function(factory){if(typeof define=="function"&&define.amd){define(["picker","jquery"],factory)}else{if(typeof exports=="object"){module.exports=factory(require("./picker.js"),require("jquery"))}else{factory(Picker,jQuery)}}}(function(Picker,$){var DAYS_IN_WEEK=7,WEEKS_IN_CALENDAR=6,_=Picker._;function DatePicker(picker,settings){var calendar=this,element=picker.$node[0],elementValue=element.value,elementDataValue=picker.$node.data("value"),valueString=elementDataValue||elementValue,formatString=elementDataValue?settings.formatSubmit:settings.format,isRTL=function(){return element.currentStyle?element.currentStyle.direction=="rtl":getComputedStyle(picker.$root[0]).direction=="rtl"};calendar.settings=settings;calendar.$node=picker.$node;calendar.queue={min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse navigate create validate",view:"parse create validate viewset",disable:"deactivate",enable:"activate"};calendar.item={};calendar.item.clear=null;calendar.item.disable=(settings.disable||[]).slice(0);calendar.item.enable=-(function(collectionDisabled){return collectionDisabled[0]===true?collectionDisabled.shift():-1})(calendar.item.disable);calendar.set("min",settings.min).set("max",settings.max).set("now");if(valueString){calendar.set("select",valueString,{format:formatString})}else{calendar.set("select",null).set("highlight",calendar.item.now)}calendar.key={40:7,38:-7,39:function(){return isRTL()?-1:1},37:function(){return isRTL()?1:-1},go:function(timeChange){var highlightedObject=calendar.item.highlight,targetDate=new Date(highlightedObject.year,highlightedObject.month,highlightedObject.date+timeChange);calendar.set("highlight",targetDate,{interval:timeChange});this.render()}};picker.on("render",function(){picker.$root.find("."+settings.klass.selectMonth).on("change",function(){var value=this.value;if(value){picker.set("highlight",[picker.get("view").year,value,picker.get("highlight").date]);picker.$root.find("."+settings.klass.selectMonth).trigger("focus")}});picker.$root.find("."+settings.klass.selectYear).on("change",function(){var value=this.value;if(value){picker.set("highlight",[value,picker.get("view").month,picker.get("highlight").date]);picker.$root.find("."+settings.klass.selectYear).trigger("focus")}})},1).on("open",function(){var includeToday="";if(calendar.disabled(calendar.get("now"))){includeToday=":not(."+settings.klass.buttonToday+")"}picker.$root.find("button"+includeToday+", select").attr("disabled",false)},1).on("close",function(){picker.$root.find("button, select").attr("disabled",true)},1)}DatePicker.prototype.set=function(type,value,options){var calendar=this,calendarItem=calendar.item;if(value===null){if(type=="clear"){type="select"}calendarItem[type]=value;return calendar}calendarItem[(type=="enable"?"disable":type=="flip"?"enable":type)]=calendar.queue[type].split(" ").map(function(method){value=calendar[method](type,value,options);
6
- return value}).pop();if(type=="select"){calendar.set("highlight",calendarItem.select,options)}else{if(type=="highlight"){calendar.set("view",calendarItem.highlight,options)}else{if(type.match(/^(flip|min|max|disable|enable)$/)){if(calendarItem.select&&calendar.disabled(calendarItem.select)){calendar.set("select",calendarItem.select,options)}if(calendarItem.highlight&&calendar.disabled(calendarItem.highlight)){calendar.set("highlight",calendarItem.highlight,options)}}}}return calendar};DatePicker.prototype.get=function(type){return this.item[type]};DatePicker.prototype.create=function(type,value,options){var isInfiniteValue,calendar=this;value=value===undefined?type:value;if(value==-Infinity||value==Infinity){isInfiniteValue=value}else{if($.isPlainObject(value)&&_.isInteger(value.pick)){value=value.obj}else{if($.isArray(value)){value=new Date(value[0],value[1],value[2]);value=_.isDate(value)?value:calendar.create().obj}else{if(_.isInteger(value)||_.isDate(value)){value=calendar.normalize(new Date(value),options)}else{value=calendar.now(type,value,options)}}}}return{year:isInfiniteValue||value.getFullYear(),month:isInfiniteValue||value.getMonth(),date:isInfiniteValue||value.getDate(),day:isInfiniteValue||value.getDay(),obj:isInfiniteValue||value,pick:isInfiniteValue||value.getTime()}};DatePicker.prototype.createRange=function(from,to){var calendar=this,createDate=function(date){if(date===true||$.isArray(date)||_.isDate(date)){return calendar.create(date)}return date};if(!_.isInteger(from)){from=createDate(from)}if(!_.isInteger(to)){to=createDate(to)}if(_.isInteger(from)&&$.isPlainObject(to)){from=[to.year,to.month,to.date+from]}else{if(_.isInteger(to)&&$.isPlainObject(from)){to=[from.year,from.month,from.date+to]}}return{from:createDate(from),to:createDate(to)}};DatePicker.prototype.withinRange=function(range,dateUnit){range=this.createRange(range.from,range.to);return dateUnit.pick>=range.from.pick&&dateUnit.pick<=range.to.pick};DatePicker.prototype.overlapRanges=function(one,two){var calendar=this;one=calendar.createRange(one.from,one.to);two=calendar.createRange(two.from,two.to);return calendar.withinRange(one,two.from)||calendar.withinRange(one,two.to)||calendar.withinRange(two,one.from)||calendar.withinRange(two,one.to)};DatePicker.prototype.now=function(type,value,options){value=new Date();if(options&&options.rel){value.setDate(value.getDate()+options.rel)}return this.normalize(value,options)};DatePicker.prototype.navigate=function(type,value,options){var targetDateObject,targetYear,targetMonth,targetDate,isTargetArray=$.isArray(value),isTargetObject=$.isPlainObject(value),viewsetObject=this.item.view;if(isTargetArray||isTargetObject){if(isTargetObject){targetYear=value.year;targetMonth=value.month;targetDate=value.date}else{targetYear=+value[0];targetMonth=+value[1];targetDate=+value[2]}if(options&&options.nav&&viewsetObject&&viewsetObject.month!==targetMonth){targetYear=viewsetObject.year;targetMonth=viewsetObject.month}targetDateObject=new Date(targetYear,targetMonth+(options&&options.nav?options.nav:0),1);targetYear=targetDateObject.getFullYear();targetMonth=targetDateObject.getMonth();while(new Date(targetYear,targetMonth,targetDate).getMonth()!==targetMonth){targetDate-=1}value=[targetYear,targetMonth,targetDate]}return value};DatePicker.prototype.normalize=function(value){value.setHours(0,0,0,0);return value};DatePicker.prototype.measure=function(type,value){var calendar=this;if(!value){value=type=="min"?-Infinity:Infinity}else{if(typeof value=="string"){value=calendar.parse(type,value)}else{if(_.isInteger(value)){value=calendar.now(type,value,{rel:value})}}}return value};DatePicker.prototype.viewset=function(type,dateObject){return this.create([dateObject.year,dateObject.month,1])};DatePicker.prototype.validate=function(type,dateObject,options){var calendar=this,originalDateObject=dateObject,interval=options&&options.interval?options.interval:1,isFlippedBase=calendar.item.enable===-1,hasEnabledBeforeTarget,hasEnabledAfterTarget,minLimitObject=calendar.item.min,maxLimitObject=calendar.item.max,reachedMin,reachedMax,hasEnabledWeekdays=isFlippedBase&&calendar.item.disable.filter(function(value){if($.isArray(value)){var dateTime=calendar.create(value).pick;if(dateTime<dateObject.pick){hasEnabledBeforeTarget=true}else{if(dateTime>dateObject.pick){hasEnabledAfterTarget=true}}}return _.isInteger(value)}).length;if(!options||!options.nav){if((!isFlippedBase&&calendar.disabled(dateObject))||(isFlippedBase&&calendar.disabled(dateObject)&&(hasEnabledWeekdays||hasEnabledBeforeTarget||hasEnabledAfterTarget))||(!isFlippedBase&&(dateObject.pick<=minLimitObject.pick||dateObject.pick>=maxLimitObject.pick))){if(isFlippedBase&&!hasEnabledWeekdays&&((!hasEnabledAfterTarget&&interval>0)||(!hasEnabledBeforeTarget&&interval<0))){interval*=-1}while(calendar.disabled(dateObject)){if(Math.abs(interval)>1&&(dateObject.month<originalDateObject.month||dateObject.month>originalDateObject.month)){dateObject=originalDateObject;
7
- interval=interval>0?1:-1}if(dateObject.pick<=minLimitObject.pick){reachedMin=true;interval=1;dateObject=calendar.create([minLimitObject.year,minLimitObject.month,minLimitObject.date+(dateObject.pick===minLimitObject.pick?0:-1)])}else{if(dateObject.pick>=maxLimitObject.pick){reachedMax=true;interval=-1;dateObject=calendar.create([maxLimitObject.year,maxLimitObject.month,maxLimitObject.date+(dateObject.pick===maxLimitObject.pick?0:1)])}}if(reachedMin&&reachedMax){break}dateObject=calendar.create([dateObject.year,dateObject.month,dateObject.date+interval])}}}return dateObject};DatePicker.prototype.disabled=function(dateToVerify){var calendar=this,isDisabledMatch=calendar.item.disable.filter(function(dateToDisable){if(_.isInteger(dateToDisable)){return dateToVerify.day===(calendar.settings.firstDay?dateToDisable:dateToDisable-1)%7}if($.isArray(dateToDisable)||_.isDate(dateToDisable)){return dateToVerify.pick===calendar.create(dateToDisable).pick}if($.isPlainObject(dateToDisable)){return calendar.withinRange(dateToDisable,dateToVerify)}});isDisabledMatch=isDisabledMatch.length&&!isDisabledMatch.filter(function(dateToDisable){return $.isArray(dateToDisable)&&dateToDisable[3]=="inverted"||$.isPlainObject(dateToDisable)&&dateToDisable.inverted}).length;return calendar.item.enable===-1?!isDisabledMatch:isDisabledMatch||dateToVerify.pick<calendar.item.min.pick||dateToVerify.pick>calendar.item.max.pick};DatePicker.prototype.parse=function(type,value,options){var calendar=this,parsingObject={};if(!value||typeof value!="string"){return value}if(!(options&&options.format)){options=options||{};options.format=calendar.settings.format}calendar.formats.toArray(options.format).map(function(label){var formattingLabel=calendar.formats[label],formatLength=formattingLabel?_.trigger(formattingLabel,calendar,[value,parsingObject]):label.replace(/^!/,"").length;if(formattingLabel){parsingObject[label]=value.substr(0,formatLength)}value=value.substr(formatLength)});return[parsingObject.yyyy||parsingObject.yy,+(parsingObject.mm||parsingObject.m)-1,parsingObject.dd||parsingObject.d]};DatePicker.prototype.formats=(function(){function getWordLengthFromCollection(string,collection,dateObject){var word=string.match(/\w+/)[0];if(!dateObject.mm&&!dateObject.m){dateObject.m=collection.indexOf(word)+1}return word.length}function getFirstWordLength(string){return string.match(/\w+/)[0].length}return{d:function(string,dateObject){return string?_.digits(string):dateObject.date},dd:function(string,dateObject){return string?2:_.lead(dateObject.date)},ddd:function(string,dateObject){return string?getFirstWordLength(string):this.settings.weekdaysShort[dateObject.day]},dddd:function(string,dateObject){return string?getFirstWordLength(string):this.settings.weekdaysFull[dateObject.day]},m:function(string,dateObject){return string?_.digits(string):dateObject.month+1},mm:function(string,dateObject){return string?2:_.lead(dateObject.month+1)},mmm:function(string,dateObject){var collection=this.settings.monthsShort;return string?getWordLengthFromCollection(string,collection,dateObject):collection[dateObject.month]},mmmm:function(string,dateObject){var collection=this.settings.monthsFull;return string?getWordLengthFromCollection(string,collection,dateObject):collection[dateObject.month]},yy:function(string,dateObject){return string?2:(""+dateObject.year).slice(2)},yyyy:function(string,dateObject){return string?4:dateObject.year},toArray:function(formatString){return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g)},toString:function(formatString,itemObject){var calendar=this;return calendar.formats.toArray(formatString).map(function(label){return _.trigger(calendar.formats[label],calendar,[0,itemObject])||label.replace(/^!/,"")}).join("")}}})();DatePicker.prototype.isDateExact=function(one,two){var calendar=this;if((_.isInteger(one)&&_.isInteger(two))||(typeof one=="boolean"&&typeof two=="boolean")){return one===two}if((_.isDate(one)||$.isArray(one))&&(_.isDate(two)||$.isArray(two))){return calendar.create(one).pick===calendar.create(two).pick}if($.isPlainObject(one)&&$.isPlainObject(two)){return calendar.isDateExact(one.from,two.from)&&calendar.isDateExact(one.to,two.to)}return false};DatePicker.prototype.isDateOverlap=function(one,two){var calendar=this,firstDay=calendar.settings.firstDay?1:0;if(_.isInteger(one)&&(_.isDate(two)||$.isArray(two))){one=one%7+firstDay;return one===calendar.create(two).day+1}if(_.isInteger(two)&&(_.isDate(one)||$.isArray(one))){two=two%7+firstDay;return two===calendar.create(one).day+1}if($.isPlainObject(one)&&$.isPlainObject(two)){return calendar.overlapRanges(one,two)}return false};DatePicker.prototype.flipEnable=function(val){var itemObject=this.item;itemObject.enable=val||(itemObject.enable==-1?1:-1)};DatePicker.prototype.deactivate=function(type,datesToDisable){var calendar=this,disabledItems=calendar.item.disable.slice(0);if(datesToDisable=="flip"){calendar.flipEnable()}else{if(datesToDisable===false){calendar.flipEnable(1);
8
- disabledItems=[]}else{if(datesToDisable===true){calendar.flipEnable(-1);disabledItems=[]}else{datesToDisable.map(function(unitToDisable){var matchFound;for(var index=0;index<disabledItems.length;index+=1){if(calendar.isDateExact(unitToDisable,disabledItems[index])){matchFound=true;break}}if(!matchFound){if(_.isInteger(unitToDisable)||_.isDate(unitToDisable)||$.isArray(unitToDisable)||($.isPlainObject(unitToDisable)&&unitToDisable.from&&unitToDisable.to)){disabledItems.push(unitToDisable)}}})}}}return disabledItems};DatePicker.prototype.activate=function(type,datesToEnable){var calendar=this,disabledItems=calendar.item.disable,disabledItemsCount=disabledItems.length;if(datesToEnable=="flip"){calendar.flipEnable()}else{if(datesToEnable===true){calendar.flipEnable(1);disabledItems=[]}else{if(datesToEnable===false){calendar.flipEnable(-1);disabledItems=[]}else{datesToEnable.map(function(unitToEnable){var matchFound,disabledUnit,index,isExactRange;for(index=0;index<disabledItemsCount;index+=1){disabledUnit=disabledItems[index];if(calendar.isDateExact(disabledUnit,unitToEnable)){matchFound=disabledItems[index]=null;isExactRange=true;break}else{if(calendar.isDateOverlap(disabledUnit,unitToEnable)){if($.isPlainObject(unitToEnable)){unitToEnable.inverted=true;matchFound=unitToEnable}else{if($.isArray(unitToEnable)){matchFound=unitToEnable;if(!matchFound[3]){matchFound.push("inverted")}}else{if(_.isDate(unitToEnable)){matchFound=[unitToEnable.getFullYear(),unitToEnable.getMonth(),unitToEnable.getDate(),"inverted"]}}}break}}}if(matchFound){for(index=0;index<disabledItemsCount;index+=1){if(calendar.isDateExact(disabledItems[index],unitToEnable)){disabledItems[index]=null;break}}}if(isExactRange){for(index=0;index<disabledItemsCount;index+=1){if(calendar.isDateOverlap(disabledItems[index],unitToEnable)){disabledItems[index]=null;break}}}if(matchFound){disabledItems.push(matchFound)}})}}}return disabledItems.filter(function(val){return val!=null})};DatePicker.prototype.nodes=function(isOpen){var calendar=this,settings=calendar.settings,calendarItem=calendar.item,nowObject=calendarItem.now,selectedObject=calendarItem.select,highlightedObject=calendarItem.highlight,viewsetObject=calendarItem.view,disabledCollection=calendarItem.disable,minLimitObject=calendarItem.min,maxLimitObject=calendarItem.max,tableHead=(function(collection,fullCollection){if(settings.firstDay){collection.push(collection.shift());fullCollection.push(fullCollection.shift())}return _.node("thead",_.node("tr",_.group({min:0,max:DAYS_IN_WEEK-1,i:1,node:"th",item:function(counter){return[collection[counter],settings.klass.weekdays,'scope=col title="'+fullCollection[counter]+'"']}})))})((settings.showWeekdaysFull?settings.weekdaysFull:settings.weekdaysLetter).slice(0),settings.weekdaysFull.slice(0)),createMonthNav=function(next){return _.node("div"," ",settings.klass["nav"+(next?"Next":"Prev")]+((next&&viewsetObject.year>=maxLimitObject.year&&viewsetObject.month>=maxLimitObject.month)||(!next&&viewsetObject.year<=minLimitObject.year&&viewsetObject.month<=minLimitObject.month)?" "+settings.klass.navDisabled:""),"data-nav="+(next||-1)+" "+_.ariaAttr({role:"button",controls:calendar.$node[0].id+"_table"})+" "+'title="'+(next?settings.labelMonthNext:settings.labelMonthPrev)+'"')},createMonthLabel=function(override){var monthsCollection=settings.showMonthsShort?settings.monthsShort:settings.monthsFull;if(override=="short_months"){monthsCollection=settings.monthsShort}if(settings.selectMonths&&override==undefined){return _.node("select",_.group({min:0,max:11,i:1,node:"option",item:function(loopedMonth){return[monthsCollection[loopedMonth],0,"value="+loopedMonth+(viewsetObject.month==loopedMonth?" selected":"")+(((viewsetObject.year==minLimitObject.year&&loopedMonth<minLimitObject.month)||(viewsetObject.year==maxLimitObject.year&&loopedMonth>maxLimitObject.month))?" disabled":"")]}}),settings.klass.selectMonth+" browser-default",(isOpen?"":"disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id+"_table"})+" "+'title="'+settings.labelMonthSelect+'"')}if(override=="short_months"){if(selectedObject!=null){return _.node("div",monthsCollection[selectedObject.month])}else{return _.node("div",monthsCollection[viewsetObject.month])}}return _.node("div",monthsCollection[viewsetObject.month],settings.klass.month)},createYearLabel=function(override){var focusedYear=viewsetObject.year,numberYears=settings.selectYears===true?5:~~(settings.selectYears/2);if(numberYears){var minYear=minLimitObject.year,maxYear=maxLimitObject.year,lowestYear=focusedYear-numberYears,highestYear=focusedYear+numberYears;if(minYear>lowestYear){highestYear+=minYear-lowestYear;lowestYear=minYear}if(maxYear<highestYear){var availableYears=lowestYear-minYear,neededYears=highestYear-maxYear;lowestYear-=availableYears>neededYears?neededYears:availableYears;highestYear=maxYear}if(settings.selectYears&&override==undefined){return _.node("select",_.group({min:lowestYear,max:highestYear,i:1,node:"option",item:function(loopedYear){return[loopedYear,0,"value="+loopedYear+(focusedYear==loopedYear?" selected":"")]
1
+ (function(factory){if(typeof define=="function"&&define.amd){define("picker",["jquery"],factory)}else{if(typeof exports=="object"){module.exports=factory(require("jquery"))}else{this.Picker=factory(jQuery)}}}(function($){var $window=$(window);var $document=$(document);var $html=$(document.documentElement);function PickerConstructor(ELEMENT,NAME,COMPONENT,OPTIONS){if(!ELEMENT){return PickerConstructor}var IS_DEFAULT_THEME=false,STATE={id:ELEMENT.id||"P"+Math.abs(~~(Math.random()*new Date()))},SETTINGS=COMPONENT?$.extend(true,{},COMPONENT.defaults,OPTIONS):OPTIONS||{},CLASSES=$.extend({},PickerConstructor.klasses(),SETTINGS.klass),$ELEMENT=$(ELEMENT),PickerInstance=function(){return this.start()},P=PickerInstance.prototype={constructor:PickerInstance,$node:$ELEMENT,start:function(){if(STATE&&STATE.start){return P}STATE.methods={};STATE.start=true;STATE.open=false;STATE.type=ELEMENT.type;ELEMENT.autofocus=ELEMENT==getActiveElement();ELEMENT.readOnly=!SETTINGS.editable;ELEMENT.id=ELEMENT.id||STATE.id;if(ELEMENT.type!="text"){ELEMENT.type="text"}P.component=new COMPONENT(P,SETTINGS);P.$root=$(PickerConstructor._.node("div",createWrappedComponent(),CLASSES.picker,'id="'+ELEMENT.id+'_root" tabindex="0"'));prepareElementRoot();if(SETTINGS.formatSubmit){prepareElementHidden()}prepareElement();if(SETTINGS.container){$(SETTINGS.container).append(P.$root)}else{$ELEMENT.after(P.$root)}P.on({start:P.component.onStart,render:P.component.onRender,stop:P.component.onStop,open:P.component.onOpen,close:P.component.onClose,set:P.component.onSet}).on({start:SETTINGS.onStart,render:SETTINGS.onRender,stop:SETTINGS.onStop,open:SETTINGS.onOpen,close:SETTINGS.onClose,set:SETTINGS.onSet});IS_DEFAULT_THEME=isUsingDefaultTheme(P.$root.children()[0]);if(ELEMENT.autofocus){P.open()}return P.trigger("start").trigger("render")},render:function(entireComponent){if(entireComponent){P.$root.html(createWrappedComponent())}else{P.$root.find("."+CLASSES.box).html(P.component.nodes(STATE.open))}return P.trigger("render")},stop:function(){if(!STATE.start){return P}P.close();if(P._hidden){P._hidden.parentNode.removeChild(P._hidden)}P.$root.remove();$ELEMENT.removeClass(CLASSES.input).removeData(NAME);setTimeout(function(){$ELEMENT.off("."+STATE.id)},0);ELEMENT.type=STATE.type;ELEMENT.readOnly=false;P.trigger("stop");STATE.methods={};STATE.start=false;return P},open:function(dontGiveFocus){if(STATE.open){return P}$ELEMENT.addClass(CLASSES.active);aria(ELEMENT,"expanded",true);setTimeout(function(){P.$root.addClass(CLASSES.opened);aria(P.$root[0],"hidden",false)},0);if(dontGiveFocus!==false){STATE.open=true;if(IS_DEFAULT_THEME){$html.css("overflow","hidden").css("padding-right","+="+getScrollbarWidth())}P.$root.eq(0).focus();$document.on("click."+STATE.id+" focusin."+STATE.id,function(event){var target=event.target;if(target!=ELEMENT&&target!=document&&event.which!=3){P.close(target===P.$root.children()[0])}}).on("keydown."+STATE.id,function(event){var keycode=event.keyCode,keycodeToMove=P.component.key[keycode],target=event.target;if(keycode==27){P.close(true)}else{if(target==P.$root[0]&&(keycodeToMove||keycode==13)){event.preventDefault();if(keycodeToMove){PickerConstructor._.trigger(P.component.key.go,P,[PickerConstructor._.trigger(keycodeToMove)])}else{if(!P.$root.find("."+CLASSES.highlighted).hasClass(CLASSES.disabled)){P.set("select",P.component.item.highlight).close()}}}else{if($.contains(P.$root[0],target)&&keycode==13){event.preventDefault();target.click()}}}})}return P.trigger("open")},close:function(giveFocus){if(giveFocus){P.$root.off("focus.toOpen").eq(0).focus();setTimeout(function(){P.$root.on("focus.toOpen",handleFocusToOpenEvent)},0)}$ELEMENT.removeClass(CLASSES.active);aria(ELEMENT,"expanded",false);setTimeout(function(){P.$root.removeClass(CLASSES.opened+" "+CLASSES.focused);aria(P.$root[0],"hidden",true)},0);if(!STATE.open){return P}STATE.open=false;if(IS_DEFAULT_THEME){$html.css("overflow","").css("padding-right","-="+getScrollbarWidth())}$document.off("."+STATE.id);return P.trigger("close")},clear:function(options){return P.set("clear",null,options)},set:function(thing,value,options){var thingItem,thingValue,thingIsObject=$.isPlainObject(thing),thingObject=thingIsObject?thing:{};options=thingIsObject&&$.isPlainObject(value)?value:options||{};if(thing){if(!thingIsObject){thingObject[thing]=value}for(thingItem in thingObject){thingValue=thingObject[thingItem];if(thingItem in P.component.item){if(thingValue===undefined){thingValue=null}P.component.set(thingItem,thingValue,options)}if(thingItem=="select"||thingItem=="clear"){$ELEMENT.val(thingItem=="clear"?"":P.get(thingItem,SETTINGS.format)).trigger("change")}}P.render()}return options.muted?P:P.trigger("set",thingObject)},get:function(thing,format){thing=thing||"value";if(STATE[thing]!=null){return STATE[thing]}if(thing=="valueSubmit"){if(P._hidden){return P._hidden.value}thing="value"}if(thing=="value"){return ELEMENT.value}if(thing in P.component.item){if(typeof format=="string"){var thingValue=P.component.get(thing);
2
+ return thingValue?PickerConstructor._.trigger(P.component.formats.toString,P.component,[format,thingValue]):""}return P.component.get(thing)}},on:function(thing,method,internal){var thingName,thingMethod,thingIsObject=$.isPlainObject(thing),thingObject=thingIsObject?thing:{};if(thing){if(!thingIsObject){thingObject[thing]=method}for(thingName in thingObject){thingMethod=thingObject[thingName];if(internal){thingName="_"+thingName}STATE.methods[thingName]=STATE.methods[thingName]||[];STATE.methods[thingName].push(thingMethod)}}return P},off:function(){var i,thingName,names=arguments;for(i=0,namesCount=names.length;i<namesCount;i+=1){thingName=names[i];if(thingName in STATE.methods){delete STATE.methods[thingName]}}return P},trigger:function(name,data){var _trigger=function(name){var methodList=STATE.methods[name];if(methodList){methodList.map(function(method){PickerConstructor._.trigger(method,P,[data])})}};_trigger("_"+name);_trigger(name);return P}};function createWrappedComponent(){return PickerConstructor._.node("div",PickerConstructor._.node("div",PickerConstructor._.node("div",PickerConstructor._.node("div",P.component.nodes(STATE.open),CLASSES.box),CLASSES.wrap),CLASSES.frame),CLASSES.holder)}function prepareElement(){$ELEMENT.data(NAME,P).addClass(CLASSES.input).attr("tabindex",-1).val($ELEMENT.data("value")?P.get("select",SETTINGS.format):ELEMENT.value);if(!SETTINGS.editable){$ELEMENT.on("focus."+STATE.id+" click."+STATE.id,function(event){event.preventDefault();P.$root.eq(0).focus()}).on("keydown."+STATE.id,handleKeydownEvent)}aria(ELEMENT,{haspopup:true,expanded:false,readonly:false,owns:ELEMENT.id+"_root"})}function prepareElementRoot(){P.$root.on({keydown:handleKeydownEvent,focusin:function(event){P.$root.removeClass(CLASSES.focused);event.stopPropagation()},"mousedown click":function(event){var target=event.target;if(target!=P.$root.children()[0]){event.stopPropagation();if(event.type=="mousedown"&&!$(target).is("input, select, textarea, button, option")){event.preventDefault();P.$root.eq(0).focus()}}}}).on({focus:function(){$ELEMENT.addClass(CLASSES.target)},blur:function(){$ELEMENT.removeClass(CLASSES.target)}}).on("focus.toOpen",handleFocusToOpenEvent).on("click","[data-pick], [data-nav], [data-clear], [data-close]",function(){var $target=$(this),targetData=$target.data(),targetDisabled=$target.hasClass(CLASSES.navDisabled)||$target.hasClass(CLASSES.disabled),activeElement=getActiveElement();activeElement=activeElement&&(activeElement.type||activeElement.href);if(targetDisabled||activeElement&&!$.contains(P.$root[0],activeElement)){P.$root.eq(0).focus()}if(!targetDisabled&&targetData.nav){P.set("highlight",P.component.item.highlight,{nav:targetData.nav})}else{if(!targetDisabled&&"pick" in targetData){P.set("select",targetData.pick)}else{if(targetData.clear){P.clear().close(true)}else{if(targetData.close){P.close(true)}}}}});aria(P.$root[0],"hidden",true)}function prepareElementHidden(){var name;if(SETTINGS.hiddenName===true){name=ELEMENT.name;ELEMENT.name=""}else{name=[typeof SETTINGS.hiddenPrefix=="string"?SETTINGS.hiddenPrefix:"",typeof SETTINGS.hiddenSuffix=="string"?SETTINGS.hiddenSuffix:"_submit"];name=name[0]+ELEMENT.name+name[1]}P._hidden=$("<input "+"type=hidden "+'name="'+name+'"'+($ELEMENT.data("value")||ELEMENT.value?' value="'+P.get("select",SETTINGS.formatSubmit)+'"':"")+">")[0];$ELEMENT.on("change."+STATE.id,function(){P._hidden.value=ELEMENT.value?P.get("select",SETTINGS.formatSubmit):""});if(SETTINGS.container){$(SETTINGS.container).append(P._hidden)}else{$ELEMENT.after(P._hidden)}}function handleKeydownEvent(event){var keycode=event.keyCode,isKeycodeDelete=/^(8|46)$/.test(keycode);if(keycode==27){P.close();return false}if(keycode==32||isKeycodeDelete||!STATE.open&&P.component.key[keycode]){event.preventDefault();event.stopPropagation();if(isKeycodeDelete){P.clear().close()}else{P.open()}}}function handleFocusToOpenEvent(event){event.stopPropagation();if(event.type=="focus"){P.$root.addClass(CLASSES.focused)}P.open()}return new PickerInstance()}PickerConstructor.klasses=function(prefix){prefix=prefix||"picker";return{picker:prefix,opened:prefix+"--opened",focused:prefix+"--focused",input:prefix+"__input",active:prefix+"__input--active",target:prefix+"__input--target",holder:prefix+"__holder",frame:prefix+"__frame",wrap:prefix+"__wrap",box:prefix+"__box"}};function isUsingDefaultTheme(element){var theme,prop="position";if(element.currentStyle){theme=element.currentStyle[prop]}else{if(window.getComputedStyle){theme=getComputedStyle(element)[prop]}}return theme=="fixed"}function getScrollbarWidth(){if($html.height()<=$window.height()){return 0}var $outer=$('<div style="visibility:hidden;width:100px" />').appendTo("body");var widthWithoutScroll=$outer[0].offsetWidth;$outer.css("overflow","scroll");var $inner=$('<div style="width:100%" />').appendTo($outer);var widthWithScroll=$inner[0].offsetWidth;$outer.remove();return widthWithoutScroll-widthWithScroll}PickerConstructor._={group:function(groupObject){var loopObjectScope,nodesList="",counter=PickerConstructor._.trigger(groupObject.min,groupObject);
3
+ for(;counter<=PickerConstructor._.trigger(groupObject.max,groupObject,[counter]);counter+=groupObject.i){loopObjectScope=PickerConstructor._.trigger(groupObject.item,groupObject,[counter]);nodesList+=PickerConstructor._.node(groupObject.node,loopObjectScope[0],loopObjectScope[1],loopObjectScope[2])}return nodesList},node:function(wrapper,item,klass,attribute){if(!item){return""}item=$.isArray(item)?item.join(""):item;klass=klass?' class="'+klass+'"':"";attribute=attribute?" "+attribute:"";return"<"+wrapper+klass+attribute+">"+item+"</"+wrapper+">"},lead:function(number){return(number<10?"0":"")+number},trigger:function(callback,scope,args){return typeof callback=="function"?callback.apply(scope,args||[]):callback},digits:function(string){return(/\d/).test(string[1])?2:1},isDate:function(value){return{}.toString.call(value).indexOf("Date")>-1&&this.isInteger(value.getDate())},isInteger:function(value){return{}.toString.call(value).indexOf("Number")>-1&&value%1===0},ariaAttr:ariaAttr};PickerConstructor.extend=function(name,Component){$.fn[name]=function(options,action){var componentData=this.data(name);if(options=="picker"){return componentData}if(componentData&&typeof options=="string"){return PickerConstructor._.trigger(componentData[options],componentData,[action])}return this.each(function(){var $this=$(this);if(!$this.data(name)){new PickerConstructor(this,name,Component,options)}})};$.fn[name].defaults=Component.defaults};function aria(element,attribute,value){if($.isPlainObject(attribute)){for(var key in attribute){ariaSet(element,key,attribute[key])}}else{ariaSet(element,attribute,value)}}function ariaSet(element,attribute,value){element.setAttribute((attribute=="role"?"":"aria-")+attribute,value)}function ariaAttr(attribute,data){if(!$.isPlainObject(attribute)){attribute={attribute:data}}data="";for(var key in attribute){var attr=(key=="role"?"":"aria-")+key,attrVal=attribute[key];data+=attrVal==null?"":attr+'="'+attribute[key]+'"'}return data}function getActiveElement(){try{return document.activeElement}catch(err){}}return PickerConstructor}));
4
+
5
+ (function(factory){if(typeof define=="function"&&define.amd){define(["picker","jquery"],factory)}else{if(typeof exports=="object"){module.exports=factory(require("./picker.js"),require("jquery"))}else{factory(Picker,jQuery)}}}(function(Picker,$){var DAYS_IN_WEEK=7,WEEKS_IN_CALENDAR=6,_=Picker._;function DatePicker(picker,settings){var calendar=this,element=picker.$node[0],elementValue=element.value,elementDataValue=picker.$node.data("value"),valueString=elementDataValue||elementValue,formatString=elementDataValue?settings.formatSubmit:settings.format,isRTL=function(){return element.currentStyle?element.currentStyle.direction=="rtl":getComputedStyle(picker.$root[0]).direction=="rtl"};calendar.settings=settings;calendar.$node=picker.$node;calendar.queue={min:"measure create",max:"measure create",now:"now create",select:"parse create validate",highlight:"parse navigate create validate",view:"parse create validate viewset",disable:"deactivate",enable:"activate"};calendar.item={};calendar.item.clear=null;calendar.item.disable=(settings.disable||[]).slice(0);calendar.item.enable=-(function(collectionDisabled){return collectionDisabled[0]===true?collectionDisabled.shift():-1})(calendar.item.disable);calendar.set("min",settings.min).set("max",settings.max).set("now");if(valueString){calendar.set("select",valueString,{format:formatString})}else{calendar.set("select",null).set("highlight",calendar.item.now)}calendar.key={40:7,38:-7,39:function(){return isRTL()?-1:1},37:function(){return isRTL()?1:-1},go:function(timeChange){var highlightedObject=calendar.item.highlight,targetDate=new Date(highlightedObject.year,highlightedObject.month,highlightedObject.date+timeChange);calendar.set("highlight",targetDate,{interval:timeChange});this.render()}};picker.on("render",function(){picker.$root.find("."+settings.klass.selectMonth).on("change",function(){var value=this.value;if(value){picker.set("highlight",[picker.get("view").year,value,picker.get("highlight").date]);picker.$root.find("."+settings.klass.selectMonth).trigger("focus")}});picker.$root.find("."+settings.klass.selectYear).on("change",function(){var value=this.value;if(value){picker.set("highlight",[value,picker.get("view").month,picker.get("highlight").date]);picker.$root.find("."+settings.klass.selectYear).trigger("focus")}})},1).on("open",function(){var includeToday="";if(calendar.disabled(calendar.get("now"))){includeToday=":not(."+settings.klass.buttonToday+")"}picker.$root.find("button"+includeToday+", select").attr("disabled",false)},1).on("close",function(){picker.$root.find("button, select").attr("disabled",true)},1)}DatePicker.prototype.set=function(type,value,options){var calendar=this,calendarItem=calendar.item;if(value===null){if(type=="clear"){type="select"}calendarItem[type]=value;return calendar}calendarItem[(type=="enable"?"disable":type=="flip"?"enable":type)]=calendar.queue[type].split(" ").map(function(method){value=calendar[method](type,value,options);
6
+ return value}).pop();if(type=="select"){calendar.set("highlight",calendarItem.select,options)}else{if(type=="highlight"){calendar.set("view",calendarItem.highlight,options)}else{if(type.match(/^(flip|min|max|disable|enable)$/)){if(calendarItem.select&&calendar.disabled(calendarItem.select)){calendar.set("select",calendarItem.select,options)}if(calendarItem.highlight&&calendar.disabled(calendarItem.highlight)){calendar.set("highlight",calendarItem.highlight,options)}}}}return calendar};DatePicker.prototype.get=function(type){return this.item[type]};DatePicker.prototype.create=function(type,value,options){var isInfiniteValue,calendar=this;value=value===undefined?type:value;if(value==-Infinity||value==Infinity){isInfiniteValue=value}else{if($.isPlainObject(value)&&_.isInteger(value.pick)){value=value.obj}else{if($.isArray(value)){value=new Date(value[0],value[1],value[2]);value=_.isDate(value)?value:calendar.create().obj}else{if(_.isInteger(value)||_.isDate(value)){value=calendar.normalize(new Date(value),options)}else{value=calendar.now(type,value,options)}}}}return{year:isInfiniteValue||value.getFullYear(),month:isInfiniteValue||value.getMonth(),date:isInfiniteValue||value.getDate(),day:isInfiniteValue||value.getDay(),obj:isInfiniteValue||value,pick:isInfiniteValue||value.getTime()}};DatePicker.prototype.createRange=function(from,to){var calendar=this,createDate=function(date){if(date===true||$.isArray(date)||_.isDate(date)){return calendar.create(date)}return date};if(!_.isInteger(from)){from=createDate(from)}if(!_.isInteger(to)){to=createDate(to)}if(_.isInteger(from)&&$.isPlainObject(to)){from=[to.year,to.month,to.date+from]}else{if(_.isInteger(to)&&$.isPlainObject(from)){to=[from.year,from.month,from.date+to]}}return{from:createDate(from),to:createDate(to)}};DatePicker.prototype.withinRange=function(range,dateUnit){range=this.createRange(range.from,range.to);return dateUnit.pick>=range.from.pick&&dateUnit.pick<=range.to.pick};DatePicker.prototype.overlapRanges=function(one,two){var calendar=this;one=calendar.createRange(one.from,one.to);two=calendar.createRange(two.from,two.to);return calendar.withinRange(one,two.from)||calendar.withinRange(one,two.to)||calendar.withinRange(two,one.from)||calendar.withinRange(two,one.to)};DatePicker.prototype.now=function(type,value,options){value=new Date();if(options&&options.rel){value.setDate(value.getDate()+options.rel)}return this.normalize(value,options)};DatePicker.prototype.navigate=function(type,value,options){var targetDateObject,targetYear,targetMonth,targetDate,isTargetArray=$.isArray(value),isTargetObject=$.isPlainObject(value),viewsetObject=this.item.view;if(isTargetArray||isTargetObject){if(isTargetObject){targetYear=value.year;targetMonth=value.month;targetDate=value.date}else{targetYear=+value[0];targetMonth=+value[1];targetDate=+value[2]}if(options&&options.nav&&viewsetObject&&viewsetObject.month!==targetMonth){targetYear=viewsetObject.year;targetMonth=viewsetObject.month}targetDateObject=new Date(targetYear,targetMonth+(options&&options.nav?options.nav:0),1);targetYear=targetDateObject.getFullYear();targetMonth=targetDateObject.getMonth();while(new Date(targetYear,targetMonth,targetDate).getMonth()!==targetMonth){targetDate-=1}value=[targetYear,targetMonth,targetDate]}return value};DatePicker.prototype.normalize=function(value){value.setHours(0,0,0,0);return value};DatePicker.prototype.measure=function(type,value){var calendar=this;if(!value){value=type=="min"?-Infinity:Infinity}else{if(typeof value=="string"){value=calendar.parse(type,value)}else{if(_.isInteger(value)){value=calendar.now(type,value,{rel:value})}}}return value};DatePicker.prototype.viewset=function(type,dateObject){return this.create([dateObject.year,dateObject.month,1])};DatePicker.prototype.validate=function(type,dateObject,options){var calendar=this,originalDateObject=dateObject,interval=options&&options.interval?options.interval:1,isFlippedBase=calendar.item.enable===-1,hasEnabledBeforeTarget,hasEnabledAfterTarget,minLimitObject=calendar.item.min,maxLimitObject=calendar.item.max,reachedMin,reachedMax,hasEnabledWeekdays=isFlippedBase&&calendar.item.disable.filter(function(value){if($.isArray(value)){var dateTime=calendar.create(value).pick;if(dateTime<dateObject.pick){hasEnabledBeforeTarget=true}else{if(dateTime>dateObject.pick){hasEnabledAfterTarget=true}}}return _.isInteger(value)}).length;if(!options||!options.nav){if((!isFlippedBase&&calendar.disabled(dateObject))||(isFlippedBase&&calendar.disabled(dateObject)&&(hasEnabledWeekdays||hasEnabledBeforeTarget||hasEnabledAfterTarget))||(!isFlippedBase&&(dateObject.pick<=minLimitObject.pick||dateObject.pick>=maxLimitObject.pick))){if(isFlippedBase&&!hasEnabledWeekdays&&((!hasEnabledAfterTarget&&interval>0)||(!hasEnabledBeforeTarget&&interval<0))){interval*=-1}while(calendar.disabled(dateObject)){if(Math.abs(interval)>1&&(dateObject.month<originalDateObject.month||dateObject.month>originalDateObject.month)){dateObject=originalDateObject;
7
+ interval=interval>0?1:-1}if(dateObject.pick<=minLimitObject.pick){reachedMin=true;interval=1;dateObject=calendar.create([minLimitObject.year,minLimitObject.month,minLimitObject.date+(dateObject.pick===minLimitObject.pick?0:-1)])}else{if(dateObject.pick>=maxLimitObject.pick){reachedMax=true;interval=-1;dateObject=calendar.create([maxLimitObject.year,maxLimitObject.month,maxLimitObject.date+(dateObject.pick===maxLimitObject.pick?0:1)])}}if(reachedMin&&reachedMax){break}dateObject=calendar.create([dateObject.year,dateObject.month,dateObject.date+interval])}}}return dateObject};DatePicker.prototype.disabled=function(dateToVerify){var calendar=this,isDisabledMatch=calendar.item.disable.filter(function(dateToDisable){if(_.isInteger(dateToDisable)){return dateToVerify.day===(calendar.settings.firstDay?dateToDisable:dateToDisable-1)%7}if($.isArray(dateToDisable)||_.isDate(dateToDisable)){return dateToVerify.pick===calendar.create(dateToDisable).pick}if($.isPlainObject(dateToDisable)){return calendar.withinRange(dateToDisable,dateToVerify)}});isDisabledMatch=isDisabledMatch.length&&!isDisabledMatch.filter(function(dateToDisable){return $.isArray(dateToDisable)&&dateToDisable[3]=="inverted"||$.isPlainObject(dateToDisable)&&dateToDisable.inverted}).length;return calendar.item.enable===-1?!isDisabledMatch:isDisabledMatch||dateToVerify.pick<calendar.item.min.pick||dateToVerify.pick>calendar.item.max.pick};DatePicker.prototype.parse=function(type,value,options){var calendar=this,parsingObject={};if(!value||typeof value!="string"){return value}if(!(options&&options.format)){options=options||{};options.format=calendar.settings.format}calendar.formats.toArray(options.format).map(function(label){var formattingLabel=calendar.formats[label],formatLength=formattingLabel?_.trigger(formattingLabel,calendar,[value,parsingObject]):label.replace(/^!/,"").length;if(formattingLabel){parsingObject[label]=value.substr(0,formatLength)}value=value.substr(formatLength)});return[parsingObject.yyyy||parsingObject.yy,+(parsingObject.mm||parsingObject.m)-1,parsingObject.dd||parsingObject.d]};DatePicker.prototype.formats=(function(){function getWordLengthFromCollection(string,collection,dateObject){var word=string.match(/\w+/)[0];if(!dateObject.mm&&!dateObject.m){dateObject.m=collection.indexOf(word)+1}return word.length}function getFirstWordLength(string){return string.match(/\w+/)[0].length}return{d:function(string,dateObject){return string?_.digits(string):dateObject.date},dd:function(string,dateObject){return string?2:_.lead(dateObject.date)},ddd:function(string,dateObject){return string?getFirstWordLength(string):this.settings.weekdaysShort[dateObject.day]},dddd:function(string,dateObject){return string?getFirstWordLength(string):this.settings.weekdaysFull[dateObject.day]},m:function(string,dateObject){return string?_.digits(string):dateObject.month+1},mm:function(string,dateObject){return string?2:_.lead(dateObject.month+1)},mmm:function(string,dateObject){var collection=this.settings.monthsShort;return string?getWordLengthFromCollection(string,collection,dateObject):collection[dateObject.month]},mmmm:function(string,dateObject){var collection=this.settings.monthsFull;return string?getWordLengthFromCollection(string,collection,dateObject):collection[dateObject.month]},yy:function(string,dateObject){return string?2:(""+dateObject.year).slice(2)},yyyy:function(string,dateObject){return string?4:dateObject.year},toArray:function(formatString){return formatString.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g)},toString:function(formatString,itemObject){var calendar=this;return calendar.formats.toArray(formatString).map(function(label){return _.trigger(calendar.formats[label],calendar,[0,itemObject])||label.replace(/^!/,"")}).join("")}}})();DatePicker.prototype.isDateExact=function(one,two){var calendar=this;if((_.isInteger(one)&&_.isInteger(two))||(typeof one=="boolean"&&typeof two=="boolean")){return one===two}if((_.isDate(one)||$.isArray(one))&&(_.isDate(two)||$.isArray(two))){return calendar.create(one).pick===calendar.create(two).pick}if($.isPlainObject(one)&&$.isPlainObject(two)){return calendar.isDateExact(one.from,two.from)&&calendar.isDateExact(one.to,two.to)}return false};DatePicker.prototype.isDateOverlap=function(one,two){var calendar=this,firstDay=calendar.settings.firstDay?1:0;if(_.isInteger(one)&&(_.isDate(two)||$.isArray(two))){one=one%7+firstDay;return one===calendar.create(two).day+1}if(_.isInteger(two)&&(_.isDate(one)||$.isArray(one))){two=two%7+firstDay;return two===calendar.create(one).day+1}if($.isPlainObject(one)&&$.isPlainObject(two)){return calendar.overlapRanges(one,two)}return false};DatePicker.prototype.flipEnable=function(val){var itemObject=this.item;itemObject.enable=val||(itemObject.enable==-1?1:-1)};DatePicker.prototype.deactivate=function(type,datesToDisable){var calendar=this,disabledItems=calendar.item.disable.slice(0);if(datesToDisable=="flip"){calendar.flipEnable()}else{if(datesToDisable===false){calendar.flipEnable(1);
8
+ disabledItems=[]}else{if(datesToDisable===true){calendar.flipEnable(-1);disabledItems=[]}else{datesToDisable.map(function(unitToDisable){var matchFound;for(var index=0;index<disabledItems.length;index+=1){if(calendar.isDateExact(unitToDisable,disabledItems[index])){matchFound=true;break}}if(!matchFound){if(_.isInteger(unitToDisable)||_.isDate(unitToDisable)||$.isArray(unitToDisable)||($.isPlainObject(unitToDisable)&&unitToDisable.from&&unitToDisable.to)){disabledItems.push(unitToDisable)}}})}}}return disabledItems};DatePicker.prototype.activate=function(type,datesToEnable){var calendar=this,disabledItems=calendar.item.disable,disabledItemsCount=disabledItems.length;if(datesToEnable=="flip"){calendar.flipEnable()}else{if(datesToEnable===true){calendar.flipEnable(1);disabledItems=[]}else{if(datesToEnable===false){calendar.flipEnable(-1);disabledItems=[]}else{datesToEnable.map(function(unitToEnable){var matchFound,disabledUnit,index,isExactRange;for(index=0;index<disabledItemsCount;index+=1){disabledUnit=disabledItems[index];if(calendar.isDateExact(disabledUnit,unitToEnable)){matchFound=disabledItems[index]=null;isExactRange=true;break}else{if(calendar.isDateOverlap(disabledUnit,unitToEnable)){if($.isPlainObject(unitToEnable)){unitToEnable.inverted=true;matchFound=unitToEnable}else{if($.isArray(unitToEnable)){matchFound=unitToEnable;if(!matchFound[3]){matchFound.push("inverted")}}else{if(_.isDate(unitToEnable)){matchFound=[unitToEnable.getFullYear(),unitToEnable.getMonth(),unitToEnable.getDate(),"inverted"]}}}break}}}if(matchFound){for(index=0;index<disabledItemsCount;index+=1){if(calendar.isDateExact(disabledItems[index],unitToEnable)){disabledItems[index]=null;break}}}if(isExactRange){for(index=0;index<disabledItemsCount;index+=1){if(calendar.isDateOverlap(disabledItems[index],unitToEnable)){disabledItems[index]=null;break}}}if(matchFound){disabledItems.push(matchFound)}})}}}return disabledItems.filter(function(val){return val!=null})};DatePicker.prototype.nodes=function(isOpen){var calendar=this,settings=calendar.settings,calendarItem=calendar.item,nowObject=calendarItem.now,selectedObject=calendarItem.select,highlightedObject=calendarItem.highlight,viewsetObject=calendarItem.view,disabledCollection=calendarItem.disable,minLimitObject=calendarItem.min,maxLimitObject=calendarItem.max,tableHead=(function(collection,fullCollection){if(settings.firstDay){collection.push(collection.shift());fullCollection.push(fullCollection.shift())}return _.node("thead",_.node("tr",_.group({min:0,max:DAYS_IN_WEEK-1,i:1,node:"th",item:function(counter){return[collection[counter],settings.klass.weekdays,'scope=col title="'+fullCollection[counter]+'"']}})))})((settings.showWeekdaysFull?settings.weekdaysFull:settings.weekdaysLetter).slice(0),settings.weekdaysFull.slice(0)),createMonthNav=function(next){return _.node("div"," ",settings.klass["nav"+(next?"Next":"Prev")]+((next&&viewsetObject.year>=maxLimitObject.year&&viewsetObject.month>=maxLimitObject.month)||(!next&&viewsetObject.year<=minLimitObject.year&&viewsetObject.month<=minLimitObject.month)?" "+settings.klass.navDisabled:""),"data-nav="+(next||-1)+" "+_.ariaAttr({role:"button",controls:calendar.$node[0].id+"_table"})+" "+'title="'+(next?settings.labelMonthNext:settings.labelMonthPrev)+'"')},createMonthLabel=function(override){var monthsCollection=settings.showMonthsShort?settings.monthsShort:settings.monthsFull;if(override=="short_months"){monthsCollection=settings.monthsShort}if(settings.selectMonths&&override==undefined){return _.node("select",_.group({min:0,max:11,i:1,node:"option",item:function(loopedMonth){return[monthsCollection[loopedMonth],0,"value="+loopedMonth+(viewsetObject.month==loopedMonth?" selected":"")+(((viewsetObject.year==minLimitObject.year&&loopedMonth<minLimitObject.month)||(viewsetObject.year==maxLimitObject.year&&loopedMonth>maxLimitObject.month))?" disabled":"")]}}),settings.klass.selectMonth+" browser-default",(isOpen?"":"disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id+"_table"})+" "+'title="'+settings.labelMonthSelect+'"')}if(override=="short_months"){if(selectedObject!=null){return _.node("div",monthsCollection[selectedObject.month])}else{return _.node("div",monthsCollection[viewsetObject.month])}}return _.node("div",monthsCollection[viewsetObject.month],settings.klass.month)},createYearLabel=function(override){var focusedYear=viewsetObject.year,numberYears=settings.selectYears===true?5:~~(settings.selectYears/2);if(numberYears){var minYear=minLimitObject.year,maxYear=maxLimitObject.year,lowestYear=focusedYear-numberYears,highestYear=focusedYear+numberYears;if(minYear>lowestYear){highestYear+=minYear-lowestYear;lowestYear=minYear}if(maxYear<highestYear){var availableYears=lowestYear-minYear,neededYears=highestYear-maxYear;lowestYear-=availableYears>neededYears?neededYears:availableYears;highestYear=maxYear}if(settings.selectYears&&override==undefined){return _.node("select",_.group({min:lowestYear,max:highestYear,i:1,node:"option",item:function(loopedYear){return[loopedYear,0,"value="+loopedYear+(focusedYear==loopedYear?" selected":"")]
9
9
  }}),settings.klass.selectYear+" browser-default",(isOpen?"":"disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id+"_table"})+" "+'title="'+settings.labelYearSelect+'"')}}if(override=="raw"){return _.node("div",focusedYear)}return _.node("div",focusedYear,settings.klass.year)};createDayLabel=function(){if(selectedObject!=null){return _.node("div",selectedObject.date)}else{return _.node("div",nowObject.date)}};createWeekdayLabel=function(){var display_day;if(selectedObject!=null){display_day=selectedObject.day}else{display_day=nowObject.day}var weekday=settings.weekdaysFull[display_day];return weekday};return _.node("div",_.node("div",createWeekdayLabel(),"picker__weekday-display")+_.node("div",createMonthLabel("short_months"),settings.klass.month_display)+_.node("div",createDayLabel(),settings.klass.day_display)+_.node("div",createYearLabel("raw"),settings.klass.year_display),settings.klass.date_display)+_.node("div",_.node("div",(settings.selectYears?createMonthLabel()+createYearLabel():createMonthLabel()+createYearLabel())+createMonthNav()+createMonthNav(1),settings.klass.header)+_.node("table",tableHead+_.node("tbody",_.group({min:0,max:WEEKS_IN_CALENDAR-1,i:1,node:"tr",item:function(rowCounter){var shiftDateBy=settings.firstDay&&calendar.create([viewsetObject.year,viewsetObject.month,1]).day===0?-7:0;return[_.group({min:DAYS_IN_WEEK*rowCounter-viewsetObject.day+shiftDateBy+1,max:function(){return this.min+DAYS_IN_WEEK-1},i:1,node:"td",item:function(targetDate){targetDate=calendar.create([viewsetObject.year,viewsetObject.month,targetDate+(settings.firstDay?1:0)]);var isSelected=selectedObject&&selectedObject.pick==targetDate.pick,isHighlighted=highlightedObject&&highlightedObject.pick==targetDate.pick,isDisabled=disabledCollection&&calendar.disabled(targetDate)||targetDate.pick<minLimitObject.pick||targetDate.pick>maxLimitObject.pick,formattedDate=_.trigger(calendar.formats.toString,calendar,[settings.format,targetDate]);return[_.node("div",targetDate.date,(function(klasses){klasses.push(viewsetObject.month==targetDate.month?settings.klass.infocus:settings.klass.outfocus);if(nowObject.pick==targetDate.pick){klasses.push(settings.klass.now)}if(isSelected){klasses.push(settings.klass.selected)}if(isHighlighted){klasses.push(settings.klass.highlighted)}if(isDisabled){klasses.push(settings.klass.disabled)}return klasses.join(" ")})([settings.klass.day]),"data-pick="+targetDate.pick+" "+_.ariaAttr({role:"gridcell",label:formattedDate,selected:isSelected&&calendar.$node.val()===formattedDate?true:null,activedescendant:isHighlighted?true:null,disabled:isDisabled?true:null})),"",_.ariaAttr({role:"presentation"})]}})]}})),settings.klass.table,'id="'+calendar.$node[0].id+"_table"+'" '+_.ariaAttr({role:"grid",controls:calendar.$node[0].id,readonly:true})),settings.klass.calendar_container)+_.node("div",_.node("button",settings.today,"mdui-btn picker__today","type=button data-pick="+nowObject.pick+(isOpen&&!calendar.disabled(nowObject)?"":" disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id}))+_.node("button",settings.clear,"mdui-btn picker__clear","type=button data-clear=1"+(isOpen?"":" disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id}))+_.node("button",settings.close,"mdui-btn picker__close","type=button data-close=true "+(isOpen?"":" disabled")+" "+_.ariaAttr({controls:calendar.$node[0].id})),settings.klass.footer)};DatePicker.defaults=(function(prefix){return{labelMonthNext:"Next month",labelMonthPrev:"Previous month",labelMonthSelect:"Select a month",labelYearSelect:"Select a year",monthsFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdaysFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],weekdaysLetter:["S","M","T","W","T","F","S"],today:"Today",clear:"Clear",close:"Close",format:"d mmmm, yyyy",klass:{table:prefix+"table",header:prefix+"header",date_display:prefix+"date-display",day_display:prefix+"day-display",month_display:prefix+"month-display",year_display:prefix+"year-display",calendar_container:prefix+"calendar-container",navPrev:prefix+"nav--prev",navNext:prefix+"nav--next",navDisabled:prefix+"nav--disabled",month:prefix+"month",year:prefix+"year",selectMonth:prefix+"select--month",selectYear:prefix+"select--year",weekdays:prefix+"weekday",day:prefix+"day",disabled:prefix+"day--disabled",selected:prefix+"day--selected",highlighted:prefix+"day--highlighted",now:prefix+"day--today",infocus:prefix+"day--infocus",outfocus:prefix+"day--outfocus",footer:prefix+"footer",buttonClear:prefix+"button--clear",buttonToday:prefix+"button--today",buttonClose:prefix+"button--close"}}})(Picker.klasses().picker+"__");Picker.extend("pickadate",DatePicker)}));
data/assets/js/pushpin.js CHANGED
@@ -1 +1 @@
1
- Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){$.fn.pushpin=function(options){var defaults={top:0,bottom:Infinity,offset:0};if(options==="remove"){this.each(function(){if(id=$(this).data("pushpin-id")){$(window).off("scroll."+id);$(this).removeData("pushpin-id").removeClass("pin-top pinned pin-bottom").removeAttr("style")}});return false}options=$.extend(defaults,options);$index=0;return this.each(function(){var $uniqueId=Materialize.guid(),$this=$(this),$original_offset=$(this).offset().top;function removePinClasses(object){object.removeClass("pin-top");object.removeClass("pinned");object.removeClass("pin-bottom")}function updateElements(objects,scrolled){objects.each(function(){if(options.top<=scrolled&&options.bottom>=scrolled&&!$(this).hasClass("pinned")){removePinClasses($(this));$(this).css("top",options.offset);$(this).addClass("pinned")}if(scrolled<options.top&&!$(this).hasClass("pin-top")){removePinClasses($(this));$(this).css("top",0);$(this).addClass("pin-top")}if(scrolled>options.bottom&&!$(this).hasClass("pin-bottom")){removePinClasses($(this));$(this).addClass("pin-bottom");$(this).css("top",options.bottom-$original_offset)}})}$(this).data("pushpin-id",$uniqueId);updateElements($this,$(window).scrollTop());$(window).on("scroll."+$uniqueId,function(){var $scrolled=$(window).scrollTop()+options.offset;updateElements($this,$scrolled)})})}}(jQuery));
1
+ Materialize={};Materialize.guid=(function(){function s4(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return function(){return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}})();(function($){$.fn.pushpin=function(options){var defaults={top:0,bottom:Infinity,offset:0};if(options==="remove"){this.each(function(){if(id=$(this).data("pushpin-id")){$(window).off("scroll."+id);$(this).removeData("pushpin-id").removeClass("pin-top pinned pin-bottom").removeAttr("style")}});return false}options=$.extend(defaults,options);$index=0;return this.each(function(){var $uniqueId=Materialize.guid(),$this=$(this),$original_offset=$(this).offset().top;function removePinClasses(object){object.removeClass("pin-top");object.removeClass("pinned");object.removeClass("pin-bottom")}function updateElements(objects,scrolled){objects.each(function(){if(options.top<=scrolled&&options.bottom>=scrolled&&!$(this).hasClass("pinned")){removePinClasses($(this));$(this).css("top",options.offset);$(this).addClass("pinned")}if(scrolled<options.top&&!$(this).hasClass("pin-top")){removePinClasses($(this));$(this).css("top",0);$(this).addClass("pin-top")}if(scrolled>options.bottom&&!$(this).hasClass("pin-bottom")){removePinClasses($(this));$(this).addClass("pin-bottom");$(this).css("top",options.bottom-$original_offset)}})}$(this).data("pushpin-id",$uniqueId);updateElements($this,$(window).scrollTop());$(window).on("scroll."+$uniqueId,function(){var $scrolled=$(window).scrollTop()+options.offset;updateElements($this,$scrolled)})})}}(jQuery));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-mdui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - KeJun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.6.12
142
+ rubygems_version: 2.6.11
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: A Jekyll theme based on mdui