mirror of
https://github.com/frappe/air-datepicker.git
synced 2026-01-14 11:01:22 +08:00
fix docs, remove rerender datepicker body when change time
This commit is contained in:
parent
50f04cdb1b
commit
36090db009
24
dist/js/datepicker.js
vendored
24
dist/js/datepicker.js
vendored
@ -954,6 +954,7 @@ var Datepicker;
|
||||
},
|
||||
|
||||
_onInput: function () {
|
||||
console.log(234);
|
||||
var val = this.$el.val();
|
||||
|
||||
if (!val) {
|
||||
@ -1048,16 +1049,25 @@ var Datepicker;
|
||||
},
|
||||
|
||||
_onTimeChange: function (e, h, m) {
|
||||
var date = new Date();
|
||||
var date = new Date(),
|
||||
selectedDates = this.selectedDates,
|
||||
selected = false;
|
||||
|
||||
if (this.selectedDates.length) {
|
||||
if (selectedDates.length) {
|
||||
selected = true;
|
||||
date = this.selectedDates[this.selectedDates.length - 1]
|
||||
}
|
||||
|
||||
date.setHours(h);
|
||||
date.setMinutes(m);
|
||||
|
||||
this.selectDate(date);
|
||||
if (!selected) {
|
||||
this.selectDate(date);
|
||||
} else {
|
||||
this.selectedDates[selectedDates.length - 1] = date;
|
||||
this._setInputValue();
|
||||
this._triggerOnChange();
|
||||
}
|
||||
},
|
||||
|
||||
set focused(val) {
|
||||
@ -1729,9 +1739,14 @@ var Datepicker;
|
||||
|
||||
datepicker.Timepicker.prototype = {
|
||||
init: function () {
|
||||
var input = 'input';
|
||||
this._buildHTML();
|
||||
|
||||
this.$ranges.on('input', this._onChangeRange.bind(this));
|
||||
if (navigator.userAgent.match(/trident/gi)) {
|
||||
input = 'change';
|
||||
}
|
||||
|
||||
this.$ranges.on(input, this._onChangeRange.bind(this));
|
||||
},
|
||||
|
||||
_buildHTML: function () {
|
||||
@ -1755,7 +1770,6 @@ var Datepicker;
|
||||
},
|
||||
|
||||
_render: function () {
|
||||
|
||||
},
|
||||
|
||||
_onChangeRange: function (e) {
|
||||
|
||||
2
dist/js/datepicker.min.js
vendored
2
dist/js/datepicker.min.js
vendored
File diff suppressed because one or more lines are too long
@ -10,19 +10,19 @@ $('#my-element').datepicker([options])
|
||||
|
||||
// Доступ к экземпляру объекта
|
||||
$('#my-element').data('datepicker')
|
||||
</code></pre></article><article><h2 id="examples">Примеры</h2><h3>Инициализация с опциями по умолчанию</h3><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type='text' class='datepicker-here' />
|
||||
</code></pre></div><h3>Выбор нескольких дат</h3><p>Передайте параметр<span class="example-inline"><code class="js">{multipleDates: true}</code></span>для выбора нескольких дат. Если требуется ограничить количество выбранных дат, то передайте необходимое число<span class="example-inline"><code class="js">{multipleDates: 3}</code></span>.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" data-multiple-dates="3" data-multiple-dates-separator=", " data-position="top left" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
</code></pre></article><article><h2 id="examples">Примеры</h2><h3 id="example-default">Инициализация с опциями по умолчанию</h3><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type='text' class='datepicker-here' />
|
||||
</code></pre></div><h3 id="example-multiple">Выбор нескольких дат</h3><p>Передайте параметр<span class="example-inline"><code class="js">{multipleDates: true}</code></span>для выбора нескольких дат. Если требуется ограничить количество выбранных дат, то передайте необходимое число<span class="example-inline"><code class="js">{multipleDates: 3}</code></span>.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" data-multiple-dates="3" data-multiple-dates-separator=", " data-position="top left" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
class="datepicker-here"
|
||||
data-multiple-dates="3"
|
||||
data-multiple-dates-separator=", "
|
||||
data-position='right top'/>
|
||||
</code></pre></div><h3>Постоянно видимый календарь</h3><p>Проинициализируйте плагин на элементе, который не является текстовым полем, например на<span class="example-inline"><code class="html"><div> … </div></code></span>, либо передайте параметр<span class="example-inline"><code class="js">{inline: true}</code></span>.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><div class="datepicker-here"></div></div><pre class="example-code"><code class="html"><div class="datepicker-here"></div>
|
||||
</code></pre></div><h3>Выбор месяца</h3><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" data-min-view="months" data-view="months" data-date-format="MM yyyy" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
</code></pre></div><h3 id="example-inline">Постоянно видимый календарь</h3><p>Проинициализируйте плагин на элементе, который не является текстовым полем, например на<span class="example-inline"><code class="html"><div> … </div></code></span>, либо передайте параметр<span class="example-inline"><code class="js">{inline: true}</code></span>.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><div class="datepicker-here"></div></div><pre class="example-code"><code class="html"><div class="datepicker-here"></div>
|
||||
</code></pre></div><h3 id="example-months">Выбор месяца</h3><div class="example"><div class="example--label">Пример</div><div class="example-content"><input type="text" data-min-view="months" data-view="months" data-date-format="MM yyyy" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
class="datepicker-here"
|
||||
data-min-view="months"
|
||||
data-view="months"
|
||||
data-date-format="MM yyyy" />
|
||||
</code></pre></div><h3>Минимальная и максимальные даты</h3><p>Чтобы ограничить выбор даты, используйте<span class="example-inline"><code class="js">minDate</code></span>и<span class="example-inline"><code class="js">maxDate</code></span>, которым нужно передать объект даты.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><input id="minMaxExample" type="text"><script>$('#minMaxExample').datepicker({
|
||||
</code></pre></div><h3 id="example-min-max">Минимальная и максимальные даты</h3><p>Чтобы ограничить выбор даты, используйте<span class="example-inline"><code class="js">minDate</code></span>и<span class="example-inline"><code class="js">maxDate</code></span>, которым нужно передать объект даты.</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><input id="minMaxExample" type="text"><script>$('#minMaxExample').datepicker({
|
||||
// Можно выбрать тольо даты, идущие за сегодняшним днем, включая сегодня.
|
||||
minDate: new Date()
|
||||
})</script></div><pre class="example-code"><code class="js">$('#minMaxExample').datepicker({
|
||||
@ -58,7 +58,7 @@ $('#disabled-days').datepicker({
|
||||
}
|
||||
}
|
||||
})
|
||||
</code></pre></div><h3>Кастомное содержимое ячеек</h3><p>Air Datepicker позволяет менять содержимое ячеек как угодно. Для этого можно также воспользоваться методом<span class="example-inline"><code>onRenderCell</code></span>.
|
||||
</code></pre></div><h3 id="example-custom-content">Кастомное содержимое ячеек</h3><p>Air Datepicker позволяет менять содержимое ячеек как угодно. Для этого можно также воспользоваться методом<span class="example-inline"><code>onRenderCell</code></span>.
|
||||
Давайте добавим вспомогательные элементы к нескольким датам и покажем случайный текст при выборе этих дат:</p><div class="example"><div class="example--label">Пример</div><div class="example-content"><div class="list-inline"><div><div id="custom-cells"></div></div><div id="custom-cells-events"><strong></strong><p></p></div></div><script>var eventDates = [1, 10, 12, 22],
|
||||
$picker = $('#custom-cells'),
|
||||
$content = $('#custom-cells-events'),
|
||||
@ -125,7 +125,6 @@ $picker.datepicker({
|
||||
// Сразу выберем какую-ниудь дату из `eventDates`
|
||||
var currentDate = currentDate = new Date();
|
||||
$picker.data('datepicker').selectDate(new Date(currentDate.getFullYear(), currentDate.getMonth(), 10))
|
||||
|
||||
</code></pre></div></article><article><h2 id="localization">Локализация</h2><p>Вы можете добавить свою локализацию в объект<span class="example-inline"><code class="js">Datepicker.language["my-lang"]</code></span>и при вызове календаря передать название языка в параметр<span class="example-inline"><code class="js">language</code></span></p><pre class="example-code"><code class="js">Datepicker.language['my-lang'] = {...}
|
||||
|
||||
$('.my-datepicker').datepicker({
|
||||
|
||||
@ -13,17 +13,17 @@ $promo.datepicker({
|
||||
</html></code></pre><p>Datepicker will automatically initialize on elements with class<span class="example-inline"><code class="css">.datepicker-here</code></span>, options may be sent via<span class="example-inline"><code class="html">data</code></span>attributes.</p><pre class="example-code"><code class="html"><input type='text' class="datepicker-here" data-position="right top" /></code></pre><h3>Manual initialization</h3><pre class="example-code"><code class="js">// Initialization
|
||||
$('#my-element').datepicker([options])
|
||||
// Access instance of plugin
|
||||
$('#my-element').data('datepicker')</code></pre></article><article><h2 id="examples">Examples</h2><h3>Initialization with default options</h3><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type='text' class='datepicker-here' data-language='en' /></code></pre></div><h3>Selecting multiple dates</h3><p>Pass parameter<span class="example-inline"><code class="js">{multipleDates: true}</code></span>for selection of multiple dates. If you want to limit the number of selected dates, pass the desired number<span class="example-inline"><code class="js">{multipleDates: 3}</code></span>.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-multiple-dates="3" data-multiple-dates-separator=", " data-position="top left" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
$('#my-element').data('datepicker')</code></pre></article><article><h2 id="examples">Examples</h2><h3 id="example-default">Initialization with default options</h3><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type='text' class='datepicker-here' data-language='en' /></code></pre></div><h3 id="example-multiple">Selecting multiple dates</h3><p>Pass parameter<span class="example-inline"><code class="js">{multipleDates: true}</code></span>for selection of multiple dates. If you want to limit the number of selected dates, pass the desired number<span class="example-inline"><code class="js">{multipleDates: 3}</code></span>.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-multiple-dates="3" data-multiple-dates-separator=", " data-position="top left" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
class="datepicker-here"
|
||||
data-language='en'
|
||||
data-multiple-dates="3"
|
||||
data-multiple-dates-separator=", "
|
||||
data-position='top left'/></code></pre></div><h3>Permanently visible calendar</h3><p>Initialize plugin on non text input element, such as<span class="example-inline"><code class="html"><div> … </div></code></span>,or pass the parameter<span class="example-inline"><code class="js">{inline: true}</code></span>.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><div data-language="en" class="datepicker-here"></div></div><pre class="example-code"><code class="html"><div class="datepicker-here" data-language='en'></div></code></pre></div><h3>Month selection</h3><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-min-view="months" data-view="months" data-date-format="MM yyyy" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
data-position='top left'/></code></pre></div><h3 id="example-inline">Permanently visible calendar</h3><p>Initialize plugin on non text input element, such as<span class="example-inline"><code class="html"><div> … </div></code></span>,or pass the parameter<span class="example-inline"><code class="js">{inline: true}</code></span>.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><div data-language="en" class="datepicker-here"></div></div><pre class="example-code"><code class="html"><div class="datepicker-here" data-language='en'></div></code></pre></div><h3 id="example-months">Month selection</h3><div class="example"><div class="example--label">Example</div><div class="example-content"><input type="text" data-min-view="months" data-view="months" data-date-format="MM yyyy" data-language="en" class="datepicker-here"></div><pre class="example-code"><code class="html"><input type="text"
|
||||
class="datepicker-here"
|
||||
data-language='en'
|
||||
data-min-view="months"
|
||||
data-view="months"
|
||||
data-date-format="MM yyyy" /></code></pre></div><h3>Minimum and maximum dates</h3><p>To limit date selection, use<span class="example-inline"><code class="js">minDate</code></span>and<span class="example-inline"><code class="js">maxDate</code></span>, they must receive JavaScript Date object.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><input id="minMaxExample" type="text"><script>$('#minMaxExample').datepicker({
|
||||
data-date-format="MM yyyy" /></code></pre></div><h3 id="example-min-max">Minimum and maximum dates</h3><p>To limit date selection, use<span class="example-inline"><code class="js">minDate</code></span>and<span class="example-inline"><code class="js">maxDate</code></span>, they must receive JavaScript Date object.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><input id="minMaxExample" type="text"><script>$('#minMaxExample').datepicker({
|
||||
language: 'en',
|
||||
minDate: new Date() // Now can select only dates, which goes after today
|
||||
})</script></div><pre class="example-code"><code class="js">$('#minMaxExample').datepicker({
|
||||
@ -66,7 +66,7 @@ $('#disabled-days').datepicker({
|
||||
}
|
||||
}
|
||||
})
|
||||
</code></pre></div><h3>Custom cells content</h3><p>Air Datepicker allows you to change contents of cells like you want. You could use<span class="example-inline"><code>onRenderCell</code></span>for this purpose.
|
||||
</code></pre></div><h3 id="example-custom-content">Custom cells content</h3><p>Air Datepicker allows you to change contents of cells like you want. You could use<span class="example-inline"><code>onRenderCell</code></span>for this purpose.
|
||||
Lets add extra elements to several dates, and show `lorem` text when selecting them.</p><div class="example"><div class="example--label">Example</div><div class="example-content"><div class="list-inline"><div><div id="custom-cells"></div></div><div id="custom-cells-events"><strong></strong><p></p></div></div><script>var eventDates = [1, 10, 12, 22],
|
||||
$picker = $('#custom-cells'),
|
||||
$content = $('#custom-cells-events'),
|
||||
|
||||
@ -63,7 +63,7 @@ block content
|
||||
|
||||
article
|
||||
h2#examples Примеры
|
||||
h3 Инициализация с опциями по умолчанию
|
||||
h3#example-default Инициализация с опциями по умолчанию
|
||||
+example
|
||||
+example-content
|
||||
input(type='text').datepicker-here
|
||||
@ -71,7 +71,7 @@ block content
|
||||
:code
|
||||
<input type='text' class='datepicker-here' />
|
||||
|
||||
h3 Выбор нескольких дат
|
||||
h3#example-multiple Выбор нескольких дат
|
||||
p
|
||||
| Передайте параметр
|
||||
+example-inline('{multipleDates: true}','js')
|
||||
@ -89,7 +89,7 @@ block content
|
||||
data-multiple-dates-separator=", "
|
||||
data-position='right top'/>
|
||||
|
||||
h3 Постоянно видимый календарь
|
||||
h3#example-inline Постоянно видимый календарь
|
||||
p
|
||||
| Проинициализируйте плагин на элементе, который не является текстовым полем, например на
|
||||
+example-inline('<div> … </div>', 'html')
|
||||
@ -103,7 +103,7 @@ block content
|
||||
:code
|
||||
<div class="datepicker-here"></div>
|
||||
|
||||
h3 Выбор месяца
|
||||
h3#example-months Выбор месяца
|
||||
+example
|
||||
+example-content
|
||||
input.datepicker-here(type='text' data-min-view='months' data-view='months' data-date-format='MM yyyy')
|
||||
@ -115,7 +115,7 @@ block content
|
||||
data-view="months"
|
||||
data-date-format="MM yyyy" />
|
||||
|
||||
h3 Минимальная и максимальные даты
|
||||
h3#example-min-max Минимальная и максимальные даты
|
||||
p
|
||||
| Чтобы ограничить выбор даты, используйте
|
||||
+example-inline('minDate', 'js')
|
||||
@ -191,7 +191,7 @@ block content
|
||||
}
|
||||
})
|
||||
|
||||
h3 Кастомное содержимое ячеек
|
||||
h3#example-custom-content Кастомное содержимое ячеек
|
||||
p Air Datepicker позволяет менять содержимое ячеек как угодно. Для этого можно также воспользоваться методом
|
||||
+example-inline('onRenderCell')
|
||||
| .
|
||||
@ -277,7 +277,6 @@ block content
|
||||
var currentDate = currentDate = new Date();
|
||||
$picker.data('datepicker').selectDate(new Date(currentDate.getFullYear(), currentDate.getMonth(), 10))
|
||||
|
||||
|
||||
article
|
||||
h2#localization Локализация
|
||||
p
|
||||
|
||||
@ -61,14 +61,14 @@ block content
|
||||
$('#my-element').data('datepicker')
|
||||
article
|
||||
h2#examples Examples
|
||||
h3 Initialization with default options
|
||||
h3#example-default Initialization with default options
|
||||
+example
|
||||
+example-content
|
||||
input(type='text', data-language='en').datepicker-here
|
||||
+example-code('html')
|
||||
:code
|
||||
<input type='text' class='datepicker-here' data-language='en' />
|
||||
h3 Selecting multiple dates
|
||||
h3#example-multiple Selecting multiple dates
|
||||
p
|
||||
| Pass parameter
|
||||
+example-inline('{multipleDates: true}','js')
|
||||
@ -86,7 +86,7 @@ block content
|
||||
data-multiple-dates="3"
|
||||
data-multiple-dates-separator=", "
|
||||
data-position='top left'/>
|
||||
h3 Permanently visible calendar
|
||||
h3#example-inline Permanently visible calendar
|
||||
p
|
||||
| Initialize plugin on non text input element, such as
|
||||
+example-inline('<div> … </div>', 'html')
|
||||
@ -99,7 +99,7 @@ block content
|
||||
+example-code('html')
|
||||
:code
|
||||
<div class="datepicker-here" data-language='en'></div>
|
||||
h3 Month selection
|
||||
h3#example-months Month selection
|
||||
+example
|
||||
+example-content
|
||||
input.datepicker-here(type='text' data-min-view='months' data-view='months' data-date-format='MM yyyy' data-language='en')
|
||||
@ -111,7 +111,7 @@ block content
|
||||
data-min-view="months"
|
||||
data-view="months"
|
||||
data-date-format="MM yyyy" />
|
||||
h3 Minimum and maximum dates
|
||||
h3#example-min-max Minimum and maximum dates
|
||||
p
|
||||
| To limit date selection, use
|
||||
+example-inline('minDate', 'js')
|
||||
@ -191,7 +191,7 @@ block content
|
||||
}
|
||||
})
|
||||
|
||||
h3 Custom cells content
|
||||
h3#example-custom-content Custom cells content
|
||||
p Air Datepicker allows you to change contents of cells like you want. You could use
|
||||
+example-inline('onRenderCell')
|
||||
| for this purpose.
|
||||
|
||||
@ -60,7 +60,6 @@ var navigation;
|
||||
var id,
|
||||
title,
|
||||
subTitles,
|
||||
subId,
|
||||
$subTitle,
|
||||
$current;
|
||||
|
||||
@ -80,8 +79,13 @@ var navigation;
|
||||
cache[id].subSections = {};
|
||||
|
||||
subTitles.each(function () {
|
||||
subId = idPrefix + idCounter++;
|
||||
$subTitle = $(this).attr('id', subId);
|
||||
var $subTitle = $(this),
|
||||
subId = $(this).attr('id');
|
||||
|
||||
if (!subId) {
|
||||
subId = idPrefix + idCounter++;
|
||||
$subTitle.attr('id', subId);
|
||||
}
|
||||
|
||||
cache[id].subSections[subId] = {
|
||||
title: $subTitle.text(),
|
||||
|
||||
@ -954,6 +954,7 @@ var Datepicker;
|
||||
},
|
||||
|
||||
_onInput: function () {
|
||||
console.log(234);
|
||||
var val = this.$el.val();
|
||||
|
||||
if (!val) {
|
||||
@ -1048,16 +1049,25 @@ var Datepicker;
|
||||
},
|
||||
|
||||
_onTimeChange: function (e, h, m) {
|
||||
var date = new Date();
|
||||
var date = new Date(),
|
||||
selectedDates = this.selectedDates,
|
||||
selected = false;
|
||||
|
||||
if (this.selectedDates.length) {
|
||||
if (selectedDates.length) {
|
||||
selected = true;
|
||||
date = this.selectedDates[this.selectedDates.length - 1]
|
||||
}
|
||||
|
||||
date.setHours(h);
|
||||
date.setMinutes(m);
|
||||
|
||||
this.selectDate(date);
|
||||
if (!selected) {
|
||||
this.selectDate(date);
|
||||
} else {
|
||||
this.selectedDates[selectedDates.length - 1] = date;
|
||||
this._setInputValue();
|
||||
this._triggerOnChange();
|
||||
}
|
||||
},
|
||||
|
||||
set focused(val) {
|
||||
|
||||
@ -22,9 +22,14 @@
|
||||
|
||||
datepicker.Timepicker.prototype = {
|
||||
init: function () {
|
||||
var input = 'input';
|
||||
this._buildHTML();
|
||||
|
||||
this.$ranges.on('input', this._onChangeRange.bind(this));
|
||||
if (navigator.userAgent.match(/trident/gi)) {
|
||||
input = 'change';
|
||||
}
|
||||
|
||||
this.$ranges.on(input, this._onChangeRange.bind(this));
|
||||
},
|
||||
|
||||
_buildHTML: function () {
|
||||
@ -48,7 +53,6 @@
|
||||
},
|
||||
|
||||
_render: function () {
|
||||
|
||||
},
|
||||
|
||||
_onChangeRange: function (e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user