mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-29 20:59:23 +02:00
029a8b9586
API Substitute Zend_Locale with Locale / NumberFormatter API Substitute Zend_Date with IntlDateFormatter API Added DBTIme::Nice12, FormatFromSettings API Added Short() method to DBDate / DBTime / DBDatetime API Add Date::getTimestamp() API Added setSubmittedValue api for FormField API Add second arg to base FormField::setValue() API Major refactor of i18n into component data parts API Implement Resettable interface to reset objects between tests ENHANCEMENT Changed DBField::create_field return type to `static` to support better type hinting ENHANCEMENT i18nTextCollector supports __CLASS__
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import $ from 'jQuery';
|
|
|
|
// entwine also required, but can't be included more than once without error
|
|
require('../../../thirdparty/jquery-ui/jquery-ui.js');
|
|
|
|
$.fn.extend({
|
|
ssDatepicker: function(opts) {
|
|
return $(this).each(function() {
|
|
|
|
// disabled, readonly or already applied
|
|
if ($(this).prop('disabled') || $(this).prop('readonly') || $(this).hasClass('hasDatepicker')) {
|
|
return;
|
|
}
|
|
|
|
$(this).siblings("button").addClass("ui-icon ui-icon-calendar");
|
|
|
|
let config = $.extend(
|
|
{},
|
|
opts || {},
|
|
$(this).data(),
|
|
$(this).data('jqueryuiconfig')
|
|
);
|
|
if(!config.showcalendar) {
|
|
return;
|
|
}
|
|
|
|
if(config.locale && $.datepicker.regional[config.locale]) {
|
|
// Note: custom config overrides regional settings
|
|
config = $.extend({}, $.datepicker.regional[config.locale], config);
|
|
}
|
|
|
|
// Initialize and open a datepicker
|
|
// live() doesn't have "onmatch", and jQuery.entwine is a bit too heavyweight
|
|
// for this, so we need to do this onclick.
|
|
$(this).datepicker(config);
|
|
});
|
|
}
|
|
});
|
|
|
|
$(document).on("click", ".field.date input.text,input.text.date", function() {
|
|
$(this).ssDatepicker();
|
|
|
|
if($(this).data('datepicker')) {
|
|
$(this).datepicker('show');
|
|
}
|
|
});
|