mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Added firstDay option to datepicker form widget (#2940)
Documented here: https://github.com/octobercms/docs/pull/243
This commit is contained in:
parent
f7f507dbdc
commit
4f97d07962
@ -46,6 +46,12 @@ class DatePicker extends FormWidgetBase
|
||||
*/
|
||||
public $yearRange = null;
|
||||
|
||||
/**
|
||||
* @var int first day of the week
|
||||
* eg: 0 (Sunday), 1 (Monday), 2 (Tuesday), etc.
|
||||
*/
|
||||
public $firstDay = 0;
|
||||
|
||||
//
|
||||
// Object properties
|
||||
//
|
||||
@ -66,6 +72,7 @@ class DatePicker extends FormWidgetBase
|
||||
'minDate',
|
||||
'maxDate',
|
||||
'yearRange',
|
||||
'firstDay',
|
||||
]);
|
||||
|
||||
$this->mode = strtolower($this->mode);
|
||||
@ -112,6 +119,7 @@ class DatePicker extends FormWidgetBase
|
||||
$this->vars['minDate'] = $this->minDate;
|
||||
$this->vars['maxDate'] = $this->maxDate;
|
||||
$this->vars['yearRange'] = $this->yearRange;
|
||||
$this->vars['firstDay'] = $this->firstDay;
|
||||
$this->vars['format'] = $this->format;
|
||||
$this->vars['formatMoment'] = $this->getDateFormatMoment();
|
||||
$this->vars['formatAlias'] = $this->getDateFormatAlias();
|
||||
|
@ -14,6 +14,7 @@
|
||||
<?php if ($minDate): ?>data-min-date="<?= $minDate ?>"<?php endif ?>
|
||||
<?php if ($maxDate): ?>data-max-date="<?= $maxDate ?>"<?php endif ?>
|
||||
<?php if ($yearRange): ?>data-year-range="<?= $yearRange ?>"<?php endif ?>
|
||||
<?php if ($firstDay): ?>data-first-day="<?= $firstDay ?>"<?php endif ?>
|
||||
>
|
||||
|
||||
<?php if ($mode == 'date'): ?>
|
||||
|
@ -102,6 +102,7 @@
|
||||
|
||||
var pikadayOptions = {
|
||||
yearRange: this.options.yearRange,
|
||||
firstDay: this.options.firstDay,
|
||||
format: dateFormat,
|
||||
setDefaultDate: now,
|
||||
onOpen: function() {
|
||||
@ -305,7 +306,8 @@
|
||||
minDate: null,
|
||||
maxDate: null,
|
||||
format: null,
|
||||
yearRange: 10
|
||||
yearRange: 10,
|
||||
firstDay: 0
|
||||
}
|
||||
|
||||
// PLUGIN DEFINITION
|
||||
|
4
modules/system/assets/ui/storm-min.js
vendored
4
modules/system/assets/ui/storm-min.js
vendored
@ -2877,7 +2877,7 @@ this.$el=null
|
||||
this.options=null
|
||||
BaseProto.dispose.call(this)}
|
||||
DatePicker.prototype.initDatePicker=function(){var self=this,dateFormat=this.getDateFormat(),now=moment().tz(this.timezone).format(dateFormat)
|
||||
var pikadayOptions={yearRange:this.options.yearRange,format:dateFormat,setDefaultDate:now,onOpen:function(){var $field=$(this._o.trigger)
|
||||
var pikadayOptions={yearRange:this.options.yearRange,firstDay:this.options.firstDay,format:dateFormat,setDefaultDate:now,onOpen:function(){var $field=$(this._o.trigger)
|
||||
$(this.el).css({left:'auto',right:$(window).width()-$field.offset().left-$field.outerWidth()})},onSelect:function(){self.onSelectDatePicker.call(self,this.getMoment())}}
|
||||
var lang=this.getLang('datepicker',false)
|
||||
if(lang){pikadayOptions.i18n=lang}
|
||||
@ -2926,7 +2926,7 @@ if(!this.appTimezone){this.appTimezone='UTC'}
|
||||
if(!this.timezone){this.timezone='UTC'}}
|
||||
DatePicker.prototype.getLang=function(name,defaultValue){if($.oc===undefined||$.oc.lang===undefined){return defaultValue}
|
||||
return $.oc.lang.get(name,defaultValue)}
|
||||
DatePicker.DEFAULTS={minDate:null,maxDate:null,format:null,yearRange:10}
|
||||
DatePicker.DEFAULTS={minDate:null,maxDate:null,format:null,yearRange:10,firstDay:0}
|
||||
var old=$.fn.datePicker
|
||||
$.fn.datePicker=function(option){var args=Array.prototype.slice.call(arguments,1),items,result
|
||||
items=this.each(function(){var $this=$(this)
|
||||
|
Loading…
x
Reference in New Issue
Block a user