bulma-extensions
Advanced tools
Comparing version 0.7.5 to 0.7.6
@@ -51,5 +51,5 @@ var datepicker_langs = { | ||
nextMonth: 'เดือนถัดไป', | ||
months: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน','กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'], | ||
monthsShort: ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.','ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'], | ||
weekdays: ['อาทิตย์','จันทร์','อังคาร','พุธ','พฤหัสบดี','ศุกร์','เสาร์'], | ||
months: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'], | ||
monthsShort: ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'], | ||
weekdays: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'], | ||
weekdaysShort: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'] | ||
@@ -79,6 +79,6 @@ }, | ||
nextMonth: '下个月', | ||
months: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'], | ||
monthsShort: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'], | ||
weekdays: ['星期天', '星期一','星期二','星期三','星期四','星期五','星期六'], | ||
weekdaysShort: ['周日', '周一','周二','周三','周四','周五','周六'] | ||
months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], | ||
monthsShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], | ||
weekdays: ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], | ||
weekdaysShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] | ||
}, | ||
@@ -96,2 +96,32 @@ es: { | ||
if (typeof Object.assign != 'function') { | ||
// Must be writable: true, enumerable: false, configurable: true | ||
Object.defineProperty(Object, "assign", { | ||
value: function assign(target, varArgs) { // .length of function is 2 | ||
'use strict'; | ||
if (target == null) { // TypeError if undefined or null | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var nextSource = arguments[index]; | ||
if (nextSource != null) { // Skip over if undefined or null | ||
for (var nextKey in nextSource) { | ||
// Avoid bugs when hasOwnProperty is shadowed | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}, | ||
writable: true, | ||
configurable: true | ||
}); | ||
} | ||
class DatePicker { | ||
@@ -111,4 +141,4 @@ constructor(selector, options = {}) { | ||
startDate: new Date(), | ||
dataFormat: 'yyyy/mm/dd', // the default data format `field` value | ||
lang: 'en', // internationalization | ||
dateFormat: 'yyyy-mm-dd', // the default data format `field` value | ||
lang: 'en', // internationalization | ||
overlay: false, | ||
@@ -134,3 +164,3 @@ closeOnOverlayClick: true, | ||
_init() { | ||
this._id = 'datePicker' + ( new Date() ).getTime() + Math.floor(Math.random() * Math.floor(9999)); | ||
this._id = 'datePicker' + (new Date()).getTime() + Math.floor(Math.random() * Math.floor(9999)); | ||
this.lang = typeof datepicker_langs[this.lang] !== 'undefined' ? this.lang : 'en'; | ||
@@ -141,2 +171,4 @@ // Set the startDate to the input value | ||
} | ||
// Transform date format according to dateFormat option | ||
this.options.startDate = new Date(this._getFormatedDate(this.options.startDate, this.options.dateFormat)); | ||
this.month = this.options.startDate.getMonth(); | ||
@@ -302,4 +334,4 @@ this.year = this.options.startDate.getFullYear(); | ||
} | ||
let date = e.currentTarget.dataset.date.split('/'); | ||
this.element.value = this.getFormatedDate(( new Date(date[0], date[1], date[2]) ), this.options.dataFormat); | ||
let date = e.currentTarget.dataset.date.split('-'); | ||
this.element.value = this._getFormatedDate((new Date(date[0], date[1], date[2])), this.options.dateFormat); | ||
if (this.options.closeOnSelect) { | ||
@@ -330,3 +362,3 @@ this.hide(); | ||
return ` | ||
<div data-date="${`${year}/${month}/${day}`}" class="calendar-date${isDisabled ? ' is-disabled' : ''}${isBetween ? ' calendar-range' : ''}${isSelectedIn ? ' calendar-range-start' : ''}${isSelectedOut ? ' calendar-range-end' : ''}"> | ||
<div data-date="${`${year}-${month}-${day}`}" class="calendar-date${isDisabled ? ' is-disabled' : ''}${isBetween ? ' calendar-range' : ''}${isSelectedIn ? ' calendar-range-start' : ''}${isSelectedOut ? ' calendar-range-end' : ''}"> | ||
<button class="date-item${isToday ? ' is-today' : ''}${isSelected ? ' is-active' : ''}">${day}</button> | ||
@@ -341,3 +373,3 @@ </div> | ||
let numberOfDays = this.getDaysInMonth(this.year, this.month), | ||
let numberOfDays = this._getDaysInMonth(this.year, this.month), | ||
before = new Date(this.year, this.month, 1).getDay(); | ||
@@ -368,3 +400,3 @@ | ||
for (var i = 0; i < cells; i++) { | ||
var day = new Date(this.year, this.month, 1 + ( i - before )), | ||
var day = new Date(this.year, this.month, 1 + (i - before)), | ||
isBetween = false, | ||
@@ -375,3 +407,3 @@ isSelected = this._compareDates(day, this.options.startDate), | ||
isToday = this._compareDates(day, now), | ||
isEmpty = i < before || i >= ( numberOfDays + before ), | ||
isEmpty = i < before || i >= (numberOfDays + before), | ||
isDisabled = false; | ||
@@ -403,3 +435,3 @@ | ||
this.month -= 1; | ||
this.adjustCalendar(); | ||
this._adjustCalendar(); | ||
} | ||
@@ -414,3 +446,3 @@ | ||
this.month += 1; | ||
this.adjustCalendar(); | ||
this._adjustCalendar(); | ||
} | ||
@@ -425,3 +457,3 @@ | ||
this.year -= 1; | ||
this.adjustCalendar(); | ||
this._adjustCalendar(); | ||
} | ||
@@ -436,3 +468,3 @@ | ||
this.year += 1; | ||
this.adjustCalendar(); | ||
this._adjustCalendar(); | ||
} | ||
@@ -453,3 +485,3 @@ | ||
this.day = this.options.startDate.getDate(); | ||
this.adjustCalendar(); | ||
this._adjustCalendar(); | ||
@@ -464,3 +496,3 @@ if (typeof this.options.onOpen != 'undefined' && | ||
if (!this.options.overlay) { | ||
this.adjustPosition(); | ||
this._adjustPosition(); | ||
} | ||
@@ -485,3 +517,3 @@ this.open = true; | ||
adjustCalendar() { | ||
_adjustCalendar() { | ||
if (this.month < 0) { | ||
@@ -505,6 +537,6 @@ this.year -= Math.ceil(Math.abs(this.month) / 12); | ||
* Recalculate calendar position | ||
* @method adjustPosition | ||
* @method _adjustPosition | ||
* @return {void} | ||
*/ | ||
adjustPosition() { | ||
_adjustPosition() { | ||
var width = this.datePickerCalendar.offsetWidth, | ||
@@ -524,3 +556,3 @@ height = this.datePickerCalendar.offsetHeight, | ||
top = this.element.offsetTop + this.element.offsetHeight; | ||
while (( this.element = this.element.offsetParent )) { | ||
while ((this.element = this.element.offsetParent)) { | ||
left += this.element.offsetLeft; | ||
@@ -547,3 +579,3 @@ top += this.element.offsetTop; | ||
* Returns date according to passed format | ||
* @method getFormatedDate | ||
* @method _getFormatedDate | ||
* @param {Date} dt Date object | ||
@@ -561,3 +593,3 @@ * @param {String} format Format string | ||
*/ | ||
getFormatedDate(dt, format) { | ||
_getFormatedDate(dt, format) { | ||
var items = { | ||
@@ -575,4 +607,4 @@ d: dt.getDate(), | ||
items.dd < 10 && ( items.dd = '0' + items.dd ); | ||
items.mm < 10 && ( items.mm = '0' + items.mm ); | ||
items.dd < 10 && (items.dd = '0' + items.dd); | ||
items.mm < 10 && (items.mm = '0' + items.mm); | ||
items.D = datepicker_langs[this.options.lang].weekdays[items.D ? items.D - 1 : 6]; | ||
@@ -582,3 +614,3 @@ items.M = datepicker_langs[this.options.lang].monthsShort[items.M]; | ||
return format.replace(/(?:[dmM]{1,2}|D|yyyy|yy)/g, function (m) { | ||
return format.replace(/(?:[dmM]{1,2}|D|yyyy|yy)/g, function(m) { | ||
return typeof items[m] !== 'undefined' ? items[m] : m; | ||
@@ -589,27 +621,8 @@ }); | ||
/** | ||
* Returns true if DatePicker is active | ||
* @method isActive | ||
* @returns {Boolean} | ||
*/ | ||
isActive() { | ||
return this.datePickerCalendar.classList.contains('is-active'); | ||
} | ||
/** | ||
* Check if Object is a Date | ||
* @method isDate | ||
* @param {Object} obj Object to check | ||
* @return {Boolean} True if Object is a Date then False | ||
*/ | ||
isDate(obj) { | ||
return ( /Date/ ).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime()); | ||
} | ||
/** | ||
* Check if given year is LeapYear or not | ||
* @method isLeapYear | ||
* @method _isLeapYear | ||
* @param {Integer} year Year to check | ||
* @return {Boolean} True if LeapYear then False | ||
*/ | ||
isLeapYear(year) { | ||
_isLeapYear(year) { | ||
// solution by Matti Virkkunen: http://stackoverflow.com/a/4881951 | ||
@@ -621,3 +634,3 @@ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; | ||
* Get the number of days in month | ||
* @method getDaysInMonth | ||
* @method _getDaysInMonth | ||
* @param {Integer} year Year to check if we are facing a leapyear or not | ||
@@ -627,4 +640,4 @@ * @param {Integer} month Month for which we want to know the amount of days | ||
*/ | ||
getDaysInMonth(year, month) { | ||
return [31, this.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; | ||
_getDaysInMonth(year, month) { | ||
return [31, this._isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; | ||
} | ||
@@ -641,6 +654,6 @@ | ||
// weak date comparison | ||
a.setHours(0,0,0,0); | ||
b.setHours(0,0,0,0); | ||
a.setHours(0, 0, 0, 0); | ||
b.setHours(0, 0, 0, 0); | ||
return a.getTime() === b.getTime(); | ||
} | ||
} |
@@ -1,37 +0,1 @@ | ||
var $jscomp={scope:{},owns:function(a,b){return Object.prototype.hasOwnProperty.call(a,b)}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this); | ||
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var f=a[d];f in c||(c[f]={});c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.assign",function(a){return a?a:function(a,c){for(var b=1;b<arguments.length;b++){var f=arguments[b];if(f)for(var e in f)$jscomp.owns(f,e)&&(a[e]=f[e])}return a}},"es6-impl","es3"); | ||
var datepicker_langs={en:{weekStart:1,previousMonth:"Previous Month",nextMonth:"Next Month",months:"January February March April May June July August September October November December".split(" "),monthsShort:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),weekdaysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" ")},fr:{weekStart:1,previousMonth:"Mois pr\u00e9c\u00e9dent",nextMonth:"Mois suivant",months:"Janvier F\u00e9vrier Mars Avril Mai Juin Juillet Ao\u00fbt Septembre Octobre Novembre D\u00e9cembre".split(" "), | ||
monthsShort:"Jan F\u00e9v Mar Avr Mai Juin Juil Auo Sep Oct Nov D\u00e9c".split(" "),weekdays:"Dimanche Lundi Mardi Mercredi Jeudi Vendredi Samedi".split(" "),weekdaysShort:"Dim Lun Mar Mer Jeu Ven Sam".split(" ")},de:{weekStart:1,previousMonth:"Vorheriger Monat",nextMonth:"N\u00e4chster Monat",months:"Januar Februar M\u00e4rz April Mai Juni Juli August September Oktober November Dezember".split(" "),monthsShort:"Jan Febr M\u00e4rz Apr Mai Juni Juli Aug Sept Okt Nov Dez".split(" "),weekdays:"Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag".split(" "), | ||
weekdaysShort:"So Mo Di Mi Do Fr Sa".split(" ")},tr:{weekStart:1,previousMonth:"\u00d6nceki Ay",nextMonth:"Gelecek Ay",months:"Ocak \u015eubat Mart Nisan May\u0131s Haziran Temmuz A\u011fustos Eyl\u00fcl Ekim Kas\u0131m Aral\u0131k".split(" "),monthsShort:"Oca \u015eub Mar Nis May Haz Tem A\u011fu Eyl Eki Kas Ara".split(" "),weekdays:"Pazar Pazartesi Sal\u0131 \u00c7ar\u015famba Per\u015fembe Cuma Cumartesi".split(" "),weekdaysShort:"Paz Pzt Sal \u00c7ar Per Cum Cmt".split(" ")},it:{weekStart:1,previousMonth:"Mese Precedente", | ||
nextMonth:"Prossimo Mese",months:"Gennaio Febbraio Marzo Aprile Maggio Giugno Luglio Agosto Settembre Ottobre Novembre Dicembre".split(" "),monthsShort:"Gen Feb Mar Apr Mag Giu Lug Ago Set Ott Nov Dic".split(" "),weekdays:"Domenica Luned\u00ec Marted\u00ec Mercoled\u00ec Gioved\u00ec Venerd\u00ec Sabato".split(" "),weekdaysShort:"Dom Lun Mar Mer Gio Ven Sab".split(" ")},th:{weekStart:1,previousMonth:"\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e01\u0e48\u0e2d\u0e19\u0e2b\u0e19\u0e49\u0e32",nextMonth:"\u0e40\u0e14\u0e37\u0e2d\u0e19\u0e16\u0e31\u0e14\u0e44\u0e1b", | ||
months:"\u0e21\u0e01\u0e23\u0e32\u0e04\u0e21 \u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c \u0e21\u0e35\u0e19\u0e32\u0e04\u0e21 \u0e40\u0e21\u0e29\u0e32\u0e22\u0e19 \u0e1e\u0e24\u0e29\u0e20\u0e32\u0e04\u0e21 \u0e21\u0e34\u0e16\u0e38\u0e19\u0e32\u0e22\u0e19 \u0e01\u0e23\u0e01\u0e0e\u0e32\u0e04\u0e21 \u0e2a\u0e34\u0e07\u0e2b\u0e32\u0e04\u0e21 \u0e01\u0e31\u0e19\u0e22\u0e32\u0e22\u0e19 \u0e15\u0e38\u0e25\u0e32\u0e04\u0e21 \u0e1e\u0e24\u0e28\u0e08\u0e34\u0e01\u0e32\u0e22\u0e19 \u0e18\u0e31\u0e19\u0e27\u0e32\u0e04\u0e21".split(" "), | ||
monthsShort:"\u0e21.\u0e04. \u0e01.\u0e1e. \u0e21\u0e35.\u0e04. \u0e40\u0e21.\u0e22. \u0e1e.\u0e04. \u0e21\u0e34.\u0e22. \u0e01.\u0e04. \u0e2a.\u0e04. \u0e01.\u0e22. \u0e15.\u0e04. \u0e1e.\u0e22. \u0e18.\u0e04.".split(" "),weekdays:"\u0e2d\u0e32\u0e17\u0e34\u0e15\u0e22\u0e4c \u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c \u0e2d\u0e31\u0e07\u0e04\u0e32\u0e23 \u0e1e\u0e38\u0e18 \u0e1e\u0e24\u0e2b\u0e31\u0e2a\u0e1a\u0e14\u0e35 \u0e28\u0e38\u0e01\u0e23\u0e4c \u0e40\u0e2a\u0e32\u0e23\u0e4c".split(" "),weekdaysShort:"\u0e2d\u0e32. \u0e08. \u0e2d. \u0e1e. \u0e1e\u0e24. \u0e28. \u0e2a.".split(" ")}, | ||
hr:{weekStart:2,previousMonth:"Pro\u0161li mjesec",nextMonth:"Slijede\u0107i mjesec",months:"sije\u010danj velja\u010da o\u017eujak travanj svibanj lipanj srpanj kolovoz rujan listopad studeni prosinac".split(" "),monthsShort:"sij velj o\u017eu tra svi lip srp kol ruj lis stu pro".split(" "),weekdays:"nedjelja ponedjeljak utorak srijeda \u010detvrtak petak subota".split(" "),weekdaysShort:"ned pon uto sri \u010det pet sub".split(" ")},sr:{weekStart:2,previousMonth:"Pro\u0161li mesec",nextMonth:"Slede\u0107i mesec", | ||
months:"januar februar mart april maj jun jul avgust septembar oktobar novembar decembar".split(" "),monthsShort:"jan feb mar apr maj jun jul avg sep okt nov dec".split(" "),weekdays:"nedelja ponedeljak utorak sreda \u010detvrtak petak subota".split(" "),weekdaysShort:"ned pon uto sre \u010det pet sub".split(" ")},"zh-cn":{weekStart:1,previousMonth:"\u4e0a\u4e2a\u6708",nextMonth:"\u4e0b\u4e2a\u6708",months:"\u4e00\u6708 \u4e8c\u6708 \u4e09\u6708 \u56db\u6708 \u4e94\u6708 \u516d\u6708 \u4e03\u6708 \u516b\u6708 \u4e5d\u6708 \u5341\u6708 \u5341\u4e00\u6708 \u5341\u4e8c\u6708".split(" "), | ||
monthsShort:"\u4e00\u6708 \u4e8c\u6708 \u4e09\u6708 \u56db\u6708 \u4e94\u6708 \u516d\u6708 \u4e03\u6708 \u516b\u6708 \u4e5d\u6708 \u5341\u6708 \u5341\u4e00\u6708 \u5341\u4e8c\u6708".split(" "),weekdays:"\u661f\u671f\u5929 \u661f\u671f\u4e00 \u661f\u671f\u4e8c \u661f\u671f\u4e09 \u661f\u671f\u56db \u661f\u671f\u4e94 \u661f\u671f\u516d".split(" "),weekdaysShort:"\u5468\u65e5 \u5468\u4e00 \u5468\u4e8c \u5468\u4e09 \u5468\u56db \u5468\u4e94 \u5468\u516d".split(" ")},es:{weekStart:1,previousMonth:"Mes anterior", | ||
nextMonth:"Pr\u00f3ximo mes",months:"Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre".split(" "),monthsShort:"Ene Feb Mar Abr May Jun Jul Ago Sep Oct Nov Dic".split(" "),weekdays:"Domingo Lunes Martes Mi\u00e9rcoles Jueves Viernes S\u00e1bado".split(" "),weekdaysShort:"Dom Lun Mar Mie Jue Vie Sab".split(" ")}},DatePicker=function(a,b){b=void 0===b?{}:b;this._clickEvent="ontouchstart"in window?"touchstart":"click";this.element="string"===typeof a?document.querySelector(a): | ||
a;if(!this.element)throw Error("An invalid selector or non-DOM node has been provided.");this.options=Object.assign({},{startDate:new Date,dataFormat:"yyyy/mm/dd",lang:"en",overlay:!1,closeOnOverlayClick:!0,closeOnSelect:!0,onSelect:null,onOpen:null,onClose:null,onRender:null},b);this._init()}; | ||
DatePicker.prototype._init=function(){this._id="datePicker"+(new Date).getTime()+Math.floor(Math.random()*Math.floor(9999));this.lang="undefined"!==typeof datepicker_langs[this.lang]?this.lang:"en";this.element.value&&(this.options.startDate=new Date(this.element.value));this.month=this.options.startDate.getMonth();this.year=this.options.startDate.getFullYear();this.day=this.options.startDate.getDate();this.open=!1;this._build();this._bindEvents();return this}; | ||
DatePicker.prototype._build=function(){var a="\n <div id='"+this._id+"' class=\"datepicker "+(this.options.overlay?"modal":"")+'">\n '+(this.options.overlay?'<div class="modal-background"></div>':"")+'\n <div class="calendar">\n <div class="calendar-nav">\n <div class="calendar-nav-month">\n <div class="calendar-nav-previous-month">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-left"></i>\n </button>\n </div>\n <div class="calendar-month">'+ | ||
datepicker_langs[this.options.lang].months[this.month]+'</div>\n <div class="calendar-nav-next-month">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-right"></i>\n </button>\n </div>\n </div>\n <div class="calendar-nav-day">\n <div class="calendar-day">'+this.day+'</div>\n </div>\n <div class="calendar-nav-year">\n <div class="calendar-nav-previous-year">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-left"></i>\n </button>\n </div>\n <div class="calendar-year">'+ | ||
this.year+'</div>\n <div class="calendar-nav-next-year">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-right"></i>\n </button>\n </div>\n </div>\n </div>\n <div class="calendar-container">\n <div class="calendar-header">\n <div class="calendar-date">'+this._getDayName(0,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(1,!0)+'</div>\n <div class="calendar-date">'+ | ||
this._getDayName(2,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(3,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(4,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(5,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(6,!0)+'</div>\n </div>\n <div class="calendar-body"></div>\n </div>\n </div>\n </div>\n ';document.body.insertAdjacentHTML("beforeend",a); | ||
this.datePickerContainer=document.getElementById(this._id);this.datePickerCalendar=this.datePickerContainer.querySelector(".calendar");this.options.overlay&&(this.datePickerOverlay=this.datePickerContainer.querySelector(".modal-background"),this.datePickerCloseButton=this.datePickerContainer.querySelector(".modal-close"));this.datePickerCalendarNav=this.datePickerCalendar.querySelector(".calendar-nav");this.datePickerCalendarNavMonth=this.datePickerCalendar.querySelector(".calendar-month");this.datePickerCalendarNavYear= | ||
this.datePickerCalendar.querySelector(".calendar-year");this.datePickerCalendarNavDay=this.datePickerCalendar.querySelector(".calendar-day");this.datePickerCalendarNavPreviousMonth=this.datePickerCalendarNav.querySelector(".calendar-nav-previous-month");this.datePickerCalendarNavNextMonth=this.datePickerCalendarNav.querySelector(".calendar-nav-next-month");this.datePickerCalendarNavPreviousYear=this.datePickerCalendarNav.querySelector(".calendar-nav-previous-year");this.datePickerCalendarNavNextYear= | ||
this.datePickerCalendarNav.querySelector(".calendar-nav-next-year");this.datePickerCalendarHeader=this.datePickerCalendar.querySelector(".calendar-header");this.datePickerCalendarBody=this.datePickerCalendar.querySelector(".calendar-body")}; | ||
DatePicker.prototype._bindEvents=function(){var a=this;this.element.addEventListener(this._clickEvent,function(b){b.preventDefault();a.open?a.hide():a.show()});this.options.overlay&&(this.datePickerCloseButton&&this.datePickerCloseButton.addEventListener(this._clickEvent,function(b){b.preventDefault();a.hide()}),this.options.closeOnOverlayClick&&this.datePickerOverlay.addEventListener(this._clickEvent,function(b){b.preventDefault();a.hide()}));this.datePickerCalendarNavPreviousYear.addEventListener(this._clickEvent, | ||
function(b){b.preventDefault();a.prevYear()});this.datePickerCalendarNavNextYear.addEventListener(this._clickEvent,function(b){b.preventDefault();a.nextYear()});this.datePickerCalendarNavPreviousMonth.addEventListener(this._clickEvent,function(b){b.preventDefault();a.prevMonth()});this.datePickerCalendarNavNextMonth.addEventListener(this._clickEvent,function(b){b.preventDefault();a.nextMonth()})}; | ||
DatePicker.prototype._bindDaysEvents=function(){var a=this;[].forEach.call(this.datePickerCalendarDays,function(b){b.addEventListener(a._clickEvent,function(b){b.preventDefault();if("undefined"!=typeof a.options.onSelect&&null!=a.options.onSelect&&a.options.onSelect)a.options.onSelect(new Date(year,month,day));b=b.currentTarget.dataset.date.split("/");a.element.value=a.getFormatedDate(new Date(b[0],b[1],b[2]),a.options.dataFormat);a.options.closeOnSelect&&a.hide()})})}; | ||
DatePicker.prototype._getDayName=function(a,b){for(a+=datepicker_langs[this.options.lang].weekStart;7<=a;)a-=7;return(void 0===b?0:b)?datepicker_langs[this.options.lang].weekdaysShort[a]:datepicker_langs[this.options.lang].weekdays[a]}; | ||
DatePicker.prototype._renderDay=function(a,b,c,d,f,e,g,h,k,l){return'\n <div data-date="'+(c+"/"+b+"/"+a)+'" class="calendar-date'+(e?" is-disabled":"")+(h?" calendar-range":"")+(k?" calendar-range-start":"")+(l?" calendar-range-end":"")+'">\n <button class="date-item'+(f?" is-today":"")+(d?" is-active":"")+'">'+a+"</button>\n </div>\n "}; | ||
DatePicker.prototype._renderDays=function(){var a=new Date,b="",c=this.getDaysInMonth(this.year,this.month),d=(new Date(this.year,this.month,1)).getDay();if("undefined"!=typeof this.options.onRender&&null!=this.options.onRender&&this.options.onRender)this.options.onRender(this);0<datepicker_langs[this.options.lang].weekStart&&(d-=datepicker_langs[this.options.lang].weekStart,0>d&&(d+=7));for(var f=c+d,e=f;7<e;)e-=7;f+=7-e;for(e=0;e<f;e++){var g=new Date(this.year,this.month,1+(e-d)),h=this._compareDates(g, | ||
this.options.startDate),k=!1,l=!1,n=this._compareDates(g,a),p=e<d||e>=c+d,m=!1;h||(l=k=!1);g.getMonth()!==this.month&&(m=!0);b+=this._renderDay(g.getDate(),this.month,this.year,h,n,m,p,!1,k,l)}this.datePickerCalendarBody.insertAdjacentHTML("beforeend",b);this.datePickerCalendarDays=this.datePickerCalendarBody.querySelectorAll(".calendar-date");this._bindDaysEvents()};DatePicker.prototype.prevMonth=function(){--this.month;this.adjustCalendar()}; | ||
DatePicker.prototype.nextMonth=function(){this.month+=1;this.adjustCalendar()};DatePicker.prototype.prevYear=function(){--this.year;this.adjustCalendar()};DatePicker.prototype.nextYear=function(){this.year+=1;this.adjustCalendar()}; | ||
DatePicker.prototype.show=function(){this.element.value&&(this.options.startDate=new Date(this.element.value));this.month=this.options.startDate.getMonth();this.year=this.options.startDate.getFullYear();this.day=this.options.startDate.getDate();this.adjustCalendar();if("undefined"!=typeof this.options.onOpen&&null!=this.options.onOpen&&this.options.onOpen)this.options.onOpen(this);this.datePickerContainer.classList.add("is-active");this.options.overlay||this.adjustPosition();this.open=!0}; | ||
DatePicker.prototype.hide=function(){this.open=!1;if("undefined"!=typeof this.options.onClose&&null!=this.options.onClose&&this.options.onClose)this.options.onClose(this);this.datePickerContainer.classList.remove("is-active")}; | ||
DatePicker.prototype.adjustCalendar=function(){0>this.month&&(this.year-=Math.ceil(Math.abs(this.month)/12),this.month+=12);11<this.month&&(this.year+=Math.floor(Math.abs(this.month)/12),this.month-=12);this.datePickerCalendarNavMonth.innerHTML=datepicker_langs[this.options.lang].months[this.month];this.datePickerCalendarNavYear.innerHTML=this.year;this.datePickerCalendarNavDay.innerHTML=this.day;this.datePickerCalendarBody.innerHTML="";this._renderDays();return this}; | ||
DatePicker.prototype.adjustPosition=function(){var a,b;if("function"===typeof this.element.getBoundingClientRect)b=this.element.getBoundingClientRect(),a=b.left+window.pageXOffset,b=b.bottom+window.pageYOffset;else for(a=this.element.offsetLeft,b=this.element.offsetTop+this.element.offsetHeight;this.element=this.element.offsetParent;)a+=this.element.offsetLeft,b+=this.element.offsetTop;this.datePickerCalendar.style.position="absolute";this.datePickerCalendar.style.left=a+"px";this.datePickerCalendar.style.top= | ||
b+"px"};DatePicker.prototype.destroy=function(){this.datePickerCalendar.remove()}; | ||
DatePicker.prototype.getFormatedDate=function(a,b){var c={d:a.getDate(),dd:a.getDate(),D:a.getDay(),m:a.getMonth()+1,mm:a.getMonth()+1,M:a.getMonth(),MM:a.getMonth(),yy:a.getFullYear().toString().substr(-2),yyyy:a.getFullYear()};10>c.dd&&(c.dd="0"+c.dd);10>c.mm&&(c.mm="0"+c.mm);c.D=datepicker_langs[this.options.lang].weekdays[c.D?c.D-1:6];c.M=datepicker_langs[this.options.lang].monthsShort[c.M];c.MM=datepicker_langs[this.options.lang].months[c.MM];return b.replace(/(?:[dmM]{1,2}|D|yyyy|yy)/g,function(a){return"undefined"!== | ||
typeof c[a]?c[a]:a})};DatePicker.prototype.isActive=function(){return this.datePickerCalendar.classList.contains("is-active")};DatePicker.prototype.isDate=function(a){return/Date/.test(Object.prototype.toString.call(a))&&!isNaN(a.getTime())};DatePicker.prototype.isLeapYear=function(a){return 0===a%4&&0!==a%100||0===a%400};DatePicker.prototype.getDaysInMonth=function(a,b){return[31,this.isLeapYear(a)?29:28,31,30,31,30,31,31,30,31,30,31][b]}; | ||
DatePicker.prototype._compareDates=function(a,b){a.setHours(0,0,0,0);b.setHours(0,0,0,0);return a.getTime()===b.getTime()}; | ||
'use strict';var _createClass=function(){function c(d,f){for(var h,g=0;g<f.length;g++)h=f[g],h.enumerable=h.enumerable||!1,h.configurable=!0,'value'in h&&(h.writable=!0),Object.defineProperty(d,h.key,h)}return function(d,f,g){return f&&c(d.prototype,f),g&&c(d,g),d}}();function _classCallCheck(c,d){if(!(c instanceof d))throw new TypeError('Cannot call a class as a function')}var datepicker_langs={en:{weekStart:1,previousMonth:'Previous Month',nextMonth:'Next Month',months:['January','February','March','April','May','June','July','August','September','October','November','December'],monthsShort:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],weekdays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],weekdaysShort:['Sun','Mon','Tue','Wed','Thu','Fri','Sat']},fr:{weekStart:1,previousMonth:'Mois pr\xE9c\xE9dent',nextMonth:'Mois suivant',months:['Janvier','F\xE9vrier','Mars','Avril','Mai','Juin','Juillet','Ao\xFBt','Septembre','Octobre','Novembre','D\xE9cembre'],monthsShort:['Jan','F\xE9v','Mar','Avr','Mai','Juin','Juil','Auo','Sep','Oct','Nov','D\xE9c'],weekdays:['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],weekdaysShort:['Dim','Lun','Mar','Mer','Jeu','Ven','Sam']},de:{weekStart:1,previousMonth:'Vorheriger Monat',nextMonth:'N\xE4chster Monat',months:['Januar','Februar','M\xE4rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],monthsShort:['Jan','Febr','M\xE4rz','Apr','Mai','Juni','Juli','Aug','Sept','Okt','Nov','Dez'],weekdays:['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],weekdaysShort:['So','Mo','Di','Mi','Do','Fr','Sa']},tr:{weekStart:1,previousMonth:'\xD6nceki Ay',nextMonth:'Gelecek Ay',months:['Ocak','\u015Eubat','Mart','Nisan','May\u0131s','Haziran','Temmuz','A\u011Fustos','Eyl\xFCl','Ekim','Kas\u0131m','Aral\u0131k'],monthsShort:['Oca','\u015Eub','Mar','Nis','May','Haz','Tem','A\u011Fu','Eyl','Eki','Kas','Ara'],weekdays:['Pazar','Pazartesi','Sal\u0131','\xC7ar\u015Famba','Per\u015Fembe','Cuma','Cumartesi'],weekdaysShort:['Paz','Pzt','Sal','\xC7ar','Per','Cum','Cmt']},it:{weekStart:1,previousMonth:'Mese Precedente',nextMonth:'Prossimo Mese',months:['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],monthsShort:['Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic'],weekdays:['Domenica','Luned\xEC','Marted\xEC','Mercoled\xEC','Gioved\xEC','Venerd\xEC','Sabato'],weekdaysShort:['Dom','Lun','Mar','Mer','Gio','Ven','Sab']},th:{weekStart:1,previousMonth:'\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E01\u0E48\u0E2D\u0E19\u0E2B\u0E19\u0E49\u0E32',nextMonth:'\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E16\u0E31\u0E14\u0E44\u0E1B',months:['\u0E21\u0E01\u0E23\u0E32\u0E04\u0E21','\u0E01\u0E38\u0E21\u0E20\u0E32\u0E1E\u0E31\u0E19\u0E18\u0E4C','\u0E21\u0E35\u0E19\u0E32\u0E04\u0E21','\u0E40\u0E21\u0E29\u0E32\u0E22\u0E19','\u0E1E\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21','\u0E21\u0E34\u0E16\u0E38\u0E19\u0E32\u0E22\u0E19','\u0E01\u0E23\u0E01\u0E0E\u0E32\u0E04\u0E21','\u0E2A\u0E34\u0E07\u0E2B\u0E32\u0E04\u0E21','\u0E01\u0E31\u0E19\u0E22\u0E32\u0E22\u0E19','\u0E15\u0E38\u0E25\u0E32\u0E04\u0E21','\u0E1E\u0E24\u0E28\u0E08\u0E34\u0E01\u0E32\u0E22\u0E19','\u0E18\u0E31\u0E19\u0E27\u0E32\u0E04\u0E21'],monthsShort:['\u0E21.\u0E04.','\u0E01.\u0E1E.','\u0E21\u0E35.\u0E04.','\u0E40\u0E21.\u0E22.','\u0E1E.\u0E04.','\u0E21\u0E34.\u0E22.','\u0E01.\u0E04.','\u0E2A.\u0E04.','\u0E01.\u0E22.','\u0E15.\u0E04.','\u0E1E.\u0E22.','\u0E18.\u0E04.'],weekdays:['\u0E2D\u0E32\u0E17\u0E34\u0E15\u0E22\u0E4C','\u0E08\u0E31\u0E19\u0E17\u0E23\u0E4C','\u0E2D\u0E31\u0E07\u0E04\u0E32\u0E23','\u0E1E\u0E38\u0E18','\u0E1E\u0E24\u0E2B\u0E31\u0E2A\u0E1A\u0E14\u0E35','\u0E28\u0E38\u0E01\u0E23\u0E4C','\u0E40\u0E2A\u0E32\u0E23\u0E4C'],weekdaysShort:['\u0E2D\u0E32.','\u0E08.','\u0E2D.','\u0E1E.','\u0E1E\u0E24.','\u0E28.','\u0E2A.']},hr:{weekStart:2,previousMonth:'Pro\u0161li mjesec',nextMonth:'Slijede\u0107i mjesec',months:['sije\u010Danj','velja\u010Da','o\u017Eujak','travanj','svibanj','lipanj','srpanj','kolovoz','rujan','listopad','studeni','prosinac'],monthsShort:['sij','velj','o\u017Eu','tra','svi','lip','srp','kol','ruj','lis','stu','pro'],weekdays:['nedjelja','ponedjeljak','utorak','srijeda','\u010Detvrtak','petak','subota'],weekdaysShort:['ned','pon','uto','sri','\u010Det','pet','sub']},sr:{weekStart:2,previousMonth:'Pro\u0161li mesec',nextMonth:'Slede\u0107i mesec',months:['januar','februar','mart','april','maj','jun','jul','avgust','septembar','oktobar','novembar','decembar'],monthsShort:['jan','feb','mar','apr','maj','jun','jul','avg','sep','okt','nov','dec'],weekdays:['nedelja','ponedeljak','utorak','sreda','\u010Detvrtak','petak','subota'],weekdaysShort:['ned','pon','uto','sre','\u010Det','pet','sub']},'zh-cn':{weekStart:1,previousMonth:'\u4E0A\u4E2A\u6708',nextMonth:'\u4E0B\u4E2A\u6708',months:['\u4E00\u6708','\u4E8C\u6708','\u4E09\u6708','\u56DB\u6708','\u4E94\u6708','\u516D\u6708','\u4E03\u6708','\u516B\u6708','\u4E5D\u6708','\u5341\u6708','\u5341\u4E00\u6708','\u5341\u4E8C\u6708'],monthsShort:['\u4E00\u6708','\u4E8C\u6708','\u4E09\u6708','\u56DB\u6708','\u4E94\u6708','\u516D\u6708','\u4E03\u6708','\u516B\u6708','\u4E5D\u6708','\u5341\u6708','\u5341\u4E00\u6708','\u5341\u4E8C\u6708'],weekdays:['\u661F\u671F\u5929','\u661F\u671F\u4E00','\u661F\u671F\u4E8C','\u661F\u671F\u4E09','\u661F\u671F\u56DB','\u661F\u671F\u4E94','\u661F\u671F\u516D'],weekdaysShort:['\u5468\u65E5','\u5468\u4E00','\u5468\u4E8C','\u5468\u4E09','\u5468\u56DB','\u5468\u4E94','\u5468\u516D']},es:{weekStart:1,previousMonth:'Mes anterior',nextMonth:'Pr\xF3ximo mes',months:['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],monthsShort:['Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'],weekdays:['Domingo','Lunes','Martes','Mi\xE9rcoles','Jueves','Viernes','S\xE1bado'],weekdaysShort:['Dom','Lun','Mar','Mie','Jue','Vie','Sab']}};'function'!=typeof Object.assign&&Object.defineProperty(Object,'assign',{value:function(d){'use strict';if(null==d)throw new TypeError('Cannot convert undefined or null to object');for(var j,g=Object(d),h=1;h<arguments.length;h++)if(j=arguments[h],null!=j)for(var k in j)Object.prototype.hasOwnProperty.call(j,k)&&(g[k]=j[k]);return g},writable:!0,configurable:!0});var DatePicker=function(){function c(d){var f=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(_classCallCheck(this,c),this._clickEvent='ontouchstart'in window?'touchstart':'click',this.element='string'==typeof d?document.querySelector(d):d,!this.element)throw new Error('An invalid selector or non-DOM node has been provided.');this.options=Object.assign({},{startDate:new Date,dateFormat:'yyyy-mm-dd',lang:'en',overlay:!1,closeOnOverlayClick:!0,closeOnSelect:!0,onSelect:null,onOpen:null,onClose:null,onRender:null},f),this._init()}return _createClass(c,[{key:'_init',value:function _init(){return this._id='datePicker'+new Date().getTime()+Math.floor(Math.random()*Math.floor(9999)),this.lang='undefined'==typeof datepicker_langs[this.lang]?'en':this.lang,this.element.value&&(this.options.startDate=new Date(this.element.value)),this.options.startDate=new Date(this._getFormatedDate(this.options.startDate,this.options.dateFormat)),this.month=this.options.startDate.getMonth(),this.year=this.options.startDate.getFullYear(),this.day=this.options.startDate.getDate(),this.open=!1,this._build(),this._bindEvents(),this}},{key:'_build',value:function _build(){var d='\n <div id=\''+this._id+'\' class="datepicker '+(this.options.overlay?'modal':'')+'">\n '+(this.options.overlay?'<div class="modal-background"></div>':'')+'\n <div class="calendar">\n <div class="calendar-nav">\n <div class="calendar-nav-month">\n <div class="calendar-nav-previous-month">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-left"></i>\n </button>\n </div>\n <div class="calendar-month">'+datepicker_langs[this.options.lang].months[this.month]+'</div>\n <div class="calendar-nav-next-month">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-right"></i>\n </button>\n </div>\n </div>\n <div class="calendar-nav-day">\n <div class="calendar-day">'+this.day+'</div>\n </div>\n <div class="calendar-nav-year">\n <div class="calendar-nav-previous-year">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-left"></i>\n </button>\n </div>\n <div class="calendar-year">'+this.year+'</div>\n <div class="calendar-nav-next-year">\n <button class="button is-small is-text">\n <i class="fa fa-chevron-right"></i>\n </button>\n </div>\n </div>\n </div>\n <div class="calendar-container">\n <div class="calendar-header">\n <div class="calendar-date">'+this._getDayName(0,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(1,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(2,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(3,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(4,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(5,!0)+'</div>\n <div class="calendar-date">'+this._getDayName(6,!0)+'</div>\n </div>\n <div class="calendar-body"></div>\n </div>\n </div>\n </div>\n ';document.body.insertAdjacentHTML('beforeend',d),this.datePickerContainer=document.getElementById(this._id),this.datePickerCalendar=this.datePickerContainer.querySelector('.calendar'),this.options.overlay&&(this.datePickerOverlay=this.datePickerContainer.querySelector('.modal-background'),this.datePickerCloseButton=this.datePickerContainer.querySelector('.modal-close')),this.datePickerCalendarNav=this.datePickerCalendar.querySelector('.calendar-nav'),this.datePickerCalendarNavMonth=this.datePickerCalendar.querySelector('.calendar-month'),this.datePickerCalendarNavYear=this.datePickerCalendar.querySelector('.calendar-year'),this.datePickerCalendarNavDay=this.datePickerCalendar.querySelector('.calendar-day'),this.datePickerCalendarNavPreviousMonth=this.datePickerCalendarNav.querySelector('.calendar-nav-previous-month'),this.datePickerCalendarNavNextMonth=this.datePickerCalendarNav.querySelector('.calendar-nav-next-month'),this.datePickerCalendarNavPreviousYear=this.datePickerCalendarNav.querySelector('.calendar-nav-previous-year'),this.datePickerCalendarNavNextYear=this.datePickerCalendarNav.querySelector('.calendar-nav-next-year'),this.datePickerCalendarHeader=this.datePickerCalendar.querySelector('.calendar-header'),this.datePickerCalendarBody=this.datePickerCalendar.querySelector('.calendar-body')}},{key:'_bindEvents',value:function _bindEvents(){var d=this;this.element.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.open?d.hide():d.show()}),this.options.overlay&&(this.datePickerCloseButton&&this.datePickerCloseButton.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.hide()}),this.options.closeOnOverlayClick&&this.datePickerOverlay.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.hide()})),this.datePickerCalendarNavPreviousYear.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.prevYear()}),this.datePickerCalendarNavNextYear.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.nextYear()}),this.datePickerCalendarNavPreviousMonth.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.prevMonth()}),this.datePickerCalendarNavNextMonth.addEventListener(this._clickEvent,function(f){f.preventDefault(),d.nextMonth()})}},{key:'_bindDaysEvents',value:function _bindDaysEvents(){var d=this;[].forEach.call(this.datePickerCalendarDays,function(f){f.addEventListener(d._clickEvent,function(g){g.preventDefault(),'undefined'!=typeof d.options.onSelect&&null!=d.options.onSelect&&d.options.onSelect&&d.options.onSelect(new Date(year,month,day));var h=g.currentTarget.dataset.date.split('-');d.element.value=d._getFormatedDate(new Date(h[0],h[1],h[2]),d.options.dateFormat),d.options.closeOnSelect&&d.hide()})})}},{key:'_getDayName',value:function _getDayName(d){var f=1<arguments.length&&void 0!==arguments[1]&&arguments[1];for(d+=datepicker_langs[this.options.lang].weekStart;7<=d;)d-=7;return f?datepicker_langs[this.options.lang].weekdaysShort[d]:datepicker_langs[this.options.lang].weekdays[d]}},{key:'_renderDay',value:function _renderDay(d,f,g,h,j,k,l,n,o,p){return'\n <div data-date="'+(g+'-'+f+'-'+d)+'" class="calendar-date'+(k?' is-disabled':'')+(n?' calendar-range':'')+(o?' calendar-range-start':'')+(p?' calendar-range-end':'')+'">\n <button class="date-item'+(j?' is-today':'')+(h?' is-active':'')+'">'+d+'</button>\n </div>\n '}},{key:'_renderDays',value:function _renderDays(){var p=new Date,q='',r=this._getDaysInMonth(this.year,this.month),s=new Date(this.year,this.month,1).getDay();'undefined'!=typeof this.options.onRender&&null!=this.options.onRender&&this.options.onRender&&this.options.onRender(this),0<datepicker_langs[this.options.lang].weekStart&&(s-=datepicker_langs[this.options.lang].weekStart,0>s&&(s+=7));for(var t=r+s,u=t;7<u;)u-=7;t+=7-u;for(var d=0;d<t;d++){var f=new Date(this.year,this.month,1+(d-s)),h=this._compareDates(f,this.options.startDate),j=!1,k=!1,l=this._compareDates(f,p),n=d<s||d>=r+s,o=!1;h||(j=!1,k=!1),f.getMonth()!==this.month&&(o=!0),q+=this._renderDay(f.getDate(),this.month,this.year,h,l,o,n,!1,j,k)}this.datePickerCalendarBody.insertAdjacentHTML('beforeend',q),this.datePickerCalendarDays=this.datePickerCalendarBody.querySelectorAll('.calendar-date'),this._bindDaysEvents()}},{key:'prevMonth',value:function prevMonth(){this.month-=1,this._adjustCalendar()}},{key:'nextMonth',value:function nextMonth(){this.month+=1,this._adjustCalendar()}},{key:'prevYear',value:function prevYear(){this.year-=1,this._adjustCalendar()}},{key:'nextYear',value:function nextYear(){this.year+=1,this._adjustCalendar()}},{key:'show',value:function show(){this.element.value&&(this.options.startDate=new Date(this.element.value)),this.month=this.options.startDate.getMonth(),this.year=this.options.startDate.getFullYear(),this.day=this.options.startDate.getDate(),this._adjustCalendar(),'undefined'!=typeof this.options.onOpen&&null!=this.options.onOpen&&this.options.onOpen&&this.options.onOpen(this),this.datePickerContainer.classList.add('is-active'),this.options.overlay||this._adjustPosition(),this.open=!0}},{key:'hide',value:function hide(){this.open=!1,'undefined'!=typeof this.options.onClose&&null!=this.options.onClose&&this.options.onClose&&this.options.onClose(this),this.datePickerContainer.classList.remove('is-active')}},{key:'_adjustCalendar',value:function _adjustCalendar(){return 0>this.month&&(this.year-=Math.ceil(Math.abs(this.month)/12),this.month+=12),11<this.month&&(this.year+=Math.floor(Math.abs(this.month)/12),this.month-=12),this.datePickerCalendarNavMonth.innerHTML=datepicker_langs[this.options.lang].months[this.month],this.datePickerCalendarNavYear.innerHTML=this.year,this.datePickerCalendarNavDay.innerHTML=this.day,this.datePickerCalendarBody.innerHTML='',this._renderDays(),this}},{key:'_adjustPosition',value:function _adjustPosition(){var k,l,n,d=this.datePickerCalendar.offsetWidth,f=this.datePickerCalendar.offsetHeight,g=window.innerWidth||document.documentElement.clientWidth,h=window.innerHeight||document.documentElement.clientHeight,j=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;if('function'==typeof this.element.getBoundingClientRect)n=this.element.getBoundingClientRect(),k=n.left+window.pageXOffset,l=n.bottom+window.pageYOffset;else for(k=this.element.offsetLeft,l=this.element.offsetTop+this.element.offsetHeight;this.element=this.element.offsetParent;)k+=this.element.offsetLeft,l+=this.element.offsetTop;this.datePickerCalendar.style.position='absolute',this.datePickerCalendar.style.left=k+'px',this.datePickerCalendar.style.top=l+'px'}},{key:'destroy',value:function destroy(){this.datePickerCalendar.remove()}},{key:'_getFormatedDate',value:function _getFormatedDate(d,f){var g={d:d.getDate(),dd:d.getDate(),D:d.getDay(),m:d.getMonth()+1,mm:d.getMonth()+1,M:d.getMonth(),MM:d.getMonth(),yy:d.getFullYear().toString().substr(-2),yyyy:d.getFullYear()};return 10>g.dd&&(g.dd='0'+g.dd),10>g.mm&&(g.mm='0'+g.mm),g.D=datepicker_langs[this.options.lang].weekdays[g.D?g.D-1:6],g.M=datepicker_langs[this.options.lang].monthsShort[g.M],g.MM=datepicker_langs[this.options.lang].months[g.MM],f.replace(/(?:[dmM]{1,2}|D|yyyy|yy)/g,function(h){return'undefined'==typeof g[h]?h:g[h]})}},{key:'_isLeapYear',value:function _isLeapYear(d){return 0==d%4&&0!=d%100||0==d%400}},{key:'_getDaysInMonth',value:function _getDaysInMonth(d,f){return[31,this._isLeapYear(d)?29:28,31,30,31,30,31,31,30,31,30,31][f]}},{key:'_compareDates',value:function _compareDates(d,f){return d.setHours(0,0,0,0),f.setHours(0,0,0,0),d.getTime()===f.getTime()}}]),c}(); |
{ | ||
"name": "bulma-calendar", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Display a calendar for date selection or for planning management, in different colors and sizes", | ||
@@ -5,0 +5,0 @@ "main": "calendar.sass", |
{ | ||
"name": "bulma-extensions", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "Set of extensions for Bulma.io CSS Framework", | ||
@@ -5,0 +5,0 @@ "main": "extensions.sass", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
537530