function applyFilter(){var n=getParameterByName("search"),t=getParameterByName("sort"),i=getTagString(),r=getTypeString(),u=$('input[name="dates"]').val().trim();document.location.href=createURL(i,r,u,n,t,null)}function applyPage(n){var t=getParameterByName("search"),i=getParameterByName("sort"),r=getParameterByName("tags"),u=getParameterByName("types"),f=getParameterByName("dateRange");document.location.href=createURL(r,u,f,t,i,n)}function applySearch(){var n=getParameterByName("sort"),t=getParameterByName("tags"),i=getParameterByName("types"),r=getParameterByName("dateRange"),u=$("#searchBox").val();document.location.href=createURL(t,i,r,u,n,null)}function applySort(n){var t=getParameterByName("tags"),i=getParameterByName("types"),r=getParameterByName("dateRange"),u=getParameterByName("search");document.location.href=createURL(t,i,r,u,n,null)}function clearFilter(){var n=getParameterByName("sort");document.location.href=createURL(null,null,null,null,n,null)}function clearSearch(){$("#searchBox").val("");applySearch()}function createURL(n,t,i,r,u,f){var e="";return n!=undefined&&n!=null&&n!=""&&(e+="?tags="+n),t!=undefined&&t!=null&&t!=""&&(e+=e!=""?"&types="+t:"?types="+t),i!=undefined&&i!=null&&i!=""&&(e+=e!=""?"&dateRange="+i:"?dateRange="+i),r!=undefined&&r!=null&&r!=""&&(e+=e!=""?"&search="+r:"?search="+r),u!=undefined&&u!=null&&u!=""&&(e+=e!=""?"&sort="+u:"?sort="+u),f!=undefined&&f!=null&&f!=""&&(e+=e!=""?"&page="+f:"?page="+f),basePath+e}function getParameterByName(n,t){t||(t=window.location.href);n=n.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+n+"(=([^&#]*)|&|#|$)"),i=r.exec(t);return i?i[2]?decodeURIComponent(i[2].replace(/\+/g," ")):"":null}function getTagString(){var n="";return $.each($("#tags input:checked"),function(){n+=$(this).attr("value")+","}),n=trimChar(n,",")}function getTypeString(){var n="";return $.each($("#types input:checked"),function(){n+=$(this).attr("value")+","}),n=trimChar(n,",")}function showHideFilter(){$("#sort").hide();$("#sortMenuItem").removeClass("selected");$("#search").hide();$("#searchMenuItem").removeClass("selected");var n=$("#filter"),t=$("#filterMenuItem");n.is(":visible")?(n.fadeOut("slow"),t.removeClass("selected")):(n.fadeIn("slow"),t.addClass("selected"))}function showHideSearch(){$("#sort").hide();$("#filter").hide();$("#sortMenuItem").removeClass("selected");$("#filterMenuItem").removeClass("selected");var n=$("#search"),t=$("#searchMenuItem");n.is(":visible")?(n.fadeOut("slow"),t.removeClass("selected")):(n.fadeIn("slow"),t.addClass("selected"))}function showHideSort(){$("#filter").hide();$("#filterMenuItem").removeClass("selected");$("#search").hide();$("#searchMenuItem").removeClass("selected");var n=$("#sort"),t=$("#sortMenuItem");n.is(":visible")?(n.fadeOut("slow"),t.removeClass("selected")):(n.fadeIn("slow"),t.addClass("selected"))}function allTagsClickHandler(){$("#all_subjects").is(":checked")?$("#tags input").prop("checked",!0):$("#tags input").prop("checked",!1)}function allTypesClickHandler(){$("#all_subjects_types").is(":checked")?$("#types input").prop("checked",!0):$("#types input").prop("checked",!1)}function allTagsInit(){$("#tags input:checkbox:checked").length==$("#tags input").length?$("#all_subjects").prop("checked",!0):$("#all_subjects").prop("checked",!1)}function allTypesInit(){$("#types input:checkbox:checked").length==$("#types input").length?$("#all_subjects_types").prop("checked",!0):$("#all_subjects_types").prop("checked",!1)}$(document).ready(function(){var i=document.getElementById("stick"),r=i.offsetTop,n=$("#numberOfPages").val(),t=$("#currentPage").val();n&&$("#pagination, #paginationTop").twbsPagination({totalPages:n,visiblePages:7,startPage:parseInt(t),onPageClick:function(n,i){t!=i&&applyPage(i)}}).show();$('input[name="dates"]').daterangepicker({locale:{format:"DD/MM/YYYY"},autoApply:!0,ranges:{Today:[moment(),moment()],Yesterday:[moment().subtract(1,"days"),moment().subtract(1,"days")],"Next 7 Days":[moment(),moment().subtract(-6,"days"),moment()],"Next 30 Days":[moment(),moment().subtract(-29,"days"),moment()],"This Month":[moment().startOf("month"),moment().endOf("month")],"Next Month":[moment().subtract(-1,"month").startOf("month"),moment().subtract(-1,"month").endOf("month")]},alwaysShowCalendars:!0,autoUpdateInput:!1});$('input[name="dates"]').on("apply.daterangepicker",function(n,t){t.startDate&&t.endDate?$('input[name="dates"]').val(t.startDate.format("DD/MM/YYYY")+" - "+t.endDate.format("DD/MM/YYYY")):$('input[name="dates"]').val("")});$("#search").keypress(function(n){var t=n.which;if(t==13)return applySearch(),!1});$('input[name="dates"]').on("cancel.daterangepicker",function(){$('input[name="dates"]').val("")});$('input[name="dates"]').change(function(){var n=$('input[name="dates"]').val();n==""&&($('input[name="dates"]').data("daterangepicker").setStartDate(moment()),$('input[name="dates"]').data("daterangepicker").setEndDate(moment()))});$("#tags input").change(function(){allTagsInit()});allTagsInit();$("#types input").change(function(){allTypesInit()});allTypesInit();$("#all_subjects").change(function(){allTagsClickHandler()});$("#all_subjects_types").change(function(){allTypesClickHandler()})}),function(n,t,i,r){"use strict";var f=n.fn.twbsPagination,u=function(t,i){var u,f,r;if(this.$element=n(t),this.options=n.extend({},n.fn.twbsPagination.defaults,i),this.options.startPage<1||this.options.startPage>this.options.totalPages)throw new Error("Start page option is incorrect");if(this.options.totalPages=parseInt(this.options.totalPages),isNaN(this.options.totalPages))throw new Error("Total pages option is not correct!");if(this.options.visiblePages=parseInt(this.options.visiblePages),isNaN(this.options.visiblePages))throw new Error("Visible pages option is not correct!");if(this.options.beforePageClick instanceof Function)this.$element.first().on("beforePage",this.options.beforePageClick);if(this.options.onPageClick instanceof Function)this.$element.first().on("page",this.options.onPageClick);return this.options.hideOnlyOnePage&&this.options.totalPages==1?(this.options.initiateStartPageClick&&this.$element.trigger("page",1),this):(this.options.href&&(this.options.startPage=this.getPageFromQueryString(),this.options.startPage||(this.options.startPage=1)),u=typeof this.$element.prop=="function"?this.$element.prop("tagName"):this.$element.attr("tagName"),u==="UL"?this.$listContainer=this.$element:(f=this.$element,r=n([]),f.each(function(){var t=n("<\/ul>");n(this).append(t);r.push(t[0])}),this.$listContainer=r,this.$element=r),this.$listContainer.addClass(this.options.paginationClass),this.options.initiateStartPageClick?this.show(this.options.startPage):(this.currentPage=this.options.startPage,this.render(this.getPages(this.options.startPage)),this.setupEvents()),this)};u.prototype={constructor:u,destroy:function(){return this.$element.empty(),this.$element.removeData("twbs-pagination"),this.$element.off("page"),this},show:function(n){if(n<1||n>this.options.totalPages)throw new Error("Page is incorrect.");this.currentPage=n;this.$element.trigger("beforePage",n);var t=this.getPages(n);return this.render(t),this.setupEvents(),this.$element.trigger("page",n),t},enable:function(){this.show(this.currentPage)},disable:function(){var t=this;this.$listContainer.off("click").on("click","li",function(n){n.preventDefault()});this.$listContainer.children().each(function(){var i=n(this);i.hasClass(t.options.activeClass)||n(this).addClass(t.options.disabledClass)})},buildListItems:function(n){var t=[],r,i,u;for(this.options.first&&t.push(this.buildItem("first",1)),this.options.prev&&(r=n.currentPage>1?n.currentPage-1:this.options.loop?this.options.totalPages:1,t.push(this.buildItem("prev",r))),i=0;i<\/li>"),u=n("<\/a>"),f=this.options[t]?this.makeText(this.options[t],i):i;return r.addClass(this.options[t+"Class"]),r.data("page",i),r.data("page-type",t),r.append(u.attr("href",this.makehref(i)).addClass(this.options.anchorClass).html(f)),r},getPages:function(n){var f=[],e=Math.floor(this.options.visiblePages/2),t=n-e+1-this.options.visiblePages%2,i=n+e,r=this.options.visiblePages,u;for(r>this.options.totalPages&&(r=this.options.totalPages),t<=0&&(t=1,i=r),i>this.options.totalPages&&(t=this.options.totalPages-r+1,i=this.options.totalPages),u=t;u<=i;)f.push(u),u++;return{currentPage:n,numeric:f}},render:function(t){var i=this,r;this.$listContainer.children().remove();r=this.buildListItems(t);n.each(r,function(n,t){i.$listContainer.append(t)});this.$listContainer.children().each(function(){var r=n(this),u=r.data("page-type");switch(u){case"page":r.data("page")===t.currentPage&&r.addClass(i.options.activeClass);break;case"first":r.toggleClass(i.options.disabledClass,t.currentPage===1);break;case"last":r.toggleClass(i.options.disabledClass,t.currentPage===i.options.totalPages);break;case"prev":r.toggleClass(i.options.disabledClass,!i.options.loop&&t.currentPage===1);break;case"next":r.toggleClass(i.options.disabledClass,!i.options.loop&&t.currentPage===i.options.totalPages)}})},setupEvents:function(){var t=this;this.$listContainer.off("click").on("click","li",function(i){var r=n(this);if(r.hasClass(t.options.disabledClass)||r.hasClass(t.options.activeClass))return!1;t.options.href||i.preventDefault();t.show(parseInt(r.data("page")))})},changeTotalPages:function(n,t){return this.options.totalPages=n,this.show(t)},makehref:function(n){return this.options.href?this.generateQueryString(n):"#"},makeText:function(n,t){return n.replace(this.options.pageVariable,t).replace(this.options.totalPagesVariable,this.options.totalPages)},getPageFromQueryString:function(n){var i=this.getSearchString(n),r=new RegExp(this.options.pageVariable+"(=([^&#]*)|&|#|$)"),t=r.exec(i);return!t||!t[2]?null:(t=decodeURIComponent(t[2]),t=parseInt(t),isNaN(t))?null:t},generateQueryString:function(n,t){var i=this.getSearchString(t),r=new RegExp(this.options.pageVariable+"=*[^&#]*");return i?"?"+i.replace(r,this.options.pageVariable+"="+n):""},getSearchString:function(n){var i=n||t.location.search;return i===""?null:(i.indexOf("?")===0&&(i=i.substr(1)),i)},getCurrentPage:function(){return this.currentPage},getTotalPages:function(){return this.options.totalPages}};n.fn.twbsPagination=function(t){var o=Array.prototype.slice.call(arguments,1),f,e=n(this),i=e.data("twbs-pagination"),s=typeof t=="object"?t:{};return i||e.data("twbs-pagination",i=new u(this,s)),typeof t=="string"&&(f=i[t].apply(i,o)),f===r?e:f};n.fn.twbsPagination.defaults={totalPages:1,startPage:1,visiblePages:5,initiateStartPageClick:!0,hideOnlyOnePage:!1,href:!1,pageVariable:"{{page}}",totalPagesVariable:"{{total_pages}}",page:null,first:"First",prev:"Previous",next:"Next",last:"Last",loop:!1,beforePageClick:null,onPageClick:null,paginationClass:"pagination",nextClass:"page-item next",prevClass:"page-item prev",lastClass:"page-item last",firstClass:"page-item first",pageClass:"page-item",activeClass:"active",disabledClass:"disabled",anchorClass:"page-link"};n.fn.twbsPagination.Constructor=u;n.fn.twbsPagination.noConflict=function(){return n.fn.twbsPagination=f,this};n.fn.twbsPagination.version="1.4.2"}(window.jQuery,window,document)