7 lines
36 KiB
JavaScript
Raw Normal View History

2020-05-19 11:43:42 +03:00
/*!
* AngularJS Material Design
* https://github.com/angular/material
* @license MIT
* v1.1.18-master-97a1616
*/
goog.provide("ngmaterial.components.datepicker"),goog.require("ngmaterial.components.icon"),goog.require("ngmaterial.components.virtualRepeat"),goog.require("ngmaterial.core"),angular.module("material.components.datepicker",["material.core","material.components.icon","material.components.virtualRepeat"]),function(){"use strict";e.$inject=["$element","$scope","$$mdDateUtil","$mdUtil","$mdConstant","$mdTheming","$$rAF","$attrs","$mdDateLocale"],angular.module("material.components.datepicker").directive("mdCalendar",function(){return{template:function(e,t){return'<div ng-switch="calendarCtrl.currentView" '+(t.hasOwnProperty("ngIf")?"":'ng-if="calendarCtrl.isInitialized"')+'><md-calendar-year ng-switch-when="year"></md-calendar-year><md-calendar-month ng-switch-default></md-calendar-month></div>'},scope:{minDate:"=mdMinDate",maxDate:"=mdMaxDate",dateFilter:"=mdDateFilter",_mode:"@mdMode",_currentView:"@mdCurrentView"},require:["ngModel","mdCalendar"],controller:e,controllerAs:"calendarCtrl",bindToController:!0,link:function(e,t,a,n){var i=n[0];n[1].configureNgModel(i)}}});var h=0,t={day:"month",month:"year"};function e(e,t,a,n,i,r,l,s,o){r(e),this.$element=e,this.$scope=t,this.dateUtil=a,this.$mdUtil=n,this.keyCode=i.KEY_CODE,this.$$rAF=l,this.$mdDateLocale=o,this.today=this.dateUtil.createDateAtMidnight(),this.ngModelCtrl=null,this.SELECTED_DATE_CLASS="md-calendar-selected-date",this.TODAY_CLASS="md-calendar-date-today",this.FOCUSED_DATE_CLASS="md-focus",this.id=h++,this.displayDate=null,this.selectedDate=null,this.firstRenderableDate=null,this.lastRenderableDate=null,this.isInitialized=!1,this.width=0,this.scrollbarWidth=0,s.tabindex||e.attr("tabindex","-1");var d,c=angular.bind(this,this.handleKeyEvent);(d=e.parent().hasClass("md-datepicker-calendar")?angular.element(document.body):e).on("keydown",c),t.$on("$destroy",function(){d.off("keydown",c)}),1===angular.version.major&&angular.version.minor<=4&&this.$onInit()}e.prototype.$onInit=function(){this._mode&&t.hasOwnProperty(this._mode)?(this.currentView=t[this._mode],this.mode=this._mode):(this.currentView=this._currentView||"month",this.mode=null);var e=this.$mdDateLocale;this.minDate&&this.minDate>e.firstRenderableDate?this.firstRenderableDate=this.minDate:this.firstRenderableDate=e.firstRenderableDate,this.maxDate&&this.maxDate<e.lastRenderableDate?this.lastRenderableDate=this.maxDate:this.lastRenderableDate=e.lastRenderableDate},e.prototype.configureNgModel=function(e){var t=this;t.ngModelCtrl=e,t.$mdUtil.nextTick(function(){t.isInitialized=!0}),e.$render=function(){var e=this.$viewValue;t.$scope.$broadcast("md-calendar-parent-changed",e),t.selectedDate||(t.selectedDate=e),t.displayDate||(t.displayDate=t.selectedDate||t.today)}},e.prototype.setNgModelValue=function(e){var t=this.dateUtil.createDateAtMidnight(e);return this.focus(t),this.$scope.$emit("md-calendar-change",t),this.ngModelCtrl.$setViewValue(t),this.ngModelCtrl.$render(),t},e.prototype.setCurrentView=function(e,t){var a=this;a.$mdUtil.nextTick(function(){a.currentView=e,t&&(a.displayDate=angular.isDate(t)?t:new Date(t))})},e.prototype.focus=function(e){if(this.dateUtil.isValidDate(e)){var t=this.$element[0].querySelector("."+this.FOCUSED_DATE_CLASS);t&&t.classList.remove(this.FOCUSED_DATE_CLASS);var a=this.getDateId(e,this.currentView),n=document.getElementById(a);n&&(n.classList.add(this.FOCUSED_DATE_CLASS),n.focus(),this.displayDate=e)}else{var i=this.$element[0].querySelector("[ng-switch]");i&&i.focus()}},e.prototype.changeSelectedDate=function(e){var t=this.SELECTED_DATE_CLASS,a=this.$element[0].querySelector("."+t);if(a&&(a.classList.remove(t),a.setAttribute("aria-selected","false")),e){var n=document.getElementById(this.getDateId(e,this.currentView));n&&(n.classList.add(t),n.setAttribute("aria-selected","true"))}this.selectedDate=e},e.prototype.getActionFromKeyEvent=function(e){var t=this.keyCode;switch(e.which){case t.ENTER:return"select";case t.RIGHT_ARROW:return"move-right";case t.LEFT_ARROW:return"move-left";case t.DOWN_ARROW:return e.metaKey?"move-page-down":"move-row-down";case t.UP_ARROW:retu