From 7dc7249624db655859e83158cab51fce6eddc1bf Mon Sep 17 00:00:00 2001 From: Guillermo Cespedes Date: Wed, 25 Apr 2018 13:17:51 -0300 Subject: [PATCH] Add settings for input type date. --- dev/jquery.jtable.core.js | 10 +++++++--- dev/jquery.jtable.forms.js | 25 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dev/jquery.jtable.core.js b/dev/jquery.jtable.core.js index 84cb4a74..0bdd0d78 100644 --- a/dev/jquery.jtable.core.js +++ b/dev/jquery.jtable.core.js @@ -4,7 +4,7 @@ (function ($) { var unloadingPage; - + $(window).on('beforeunload', function () { unloadingPage = true; }); @@ -24,6 +24,10 @@ fields: {}, animationsEnabled: true, defaultDateFormat: 'yy-mm-dd', + defaultChangeMonth: false, + defaultChangeYear: false, + defaultYearRange: 'c-10:c+10', + defaultMaxDate: null, dialogShowEffect: 'fade', dialogHideEffect: 'fade', showCloseButton: false, @@ -119,7 +123,7 @@ this._createErrorDialogDiv(); this._addNoDataRow(); - this._cookieKeyPrefix = this._generateCookieKeyPrefix(); + this._cookieKeyPrefix = this._generateCookieKeyPrefix(); }, /* Normalizes some options for all fields (sets default values). @@ -1186,7 +1190,7 @@ jqXHR.abort(); return; } - + if (options.error) { options.error(arguments); } diff --git a/dev/jquery.jtable.forms.js b/dev/jquery.jtable.forms.js index 0ef0c964..799a35b0 100644 --- a/dev/jquery.jtable.forms.js +++ b/dev/jquery.jtable.forms.js @@ -105,9 +105,20 @@ if(value != undefined) { $input.val(value); } - + var displayFormat = field.displayFormat || this.options.defaultDateFormat; - $input.datepicker({ dateFormat: displayFormat }); + var changeMonth = field.changeMonth || this.options.defaultChangeMonth; + var changeYear = field.changeYear || this.options.defaultChangeYear; + var yearRange = field.yearRange || this.options.defaultYearRange; + var maxDate = field.maxDate || this.options.defaultMaxDate; + + $input.datepicker({ + dateFormat: displayFormat, + changeMonth: changeMonth, + changeYear: changeYear, + yearRange: yearRange, + maxDate: maxDate + }); return $('
') .addClass('jtable-input jtable-date-input') .append($input); @@ -120,7 +131,7 @@ if (value != undefined) { $textArea.val(value); } - + return $('
') .addClass('jtable-input jtable-textarea-input') .append($textArea); @@ -133,7 +144,7 @@ if (value != undefined) { $input.val(value); } - + return $('
') .addClass('jtable-input jtable-text-input') .append($input); @@ -146,7 +157,7 @@ if (value != undefined) { $input.val(value); } - + return $('
') .addClass('jtable-input jtable-password-input') .append($input); @@ -236,7 +247,7 @@ return $containerDiv; }, - + /* Fills a dropdown list with given options. *************************************************************************/ _fillDropDownListWithOptions: function ($select, options, value) { @@ -373,7 +384,7 @@ } var field = self.options.fields[fieldName]; - + //check if this combobox depends on others if (!field.dependsOn) { return;