/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */ !function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(u){var e=function(){if(u&&u.fn&&u.fn.select2&&u.fn.select2.amd)var e=u.fn.select2.amd;var t,n,r,h,o,s,f,g,m,v,y,_,i,a,b;function w(e,t){return i.call(e,t)}function l(e,t){var n,r,i,o,s,a,l,c,u,d,p,h=t&&t.split("/"),f=y.map,g=f&&f["*"]||{};if(e){for(s=(e=e.split("/")).length-1,y.nodeIdCompat&&b.test(e[s])&&(e[s]=e[s].replace(b,"")),"."===e[0].charAt(0)&&h&&(e=h.slice(0,h.length-1).concat(e)),u=0;u":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},i.appendMany=function(e,t){if("1.7"===o.fn.jquery.substr(0,3)){var n=o();o.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},i.__cache={};var n=0;return i.GetUniqueElementId=function(e){var t=e.getAttribute("data-select2-id");return null==t&&(e.id?(t=e.id,e.setAttribute("data-select2-id",t)):(e.setAttribute("data-select2-id",++n),t=n.toString())),t},i.StoreData=function(e,t,n){var r=i.GetUniqueElementId(e);i.__cache[r]||(i.__cache[r]={}),i.__cache[r][t]=n},i.GetData=function(e,t){var n=i.GetUniqueElementId(e);return t?i.__cache[n]&&null!=i.__cache[n][t]?i.__cache[n][t]:o(e).data(t):i.__cache[n]},i.RemoveData=function(e){var t=i.GetUniqueElementId(e);null!=i.__cache[t]&&delete i.__cache[t],e.removeAttribute("data-select2-id")},i}),e.define("select2/results",["jquery","./utils"],function(h,f){function r(e,t,n){this.$element=e,this.data=n,this.options=t,r.__super__.constructor.call(this)}return f.Extend(r,f.Observable),r.prototype.render=function(){var e=h('');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},r.prototype.clear=function(){this.$results.empty()},r.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h(''),r=this.options.get("translations").get(e.message);n.append(t(r(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},r.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},r.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{class:"select2-results__options select2-results__options--nested"});p.append(l),s.append(a),s.append(p)}else this.template(e,t);return f.StoreData(t,"data",e),t},r.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=f.GetData(e[0],"data");"true"==e.attr("aria-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e);if(!(n<=0)){var r=n-1;0===e.length&&(r=0);var i=t.eq(r);i.trigger("mouseenter");var o=l.$results.offset().top,s=i.offset().top,a=l.$results.scrollTop()+(s-o);0===r?l.$results.scrollTop(0):s-o<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[aria-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var r=t.eq(n);r.trigger("mouseenter");var i=l.$results.offset().top+l.$results.outerHeight(!1),o=r.offset().top+r.outerHeight(!1),s=l.$results.scrollTop()+o-i;0===n?l.$results.scrollTop(0):ithis.$results.outerHeight()||o<0)&&this.$results.scrollTop(i)}},r.prototype.template=function(e,t){var n=this.options.get("templateResult"),r=this.options.get("escapeMarkup"),i=n(e,t);null==i?t.style.display="none":"string"==typeof i?t.innerHTML=r(i):h(t).append(i)},r}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(n,r,i){function o(e,t){this.$element=e,this.options=t,o.__super__.constructor.call(this)}return r.Extend(o,r.Observable),o.prototype.render=function(){var e=n('');return this._tabindex=0,null!=r.GetData(this.$element[0],"old-tabindex")?this._tabindex=r.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),e.attr("aria-disabled","false"),this.$selection=e},o.prototype.bind=function(e,t){var n=this,r=e.id+"-results";this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===i.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",r),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.trigger("focus"),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex),n.$selection.attr("aria-disabled","false")}),e.on("disable",function(){n.$selection.attr("tabindex","-1"),n.$selection.attr("aria-disabled","true")})},o.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},o.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.select2."+e.id,function(e){var t=n(e.target).closest(".select2");n(".select2.select2-container--open").each(function(){this!=t[0]&&r.GetData(this,"element").select2("close")})})},o.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.select2."+e.id)},o.prototype.position=function(e,t){t.find(".selection").append(e)},o.prototype.destroy=function(){this._detachCloseHandler(this.container)},o.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},o.prototype.isEnabled=function(){return!this.isDisabled()},o.prototype.isDisabled=function(){return this.options.get("disabled")},o}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,r){function i(){i.__super__.constructor.apply(this,arguments)}return n.Extend(i,t),i.prototype.render=function(){var e=i.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html(''),e},i.prototype.bind=function(t,e){var n=this;i.__super__.bind.apply(this,arguments);var r=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",r).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",r),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.trigger("focus")})},i.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},i.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},i.prototype.selectionContainer=function(){return e("")},i.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),r=this.display(t,n);n.empty().append(r);var i=t.title||t.text;i?n.attr("title",i):n.removeAttr("title")}else this.clear()},i}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,l){function n(e,t){n.__super__.constructor.apply(this,arguments)}return l.Extend(n,e),n.prototype.render=function(){var e=n.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('
    '),e},n.prototype.bind=function(e,t){var r=this;n.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){r.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!r.isDisabled()){var t=i(this).parent(),n=l.GetData(t[0],"data");r.trigger("unselect",{originalEvent:e,data:n})}})},n.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},n.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},n.prototype.selectionContainer=function(){return i('
  • ×
  • ')},n.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n×');a.StoreData(r[0],"data",t),this.$selection.find(".select2-selection__rendered").prepend(r)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(r,a,l){function e(e,t,n){e.call(this,t,n)}return e.prototype.render=function(e){var t=r('');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},e.prototype.bind=function(e,t,n){var r=this,i=t.id+"-results";e.call(this,t,n),t.on("open",function(){r.$search.attr("aria-controls",i),r.$search.trigger("focus")}),t.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-controls"),r.$search.removeAttr("aria-activedescendant"),r.$search.trigger("focus")}),t.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),t.on("disable",function(){r.$search.prop("disabled",!0)}),t.on("focus",function(e){r.$search.trigger("focus")}),t.on("results:focus",function(e){e.data._resultId?r.$search.attr("aria-activedescendant",e.data._resultId):r.$search.removeAttr("aria-activedescendant")}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===l.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("select",function(){r._checkIfMaximumSelected()})},e.prototype.query=function(e,t,n){var r=this;this._checkIfMaximumSelected(function(){e.call(r,t,n)})},e.prototype._checkIfMaximumSelected=function(e,n){var r=this;this.current(function(e){var t=null!=e?e.length:0;0=r.maximumSelectionLength?r.trigger("results:message",{message:"maximumSelected",args:{maximum:r.maximumSelectionLength}}):n&&n()})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var r=this,i=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){r.handleSearch(e)}),t.on("open",function(){r.$search.attr("tabindex",0),r.$search.attr("aria-controls",i),r.$search.trigger("focus"),window.setTimeout(function(){r.$search.trigger("focus")},0)}),t.on("close",function(){r.$search.attr("tabindex",-1),r.$search.removeAttr("aria-controls"),r.$search.removeAttr("aria-activedescendant"),r.$search.val(""),r.$search.trigger("blur")}),t.on("focus",function(){t.isOpen()||r.$search.trigger("focus")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(r.showSearch(e)?r.$searchContainer.removeClass("select2-search--hide"):r.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){e.data._resultId?r.$search.attr("aria-activedescendant",e.data._resultId):r.$search.removeAttr("aria-activedescendant")})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,r){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,r)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),r=t.length-1;0<=r;r--){var i=t[r];this.placeholder.id===i.id&&n.splice(r,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(n){function e(e,t,n,r){this.lastParams={},e.call(this,t,n,r),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&(this.$results.append(this.$loadingMore),this.loadMoreIfNeeded())},e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("query",function(e){r.lastParams=e,r.loading=!0}),t.on("query:append",function(e){r.lastParams=e,r.loading=!0}),this.$results.on("scroll",this.loadMoreIfNeeded.bind(this))},e.prototype.loadMoreIfNeeded=function(){var e=n.contains(document.documentElement,this.$loadingMore[0]);if(!this.loading&&e){var t=this.$results.offset().top+this.$results.outerHeight(!1);this.$loadingMore.offset().top+this.$loadingMore.outerHeight(!1)<=t+50&&this.loadMore()}},e.prototype.loadMore=function(){this.loading=!0;var e=n.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=n('
  • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=f(n.get("dropdownParent")||document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var r=this;e.call(this,t,n),t.on("open",function(){r._showDropdown(),r._attachPositioningHandler(t),r._bindContainerResultHandlers(t)}),t.on("close",function(){r._hideDropdown(),r._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._bindContainerResultHandlers=function(e,t){if(!this._containerResultsHandlersBound){var n=this;t.on("results:all",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:append",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:message",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("select",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("unselect",function(){n._positionDropdown(),n._resizeDropdown()}),this._containerResultsHandlersBound=!0}},e.prototype._attachPositioningHandler=function(e,t){var n=this,r="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){a.StoreData(this,"select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(r,function(e){var t=a.GetData(this,"select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(r+" "+i+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,r="resize.select2."+t.id,i="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+r+" "+i)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),r=null,i=this.$container.offset();i.bottom=i.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=i.top,o.bottom=i.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ai.bottom+s,d={left:i.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h={top:0,left:0};(f.contains(document.body,p[0])||p[0].isConnected)&&(h=p.offset()),d.top-=h.top,d.left-=h.left,t||n||(r="below"),u||!c||t?!c&&u&&t&&(r="below"):r="above",("above"==r||t&&"below"!==r)&&(d.top=o.top-h.top-s),null!=r&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+r),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+r)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,r){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,r)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,r=0;r');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),u.StoreData(e[0],"element",this.$element),e},d}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(i,e,o,t,s){if(null==i.fn.select2){var a=["open","close","destroy"];i.fn.select2=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=i.extend(!0,{},t);new o(i(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,r=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=s.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,r)}),-1'); $('.' + wrapper).css({height: 'auto', display:'none', overflow: 'hidden', width: '100%'}); // Calculate the init height of the target. // With both elem hidden the height calc does not work // Currently it shows both elems, calculates the height and hides the wrapper // ***** There has to be a better way target.show(); $('.' + wrapper).show(); var h = target.outerHeight(); $('.' + wrapper).hide(); //move target to top of wrapper div so it can slide down target.css({top:'-' + h + 'px'}); } // Do it this.slide(target, wrapper); }, slide: function(target, wrapper) { //slide down the outer wrapper an animate the element position $('.' + wrapper).slideDown(200); target.animate({top:'0'}, 200); } }; slideUp.prototype = { init: function() { // Do it this.slide($(this.elem), this.wrapper, this.speed); }, slide: function(target, wrapper, speed) { // Get the height of the elem (performed each time for responsivenes) var h = target.outerHeight(); $('.' + wrapper).slideUp(speed); target.animate({top: '-' + h}, speed); } }; // the slideDown constructor $.fn['betterSlideDown'] = function(options) { new slideDown(this, options); }; // the slideUp constructor $.fn['betterSlideUp'] = function(options) { new slideUp(this, options); }; })(jQuery, window, document); // eslint-disable-next-line no-unused-vars var modalHandling = { setClickHandlers: function(button_selector) { // legacy bootstrap modal handling with a lot of ajax crap baked in // return true, because bootstrap modal js will show and position modal $('[data-toggle=modal]').click(function() { var url = $(this).attr('data-url'); if (! url) { return true; } var strType = $(this).attr('data-type'); var recid = $(this).attr('data-id'); var classes = $(this).attr('data-classes'); var modalContainer = $(this).attr('data-target'); var redirectMsg = $(this).attr('data-redirectMsg'); var thisItem = $(this); // store $this to use inside return function var content = modalContainer + ' ' + thisItem.attr('data-contentContainer'); if (document.getElementById('generic-spinner').content) { // prevent errors in IE11: https://caniuse.com/#search=template $(content).html(document.getElementById('generic-spinner').content.cloneNode(true)); } // add extra classes; NB can add 2 classes in one string :) $(modalContainer).addClass(classes); // place modal title $('#' + $(modalContainer).attr('aria-labelledby')).html($(this).attr('data-title')); $.ajax({ type: 'POST', url: url, data: {strType:strType, intRecordId:recid}, success: function(data){ // reload when back end says so if (data.blnReload) { if ('undefined' !== typeof data.strReloadUrl) { // redirect to new location $(content).html(redirectMsg); window.location = data.strReloadUrl; } else { // reload same location location.reload(); } return; } if (data.blnResult) { // place content $(content).html(data.strHtml); } }, error: function(jqXHR, textStatus, errorThrown){ // eslint-disable-next-line no-console console.error(textStatus + ' ' + errorThrown); }, dataType: 'json' }); return true; }); // modern modals (function(){ var buttons = document.querySelectorAll(button_selector); if (! buttons) { return; } function propagateState(modal, state) { modal.setAttribute('aria-expanded', state); buttons.forEach(function(b){ b.setAttribute('aria-expanded', state); }); } buttons.forEach(function(button){ var target_modal = document.getElementById(button.getAttribute('aria-controls')); propagateState(target_modal, target_modal.getAttribute('aria-expanded')); target_modal.addEventListener('click', function(event){ event.stopPropagation(); event.preventDefault(); propagateState(target_modal, 'false'); }); target_modal.querySelector('.modal-content').addEventListener('click', function(event){ event.stopPropagation(); }); button.onclick = function(event) { event.preventDefault(); event.stopPropagation(); if (target_modal.getAttribute('aria-expanded') === 'true') { propagateState(target_modal, 'false'); } else { propagateState(target_modal, 'true'); } }; }); }()); } }; /* eslint-disable no-unused-vars, no-multi-spaces */ /* global moment */ function strftime2moment(strftime_format) { // maps strftime to moment format string var moment_format = strftime_format.replace('%a', 'ddd'); // An abbreviated textual representation of the day moment_format = moment_format.replace('%A', 'dddd'); // A full textual representation of the day moment_format = moment_format.replace('%d', 'DD'); // Two-digit day of the month moment_format = moment_format.replace('%e', 'D'); // Day of the month, with a space preceding single digits. moment_format = moment_format.replace('%j', 'DDDD'); // Day of the year, 3 digits with leading zeros moment_format = moment_format.replace('%u', 'E'); // Day of the year, 3 digits with leading zeros moment_format = moment_format.replace('%w', 'd'); // Numeric representation of the day of the week moment_format = moment_format.replace('%U', 'w'); // Week number of the given year moment_format = moment_format.replace('%V', 'W'); // ISO-8601:1988 week number of the given year moment_format = moment_format.replace('%W', 'w'); // A numeric representation of the week of the year -- probably incorrect but ¯\_(ツ)_/¯ moment_format = moment_format.replace('%b', 'MMM'); // Abbreviated month name, based on the locale moment_format = moment_format.replace('%B', 'MMMM'); // Full month name, based on the locale moment_format = moment_format.replace('%h', 'MMM'); // Abbreviated month name, based on the locale (an alias of %b) moment_format = moment_format.replace('%m', 'MM'); // Two digit representation of the month moment_format = moment_format.replace('%C', ''); // Two digit representation of the century moment_format = moment_format.replace('%g', 'YY'); // Two digit representation of the year going by ISO-8601:1988 moment_format = moment_format.replace('%G', 'Y'); // The full four-digit version of %g moment_format = moment_format.replace('%y', 'YY'); // Two digit representation of the year moment_format = moment_format.replace('%Y', 'YYYY'); // Four digit representation for the year moment_format = moment_format.replace('%D', 'MMDDYY'); // Same as "%m/%d/%y" moment_format = moment_format.replace('%F', 'YYYY-MM-DD'); // Same as "%Y-%m-%d" moment_format = moment_format.replace('%x', 'l'); // Preferred date representation based on locale, without the time moment_format = moment_format.replace('%H', 'HH'); // Two digit representation of the hour in 24-hour format moment_format = moment_format.replace('%k', 'H'); // Hour in 24-hour format, with a space preceding single digits moment_format = moment_format.replace('%I', 'hh'); // Two digit representation of the hour in 12-hour format moment_format = moment_format.replace('%l', 'h'); // Hour in 12-hour format moment_format = moment_format.replace('%M', 'mm'); // Two digit representation of the minute moment_format = moment_format.replace('%p', 'A'); // UPPER-CASE 'AM' or 'PM' based on the given time moment_format = moment_format.replace('%P', 'a'); // lower-case 'am' or 'pm' based on the given time moment_format = moment_format.replace('%r', 'hh:mm:ss a'); // Same as "%I:%M:%S %p" moment_format = moment_format.replace('%R', 'HH:mm'); // Same as "%H:%M" moment_format = moment_format.replace('%S', 'ss'); // Two digit representation of the second moment_format = moment_format.replace('%T', 'HH:MM:SS'); // Same as "%H:%M:%S" moment_format = moment_format.replace('%X', 'LTS'); // Preferred time representation based on locale, without the date moment_format = moment_format.replace('%z', 'ZZ'); // The time zone offset moment_format = moment_format.replace('%Z', 'z'); // The time zone abbreviation moment_format = moment_format.replace('%c', 'llll'); // The time zone abbreviation moment_format = moment_format.replace('%s', 'X'); // Unix Epoch Time timestamp return moment_format; } (function() { // updates moment locales to match the output of strftime var nl_like_strftime = { monthsShort : [ 'jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec' ], weekdaysShort : [ 'zo', 'ma', 'di', 'wo', 'do', 'vr', 'za' ] }; var current_locale = moment.locale(); moment.updateLocale('nl', nl_like_strftime); moment.updateLocale('nl', nl_like_strftime); // updating the locales in moment also sets the locale, so set it back now moment.locale(current_locale); }()); // https://github.com/polyfill/Array.prototype.forEach/blob/master/Array.prototype.forEach.js if (!NodeList.prototype.forEach) { NodeList.prototype.forEach = function(fn, scope) { 'use strict'; var i; var len; for (i = 0, len = this.length; i < len; ++i) { if (i in this) { fn.call(scope, this[i], i, this); } } }; } if (!Array.prototype.forEach) { Array.prototype.forEach = function(fn, scope) { 'use strict'; var i; var len; for (i = 0, len = this.length; i < len; ++i) { if (i in this) { fn.call(scope, this[i], i, this); } } }; } /* global YT, Vimeo */ // eslint-disable-next-line no-unused-vars var videoHandling = { youtubes: {}, vimeos: {}, getYouTubeID: function(yt_url){ // because YT has a pretty useless oembed endpoint, we resort to regex // adapted from: https://gist.github.com/takien/4077195 var id = false; var url = yt_url.replace(/(>|<)/gi, '').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/); if (url[2] !== undefined) { id = url[2].split(/[^0-9a-z_-]/i); id = id[0]; } if (id) { return id; } else { // it the url wasn't parseable perhaps it was just a video id return yt_url; } }, rgbToHex: function(rgb) { function convert(color) { var hex = Number(color).toString(16); if (hex.length < 2) { hex = '0' + hex; } return hex; } var regex = /^.*\((\d+), (\d+), (\d+)/; var colors = rgb.match(regex); var red = convert(colors[1]); var green = convert(colors[2]); var blue = convert(colors[3]); return red + green + blue; }, buildVideo: function(element, url, mode) { // eslint-disable-next-line no-unused-vars var player; var placeholder = element.querySelector('.placeholder'); if (url.includes('vimeo')) { player = new Vimeo.Player(placeholder.parentNode, { url: url, width: element.clientWidth, height: Math.round(element.clientWidth / 16 * 9), byline: false, title: false, autoplay: mode === 'autoplay' ? true : false, color: videoHandling.rgbToHex(window.getComputedStyle(element).color) }); // vimeo inserts the player in the placeholder placeholder.remove(); // vimeo auto-scales to the iframe so make sure it's 16/9 window.addEventListener('resize', function() { element.querySelector('iframe').height = element.clientWidth / 16 * 9; }); videoHandling.vimeos[url] = player; } else { // youtube replaces the placeholder with the player player = new YT.Player(placeholder, { width: element.clientWidth, height: Math.round(element.clientWidth / 16 * 9), videoId: videoHandling.getYouTubeID(url), playerVars: { autoplay: mode === 'autoplay' ? 1 : 0, iv_load_policy: 3, modestbranding: 1, playsinline: 1 } }); // ensure a 16x9 sized player that fills it's parent container window.addEventListener('resize', function() { player.setSize(element.clientWidth, element.clientWidth / 16 * 9); }); videoHandling.youtubes[url] = player; } } }; /* global moment */ // eslint-disable-next-line no-unused-vars var dateHandling = { dates: [], ranges: [], getSelectedDate: function(input) { /* tries to return the user selected date (in moment format) or a sane fallback: - get the date value of a given input, - or the first date in a range, if it's later than today - if all else fails return the current time i.e. "today" */ var dates = dateHandling.dates; if (input.value) { return moment(input.value); } if (dates.length > 0 && dates[0] !== '') { if (! moment(dates[0]).isBefore(moment())) { return moment(dates[0]); } } return moment(); }, getMinDate: function(show_history) { /* if show_history, or the date range isn't usable, just return some date a few years ago, but ideally return, in moment format, the first date in the range */ var dates = dateHandling.dates; if (!show_history && dates.length > 0 && dates[0] !== '') { return moment(dates[0]); } else { return moment().subtract(10, 'years').startOf('month'); } }, getMaxDate: function() { /* ideally return, in moment format, the last date in the range, and fall back to some time several years in the future */ var dates = dateHandling.dates; if (dates.length > 0 && dates[0] !== '') { return moment(dates[dates.length - 1]); } else { return moment().add(10, 'years').startOf('month'); } }, getDateClassnames: function(date) { /* for a given date - if it falls in the ranges set it should be marked as being a date that where a longterm event is ongoing - if it is in the dates collection it should be marked as being a date with an event */ var dates = dateHandling.dates; var ranges = dateHandling.ranges; var return_string = ''; if (dates.length < 1 || dates[0] === '') { return ''; } if (ranges.length > 0) { ranges.forEach(function(range) { if (moment(date).isBetween(range[0], range[1])) { return_string += ' has-longterm'; } }); } if (dates.indexOf(moment(date).format('YYYY-MM-DD')) !== -1) { return_string += ' has-event'; } return return_string; } }; /* global moment, strftime2moment, dataLayer */ // eslint-disable-next-line no-unused-vars var cartHandling = { root_element: document.getElementById('cart'), toggle_button_selector: '[data-toggle="cart"], [aria-controls="cart"]', removed_buffer: [], modalOpen: function() { cartHandling.root_element.setAttribute('aria-expanded', true); $.each(document.querySelectorAll(cartHandling.toggle_button_selector), function(ib, button) { button.setAttribute('aria-expanded', true); }); document.body.classList.add('modal-open'); }, modalClose: function() { cartHandling.removed_buffer = []; // clear the list of removed entries cartHandling.root_element.setAttribute('aria-expanded', false); $.each(document.querySelectorAll(cartHandling.toggle_button_selector), function(ib, button) { button.setAttribute('aria-expanded', false); }); document.body.classList.remove('modal-open'); }, modalToggle: function() { if (cartHandling.root_element.getAttribute('aria-expanded') === 'true') { cartHandling.modalClose(); } else { cartHandling.updateCart(); cartHandling.modalOpen(); } }, drawCartItem: function(item) { var cart_root = cartHandling.root_element; var cart_item_slot = cart_root.querySelector('.itemList'); var cart_next_btn = document.getElementById('cart-next-button'); var ghost_entry = cart_item_slot.querySelector('[data-sku-id="' + item.sku_id + '"]'); if (ghost_entry) { // a basic entry already exists, so update the image (if we have it) and get out of here if (! item.image) { return; } ghost_entry.querySelector('.thumb').style.backgroundImage = 'url(' + item.image + ')'; ghost_entry.classList.remove('new'); return; } var start_time; if (item.aanvang_ts) { start_time = moment.unix(Number(item.aanvang_ts)); } else if (item.start) { start_time = moment(item.start); } function removeFromCart(target_item) { var entry = cart_item_slot.querySelector('[data-sku-id="' + target_item.sku_id + '"]'); var kassacode = entry.dataset.kvksysteem_code; entry.remove(); cartHandling.removed_buffer.push(target_item.sku_id); dataLayer.push({ 'event': 'cart_remove', 'eventCategory': 'product', 'eventAction': 'remove_from_cart', 'eventLabel': kassacode }); // live update the datalayer // the first object in it is our moder datablob $.each(dataLayer[0].order_items, function(i, cart_entry){ if (cart_entry.item_code === kassacode) { dataLayer[0].order_items.splice(i, 1); return false; } }); // flag the cart as "busy" until the ajax call comes through cart_next_btn.classList.add('btn-disabled'); cart_root.classList.add('busy'); var data_object = { 'ajax': true, 'ac_action': 'remove', }; if (undefined !== target_item.voorstelling_id) { data_object['voorstelling_id'] = target_item.voorstelling_id; } if (undefined !== target_item.productId) { data_object['product_id'] = target_item.productId; } $.ajax({ type: 'POST', url: cart_root.dataset.sendEndpoint, data: data_object, dataType: 'json' }).done(function(){ // eslint-disable-next-line no-use-before-define cartHandling.updateCart(); }); } var item_root = document.createElement('div'); item_root.classList.add('cartItemCard'); item_root.setAttribute('data-sku-id', item.sku_id); item_root.setAttribute('data-sku-code', item.kvksysteem_code); var main; var main_inside = ''; if (item.production_id) { main = document.createElement('a'); main.setAttribute('href', cart_root.dataset.eventBaseUrl + item.production_id); } else { main = document.createElement('div'); } if (item.image) { main_inside = '
    '; } else if (item.production_id) { item_root.classList.add('new'); main_inside = '
    '; } if (item.titel) { main_inside += '

    ' + item.titel + '

    '; } else if (item.name) { main_inside += '

    ' + item.name + '

    '; } main_inside += '
    '; if (item.artiest) { main_inside += item.artiest; main_inside += '
    '; } if (start_time) { main_inside += start_time.format(strftime2moment(cart_root.dataset.dateformat)); main_inside += ' '; main_inside += start_time.format(strftime2moment(cart_root.dataset.timeformat)); } main_inside += '
    '; main.classList.add('desc'); main.innerHTML = main_inside; var remover = document.createElement('a'); var remover_inside; remover_inside = ''; remover_inside += ''; remover_inside += cart_root.dataset.removalLabel; remover_inside += ''; remover.innerHTML = remover_inside; remover.classList.add('remove'); remover.setAttribute('href', '#'); remover.onclick = function(e) { e.preventDefault(); e.stopPropagation(); removeFromCart(item); }; item_root.appendChild(main); item_root.appendChild(remover); if (cart_item_slot.children.length === 0) { cart_item_slot.appendChild(item_root); } else { cart_item_slot.insertBefore(item_root, cart_item_slot.children[0]); } }, addToCart: function(form) { var data_object; var cart_root = cartHandling.root_element; var cart_next_btn = document.getElementById('cart-next-button'); function drawMessage(text) { var entry = document.createElement('li'); var entry_inside = ''; entry.classList.add('msg', 'error'); entry_inside += ''; entry_inside += text; entry.innerHTML = entry_inside; cart_root.querySelector('.messageList').appendChild(entry); } // hide the empty cart message document.getElementById('cart-empty-desc').style.display = 'none'; // flag the cart as "busy" until the ajax call comes through cart_next_btn.classList.add('btn-disabled'); cart_root.classList.add('busy'); // draw it right away, check and update later with ajax if (form.elements.voorstelling_id) { var item = { 'start': form.dataset.eventStart, 'sku_id': form.elements.voorstelling_id.value, 'kvksysteem_code': form.dataset.eventBoxofficeid, 'production_id': form.dataset.productionId, 'titel': form.dataset.productionTitle, 'artiest': form.dataset.productionSubtitle, }; cartHandling.drawCartItem(item); // update the datalayer if (dataLayer !== undefined) { // send an event, that might be useful for tracking in Google Analytics // use the 'event' variable for Tag Manager: https://developers.google.com/tag-manager/devguide#events // payload format for Analytics: https://developers.google.com/analytics/devguides/collection/analyticsjs/events#event_fields dataLayer.push({ 'event': 'cart_add', 'eventCategory': 'product', 'eventAction': 'add_to_cart', 'eventLabel': form.dataset.eventBoxofficeid }); // live update the datalayer // the first object in it is our moder datablob dataLayer[0].order_items.push({ 'item_code': form.dataset.eventBoxofficeid, 'item_name': form.dataset.productionTitle + (form.dataset.productionSubtitle ? ' — ' + form.dataset.productionSubtitle : ''), 'item_date': moment(form.dataset.eventStart, 'YYYY-MM-DD hh:mm:ss').format(), 'products': [], 'products_value': 0 }); // legacy dataLayer.push({ 'event': 'GAevent', 'eventCategory': 'Bestellen', 'eventAction': 'In winkelmandje', 'eventLabel': form.dataset.eventCode }); } data_object = { 'ajax_popup': true, 'ac_action': 'add', 'voorstelling_id': form.elements.voorstelling_id.value }; } else { data_object = { 'ajax_popup': true, 'ac_action': 'add', 'theme_id': form.elements.theme_id.value }; } cartHandling.modalOpen(); $.ajax({ type: 'POST', url: cart_root.dataset.sendEndpoint, data: data_object, dataType: 'json', success: function(data) { cart_root.querySelector('.messageList').innerHTML = ''; if (data.success === false && data.message) { drawMessage(data.message); } } }).done(function(){ // eslint-disable-next-line no-use-before-define cartHandling.updateCart(); }); }, updateCart: function() { var cart_root = cartHandling.root_element; var cart_combo_slot = cart_root.querySelector('.comboList'); var cart_next_btn = document.getElementById('cart-next-button'); cart_root.classList.add('busy'); $.ajax({ type: 'POST', url: cart_root.dataset.retrieveEndpoint, data: { 'thumb': cart_root.dataset.thumb }, dataType: 'json', success: function(data) { var combos = data.eligibleThemes; var combo_list_valid = []; var combo_list_invalid = []; var invalid_combo_limit = null; var entries = cart_root.querySelector('.itemList').querySelectorAll('[data-sku-id]'); var skus = []; var items = data.cartItems; var sorted_items = items.sort(function(a, b) { if (a.added < b.added) { return -1; } else if (a.added > b.added) { return 1; } return 0; }); $.each(items, function(i, item) { if (item.voorstelling_id) { item.sku_id = 'event' + item.voorstelling_id; } else if (item.productId) { item.sku_id = 'product' + item.productId; } }); function setCounters(amount) { var badges = document.querySelectorAll('#cartLabel .badge, #cartLabelMobile .badge, #cartLabelSticky .badge, #cart .badge'); document.getElementById('cartLabel').dataset.count = amount; $.each(badges, function(i, badge) { badge.innerText = amount; if (amount > 0) { badge.style.display = null; } else { badge.style.display = 'none'; } }); } function drawCombo(item) { var entry = document.createElement('li'); var entry_inside = ''; if (item.blnMinRequiredEventsInBasket) { entry.classList.add('upsellMsg', 'msg', 'notice'); entry_inside += ''; entry_inside += '

    ' + item.combo_price_name + '

    '; if (item.conditions_met_text) { entry_inside += item.conditions_met_text; } } else if (item.blnMinRequiredEventsInBasket === false) { entry.classList.add('upsellDescription'); entry_inside += ''; entry_inside += '

    ' + item.combo_price_name + '

    '; if (item.conditions_not_met_text) { entry_inside += item.conditions_not_met_text; } if (item.hyperlink_naam && item.hyperlink) { entry_inside += '

    '; entry_inside += item.hyperlink_naam + '

    '; } } entry.innerHTML = entry_inside; cart_combo_slot.appendChild(entry); } if (data.blnIsRaffleBasket) { document.getElementById('cart-title').innerHTML = cart_root.dataset.raffleTitle; } else { document.getElementById('cart-title').innerHTML = cart_root.dataset.defaultTitle; } // split out the combo messages into lists of valid and invalid combos $.each(combos, function(i, combo) { if (combo.blnMinRequiredEventsInBasket) { combo_list_valid.push(combo); } else { combo_list_invalid.push(combo); } }); if (combo_list_valid.length > 0) { if (cart_root.dataset.limitInvalidMessagesIfAnyValid.length > 0) { invalid_combo_limit = Number(cart_root.dataset.limitInvalidMessagesIfAnyValid); } } else if (cart_root.dataset.limitInvalidMessages.length > 0) { invalid_combo_limit = Number(cart_root.dataset.limitInvalidMessages); } // empty the list cart_combo_slot.innerHTML = ''; // and then fill it back up $.each(combo_list_valid, function(i, combo) { drawCombo(combo); }); $.each(combo_list_invalid, function(i, combo) { if (invalid_combo_limit === null || i < invalid_combo_limit) { drawCombo(combo); } }); // add the items, drawCartItem will prevent duplications $.each(sorted_items, function(i, item) { skus.push(item.sku_id); if (cartHandling.removed_buffer.indexOf(item.sku_id) === -1) { cartHandling.drawCartItem(item); } }); // remove entries no longer in the cart $.each(entries, function(i, entry) { if (skus.indexOf(entry.dataset.skuId) === -1) { entry.remove(); } }); // if the cart is empty, we have a little message to display if (skus.length > 0) { document.getElementById('cart-empty-desc').style.display = 'none'; cart_next_btn.classList.remove('btn-disabled'); } else { document.getElementById('cart-empty-desc').style.display = null; cart_next_btn.classList.add('btn-disabled'); } setCounters(skus.length); // flip the buttons for the entries in the cart $.each(document.querySelectorAll('form input[name=ac_action][value=add]'), function(i, input) { var form = input.form; var button = form.querySelector('[type="submit"]'); if (form.elements.theme_id) { return; } if (skus.indexOf('event' + form.elements.voorstelling_id.value) > -1) { button.classList.add('event-in-cart'); if (form.dataset.buttonLabelDefault) { button.innerHTML = cart_root.dataset.buttonLabelAdded; } form.onsubmit = function(e) { e.preventDefault(); e.stopPropagation(); window.location = cart_root.dataset.checkoutUrl; }; } else { button.classList.remove('event-in-cart'); if (form.dataset.buttonLabelDefault) { button.innerHTML = form.dataset.buttonLabelDefault; } form.onsubmit = function(e) { e.preventDefault(); e.stopPropagation(); cartHandling.addToCart(form); }; } }); } }).done(function(){ cart_root.classList.remove('busy'); }); } }; (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['exports'], factory); } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports); } else { // Browser globals factory(root.IBAN = {}); } }(this, function(exports){ // Array.prototype.map polyfill // code from https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map if (!Array.prototype.map){ Array.prototype.map = function(fun /*, thisArg */){ "use strict"; if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") throw new TypeError(); var res = new Array(len); var thisArg = arguments.length >= 2 ? arguments[1] : void 0; for (var i = 0; i < len; i++) { // NOTE: Absolute correctness would demand Object.defineProperty // be used. But this method is fairly new, and failure is // possible only if Object.prototype or Array.prototype // has a property |i| (very unlikely), so use a less-correct // but more portable alternative. if (i in t) res[i] = fun.call(thisArg, t[i], i, t); } return res; }; } var A = 'A'.charCodeAt(0), Z = 'Z'.charCodeAt(0); /** * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616. * * @param {string} iban the IBAN * @returns {string} the prepared IBAN */ function iso13616Prepare(iban) { iban = iban.toUpperCase(); iban = iban.substr(4) + iban.substr(0,4); return iban.split('').map(function(n){ var code = n.charCodeAt(0); if (code >= A && code <= Z){ // A = 10, B = 11, ... Z = 35 return code - A + 10; } else { return n; } }).join(''); } /** * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064. * * @param iban * @returns {number} */ function iso7064Mod97_10(iban) { var remainder = iban, block; while (remainder.length > 2){ block = remainder.slice(0, 9); remainder = parseInt(block, 10) % 97 + remainder.slice(block.length); } return parseInt(remainder, 10) % 97; } /** * Parse the BBAN structure used to configure each IBAN Specification and returns a matching regular expression. * A structure is composed of blocks of 3 characters (one letter and 2 digits). Each block represents * a logical group in the typical representation of the BBAN. For each group, the letter indicates which characters * are allowed in this group and the following 2-digits number tells the length of the group. * * @param {string} structure the structure to parse * @returns {RegExp} */ function parseStructure(structure){ // split in blocks of 3 chars var regex = structure.match(/(.{3})/g).map(function(block){ // parse each structure block (1-char + 2-digits) var format, pattern = block.slice(0, 1), repeats = parseInt(block.slice(1), 10); switch (pattern){ case "A": format = "0-9A-Za-z"; break; case "B": format = "0-9A-Z"; break; case "C": format = "A-Za-z"; break; case "F": format = "0-9"; break; case "L": format = "a-z"; break; case "U": format = "A-Z"; break; case "W": format = "0-9a-z"; break; } return '([' + format + ']{' + repeats + '})'; }); return new RegExp('^' + regex.join('') + '$'); } /** * * @param iban * @returns {string} */ function electronicFormat(iban){ return iban.replace(NON_ALPHANUM, '').toUpperCase(); } /** * Create a new Specification for a valid IBAN number. * * @param countryCode the code of the country * @param length the length of the IBAN * @param structure the structure of the underlying BBAN (for validation and formatting) * @param example an example valid IBAN * @constructor */ function Specification(countryCode, length, structure, example){ this.countryCode = countryCode; this.length = length; this.structure = structure; this.example = example; } /** * Lazy-loaded regex (parse the structure and construct the regular expression the first time we need it for validation) */ Specification.prototype._regex = function(){ return this._cachedRegex || (this._cachedRegex = parseStructure(this.structure)) }; /** * Check if the passed iban is valid according to this specification. * * @param {String} iban the iban to validate * @returns {boolean} true if valid, false otherwise */ Specification.prototype.isValid = function(iban){ return this.length == iban.length && this.countryCode === iban.slice(0,2) && this._regex().test(iban.slice(4)) && iso7064Mod97_10(iso13616Prepare(iban)) == 1; }; /** * Convert the passed IBAN to a country-specific BBAN. * * @param iban the IBAN to convert * @param separator the separator to use between BBAN blocks * @returns {string} the BBAN */ Specification.prototype.toBBAN = function(iban, separator) { return this._regex().exec(iban.slice(4)).slice(1).join(separator); }; /** * Convert the passed BBAN to an IBAN for this country specification. * Please note that "generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account". * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits * * @param bban the BBAN to convert to IBAN * @returns {string} the IBAN */ Specification.prototype.fromBBAN = function(bban) { if (!this.isValidBBAN(bban)){ throw new Error('Invalid BBAN'); } var remainder = iso7064Mod97_10(iso13616Prepare(this.countryCode + '00' + bban)), checkDigit = ('0' + (98 - remainder)).slice(-2); return this.countryCode + checkDigit + bban; }; /** * Check of the passed BBAN is valid. * This function only checks the format of the BBAN (length and matching the letetr/number specs) but does not * verify the check digit. * * @param bban the BBAN to validate * @returns {boolean} true if the passed bban is a valid BBAN according to this specification, false otherwise */ Specification.prototype.isValidBBAN = function(bban) { return this.length - 4 == bban.length && this._regex().test(bban); }; var countries = {}; function addSpecification(IBAN){ countries[IBAN.countryCode] = IBAN; } addSpecification(new Specification("AD", 24, "F04F04A12", "AD1200012030200359100100")); addSpecification(new Specification("AE", 23, "F03F16", "AE070331234567890123456")); addSpecification(new Specification("AL", 28, "F08A16", "AL47212110090000000235698741")); addSpecification(new Specification("AT", 20, "F05F11", "AT611904300234573201")); addSpecification(new Specification("AZ", 28, "U04A20", "AZ21NABZ00000000137010001944")); addSpecification(new Specification("BA", 20, "F03F03F08F02", "BA391290079401028494")); addSpecification(new Specification("BE", 16, "F03F07F02", "BE68539007547034")); addSpecification(new Specification("BG", 22, "U04F04F02A08", "BG80BNBG96611020345678")); addSpecification(new Specification("BH", 22, "U04A14", "BH67BMAG00001299123456")); addSpecification(new Specification("BR", 29, "F08F05F10U01A01", "BR9700360305000010009795493P1")); addSpecification(new Specification("BY", 28, "A04F04A16", "BY13NBRB3600900000002Z00AB00")); addSpecification(new Specification("CH", 21, "F05A12", "CH9300762011623852957")); addSpecification(new Specification("CR", 22, "F04F14", "CR72012300000171549015")); addSpecification(new Specification("CY", 28, "F03F05A16", "CY17002001280000001200527600")); addSpecification(new Specification("CZ", 24, "F04F06F10", "CZ6508000000192000145399")); addSpecification(new Specification("DE", 22, "F08F10", "DE89370400440532013000")); addSpecification(new Specification("DK", 18, "F04F09F01", "DK5000400440116243")); addSpecification(new Specification("DO", 28, "U04F20", "DO28BAGR00000001212453611324")); addSpecification(new Specification("EE", 20, "F02F02F11F01", "EE382200221020145685")); addSpecification(new Specification("EG", 29, "F04F04F17", "EG800002000156789012345180002")); addSpecification(new Specification("ES", 24, "F04F04F01F01F10", "ES9121000418450200051332")); addSpecification(new Specification("FI", 18, "F06F07F01", "FI2112345600000785")); addSpecification(new Specification("FO", 18, "F04F09F01", "FO6264600001631634")); addSpecification(new Specification("FR", 27, "F05F05A11F02", "FR1420041010050500013M02606")); addSpecification(new Specification("GB", 22, "U04F06F08", "GB29NWBK60161331926819")); addSpecification(new Specification("GE", 22, "U02F16", "GE29NB0000000101904917")); addSpecification(new Specification("GI", 23, "U04A15", "GI75NWBK000000007099453")); addSpecification(new Specification("GL", 18, "F04F09F01", "GL8964710001000206")); addSpecification(new Specification("GR", 27, "F03F04A16", "GR1601101250000000012300695")); addSpecification(new Specification("GT", 28, "A04A20", "GT82TRAJ01020000001210029690")); addSpecification(new Specification("HR", 21, "F07F10", "HR1210010051863000160")); addSpecification(new Specification("HU", 28, "F03F04F01F15F01", "HU42117730161111101800000000")); addSpecification(new Specification("IE", 22, "U04F06F08", "IE29AIBK93115212345678")); addSpecification(new Specification("IL", 23, "F03F03F13", "IL620108000000099999999")); addSpecification(new Specification("IS", 26, "F04F02F06F10", "IS140159260076545510730339")); addSpecification(new Specification("IT", 27, "U01F05F05A12", "IT60X0542811101000000123456")); addSpecification(new Specification("IQ", 23, "U04F03A12", "IQ98NBIQ850123456789012")); addSpecification(new Specification("JO", 30, "A04F22", "JO15AAAA1234567890123456789012")); addSpecification(new Specification("KW", 30, "U04A22", "KW81CBKU0000000000001234560101")); addSpecification(new Specification("KZ", 20, "F03A13", "KZ86125KZT5004100100")); addSpecification(new Specification("LB", 28, "F04A20", "LB62099900000001001901229114")); addSpecification(new Specification("LC", 32, "U04F24", "LC07HEMM000100010012001200013015")); addSpecification(new Specification("LI", 21, "F05A12", "LI21088100002324013AA")); addSpecification(new Specification("LT", 20, "F05F11", "LT121000011101001000")); addSpecification(new Specification("LU", 20, "F03A13", "LU280019400644750000")); addSpecification(new Specification("LV", 21, "U04A13", "LV80BANK0000435195001")); addSpecification(new Specification("MC", 27, "F05F05A11F02", "MC5811222000010123456789030")); addSpecification(new Specification("MD", 24, "U02A18", "MD24AG000225100013104168")); addSpecification(new Specification("ME", 22, "F03F13F02", "ME25505000012345678951")); addSpecification(new Specification("MK", 19, "F03A10F02", "MK07250120000058984")); addSpecification(new Specification("MR", 27, "F05F05F11F02", "MR1300020001010000123456753")); addSpecification(new Specification("MT", 31, "U04F05A18", "MT84MALT011000012345MTLCAST001S")); addSpecification(new Specification("MU", 30, "U04F02F02F12F03U03", "MU17BOMM0101101030300200000MUR")); addSpecification(new Specification("NL", 18, "U04F10", "NL91ABNA0417164300")); addSpecification(new Specification("NO", 15, "F04F06F01", "NO9386011117947")); addSpecification(new Specification("PK", 24, "U04A16", "PK36SCBL0000001123456702")); addSpecification(new Specification("PL", 28, "F08F16", "PL61109010140000071219812874")); addSpecification(new Specification("PS", 29, "U04A21", "PS92PALS000000000400123456702")); addSpecification(new Specification("PT", 25, "F04F04F11F02", "PT50000201231234567890154")); addSpecification(new Specification("QA", 29, "U04A21", "QA30AAAA123456789012345678901")); addSpecification(new Specification("RO", 24, "U04A16", "RO49AAAA1B31007593840000")); addSpecification(new Specification("RS", 22, "F03F13F02", "RS35260005601001611379")); addSpecification(new Specification("SA", 24, "F02A18", "SA0380000000608010167519")); addSpecification(new Specification("SC", 31, "U04F04F16U03", "SC18SSCB11010000000000001497USD")); addSpecification(new Specification("SE", 24, "F03F16F01", "SE4550000000058398257466")); addSpecification(new Specification("SI", 19, "F05F08F02", "SI56263300012039086")); addSpecification(new Specification("SK", 24, "F04F06F10", "SK3112000000198742637541")); addSpecification(new Specification("SM", 27, "U01F05F05A12", "SM86U0322509800000000270100")); addSpecification(new Specification("ST", 25, "F08F11F02", "ST68000100010051845310112")); addSpecification(new Specification("SV", 28, "U04F20", "SV62CENR00000000000000700025")); addSpecification(new Specification("TL", 23, "F03F14F02", "TL380080012345678910157")); addSpecification(new Specification("TN", 24, "F02F03F13F02", "TN5910006035183598478831")); addSpecification(new Specification("TR", 26, "F05F01A16", "TR330006100519786457841326")); addSpecification(new Specification("UA", 29, "F25", "UA511234567890123456789012345")); addSpecification(new Specification("VA", 22, "F18", "VA59001123000012345678")); addSpecification(new Specification("VG", 24, "U04F16", "VG96VPVG0000012345678901")); addSpecification(new Specification("XK", 20, "F04F10F02", "XK051212012345678906")); // The following countries are not included in the official IBAN registry but use the IBAN specification // Angola addSpecification(new Specification("AO", 25, "F21", "AO69123456789012345678901")); // Burkina addSpecification(new Specification("BF", 27, "F23", "BF2312345678901234567890123")); // Burundi addSpecification(new Specification("BI", 16, "F12", "BI41123456789012")); // Benin addSpecification(new Specification("BJ", 28, "F24", "BJ39123456789012345678901234")); // Ivory addSpecification(new Specification("CI", 28, "U02F22", "CI70CI1234567890123456789012")); // Cameron addSpecification(new Specification("CM", 27, "F23", "CM9012345678901234567890123")); // Cape Verde addSpecification(new Specification("CV", 25, "F21", "CV30123456789012345678901")); // Algeria addSpecification(new Specification("DZ", 24, "F20", "DZ8612345678901234567890")); // Iran addSpecification(new Specification("IR", 26, "F22", "IR861234568790123456789012")); // Madagascar addSpecification(new Specification("MG", 27, "F23", "MG1812345678901234567890123")); // Mali addSpecification(new Specification("ML", 28, "U01F23", "ML15A12345678901234567890123")); // Mozambique addSpecification(new Specification("MZ", 25, "F21", "MZ25123456789012345678901")); // Senegal addSpecification(new Specification("SN", 28, "U01F23", "SN52A12345678901234567890123")); // The following are regional and administrative French Republic subdivision IBAN specification (same structure as FR, only country code vary) addSpecification(new Specification("GF", 27, "F05F05A11F02", "GF121234512345123456789AB13")); addSpecification(new Specification("GP", 27, "F05F05A11F02", "GP791234512345123456789AB13")); addSpecification(new Specification("MQ", 27, "F05F05A11F02", "MQ221234512345123456789AB13")); addSpecification(new Specification("RE", 27, "F05F05A11F02", "RE131234512345123456789AB13")); addSpecification(new Specification("PF", 27, "F05F05A11F02", "PF281234512345123456789AB13")); addSpecification(new Specification("TF", 27, "F05F05A11F02", "TF891234512345123456789AB13")); addSpecification(new Specification("YT", 27, "F05F05A11F02", "YT021234512345123456789AB13")); addSpecification(new Specification("NC", 27, "F05F05A11F02", "NC551234512345123456789AB13")); addSpecification(new Specification("BL", 27, "F05F05A11F02", "BL391234512345123456789AB13")); addSpecification(new Specification("MF", 27, "F05F05A11F02", "MF551234512345123456789AB13")); addSpecification(new Specification("PM", 27, "F05F05A11F02", "PM071234512345123456789AB13")); addSpecification(new Specification("WF", 27, "F05F05A11F02", "WF621234512345123456789AB13")); var NON_ALPHANUM = /[^a-zA-Z0-9]/g, EVERY_FOUR_CHARS =/(.{4})(?!$)/g; /** * Utility function to check if a variable is a String. * * @param v * @returns {boolean} true if the passed variable is a String, false otherwise. */ function isString(v){ return (typeof v == 'string' || v instanceof String); } /** * Check if an IBAN is valid. * * @param {String} iban the IBAN to validate. * @returns {boolean} true if the passed IBAN is valid, false otherwise */ exports.isValid = function(iban){ if (!isString(iban)){ return false; } iban = electronicFormat(iban); var countryStructure = countries[iban.slice(0,2)]; return !!countryStructure && countryStructure.isValid(iban); }; /** * Convert an IBAN to a BBAN. * * @param iban * @param {String} [separator] the separator to use between the blocks of the BBAN, defaults to ' ' * @returns {string|*} */ exports.toBBAN = function(iban, separator){ if (typeof separator == 'undefined'){ separator = ' '; } iban = electronicFormat(iban); var countryStructure = countries[iban.slice(0,2)]; if (!countryStructure) { throw new Error('No country with code ' + iban.slice(0,2)); } return countryStructure.toBBAN(iban, separator); }; /** * Convert the passed BBAN to an IBAN for this country specification. * Please note that "generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account". * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits * * @param countryCode the country of the BBAN * @param bban the BBAN to convert to IBAN * @returns {string} the IBAN */ exports.fromBBAN = function(countryCode, bban){ var countryStructure = countries[countryCode]; if (!countryStructure) { throw new Error('No country with code ' + countryCode); } return countryStructure.fromBBAN(electronicFormat(bban)); }; /** * Check the validity of the passed BBAN. * * @param countryCode the country of the BBAN * @param bban the BBAN to check the validity of */ exports.isValidBBAN = function(countryCode, bban){ if (!isString(bban)){ return false; } var countryStructure = countries[countryCode]; return countryStructure && countryStructure.isValidBBAN(electronicFormat(bban)); }; /** * * @param iban * @param separator * @returns {string} */ exports.printFormat = function(iban, separator){ if (typeof separator == 'undefined'){ separator = ' '; } return electronicFormat(iban).replace(EVERY_FOUR_CHARS, "$1" + separator); }; exports.electronicFormat = electronicFormat; /** * An object containing all the known IBAN specifications. */ exports.countries = countries; })); /* * jQuery throttle / debounce - v1.1 - 3/7/2010 * http://benalman.com/projects/jquery-throttle-debounce-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); +function(a){"use strict";function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var c=function(){function a(a,b){for(var c=0;c
    ',leftArrow:"",rightArrow:"",strings:{close:"Close",fail:"Failed to load image:",type:"Could not detect remote target type. Force the type using data-type"},doc:document,onShow:function(){},onShown:function(){},onHide:function(){},onHidden:function(){},onNavigate:function(){},onContentLoaded:function(){}},g=function(){function d(c,e){var g=this;b(this,d),this._config=a.extend({},f,e),this._$modalArrows=null,this._galleryIndex=0,this._galleryName=null,this._padding=null,this._border=null,this._titleIsShown=!1,this._footerIsShown=!1,this._wantedWidth=0,this._wantedHeight=0,this._modalId="ekkoLightbox-"+Math.floor(1e3*Math.random()+1),this._$element=c instanceof jQuery?c:a(c),this._isBootstrap3=3==a.fn.modal.Constructor.VERSION[0];var h='",i='',j='",k='",l='',m='";a(this._config.doc.body).append('"),this._$modal=a("#"+this._modalId,this._config.doc),this._$modalDialog=this._$modal.find(".modal-dialog").first(),this._$modalContent=this._$modal.find(".modal-content").first(),this._$modalBody=this._$modal.find(".modal-body").first(),this._$modalHeader=this._$modal.find(".modal-header").first(),this._$modalFooter=this._$modal.find(".modal-footer").first(),this._$lightboxContainer=this._$modalBody.find(".ekko-lightbox-container").first(),this._$lightboxBodyOne=this._$lightboxContainer.find("> div:first-child").first(),this._$lightboxBodyTwo=this._$lightboxContainer.find("> div:last-child").first(),this._border=this._calculateBorders(),this._padding=this._calculatePadding(),this._galleryName=this._$element.data("gallery"),this._galleryName&&(this._$galleryItems=a(document.body).find('*[data-gallery="'+this._galleryName+'"]'),this._galleryIndex=this._$galleryItems.index(this._$element),a(document).on("keydown.ekkoLightbox",this._navigationalBinder.bind(this)),this._config.showArrows&&this._$galleryItems.length>1&&(this._$lightboxContainer.append('"),this._$modalArrows=this._$lightboxContainer.find("div.ekko-lightbox-nav-overlay").first(),this._$lightboxContainer.on("click","a:first-child",function(a){return a.preventDefault(),g.navigateLeft()}),this._$lightboxContainer.on("click","a:last-child",function(a){return a.preventDefault(),g.navigateRight()}))),this._$modal.on("show.bs.modal",this._config.onShow.bind(this)).on("shown.bs.modal",function(){return g._toggleLoading(!0),g._handle(),g._config.onShown.call(g)}).on("hide.bs.modal",this._config.onHide.bind(this)).on("hidden.bs.modal",function(){return g._galleryName&&(a(document).off("keydown.ekkoLightbox"),a(window).off("resize.ekkoLightbox")),g._$modal.remove(),g._config.onHidden.call(g)}).modal(this._config),a(window).on("resize.ekkoLightbox",function(){g._resize(g._wantedWidth,g._wantedHeight)})}return c(d,null,[{key:"Default",get:function(){return f}}]),c(d,[{key:"element",value:function(){return this._$element}},{key:"modal",value:function(){return this._$modal}},{key:"navigateTo",value:function(b){return b<0||b>this._$galleryItems.length-1?this:(this._galleryIndex=b,this._$element=a(this._$galleryItems.get(this._galleryIndex)),void this._handle())}},{key:"navigateLeft",value:function(){if(1!==this._$galleryItems.length)return 0===this._galleryIndex?this._galleryIndex=this._$galleryItems.length-1:this._galleryIndex--,this._config.onNavigate.call(this,"left",this._galleryIndex),this.navigateTo(this._galleryIndex)}},{key:"navigateRight",value:function(){if(1!==this._$galleryItems.length)return this._galleryIndex===this._$galleryItems.length-1?this._galleryIndex=0:this._galleryIndex++,this._config.onNavigate.call(this,"right",this._galleryIndex),this.navigateTo(this._galleryIndex)}},{key:"close",value:function(){return this._$modal.modal("hide")}},{key:"_navigationalBinder",value:function(a){return a=a||window.event,39===a.keyCode?this.navigateRight():37===a.keyCode?this.navigateLeft():void 0}},{key:"_detectRemoteType",value:function(a,b){return b=b||!1,!b&&this._isImage(a)&&(b="image"),!b&&this._getYoutubeId(a)&&(b="youtube"),!b&&this._getVimeoId(a)&&(b="vimeo"),!b&&this._getInstagramId(a)&&(b="instagram"),(!b||["image","youtube","vimeo","instagram","video","url"].indexOf(b)<0)&&(b="url"),b}},{key:"_isImage",value:function(a){return a&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)}},{key:"_containerToUse",value:function(){var a=this,b=this._$lightboxBodyTwo,c=this._$lightboxBodyOne;return this._$lightboxBodyTwo.hasClass("in")&&(b=this._$lightboxBodyOne,c=this._$lightboxBodyTwo),c.removeClass("in show"),setTimeout(function(){a._$lightboxBodyTwo.hasClass("in")||a._$lightboxBodyTwo.empty(),a._$lightboxBodyOne.hasClass("in")||a._$lightboxBodyOne.empty()},500),b.addClass("in show"),b}},{key:"_handle",value:function(){var a=this._containerToUse();this._updateTitleAndFooter();var b=this._$element.attr("data-remote")||this._$element.attr("href"),c=this._detectRemoteType(b,this._$element.attr("data-type")||!1);if(["image","youtube","vimeo","instagram","video","url"].indexOf(c)<0)return this._error(this._config.strings.type);switch(c){case"image":this._preloadImage(b,a),this._preloadImageByIndex(this._galleryIndex,3);break;case"youtube":this._showYoutubeVideo(b,a);break;case"vimeo":this._showVimeoVideo(this._getVimeoId(b),a);break;case"instagram":this._showInstagramVideo(this._getInstagramId(b),a);break;case"video":this._showHtml5Video(b,a);break;default:this._loadRemoteContent(b,a)}return this}},{key:"_getYoutubeId",value:function(a){if(!a)return!1;var b=a.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/);return!(!b||11!==b[2].length)&&b[2]}},{key:"_getVimeoId",value:function(a){return!!(a&&a.indexOf("vimeo")>0)&&a}},{key:"_getInstagramId",value:function(a){return!!(a&&a.indexOf("instagram")>0)&&a}},{key:"_toggleLoading",value:function(b){return b=b||!1,b?(this._$modalDialog.css("display","none"),this._$modal.removeClass("in show"),a(".modal-backdrop").append(this._config.loadingMessage)):(this._$modalDialog.css("display","block"),this._$modal.addClass("in show"),a(".modal-backdrop").find(".ekko-lightbox-loader").remove()),this}},{key:"_calculateBorders",value:function(){return{top:this._totalCssByAttribute("border-top-width"),right:this._totalCssByAttribute("border-right-width"),bottom:this._totalCssByAttribute("border-bottom-width"),left:this._totalCssByAttribute("border-left-width")}}},{key:"_calculatePadding",value:function(){return{top:this._totalCssByAttribute("padding-top"),right:this._totalCssByAttribute("padding-right"),bottom:this._totalCssByAttribute("padding-bottom"),left:this._totalCssByAttribute("padding-left")}}},{key:"_totalCssByAttribute",value:function(a){return parseInt(this._$modalDialog.css(a),10)+parseInt(this._$modalContent.css(a),10)+parseInt(this._$modalBody.css(a),10)}},{key:"_updateTitleAndFooter",value:function(){var a=this._$element.data("title")||"",b=this._$element.data("footer")||"";return this._titleIsShown=!1,a||this._config.alwaysShowClose?(this._titleIsShown=!0,this._$modalHeader.css("display","").find(".modal-title").html(a||" ")):this._$modalHeader.css("display","none"),this._footerIsShown=!1,b?(this._footerIsShown=!0,this._$modalFooter.css("display","").html(b)):this._$modalFooter.css("display","none"),this}},{key:"_showYoutubeVideo",value:function(a,b){var c=this._getYoutubeId(a),d=a.indexOf("&")>0?a.substr(a.indexOf("&")):"",e=this._$element.data("width")||560,f=this._$element.data("height")||e/(560/315);return this._showVideoIframe("//www.youtube.com/embed/"+c+"?badge=0&autoplay=1&html5=1"+d,e,f,b)}},{key:"_showVimeoVideo",value:function(a,b){var c=500,d=this._$element.data("height")||c/(560/315);return this._showVideoIframe(a+"?autoplay=1",c,d,b)}},{key:"_showInstagramVideo",value:function(a,b){var c=this._$element.data("width")||612,d=c+80;return a="/"!==a.substr(-1)?a+"/":a,b.html(''),this._resize(c,d),this._config.onContentLoaded.call(this),this._$modalArrows&&this._$modalArrows.css("display","none"),this._toggleLoading(!1),this}},{key:"_showVideoIframe",value:function(a,b,c,d){return c=c||b,d.html('
    '),this._resize(b,c),this._config.onContentLoaded.call(this),this._$modalArrows&&this._$modalArrows.css("display","none"),this._toggleLoading(!1),this}},{key:"_showHtml5Video",value:function(a,b){var c=this._$element.data("width")||560,d=this._$element.data("height")||c/(560/315);return b.html('
    '),this._resize(c,d),this._config.onContentLoaded.call(this),this._$modalArrows&&this._$modalArrows.css("display","none"),this._toggleLoading(!1),this}},{key:"_loadRemoteContent",value:function(b,c){var d=this,e=this._$element.data("width")||560,f=this._$element.data("height")||560,g=this._$element.data("disableExternalCheck")||!1;return this._toggleLoading(!1),g||this._isExternal(b)?(c.html(''),this._config.onContentLoaded.call(this)):c.load(b,a.proxy(function(){return d._$element.trigger("loaded.bs.modal")})),this._$modalArrows&&this._$modalArrows.css("display","none"),this._resize(e,f),this}},{key:"_isExternal",value:function(a){var b=a.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);return"string"==typeof b[1]&&b[1].length>0&&b[1].toLowerCase()!==location.protocol||"string"==typeof b[2]&&b[2].length>0&&b[2].replace(new RegExp(":("+{"http:":80,"https:":443}[location.protocol]+")?$"),"")!==location.host}},{key:"_error",value:function(a){return console.error(a),this._containerToUse().html(a),this._resize(300,300),this}},{key:"_preloadImageByIndex",value:function(b,c){if(this._$galleryItems){var d=a(this._$galleryItems.get(b),!1);if("undefined"!=typeof d){var e=d.attr("data-remote")||d.attr("href");return("image"===d.attr("data-type")||this._isImage(e))&&this._preloadImage(e,!1),c>0?this._preloadImageByIndex(b+1,c-1):void 0}}}},{key:"_preloadImage",value:function(b,c){var d=this;c=c||!1;var e=new Image;return c&&!function(){var f=setTimeout(function(){c.append(d._config.loadingMessage)},200);e.onload=function(){f&&clearTimeout(f),f=null;var b=a("");return b.attr("src",e.src),b.addClass("img-fluid"),b.css("width","100%"),c.html(b),d._$modalArrows&&d._$modalArrows.css("display",""),d._resize(e.width,e.height),d._toggleLoading(!1),d._config.onContentLoaded.call(d)},e.onerror=function(){return d._toggleLoading(!1),d._error(d._config.strings.fail+(" "+b))}}(),e.src=b,e}},{key:"_resize",value:function(b,c){c=c||b,this._wantedWidth=b,this._wantedHeight=c;var d=this._padding.left+this._padding.right+this._border.left+this._border.right,e=Math.min(b+d,this._config.doc.body.clientWidth);b+d>e?(c=(e-d)/b*c,b=e):b+=d;var f=0,g=0;this._footerIsShown&&(g=this._$modalFooter.outerHeight(!0)||55),this._titleIsShown&&(f=this._$modalHeader.outerHeight(!0)||67);var h=this._padding.top+this._padding.bottom+this._border.bottom+this._border.top,i=parseFloat(this._$modalDialog.css("margin-top"))+parseFloat(this._$modalDialog.css("margin-bottom")),j=Math.min(c,a(window).height()-h-i-f-g);if(c>j){var k=Math.min(j/c,1);b=Math.ceil(k*b)}if(this._$lightboxContainer.css("height",j),this._$modalDialog.css("width","auto").css("maxWidth",b),this._isBootstrap3){var l=this._$modal.data("bs.modal");l&&l.handleUpdate()}else{var l=this._$modal.data("bs.modal");l&&l._handleUpdate()}return this}}],[{key:"_jQueryInterface",value:function(b){var c=this;return b=b||{},this.each(function(){var e=a(c),f=a.extend({},d.Default,e.data(),"object"==typeof b&&b);new d(c,f)})}}]),d}();return a.fn[d]=g._jQueryInterface,a.fn[d].Constructor=g,a.fn[d].noConflict=function(){return a.fn[d]=e,g._jQueryInterface},g})(jQuery)}(jQuery); /* Peppered Forked from https://github.com/dangrossman/daterangepicker to selectively apply patches */ /** * @version: 3.1 * @author: Dan Grossman http://www.dangrossman.info/ * @copyright: Copyright (c) 2012-2019 Dan Grossman. All rights reserved. * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php * @website: http://www.daterangepicker.com/ */ // Following the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Make globaly available as well define(['moment', 'jquery'], function (moment, jquery) { if (!jquery.fn) jquery.fn = {}; // webpack server rendering if (typeof moment !== 'function' && moment.hasOwnProperty('default')) moment = moment['default'] return factory(moment, jquery); }); } else if (typeof module === 'object' && module.exports) { // Node / Browserify //isomorphic issue var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; if (!jQuery) { jQuery = require('jquery'); if (!jQuery.fn) jQuery.fn = {}; } var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment'); module.exports = factory(moment, jQuery); } else { // Browser globals root.daterangepicker = factory(root.moment, root.jQuery); } }(typeof window !== 'undefined' ? window : this, function(moment, $) { var DateRangePicker = function(element, options, cb) { //default settings for options this.parentEl = 'body'; this.element = $(element); this.startDate = moment().startOf('day'); this.endDate = moment().endOf('day'); this.minDate = false; this.maxDate = false; this.maxSpan = false; this.autoApply = false; this.singleDatePicker = false; this.singleRangePicker = false; this.endDateFallback = false; this.showDropdowns = false; this.minYear = moment().subtract(100, 'year').format('YYYY'); this.maxYear = moment().add(100, 'year').format('YYYY'); this.showWeekNumbers = false; this.showISOWeekNumbers = false; this.showCustomRangeLabel = true; this.timePicker = false; this.timePicker24Hour = false; this.timePickerIncrement = 1; this.timePickerSeconds = false; this.linkedCalendars = true; this.autoUpdateInput = true; this.alwaysShowCalendars = false; this.ranges = {}; this.opens = 'right'; if (this.element.hasClass('pull-right')) this.opens = 'left'; this.drops = 'down'; if (this.element.hasClass('dropup')) this.drops = 'up'; this.buttonClasses = 'btn btn-sm'; this.applyButtonClasses = 'btn-primary'; this.cancelButtonClasses = 'btn-default'; this.locale = { direction: 'ltr', format: moment.localeData().longDateFormat('L'), separator: ' - ', applyLabel: 'Apply', cancelLabel: 'Cancel', weekLabel: 'W', customRangeLabel: 'Custom Range', daysOfWeek: moment.weekdaysMin(), monthNames: moment.monthsShort(), firstDay: moment.localeData().firstDayOfWeek() }; this.callback = function() { }; //some state information this.isShowing = false; this.leftCalendar = {}; this.rightCalendar = {}; //custom options from user if (typeof options !== 'object' || options === null) options = {}; //allow setting options with data attributes //data-api options will be overwritten with custom javascript options options = $.extend(this.element.data(), options); //html template for the picker UI if (typeof options.template !== 'string' && !(options.template instanceof $)) options.template = '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + '' + ' ' + '
    ' + '
    '; this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl); this.container = $(options.template).appendTo(this.parentEl); // // handle all the possible options overriding defaults // if (typeof options.locale === 'object') { if (typeof options.locale.direction === 'string') this.locale.direction = options.locale.direction; if (typeof options.locale.format === 'string') this.locale.format = options.locale.format; if (typeof options.locale.separator === 'string') this.locale.separator = options.locale.separator; if (typeof options.locale.daysOfWeek === 'object') this.locale.daysOfWeek = options.locale.daysOfWeek.slice(); if (typeof options.locale.monthNames === 'object') this.locale.monthNames = options.locale.monthNames.slice(); if (typeof options.locale.firstDay === 'number') this.locale.firstDay = options.locale.firstDay; if (typeof options.locale.applyLabel === 'string') this.locale.applyLabel = options.locale.applyLabel; if (typeof options.locale.cancelLabel === 'string') this.locale.cancelLabel = options.locale.cancelLabel; if (typeof options.locale.weekLabel === 'string') this.locale.weekLabel = options.locale.weekLabel; if (typeof options.locale.customRangeLabel === 'string'){ //Support unicode chars in the custom range name. var elem = document.createElement('textarea'); elem.innerHTML = options.locale.customRangeLabel; var rangeHtml = elem.value; this.locale.customRangeLabel = rangeHtml; } } this.container.addClass(this.locale.direction); if (typeof options.startDate === 'string') this.startDate = moment(options.startDate, this.locale.format); if (typeof options.endDate === 'string') this.endDate = moment(options.endDate, this.locale.format); if (typeof options.minDate === 'string') this.minDate = moment(options.minDate, this.locale.format); if (typeof options.maxDate === 'string') this.maxDate = moment(options.maxDate, this.locale.format); if (typeof options.startDate === 'object') this.startDate = moment(options.startDate); if (typeof options.endDate === 'object') this.endDate = moment(options.endDate); if (typeof options.endDateFallback === 'object') this.endDateFallback = moment(options.endDateFallback); if (typeof options.minDate === 'object') this.minDate = moment(options.minDate); if (typeof options.maxDate === 'object') this.maxDate = moment(options.maxDate); // sanity check for bad options if (this.minDate && this.startDate.isBefore(this.minDate)) this.startDate = this.minDate.clone(); // sanity check for bad options if (this.maxDate && this.endDate.isAfter(this.maxDate)) this.endDate = this.maxDate.clone(); if (typeof options.applyButtonClasses === 'string') this.applyButtonClasses = options.applyButtonClasses; if (typeof options.applyClass === 'string') //backwards compat this.applyButtonClasses = options.applyClass; if (typeof options.cancelButtonClasses === 'string') this.cancelButtonClasses = options.cancelButtonClasses; if (typeof options.cancelClass === 'string') //backwards compat this.cancelButtonClasses = options.cancelClass; if (typeof options.maxSpan === 'object') this.maxSpan = options.maxSpan; if (typeof options.dateLimit === 'object') //backwards compat this.maxSpan = options.dateLimit; if (typeof options.opens === 'string') this.opens = options.opens; if (typeof options.drops === 'string') this.drops = options.drops; if (typeof options.showWeekNumbers === 'boolean') this.showWeekNumbers = options.showWeekNumbers; if (typeof options.showISOWeekNumbers === 'boolean') this.showISOWeekNumbers = options.showISOWeekNumbers; if (typeof options.buttonClasses === 'string') this.buttonClasses = options.buttonClasses; if (typeof options.buttonClasses === 'object') this.buttonClasses = options.buttonClasses.join(' '); if (typeof options.showDropdowns === 'boolean') this.showDropdowns = options.showDropdowns; if (typeof options.minYear === 'number') this.minYear = options.minYear; if (typeof options.maxYear === 'number') this.maxYear = options.maxYear; if (typeof options.showCustomRangeLabel === 'boolean') this.showCustomRangeLabel = options.showCustomRangeLabel; if (typeof options.singleRangePicker === 'boolean') this.singleRangePicker = options.singleRangePicker; if (typeof options.singleDatePicker === 'boolean') { this.singleDatePicker = options.singleDatePicker; if (this.singleDatePicker && !this.singleRangePicker) this.endDate = this.startDate.clone(); } if (typeof options.timePicker === 'boolean') this.timePicker = options.timePicker; if (typeof options.timePickerSeconds === 'boolean') this.timePickerSeconds = options.timePickerSeconds; if (typeof options.timePickerIncrement === 'number') this.timePickerIncrement = options.timePickerIncrement; if (typeof options.timePicker24Hour === 'boolean') this.timePicker24Hour = options.timePicker24Hour; if (typeof options.autoApply === 'boolean') this.autoApply = options.autoApply; if (typeof options.autoUpdateInput === 'boolean') this.autoUpdateInput = options.autoUpdateInput; if (typeof options.linkedCalendars === 'boolean') this.linkedCalendars = options.linkedCalendars; if (typeof options.isInvalidDate === 'function') this.isInvalidDate = options.isInvalidDate; if (typeof options.isCustomDate === 'function') this.isCustomDate = options.isCustomDate; if (typeof options.alwaysShowCalendars === 'boolean') this.alwaysShowCalendars = options.alwaysShowCalendars; // update day names order to firstDay if (this.locale.firstDay != 0) { var iterator = this.locale.firstDay; while (iterator > 0) { this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()); iterator--; } } var start, end, range; //if no start/end dates set, check if an input element contains initial values if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') { if ($(this.element).is(':text')) { var val = $(this.element).val(), split = val.split(this.locale.separator); start = end = null; if (split.length == 2) { start = moment(split[0], this.locale.format); end = moment(split[1], this.locale.format); } else if (this.singleDatePicker && val !== "") { start = moment(val, this.locale.format); end = moment(val, this.locale.format); } if (start !== null && end !== null) { this.setStartDate(start); this.setEndDate(end); } } } if (typeof options.ranges === 'object') { for (range in options.ranges) { if (typeof options.ranges[range][0] === 'string') start = moment(options.ranges[range][0], this.locale.format); else start = moment(options.ranges[range][0]); if (typeof options.ranges[range][1] === 'string') end = moment(options.ranges[range][1], this.locale.format); else end = moment(options.ranges[range][1]); // If the start or end date exceed those allowed by the minDate or maxSpan // options, shorten the range to the allowable period. if (this.minDate && start.isBefore(this.minDate)) start = this.minDate.clone(); var maxDate = this.maxDate; if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate)) maxDate = start.clone().add(this.maxSpan); if (maxDate && end.isAfter(maxDate)) end = maxDate.clone(); // If the end of the range is before the minimum or the start of the range is // after the maximum, don't display this range option at all. if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day')) || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day'))) continue; //Support unicode chars in the range names. var elem = document.createElement('textarea'); elem.innerHTML = range; var rangeHtml = elem.value; this.ranges[rangeHtml] = [start, end]; } var list = '
      '; for (range in this.ranges) { list += '
    • ' + range + '
    • '; } if (this.showCustomRangeLabel) { list += '
    • ' + this.locale.customRangeLabel + '
    • '; } list += '
    '; this.container.find('.ranges').prepend(list); } if (typeof cb === 'function') { this.callback = cb; } if (!this.timePicker) { this.startDate = this.startDate.startOf('day'); this.endDate = this.endDate.endOf('day'); this.container.find('.calendar-time').hide(); } //can't be used together for now if (this.timePicker && this.autoApply) this.autoApply = false; if (this.autoApply) { this.container.addClass('auto-apply'); } if (typeof options.ranges === 'object') this.container.addClass('show-ranges'); if (this.singleDatePicker) { this.container.addClass('single'); this.container.find('.drp-calendar.left').addClass('single'); this.container.find('.drp-calendar.left').show(); this.container.find('.drp-calendar.right').hide(); if (!this.timePicker && (this.singleRangePicker && this.autoApply)) { this.container.addClass('auto-apply'); } } if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) { this.container.addClass('show-calendar'); } this.container.addClass('opens' + this.opens); //apply CSS classes and labels to buttons this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses); if (this.applyButtonClasses.length) this.container.find('.applyBtn').addClass(this.applyButtonClasses); if (this.cancelButtonClasses.length) this.container.find('.cancelBtn').addClass(this.cancelButtonClasses); this.container.find('.applyBtn').html(this.locale.applyLabel); this.container.find('.cancelBtn').html(this.locale.cancelLabel); // // event listeners // this.container.find('.drp-calendar') .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this)) .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this)) .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this)) .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this)) .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this)); this.container.find('.ranges') .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)); this.container.find('.drp-buttons') .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this)) .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this)); if (this.element.is('input') || this.element.is('button')) { this.element.on({ 'click.daterangepicker': $.proxy(this.show, this), 'focus.daterangepicker': $.proxy(this.show, this), 'keyup.daterangepicker': $.proxy(this.elementChanged, this), 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility }); } else { this.element.on('click.daterangepicker', $.proxy(this.toggle, this)); this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this)); } // // if attached to a text input, set the initial value // this.updateElement(); }; DateRangePicker.prototype = { constructor: DateRangePicker, setStartDate: function(startDate) { if (typeof startDate === 'string') this.startDate = moment(startDate, this.locale.format); if (typeof startDate === 'object') this.startDate = moment(startDate); if (!this.timePicker) this.startDate = this.startDate.startOf('day'); if (this.timePicker && this.timePickerIncrement) this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); if (this.minDate && this.startDate.isBefore(this.minDate)) { this.startDate = this.minDate.clone(); if (this.timePicker && this.timePickerIncrement) this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); } if (this.maxDate && this.startDate.isAfter(this.maxDate)) { this.startDate = this.maxDate.clone(); if (this.timePicker && this.timePickerIncrement) this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); } if (!this.isShowing) this.updateElement(); this.updateMonthsInView(); }, setEndDate: function(endDate) { if (typeof endDate === 'string') this.endDate = moment(endDate, this.locale.format); if (typeof endDate === 'object') this.endDate = moment(endDate); if (!this.timePicker) this.endDate = this.endDate.endOf('day'); if (this.timePicker && this.timePickerIncrement) this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); if (this.endDate.isBefore(this.startDate)) this.endDate = this.startDate.clone(); if (this.maxDate && this.endDate.isAfter(this.maxDate)) this.endDate = this.maxDate.clone(); if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)) this.endDate = this.startDate.clone().add(this.maxSpan); this.previousRightTime = this.endDate.clone(); this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); if (!this.isShowing) this.updateElement(); this.updateMonthsInView(); }, isInvalidDate: function() { return false; }, isCustomDate: function() { return false; }, updateView: function() { if (this.timePicker) { this.renderTimePicker('left'); this.renderTimePicker('right'); if (!this.endDate) { this.container.find('.right .calendar-time select').prop('disabled', true).addClass('disabled'); } else { this.container.find('.right .calendar-time select').prop('disabled', false).removeClass('disabled'); } } if (this.endDate) this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); this.updateMonthsInView(); this.updateCalendars(); this.updateFormInputs(); }, updateMonthsInView: function() { if (this.endDate) { //if both dates are visible already, do nothing if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month && (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) && (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) ) { return; } // in single range mode it is very disorienting if the date picker jumps to the start date if (this.singleDatePicker && this.singleRangePicker && this.leftCalendar.month && this.rightCalendar.month) { return; } this.leftCalendar.month = this.startDate.clone().date(2); if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) { this.rightCalendar.month = this.endDate.clone().date(2); } else { this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month'); } } else { if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) { this.leftCalendar.month = this.startDate.clone().date(2); this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month'); } } if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) { this.rightCalendar.month = this.maxDate.clone().date(2); this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month'); } }, updateCalendars: function() { if (this.timePicker) { var hour, minute, second; if (this.endDate) { hour = parseInt(this.container.find('.left .hourselect').val(), 10); minute = parseInt(this.container.find('.left .minuteselect').val(), 10); if (isNaN(minute)) { minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10); } second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0; if (!this.timePicker24Hour) { var ampm = this.container.find('.left .ampmselect').val(); if (ampm === 'PM' && hour < 12) hour += 12; if (ampm === 'AM' && hour === 12) hour = 0; } } else { hour = parseInt(this.container.find('.right .hourselect').val(), 10); minute = parseInt(this.container.find('.right .minuteselect').val(), 10); if (isNaN(minute)) { minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10); } second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0; if (!this.timePicker24Hour) { var ampm = this.container.find('.right .ampmselect').val(); if (ampm === 'PM' && hour < 12) hour += 12; if (ampm === 'AM' && hour === 12) hour = 0; } } this.leftCalendar.month.hour(hour).minute(minute).second(second); this.rightCalendar.month.hour(hour).minute(minute).second(second); } this.renderCalendar('left'); this.renderCalendar('right'); //highlight any predefined range matching the current start and end dates this.container.find('.ranges li').removeClass('active'); if (this.endDate == null) return; this.calculateChosenLabel(); }, renderCalendar: function(side) { // // Build the matrix of dates that will populate the calendar // var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar; var month = calendar.month.month(); var year = calendar.month.year(); var hour = calendar.month.hour(); var minute = calendar.month.minute(); var second = calendar.month.second(); var daysInMonth = moment([year, month]).daysInMonth(); var firstDay = moment([year, month, 1]); var lastDay = moment([year, month, daysInMonth]); var lastMonth = moment(firstDay).subtract(1, 'month').month(); var lastYear = moment(firstDay).subtract(1, 'month').year(); var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth(); var dayOfWeek = firstDay.day(); //initialize a 6 rows x 7 columns array for the calendar var calendar = []; calendar.firstDay = firstDay; calendar.lastDay = lastDay; for (var i = 0; i < 6; i++) { calendar[i] = []; } //populate the calendar with date objects var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1; if (startDay > daysInLastMonth) startDay -= 7; if (dayOfWeek == this.locale.firstDay) startDay = daysInLastMonth - 6; var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]); var col, row; for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) { if (i > 0 && col % 7 === 0) { col = 0; row++; } calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second); curDate.hour(12); if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') { calendar[row][col] = this.minDate.clone(); } if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') { calendar[row][col] = this.maxDate.clone(); } } //make the calendar object available to hoverDate/clickDate if (side == 'left') { this.leftCalendar.calendar = calendar; } else { this.rightCalendar.calendar = calendar; } // // Display the calendar // var minDate = side == 'left' ? this.minDate : this.startDate; var maxDate = this.maxDate; var selected = side == 'left' ? this.startDate : this.endDate; var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'}; var html = ''; html += ''; html += ''; // add empty cell for week number if (this.showWeekNumbers || this.showISOWeekNumbers) html += ''; if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) { html += ''; } else { html += ''; } var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY"); if (this.showDropdowns) { var currentMonth = calendar[1][1].month(); var currentYear = calendar[1][1].year(); var maxYear = (maxDate && maxDate.year()) || (this.maxYear); var minYear = (minDate && minDate.year()) || (this.minYear); var inMinYear = currentYear == minYear; var inMaxYear = currentYear == maxYear; var monthHtml = '"; var yearHtml = ''; dateHtml = monthHtml + yearHtml; } html += ''; if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) { html += ''; } else { html += ''; } html += ''; html += ''; // add week number label if (this.showWeekNumbers || this.showISOWeekNumbers) html += ''; $.each(this.locale.daysOfWeek, function(index, dayOfWeek) { html += ''; }); html += ''; html += ''; html += ''; //adjust maxDate to reflect the maxSpan setting in order to //grey out end dates beyond the maxSpan if (this.endDate == null && this.maxSpan) { var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day'); if (!maxDate || maxLimit.isBefore(maxDate)) { maxDate = maxLimit; } } for (var row = 0; row < 6; row++) { html += ''; // add week number if (this.showWeekNumbers) html += ''; else if (this.showISOWeekNumbers) html += ''; for (var col = 0; col < 7; col++) { var classes = []; //highlight today's date if (calendar[row][col].isSame(new Date(), "day")) classes.push('today'); //highlight weekends if (calendar[row][col].isoWeekday() > 5) classes.push('weekend'); //grey out the dates in other months displayed at beginning and end of this calendar if (calendar[row][col].month() != calendar[1][1].month()) classes.push('off', 'ends'); //don't allow selection of dates before the minimum date if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day')) classes.push('off', 'disabled'); //don't allow selection of dates after the maximum date if (maxDate && calendar[row][col].isAfter(maxDate, 'day')) classes.push('off', 'disabled'); //don't allow selection of date if a custom function decides it's invalid if (this.isInvalidDate(calendar[row][col])) classes.push('off', 'disabled'); //highlight the currently selected start date if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD')) classes.push('active', 'start-date'); //highlight the currently selected end date if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD')) classes.push('active', 'end-date'); //highlight dates in-between the selected dates if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate) classes.push('in-range'); //apply custom classes for this date var isCustom = this.isCustomDate(calendar[row][col]); if (isCustom !== false) { if (typeof isCustom === 'string') classes.push(isCustom); else Array.prototype.push.apply(classes, isCustom); } var cname = '', disabled = false; for (var i = 0; i < classes.length; i++) { cname += classes[i] + ' '; if (classes[i] == 'disabled') disabled = true; } if (!disabled) cname += 'available'; html += ''; } html += ''; } html += ''; html += '
    ' + dateHtml + '
    ' + this.locale.weekLabel + '' + dayOfWeek + '
    ' + calendar[row][0].week() + '' + calendar[row][0].isoWeek() + '' + calendar[row][col].date() + '
    '; this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html); }, renderTimePicker: function(side) { // Don't bother updating the time picker if it's currently disabled // because an end date hasn't been clicked yet if (side == 'right' && !this.endDate) return; var html, selected, minDate, maxDate = this.maxDate; if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate))) maxDate = this.startDate.clone().add(this.maxSpan); if (side == 'left') { selected = this.startDate.clone(); minDate = this.minDate; } else if (side == 'right') { selected = this.endDate.clone(); minDate = this.startDate; //Preserve the time already selected var timeSelector = this.container.find('.drp-calendar.right .calendar-time'); if (timeSelector.html() != '') { selected.hour(!isNaN(selected.hour()) ? selected.hour() : timeSelector.find('.hourselect option:selected').val()); selected.minute(!isNaN(selected.minute()) ? selected.minute() : timeSelector.find('.minuteselect option:selected').val()); selected.second(!isNaN(selected.second()) ? selected.second() : timeSelector.find('.secondselect option:selected').val()); if (!this.timePicker24Hour) { var ampm = timeSelector.find('.ampmselect option:selected').val(); if (ampm === 'PM' && selected.hour() < 12) selected.hour(selected.hour() + 12); if (ampm === 'AM' && selected.hour() === 12) selected.hour(0); } } if (selected.isBefore(this.startDate)) selected = this.startDate.clone(); if (maxDate && selected.isAfter(maxDate)) selected = maxDate.clone(); } // // hours // html = ' '; // // minutes // html += ': '; // // seconds // if (this.timePickerSeconds) { html += ': '; } // // AM/PM // if (!this.timePicker24Hour) { html += ''; } this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html); }, updateFormInputs: function() { if ( (this.singleDatePicker && ! this.singleRangePicker) || (this.singleDatePicker && this.singleRangePicker && this.endDateFallback) || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate))) ) { this.container.find('button.applyBtn').prop('disabled', false); } else { this.container.find('button.applyBtn').prop('disabled', true); } }, move: function() { var parentOffset = { top: 0, left: 0 }, containerTop, drops = this.drops; var parentRightEdge = $(window).width(); if (!this.parentEl.is('body')) { parentOffset = { top: this.parentEl.offset().top - this.parentEl.scrollTop(), left: this.parentEl.offset().left - this.parentEl.scrollLeft() }; parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left; } switch (drops) { case 'auto': containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; if (containerTop + this.container.outerHeight() >= this.parentEl[0].scrollHeight) { containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; drops = 'up'; } break; case 'up': containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; break; default: containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; break; } // Force the container to it's actual width this.container.css({ top: 0, left: 0, right: 'auto' }); var containerWidth = this.container.outerWidth(); this.container.toggleClass('drop-up', drops == 'up'); if (this.opens == 'left') { var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth(); if (containerWidth + containerRight > $(window).width()) { this.container.css({ top: containerTop, right: 'auto', left: 9 }); } else { this.container.css({ top: containerTop, right: containerRight, left: 'auto' }); } } else if (this.opens == 'center') { var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 - containerWidth / 2; if (containerLeft < 0) { this.container.css({ top: containerTop, right: 'auto', left: 9 }); } else if (containerLeft + containerWidth > $(window).width()) { this.container.css({ top: containerTop, left: 'auto', right: 0 }); } else { this.container.css({ top: containerTop, left: containerLeft, right: 'auto' }); } } else { var containerLeft = this.element.offset().left - parentOffset.left; if (containerLeft + containerWidth > $(window).width()) { this.container.css({ top: containerTop, left: 'auto', right: 0 }); } else { this.container.css({ top: containerTop, left: containerLeft, right: 'auto' }); } } }, show: function(e) { if (this.isShowing) return; // Create a click proxy that is private to this instance of datepicker, for unbinding this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this); // Bind global datepicker mousedown for hiding and $(document) .on('mousedown.daterangepicker', this._outsideClickProxy) // also support mobile devices .on('touchend.daterangepicker', this._outsideClickProxy) // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) // and also close when focus changes to outside the picker (eg. tabbing between controls) .on('focusin.daterangepicker', this._outsideClickProxy); // Reposition the picker if the window is resized while it's open $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this)); this.oldStartDate = this.startDate.clone(); this.oldEndDate = this.endDate.clone(); this.previousRightTime = this.endDate.clone(); this.updateView(); this.container.show(); this.move(); this.element.trigger('show.daterangepicker', this); this.isShowing = true; }, hide: function(e) { if (!this.isShowing) return; //incomplete date selection, revert to last values if (!this.endDate) { if (this.endDateFallback && this.startDate) { this.endDate = this.endDateFallback; } else { this.startDate = this.oldStartDate.clone(); this.endDate = this.oldEndDate.clone(); } } //if a new date range was selected, invoke the user callback function if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel); //if picker is attached to a text input, update it this.updateElement(); $(document).off('.daterangepicker'); $(window).off('.daterangepicker'); this.container.hide(); this.element.trigger('hide.daterangepicker', this); this.isShowing = false; }, toggle: function(e) { if (this.isShowing) { this.hide(); } else { this.show(); } }, outsideClick: function(e) { var target = $(e.target); // if the page is clicked anywhere except within the daterangerpicker/button // itself then call this.hide() if ( // ie modal dialog fix e.type == "focusin" || target.closest(this.element).length || target.closest(this.container).length || target.closest('.calendar-table').length ) return; this.hide(); this.element.trigger('outsideClick.daterangepicker', this); }, showCalendars: function() { this.container.addClass('show-calendar'); this.move(); this.element.trigger('showCalendar.daterangepicker', this); }, hideCalendars: function() { this.container.removeClass('show-calendar'); this.element.trigger('hideCalendar.daterangepicker', this); }, clickRange: function(e) { var label = e.target.getAttribute('data-range-key'); this.chosenLabel = label; if (label == this.locale.customRangeLabel) { this.showCalendars(); } else { var dates = this.ranges[label]; this.setStartDate(dates[0]); this.setEndDate(dates[1]); if (!this.timePicker) { this.startDate.startOf('day'); this.endDate.endOf('day'); } if (!this.alwaysShowCalendars) this.hideCalendars(); this.updateCalendars(); if (this.autoApply) this.clickApply(); } }, clickPrev: function(e) { var cal = $(e.target).parents('.drp-calendar'); if (cal.hasClass('left')) { this.leftCalendar.month.subtract(1, 'month'); if (this.linkedCalendars) this.rightCalendar.month.subtract(1, 'month'); } else { this.rightCalendar.month.subtract(1, 'month'); } this.updateCalendars(); }, clickNext: function(e) { var cal = $(e.target).parents('.drp-calendar'); if (cal.hasClass('left')) { this.leftCalendar.month.add(1, 'month'); } else { this.rightCalendar.month.add(1, 'month'); if (this.linkedCalendars) this.leftCalendar.month.add(1, 'month'); } this.updateCalendars(); }, hoverDate: function(e) { //ignore dates that can't be selected if (!$(e.target).hasClass('available')) return; var title = $(e.target).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); var cal = $(e.target).parents('.drp-calendar'); var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; //highlight the dates between the start date and the date being hovered as a potential end date var leftCalendar = this.leftCalendar; var rightCalendar = this.rightCalendar; var startDate = this.startDate; if (!this.endDate) { this.container.find('.drp-calendar tbody td').each(function(index, el) { //skip week numbers, only look at dates if ($(el).hasClass('week')) return; var title = $(el).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); var cal = $(el).parents('.drp-calendar'); var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col]; if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) { $(el).addClass('in-range'); } else { $(el).removeClass('in-range'); } }); } }, clickDate: function(e) { if (!$(e.target).hasClass('available')) return; var title = $(e.target).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); var cal = $(e.target).parents('.drp-calendar'); var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; // // this function needs to do a few things: // * alternate between selecting a start and end date for the range, // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date // * if autoapply is enabled, and an end date was chosen, apply the selection // * if single date picker mode, and time picker isn't enabled, apply the selection immediately // * if one of the inputs above the calendars was focused, cancel that manual input // if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start if (this.timePicker) { var hour = parseInt(this.container.find('.left .hourselect').val(), 10); if (!this.timePicker24Hour) { var ampm = this.container.find('.left .ampmselect').val(); if (ampm === 'PM' && hour < 12) hour += 12; if (ampm === 'AM' && hour === 12) hour = 0; } var minute = parseInt(this.container.find('.left .minuteselect').val(), 10); if (isNaN(minute)) { minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10); } var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0; date = date.clone().hour(hour).minute(minute).second(second); } this.endDate = null; this.setStartDate(date.clone()); } else if (!this.endDate && date.isBefore(this.startDate)) { //special case: clicking the same date for start/end, //but the time of the end date is before the start date this.setEndDate(this.startDate.clone()); } else { // picking end if (this.timePicker) { var hour = parseInt(this.container.find('.right .hourselect').val(), 10); if (!this.timePicker24Hour) { var ampm = this.container.find('.right .ampmselect').val(); if (ampm === 'PM' && hour < 12) hour += 12; if (ampm === 'AM' && hour === 12) hour = 0; } var minute = parseInt(this.container.find('.right .minuteselect').val(), 10); if (isNaN(minute)) { minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10); } var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0; date = date.clone().hour(hour).minute(minute).second(second); } this.setEndDate(date.clone()); if (this.autoApply) { this.calculateChosenLabel(); this.clickApply(); } } if (this.singleDatePicker && !this.singleRangePicker) { this.setEndDate(this.startDate); if (!this.timePicker && this.autoApply) this.clickApply(); } this.updateView(); //This is to cancel the blur event handler if the mouse was in one of the inputs e.stopPropagation(); }, calculateChosenLabel: function () { var customRange = true; var i = 0; for (var range in this.ranges) { if (this.timePicker) { var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm"; //ignore times when comparing dates if time picker seconds is not enabled if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) { customRange = false; this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; } } else { //ignore times when comparing dates if time picker is not enabled if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) { customRange = false; this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; } } i++; } if (customRange) { if (this.showCustomRangeLabel) { this.chosenLabel = this.container.find('.ranges li:last').addClass('active').attr('data-range-key'); } else { this.chosenLabel = null; } this.showCalendars(); } }, clickApply: function(e) { this.hide(); this.element.trigger('apply.daterangepicker', this); }, clickCancel: function(e) { this.startDate = this.oldStartDate; this.endDate = this.oldEndDate; this.hide(); this.element.trigger('cancel.daterangepicker', this); }, monthOrYearChanged: function(e) { var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'), leftOrRight = isLeft ? 'left' : 'right', cal = this.container.find('.drp-calendar.'+leftOrRight); // Month must be Number for new moment versions var month = parseInt(cal.find('.monthselect').val(), 10); var year = cal.find('.yearselect').val(); if (!isLeft) { if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) { month = this.startDate.month(); year = this.startDate.year(); } } if (this.minDate) { if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) { month = this.minDate.month(); year = this.minDate.year(); } } if (this.maxDate) { if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) { month = this.maxDate.month(); year = this.maxDate.year(); } } if (isLeft) { this.leftCalendar.month.month(month).year(year); if (this.linkedCalendars) this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month'); } else { this.rightCalendar.month.month(month).year(year); if (this.linkedCalendars) this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month'); } this.updateCalendars(); }, timeChanged: function(e) { var cal = $(e.target).closest('.drp-calendar'), isLeft = cal.hasClass('left'); var hour = parseInt(cal.find('.hourselect').val(), 10); var minute = parseInt(cal.find('.minuteselect').val(), 10); if (isNaN(minute)) { minute = parseInt(cal.find('.minuteselect option:last').val(), 10); } var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0; if (!this.timePicker24Hour) { var ampm = cal.find('.ampmselect').val(); if (ampm === 'PM' && hour < 12) hour += 12; if (ampm === 'AM' && hour === 12) hour = 0; } if (isLeft) { var start = this.startDate.clone(); start.hour(hour); start.minute(minute); start.second(second); this.setStartDate(start); if (this.singleDatePicker && this.singleRangePicker) { this.endDate = this.startDate.clone(); } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) { this.setEndDate(start.clone()); } } else if (this.endDate) { var end = this.endDate.clone(); end.hour(hour); end.minute(minute); end.second(second); this.setEndDate(end); } //update the calendars so all clickable dates reflect the new time component this.updateCalendars(); //update the form inputs above the calendars with the new time this.updateFormInputs(); //re-render the time pickers because changing one selection can affect what's enabled in another this.renderTimePicker('left'); this.renderTimePicker('right'); }, elementChanged: function() { if (!this.element.is('input')) return; if (!this.element.val().length) return; var dateString = this.element.val().split(this.locale.separator), start = null, end = null; if (dateString.length === 2) { start = moment(dateString[0], this.locale.format); end = moment(dateString[1], this.locale.format); } if ((this.singleDatePicker && !this.singleRangePicker) || start === null || end === null) { start = moment(this.element.val(), this.locale.format); end = start; } if (!start.isValid() || !end.isValid()) return; this.setStartDate(start); this.setEndDate(end); this.updateView(); }, keydown: function(e) { //hide on tab or enter if ((e.keyCode === 9) || (e.keyCode === 13)) { this.hide(); } //hide on esc and prevent propagation if (e.keyCode === 27) { e.preventDefault(); e.stopPropagation(); this.hide(); } }, updateElement: function() { if (this.element.is('input') && this.autoUpdateInput) { var newValue = this.startDate.format(this.locale.format); if (!this.singleDatePicker) { newValue += this.locale.separator + this.endDate.format(this.locale.format); } if (this.singleDatePicker && this.singleRangePicker) { newValue += this.locale.separator + this.endDate.format(this.locale.format); } if (newValue !== this.element.val()) { this.element.val(newValue).trigger('change'); } } }, remove: function() { this.container.remove(); this.element.off('.daterangepicker'); this.element.removeData(); } }; $.fn.daterangepicker = function(options, callback) { var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options); this.each(function() { var el = $(this); if (el.data('daterangepicker')) el.data('daterangepicker').remove(); el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback)); }); return this; }; return DateRangePicker; })); /** * Autotab - jQuery plugin 1.9.2 * https://github.com/Mathachew/jquery-autotab * * Copyright (c) 2008, 2015 Matthew Miller * * Licensed under the MIT licensing: * http://www.opensource.org/licenses/mit-license.php */ (function(d){var u=navigator.platform,g=null,r="iPad"===u||"iPhone"===u||"iPod"===u,w="undefined"!==typeof InstallTrigger,x=!window.ActiveXObject&&"ActiveXObject"in window,h=function(a,f){if(null!==f&&"undefined"!==typeof f)for(var b in f)d(a).data("autotab-"+b,f[b])},l=function(a){var f={arrowKey:!1,format:"all",loaded:!1,disabled:!1,pattern:null,uppercase:!1,lowercase:!1,nospace:!1,maxlength:2147483647,target:null,previous:null,trigger:null,originalValue:"",changed:!1,editable:"text"===a.type|| "password"===a.type||"textarea"===a.type||"tel"===a.type||"number"===a.type||"email"===a.type||"search"===a.type||"url"===a.type,filterable:"text"===a.type||"password"===a.type||"textarea"===a.type,tabOnSelect:!1};if(!0===d.autotab.selectFilterByClass&&"undefined"===typeof d(a).data("autotab-format")){var b="all text alpha number numeric alphanumeric hex hexadecimal custom".split(" "),e;for(e in b)if(d(a).hasClass(b[e])){f.format=b[e];break}}for(e in f)"undefined"!==typeof d(a).data("autotab-"+e)&& (f[e]=d(a).data("autotab-"+e));f.loaded||(null!==f.trigger&&"string"===typeof f.trigger&&(f.trigger=f.trigger.toString()),h(a,f));return f},p=function(a){return"undefined"!==typeof a&&("string"===typeof a||!(a instanceof jQuery))},y=function(a){var d=0,b=0,e=0;if("text"===a.type||"password"===a.type||"textarea"===a.type)"number"===typeof a.selectionStart&&"number"===typeof a.selectionEnd?(d=a.selectionStart,b=a.selectionEnd,e=1):document.selection&&document.selection.createRange&&(b=document.selection.createRange(), d=a.createTextRange(),a=a.createTextRange(),e=b.getBookmark(),d.moveToBookmark(e),a.setEndPoint("EndToStart",d),d=a.text.length,b=d+b.text.length,e=2);return{start:d,end:b,selectionType:e}};d.autotab=function(a){"object"!==typeof a&&(a={});d(":input").autotab(a)};d.autotab.selectFilterByClass=!1;d.autotab.next=function(){var a=d(document.activeElement);a.length&&a.trigger("autotab-next")};d.autotab.previous=function(){var a=d(document.activeElement);a.length&&a.trigger("autotab-previous")};d.autotab.remove= function(a){p(a)?d(a).autotab("remove"):d(":input").autotab("remove")};d.autotab.restore=function(a){p(a)?d(a).autotab("restore"):d(":input").autotab("restore")};d.autotab.refresh=function(a){p(a)?d(a).autotab("refresh"):d(":input").autotab("refresh")};d.fn.autotab=function(a,f){if(!this.length)return this;var b=d.grep(this,function(a,c){return"hidden"!=a.type});if("filter"==a){if("string"===typeof f||"function"===typeof f)f={format:f};for(var e=0,m=b.length;e(new Date).getTime()-g.getTime())return g=null,!1}else"range"!==this.type&&"select-one"!==this.type&&"select-multiple"!==this.type&&("tel"!==this.type&&"number"!==this.type||("tel"===this.type||"number"===this.type)&&0==this.value.length)&&(37!=e||c.editable&&0!=b.start?39!=e||c.editable&&c.filterable&&b.end!=this.value.length&&0!=this.value.length||(c.arrowKey=!0,d(this).trigger("autotab-next",c)):(c.arrowKey= !0,d(this).trigger("autotab-previous",c)))}).on("keypress.autotab",function(a){var c=l(this),b=a.which||a.keyCode;if(!c||c.disabled||w&&0===a.charCode||a.ctrlKey||a.altKey||13==b||this.disabled)return!0;a=String.fromCharCode(b);if("text"!=this.type&&"password"!=this.type&&"textarea"!=this.type)return this.value.length+1>=c.maxlength&&(c.arrowKey=!1,d(this).trigger("autotab-next",c)),this.value.length!=c.maxlength;if(null!==c.trigger&&0<=c.trigger.indexOf(a))return null!==g&&800>(new Date).getTime()- g.getTime()?g=null:(c.arrowKey=!1,d(this).trigger("autotab-next",c)),!1;g=null;b=document.selection&&document.selection.createRange?!0:0=e[r];)r+=1;return r}function r(t,e,r){if(r>=t.slice(-1)[0])return 100;var n,i,o=f(r,t),a=t[o-1],s=t[o],l=e[o-1],u=e[o];return l+(i=r,p(n=[a,s],n[0]<0?i+Math.abs(n[0]):i-n[0])/c(l,u))}function n(t,e,r,n){if(100===n)return n;var i,o,a=f(n,t),s=t[a-1],l=t[a];return r?(l-s)/2= 2) required for mode 'count'.");var n=e-1,i=100/n;for(e=[];n--;)e[n]=n*i;e.push(100),t="positions"}return"positions"===t?e.map(function(t){return E.fromStepping(r?E.getStep(t):t)}):"values"===t?r?e.map(function(t){return E.fromStepping(E.getStep(E.toStepping(t)))}):e:void 0}(n,t.values||!1,t.stepped||!1),s=(m=i,g=n,v=a,b={},e=E.xVal[0],r=E.xVal[E.xVal.length-1],x=S=!1,w=0,(v=v.slice().sort(function(t,e){return t-e}).filter(function(t){return!this[t]&&(this[t]=!0)},{}))[0]!==e&&(v.unshift(e),S=!0),v[v.length-1]!==r&&(v.push(r),x=!0),v.forEach(function(t,e){var r,n,i,o,a,s,l,u,c,p,f=t,d=v[e+1],h="steps"===g;if(h&&(r=E.xNumSteps[e]),r||(r=d-f),!1!==f&&void 0!==d)for(r=Math.max(r,1e-7),n=f;n<=d;n=(n+r).toFixed(7)/1){for(u=(a=(o=E.toStepping(n))-w)/m,p=a/(c=Math.round(u)),i=1;i<=c;i+=1)b[(s=w+i*p).toFixed(5)]=[E.fromStepping(s),0];l=-1r.stepAfter.startValue&&(i=r.stepAfter.startValue-n),o=n>r.thisStep.startValue?r.thisStep.step:!1!==r.stepBefore.step&&n-r.stepBefore.highestStep,100===e?i=null:0===e&&(o=null);var a=E.countStepDecimals();return null!==i&&!1!==i&&(i=Number(i.toFixed(a))),null!==o&&!1!==o&&(o=Number(o.toFixed(a))),[o,i]}return ht(e=y,f.cssClasses.target),0===f.dir?ht(e,f.cssClasses.ltr):ht(e,f.cssClasses.rtl),0===f.ort?ht(e,f.cssClasses.horizontal):ht(e,f.cssClasses.vertical),l=V(e,f.cssClasses.base),function(t,e){var r=V(e,f.cssClasses.connects);u=[],(a=[]).push(O(r,t[0]));for(var n=0;nPrevious',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('