updated Uikit v2

This commit is contained in:
2017-11-12 02:33:10 +02:00
parent 7d27af5d59
commit 1cc40dbfe4
437 changed files with 9171 additions and 5797 deletions

View File

@ -1,15 +1,15 @@
/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
var component;
if (window.UIkit) {
component = addon(UIkit);
if (window.UIkit2) {
component = addon(UIkit2);
}
if (typeof define == "function" && define.amd) {
define("uikit-datepicker", ["uikit"], function(){
return component || addon(UIkit);
if (typeof define == 'function' && define.amd) {
define('uikit-datepicker', ['uikit'], function(){
return component || addon(UIkit2);
});
}
@ -30,11 +30,12 @@
months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
weekdays : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
},
format: "YYYY-MM-DD",
format: 'YYYY-MM-DD',
offsettop: 5,
maxDate: false,
minDate: false,
pos: 'auto',
container: 'body',
template: function(data, opts) {
var content = '', i;
@ -120,7 +121,7 @@
boot: function() {
UI.$win.on("resize orientationchange", function() {
UI.$win.on('resize orientationchange', function() {
if (active) {
active.hide();
@ -128,22 +129,22 @@
});
// init code
UI.$html.on("focus.datepicker.uikit", "[data-uk-datepicker]", function(e) {
UI.$html.on('focus.datepicker.uikit', '[data-uk-datepicker]', function(e) {
var ele = UI.$(this);
if (!ele.data("datepicker")) {
if (!ele.data('datepicker')) {
e.preventDefault();
UI.datepicker(ele, UI.Utils.options(ele.attr("data-uk-datepicker")));
ele.trigger("focus");
UI.datepicker(ele, UI.Utils.options(ele.attr('data-uk-datepicker')));
ele.trigger('focus');
}
});
UI.$html.on("click focus", '*', function(e) {
UI.$html.on('click focus', '*', function(e) {
var target = UI.$(e.target);
if (active && target[0] != dropdown[0] && !target.data("datepicker") && !target.parents(".uk-datepicker:first").length) {
if (active && target[0] != dropdown[0] && !target.data('datepicker') && !target.parents('.uk-datepicker:first').length) {
active.hide();
}
});
@ -160,9 +161,9 @@
this.current = this.element.val() ? moment(this.element.val(), this.options.format) : moment();
this.on("click focus", function(){
if (active!==$this) $this.pick(this.value ? this.value:($this.options.minDate ? $this.options.minDate :''));
}).on("change", function(){
this.on('click focus', function(){
if (active!==$this) $this.pick(this.value ? this.value:'');
}).on('change', function(){
if ($this.element.val() && !moment($this.element.val(), $this.options.format).isValid()) {
$this.element.val(moment().format($this.options.format));
@ -174,7 +175,7 @@
dropdown = UI.$('<div class="uk-dropdown uk-datepicker"></div>');
dropdown.on("click", ".uk-datepicker-next, .uk-datepicker-previous, [data-date]", function(e){
dropdown.on('click', '.uk-datepicker-next, .uk-datepicker-previous, [data-date]', function(e){
e.stopPropagation();
e.preventDefault();
@ -185,7 +186,7 @@
if (ele.is('[data-date]')) {
active.current = moment(ele.data("date"));
active.element.val(active.current.format(active.options.format)).trigger("change");
active.element.val(active.current.isValid() ? active.current.format(active.options.format) : null).trigger("change");
active.hide();
} else {
active.add((ele.hasClass("uk-datepicker-next") ? 1:-1), "months");
@ -198,14 +199,14 @@
active[select.is('.update-picker-year') ? 'setYear':'setMonth'](Number(select.val()));
});
dropdown.appendTo("body");
dropdown.appendTo(this.options.container);
}
},
pick: function(initdate) {
var offset = this.element.offset(),
css = {"left": offset.left, "right":""};
css = {left: offset.left, right:''};
this.current = isNaN(initdate) ? moment(initdate, this.options.format):moment();
this.initdate = this.current.format("YYYY-MM-DD");
@ -214,7 +215,7 @@
if (UI.langdirection == 'right') {
css.right = window.innerWidth - (css.left + this.element.outerWidth());
css.left = "";
css.left = '';
}
var posTop = (offset.top - this.element.outerHeight() + this.element.height()) - this.options.offsettop - dropdown.outerHeight(),
@ -265,15 +266,16 @@
now = moment().format('YYYY-MM-DD'),
days = [31, (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month],
before = new Date(year, month, 1, 12).getDay(),
data = {"month":month, "year":year,"weekdays":[],"days":[], "maxDate": false, "minDate": false},
data = {month:month, year:year, weekdays:[], days:[], maxDate:false, minDate:false},
row = [];
// We need these to be midday to avoid issues from DST transition protection.
if (opts.maxDate!==false){
data.maxDate = isNaN(opts.maxDate) ? moment(opts.maxDate, opts.format) : moment().add(opts.maxDate, 'days');
data.maxDate = isNaN(opts.maxDate) ? moment(opts.maxDate, opts.format).startOf('day').hours(12) : moment().add(opts.maxDate, 'days').startOf('day').hours(12);
}
if (opts.minDate!==false){
data.minDate = isNaN(opts.minDate) ? moment(opts.minDate, opts.format) : moment().add(opts.minDate-1, 'days');
data.minDate = isNaN(opts.minDate) ? moment(opts.minDate, opts.format).startOf('day').hours(12) : moment().add(opts.minDate-1, 'days').startOf('day').hours(12);
}
data.weekdays = (function(){
@ -315,10 +317,10 @@
day = moment(day);
isSelected = this.initdate == day.format("YYYY-MM-DD");
isToday = now == day.format("YYYY-MM-DD");
isSelected = this.initdate == day.format('YYYY-MM-DD');
isToday = now == day.format('YYYY-MM-DD');
row.push({"selected": isSelected, "today": isToday, "disabled": isDisabled, "day":day, "inmonth":isInMonth});
row.push({selected: isSelected, today: isToday, disabled: isDisabled, day:day, inmonth:isInMonth});
if (++r === 7) {
data.days.push(row);