powerdns-admin/app/static/global/plugins/bootstrap-datepaginator/bootstrap-datepaginator.min.js

1 line
9.3 KiB
JavaScript
Raw Normal View History

2015-12-13 09:34:12 +00:00
!function(t,e,i,s){"use strict";var a="datepaginator",o=function(e,i){this._element=e,this.$element=t(e),this._init(i)};o.defaults={fillWidth:!0,highlightSelectedDate:!0,highlightToday:!0,hint:"dddd, Do MMMM YYYY",injectStyle:!0,itemWidth:35,navItemWidth:20,offDays:"Sat,Sun",offDaysFormat:"ddd",onSelectedDateChanged:null,selectedDate:moment().clone().startOf("day"),selectedDateFormat:"YYYY-MM-DD",selectedItemWidth:140,showCalendar:!0,showOffDays:!0,showStartOfWeek:!0,size:s,startOfWeek:"Mon",startOfWeekFormat:"ddd",squareEdges:!1,text:"ddd<br/>Do",textSelected:"dddd<br/>Do, MMMM YYYY",width:0,startDate:moment(new Date(-864e13)),startDateFormat:"YYYY-MM-DD",endDate:moment(new Date(864e13)),endDateFormat:"YYYY-MM-DD"},o.prototype={setSelectedDate:function(t,e){this._setSelectedDate(moment(t,e?e:this.options.selectedDateFormat)),this._render()},remove:function(){this._destroy(),t.removeData(this,"plugin_"+a)},_init:function(e){this.options=t.extend({},o.defaults,e),this.options.width?this.options.fillWidth=!1:(this.options.width=this.$element.width(),this.options.fillWidth=!0),"string"==typeof this.options.startDate&&(this.options.startDate=moment(this.options.startDate,this.options.startDateFormat).clone().startOf("day")),"string"==typeof this.options.endDate&&(this.options.endDate=moment(this.options.endDate,this.options.endDateFormat).clone().startOf("day")),"string"==typeof this.options.selectedDate&&(this.options.selectedDate=moment(this.options.selectedDate,this.options.selectedDateFormat).clone().startOf("day")),this.options.selectedDate.isBefore(this.options.startDate)&&(this.options.selectedDate=this.options.startDate.clone()),this.options.selectedDate.isAfter(this.options.endDate)&&(this.options.selectedDate=this.options.endDate.clone()),"small"===this.options.size?this.options.size="sm":"large"===this.options.size&&(this.options.size="lg"),this._destroy(),this._subscribeEvents(),this._render()},_unsubscribeEvents:function(){this.$element.off("click"),this.$element.off("selectedDateChanged")},_subscribeEvents:function(){this._unsubscribeEvents(),this.$element.on("click",t.proxy(this._clickedHandler,this)),"function"==typeof this.options.onSelectedDateChanged&&this.$element.on("selectedDateChanged",this.options.onSelectedDateChanged),this.options.fillWidth&&t(e).on("resize",t.proxy(this._resize,this))},_destroy:function(){this.initialized&&(this.$calendar&&this.$calendar.datepicker("remove"),this.$wrapper.remove(),this.$wrapper=null,this._unsubscribeEvents()),this.initialized=!1},_clickedHandler:function(e){e.preventDefault();var i=t(e.target),s=i.attr("class");-1!=s.indexOf("dp-nav-left")?this._back():-1!=s.indexOf("dp-nav-right")?this._forward():-1!=s.indexOf("dp-item")&&this._select(i.attr("data-moment"))},_setSelectedDate:function(t){t.isSame(this.options.selectedDate)||t.isBefore(this.options.startDate)||t.isAfter(this.options.endDate)||(this.options.selectedDate=t.startOf("day"),this.$element.trigger("selectedDateChanged",[t.clone()]))},_back:function(){this._setSelectedDate(this.options.selectedDate.clone().subtract("day",1)),this._render()},_forward:function(){this._setSelectedDate(this.options.selectedDate.clone().add("day",1)),this._render()},_select:function(t){this._setSelectedDate(moment(t,this.options.selectedDateFormat)),this._render()},_calendarSelect:function(t){this._setSelectedDate(moment(t.date)),this._render()},_resize:function(){this.options.width=this.$element.width(),this._render()},_render:function(){var e=this;this.initialized?this.$calendar&&this.$calendar.datepicker("remove"):(this.$element.removeClass("datepaginator datepaginator-sm datepaginator-lg").addClass("sm"===this.options.size?"datepaginator-sm":"lg"===this.options.size?"datepaginator-lg":"datepaginator"),this.$wrapper=t(this._template.list),this.$leftNav=t(this._template.navItem).addClass("dp-nav-left").addClass("sm"===this.options.size?"dp-nav-sm":"lg"===this.options.size?"dp-nav-lg":"").addClass(this.options.squareEdges?"dp-nav-square-edges":"").append(t(this._template.icon).addClass("glyphicon-chevron-left").addClass("dp-na