UNPKG

datepicker-for-ionic

Version:
1 lines 5.21 kB
!function(){"use strict";angular.module("ionic-datepicker",["ionic","ionic-datepicker.templates"])}(),function(){"use strict";angular.module("ionic-datepicker").controller("DatepickerCtrl",["$scope","DatepickerService",function(t,e){var i="date",n=new Date;this.getDaysOfWeek=function(){return this.weekdays||(this.weekdays=e.getDaysOfWeek()),this.weekdays},this.getMonths=function(){return this.months||(this.months=e.getMonths()),this.months},this.getYears=e.getYears,this.initialize=function(){this.selectedDate=angular.copy(t.date||new Date),this.tempDate=angular.copy(this.selectedDate),this.createDateList(this.selectedDate)},this.getDate=function(t,e){return this.dateList[7*t+e]},this.isDefined=function(t){return void 0!==t},this.isDisabled=function(e){return e?t.min&&(t.min.setHours(0,0,0,0),e<t.min)?!0:t.max&&(t.max.setHours(0,0,0,0),e>t.max)?!0:!1:!0},this.isActualDate=function(t){return t?t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear():!1},this.isActualMonth=function(t){return t===n.getMonth()},this.isActualYear=function(t){return t===n.getFullYear()},this.isSelectedDate=function(t){return t?t.getDate()===this.selectedDate.getDate()&&t.getMonth()===this.selectedDate.getMonth()&&t.getFullYear()===this.selectedDate.getFullYear():!1},this.isSelectedMonth=function(t){return t===this.tempDate.getMonth()},this.isSelectedYear=function(t){return t===this.tempDate.getFullYear()},this.changeType=function(t){i=t},this.showType=function(t){return i===t},this.selectDate=function(t){this.isDisabled(t)||(this.selectedDate=angular.copy(t),this.selectedDate.setHours(0,0,0,0),this.tempDate=angular.copy(this.selectedDate))},this.selectMonth=function(t){this.tempDate=angular.copy(this.tempDate),this.tempDate.setMonth(t),this.tempDate.getMonth()!==t&&this.tempDate.setDate(0),this._selectMonthOrYear()},this.selectYear=function(t){this.tempDate=angular.copy(this.tempDate),this.tempDate.setFullYear(t),this._selectMonthOrYear()},this._selectMonthOrYear=function(){this.changeType("date"),this.createDateList(this.tempDate),this.isDisabled(this.tempDate)||(this.selectedDate=this.tempDate)},this.createDateList=function(t){this.dateList=e.createDateList(t),this.cols=new Array(7),this.rows=new Array(parseInt(this.dateList.length/this.cols.length)+1)},this.getSelectedWeekday=function(){return this.weekdays||this.getDaysOfWeek(),this.weekdays[this.selectedDate.getDay()]},this.getSelectedMonth=function(){return this.months||this.getMonths(),this.months[this.selectedDate.getMonth()]},this.getTempMonth=function(){return this.months||this.getMonths(),this.months[this.tempDate.getMonth()]},this.onCancel=function(e){this.selectedDate=angular.copy(t.date||new Date),t.callback(void 0)},this.onDone=function(e){t.date=angular.copy(this.selectedDate),t.callback(t.date)}}])}(),function(){"use strict";angular.module("ionic-datepicker").directive("ionicDatepicker",["$ionicModal",function(t){return{restrict:"E",replace:!0,controller:"DatepickerCtrl",controllerAs:"datepickerCtrl",scope:{date:"=",min:"=",max:"=",callback:"="},link:function(e,i,n,a){var s=function(t){var e=$(t),i=$(t+" .datepicker-selected"),n=i.offset().top+e.scrollTop()-e.offset().top-e.height()/2;0!==n&&e.animate({scrollTop:n})};e.show=function(t){e.modal=t,a.initialize(),e.modal.show(),$(".datepicker-month-js").on("click",function(){s(".datepicker-month-content-js")}),$(".datepicker-year-js").on("click",function(){s(".datepicker-year-content-js")}),$(".datepicker-cancel-js").on("click",e.onCancel),$(".datepicker-ok-js").on("click",e.onDone)},e.onCancel=function(){a.onCancel(),e.modal.remove()},e.onDone=function(){a.onDone(),e.modal.remove()},e.onDirectiveClick=function(){t.fromTemplateUrl("template.html",{scope:e,hideDelay:1}).then(e.show)},i.on("click",e.onDirectiveClick)}}}])}(),function(){"use strict";angular.module("ionic-datepicker").service("DatepickerNls",function(){var t={"en-us":{weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},"pt-br":{weekdays:["Domingo","Segunda-Feira","Terça-Feira","Quarta-Feira","Quinta-Feira","Sexta-Feira","Sábado"],months:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"]}};this.getWeekdays=function(t){return this._getNls(t).weekdays},this.getMonths=function(t){return this._getNls(t).months},this._getNls=function(e){return t[e]||t["en-us"]}})}(),function(){"use strict";angular.module("ionic-datepicker").service("DatepickerService",["DatepickerNls",function(t){var e=window.navigator.userLanguage||window.navigator.language;e=e.toLowerCase(),this.getDaysOfWeek=function(){return t.getWeekdays(e)},this.getMonths=function(){return t.getMonths(e)},this.getYears=function(){for(var t=[],e=1900;2101>e;e++)t.push(e);return t},this.createDateList=function(t){for(var e=new Date(t.getFullYear(),t.getMonth(),1).getDate(),i=new Date(t.getFullYear(),t.getMonth()+1,0).getDate(),n=[],a=e;i>=a;a++)n.push(new Date(t.getFullYear(),t.getMonth(),a));e=n[0].getDay();for(var s=0;e>s;s++)n.unshift(void 0);return n}}])}();