datatables.net-datetime 1.0.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/{dateTime.scss → dataTables.dateTime.scss} +15 -0
- package/dist/dataTables.dateTime.css +218 -0
- package/{js/dateTime.js → dist/dataTables.dateTime.js} +191 -51
- package/dist/dataTables.dateTime.min.css +1 -0
- package/dist/dataTables.dateTime.min.js +43 -0
- package/docs/api/DateTime.use().xml +32 -0
- package/docs/api/destroy().xml +28 -0
- package/docs/api/errorMsg().xml +52 -0
- package/docs/api/hide().xml +36 -0
- package/docs/api/max().xml +35 -0
- package/docs/api/min().xml +35 -0
- package/docs/api/owns().xml +30 -0
- package/docs/api/val().xml +44 -0
- package/docs/option/buttons.clear.xml +27 -0
- package/docs/option/buttons.today.xml +29 -0
- package/docs/option/buttons.xml +28 -0
- package/docs/option/disableDays.xml +45 -0
- package/docs/option/firstDay.xml +34 -0
- package/docs/option/format.xml +31 -0
- package/docs/option/hoursAvailable.xml +36 -0
- package/docs/option/i18n.amPm.xml +32 -0
- package/docs/option/i18n.clear.xml +28 -0
- package/docs/option/i18n.hours.xml +33 -0
- package/docs/option/i18n.minutes.xml +33 -0
- package/docs/option/i18n.months.xml +32 -0
- package/docs/option/i18n.next.xml +32 -0
- package/docs/option/i18n.previous.xml +32 -0
- package/docs/option/i18n.seconds.xml +33 -0
- package/docs/option/i18n.today.xml +28 -0
- package/docs/option/i18n.unknown.xml +32 -0
- package/docs/option/i18n.weekdays.xml +32 -0
- package/docs/option/i18n.xml +37 -0
- package/docs/option/locale.xml +31 -0
- package/docs/option/maxDate.xml +51 -0
- package/docs/option/minDate.xml +52 -0
- package/docs/option/minutesAvailable.xml +36 -0
- package/docs/option/onChange.xml +38 -0
- package/docs/option/secondsAvailable.xml +36 -0
- package/docs/option/showWeekNumber.xml +30 -0
- package/docs/option/yearRange.xml +35 -0
- package/examples/index.xml +12 -0
- package/examples/initialisation/buttons.xml +38 -0
- package/examples/initialisation/datetime.xml +30 -0
- package/examples/initialisation/dayjs.xml +34 -0
- package/examples/initialisation/hidden.xml +28 -0
- package/examples/initialisation/i18n.xml +37 -0
- package/examples/initialisation/index.xml +12 -0
- package/examples/initialisation/jquery.xml +28 -0
- package/examples/initialisation/luxon.xml +29 -0
- package/examples/initialisation/moment.xml +29 -0
- package/examples/initialisation/simple.xml +30 -0
- package/examples/integration/datatables.xml +74 -0
- package/examples/integration/form.xml +65 -0
- package/gulpfile.js +3 -3
- package/js/{dateTime.d.ts → dataTables.dateTime.d.ts} +0 -1
- package/{dist/dateTime.js → js/dataTables.dateTime.js} +191 -51
- package/license.txt +9 -0
- package/make.sh +50 -0
- package/nuget.nuspec +20 -0
- package/package.json +6 -4
- package/readme.md +3 -1
- package/test/api/dateTime.destroy().js +49 -0
- package/test/api/dateTime.errorMsg().js +52 -0
- package/test/api/dateTime.hide().js +49 -0
- package/test/api/dateTime.max().js +86 -0
- package/test/api/dateTime.min().js +85 -0
- package/test/api/dateTime.owns().js +53 -0
- package/test/api/dateTime.val().js +70 -0
- package/test/options/dateTime.YearRange.js +51 -0
- package/test/options/dateTime.disableDays.js +46 -0
- package/test/options/dateTime.firstDay.js +33 -0
- package/test/options/dateTime.format.js +85 -0
- package/test/options/dateTime.i18n.amPm.js +35 -0
- package/test/options/dateTime.i18n.hours.js +33 -0
- package/test/options/dateTime.i18n.minutes.js +33 -0
- package/test/options/dateTime.i18n.months.js +33 -0
- package/test/options/dateTime.i18n.next.js +31 -0
- package/test/options/dateTime.i18n.previous.js +31 -0
- package/test/options/dateTime.i18n.seconds.js +33 -0
- package/test/options/dateTime.i18n.unknown.js +33 -0
- package/test/options/dateTime.i18n.weekdays.js +30 -0
- package/test/options/dateTime.init.js +54 -0
- package/test/options/dateTime.maxDate.js +66 -0
- package/test/options/dateTime.minDate.js +66 -0
- package/test/options/dateTime.onChange.js +130 -0
- package/test/options/dateTime.showWeekNumber.js +36 -0
- package/dist/dateTime.css +0 -168
- package/examples/basic.html +0 -26
- package/examples/datetime.html +0 -29
- package/examples/dayjs.html +0 -32
- package/examples/hidden.html +0 -26
- package/examples/jquery.html +0 -26
- package/examples/moment.html +0 -29
- package/examples/right.html +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
div.dt-datetime{position:absolute;background-color:white;z-index:2050;border:1px solid #ccc;box-shadow:0 5px 15px -5px rgba(0, 0, 0, 0.5);padding:0 20px 6px 20px;width:275px}div.dt-datetime.inline{position:relative;box-shadow:none}div.dt-datetime div.dt-datetime-title{text-align:center;padding:5px 0px 3px}div.dt-datetime div.dt-datetime-buttons{text-align:center}div.dt-datetime div.dt-datetime-buttons a{display:inline-block;padding:0 .5em .5em .5em;margin:0;font-size:.9em}div.dt-datetime div.dt-datetime-buttons a:hover{text-decoration:underline}div.dt-datetime table{border-spacing:0;margin:12px 0;width:100%}div.dt-datetime table.dt-datetime-table-nospace{margin-top:-12px}div.dt-datetime table th{font-size:.8em;color:#777;font-weight:normal;width:14.285714286%;padding:0 0 4px 0;text-align:center}div.dt-datetime table td{font-size:.9em;color:#444;padding:0}div.dt-datetime table td.selectable{text-align:center;background:#f5f5f5}div.dt-datetime table td.selectable.disabled{color:#aaa;background:white}div.dt-datetime table td.selectable.disabled button:hover{color:#aaa;background:white}div.dt-datetime table td.selectable.now{background-color:#ddd}div.dt-datetime table td.selectable.now button{font-weight:bold}div.dt-datetime table td.selectable.selected button{background:#4e6ca3;color:white;border-radius:2px}div.dt-datetime table td.selectable button:hover{background:#ff8000;color:white;border-radius:2px}div.dt-datetime table td.dt-datetime-week{font-size:.7em}div.dt-datetime table button{width:100%;box-sizing:border-box;border:none;background:transparent;font-size:inherit;color:inherit;text-align:center;padding:4px 0;cursor:pointer;margin:0}div.dt-datetime table button span{display:inline-block;min-width:14px;text-align:right}div.dt-datetime table.weekNumber th{width:12.5%}div.dt-datetime div.dt-datetime-calendar table{margin-top:0}div.dt-datetime div.dt-datetime-label{position:relative;display:inline-block;height:30px;padding:5px 6px;border:1px solid transparent;box-sizing:border-box;cursor:pointer}div.dt-datetime div.dt-datetime-label:hover{border:1px solid #ddd;border-radius:2px;background-color:#f5f5f5}div.dt-datetime div.dt-datetime-label select{position:absolute;top:6px;left:0;cursor:pointer;opacity:0}div.dt-datetime.horizontal{width:550px}div.dt-datetime.horizontal div.dt-datetime-date,div.dt-datetime.horizontal div.dt-datetime-time{width:48%}div.dt-datetime.horizontal div.dt-datetime-time{margin-left:4%}div.dt-datetime div.dt-datetime-date{position:relative;float:left;width:100%}div.dt-datetime div.dt-datetime-time{position:relative;float:left;width:100%;text-align:center}div.dt-datetime div.dt-datetime-time>span{vertical-align:middle}div.dt-datetime div.dt-datetime-time th{text-align:left}div.dt-datetime div.dt-datetime-time div.dt-datetime-timeblock{display:inline-block;vertical-align:middle}div.dt-datetime div.dt-datetime-iconLeft,div.dt-datetime div.dt-datetime-iconRight,div.dt-datetime div.dt-datetime-iconUp,div.dt-datetime div.dt-datetime-iconDown{width:30px;height:30px;background-position:center;background-repeat:no-repeat;opacity:.3;overflow:hidden;box-sizing:border-box}div.dt-datetime div.dt-datetime-iconLeft:hover,div.dt-datetime div.dt-datetime-iconRight:hover,div.dt-datetime div.dt-datetime-iconUp:hover,div.dt-datetime div.dt-datetime-iconDown:hover{border:1px solid #ccc;border-radius:2px;background-color:#f0f0f0;opacity:.6}div.dt-datetime div.dt-datetime-iconLeft button,div.dt-datetime div.dt-datetime-iconRight button,div.dt-datetime div.dt-datetime-iconUp button,div.dt-datetime div.dt-datetime-iconDown button{border:none;background:transparent;text-indent:30px;height:100%;width:100%;cursor:pointer}div.dt-datetime div.dt-datetime-iconLeft{position:absolute;top:5px;left:5px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==")}div.dt-datetime div.dt-datetime-iconRight{position:absolute;top:5px;right:5px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=")}div.dt-datetime div.dt-datetime-iconUp{height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAALCAMAAABf9c24AAAAFVBMVEX///99fX1+fn57e3t6enoAAAAAAAC73bqPAAAABnRSTlMAYmJkZt92bnysAAAAL0lEQVR4AWOgJmBhxCvLyopHnpmVjY2VCadeoCxIHrcsWJ4RlyxCHlMWCTBRJxwAjrIBDMWSiM0AAAAASUVORK5CYII=")}div.dt-datetime div.dt-datetime-iconDown{height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAALCAMAAABf9c24AAAAFVBMVEX///99fX1+fn57e3t6enoAAAAAAAC73bqPAAAABnRSTlMAYmJkZt92bnysAAAAMElEQVR4AWOgDmBiRQIsmPKMrGxQgJDFlEfIYpoPk8Utz8qM232MYFfhkQfKUg8AANefAQxecJ58AAAAAElFTkSuQmCC")}div.dt-datetime-error{clear:both;padding:0 1em;max-width:240px;font-size:11px;line-height:1.25em;text-align:center;color:#b11f1f}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
DateTime picker for DataTables.net v1.1.2
|
|
3
|
+
|
|
4
|
+
© SpryMedia Ltd, all rights reserved.
|
|
5
|
+
License: MIT datatables.net/license/mit
|
|
6
|
+
*/
|
|
7
|
+
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(d,f,l){d instanceof String&&(d=String(d));for(var m=d.length,g=0;g<m;g++){var q=d[g];if(f.call(l,q,g,d))return{i:g,v:q}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;
|
|
8
|
+
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,f,l){if(d==Array.prototype||d==Object.prototype)return d;d[f]=l.value;return d};$jscomp.getGlobal=function(d){d=["object"==typeof globalThis&&globalThis,d,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var f=0;f<d.length;++f){var l=d[f];if(l&&l.Math==Math)return l}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
|
|
9
|
+
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(d,f){var l=$jscomp.propertyToPolyfillSymbol[f];if(null==l)return d[f];l=d[l];return void 0!==l?l:d[f]};
|
|
10
|
+
$jscomp.polyfill=function(d,f,l,m){f&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(d,f,l,m):$jscomp.polyfillUnisolated(d,f,l,m))};$jscomp.polyfillUnisolated=function(d,f,l,m){l=$jscomp.global;d=d.split(".");for(m=0;m<d.length-1;m++){var g=d[m];if(!(g in l))return;l=l[g]}d=d[d.length-1];m=l[d];f=f(m);f!=m&&null!=f&&$jscomp.defineProperty(l,d,{configurable:!0,writable:!0,value:f})};
|
|
11
|
+
$jscomp.polyfillIsolated=function(d,f,l,m){var g=d.split(".");d=1===g.length;m=g[0];m=!d&&m in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var q=0;q<g.length-1;q++){var a=g[q];if(!(a in m))return;m=m[a]}g=g[g.length-1];l=$jscomp.IS_SYMBOL_NATIVE&&"es6"===l?m[g]:null;f=f(l);null!=f&&(d?$jscomp.defineProperty($jscomp.polyfills,g,{configurable:!0,writable:!0,value:f}):f!==l&&($jscomp.propertyToPolyfillSymbol[g]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(g):$jscomp.POLYFILL_PREFIX+g,g=
|
|
12
|
+
$jscomp.propertyToPolyfillSymbol[g],$jscomp.defineProperty(m,g,{configurable:!0,writable:!0,value:f})))};$jscomp.polyfill("Array.prototype.find",function(d){return d?d:function(f,l){return $jscomp.findInternal(this,f,l).v}},"es6","es3");
|
|
13
|
+
(function(d){"function"===typeof define&&define.amd?define(["jquery"],function(f){return d(f,window,document)}):"object"===typeof exports?module.exports=function(f,l){f||(f=window);return d(l,f,f.document)}:d(jQuery,window,document)})(function(d,f,l,m){var g,q=function(a,b){"undefined"===typeof g&&(g=f.moment?f.moment:f.dayjs?f.dayjs:f.luxon?f.luxon:null);this.c=d.extend(!0,{},q.defaults,b);b=this.c.classPrefix;var c=this.c.i18n;if(!g&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";
|
|
14
|
+
"string"===typeof this.c.minDate&&(this.c.minDate=new Date(this.c.minDate));"string"===typeof this.c.maxDate&&(this.c.maxDate=new Date(this.c.maxDate));c=d('<div class="'+b+'"><div class="'+b+'-date"><div class="'+b+'-title"><div class="'+b+'-iconLeft"><button type="button" title="'+c.previous+'">'+c.previous+'</button></div><div class="'+b+'-iconRight"><button type="button" title="'+c.next+'">'+c.next+'</button></div><div class="'+b+'-label"><span></span><select class="'+b+'-month"></select></div><div class="'+
|
|
15
|
+
b+'-label"><span></span><select class="'+b+'-year"></select></div></div><div class="'+b+'-buttons"><a class="'+b+'-clear">'+c.clear+'</a><a class="'+b+'-today">'+c.today+'</a></div><div class="'+b+'-calendar"></div></div><div class="'+b+'-time"><div class="'+b+'-hours"></div><div class="'+b+'-minutes"></div><div class="'+b+'-seconds"></div></div><div class="'+b+'-error"></div></div>');this.dom={container:c,date:c.find("."+b+"-date"),title:c.find("."+b+"-title"),calendar:c.find("."+b+"-calendar"),
|
|
16
|
+
time:c.find("."+b+"-time"),error:c.find("."+b+"-error"),buttons:c.find("."+b+"-buttons"),clear:c.find("."+b+"-clear"),today:c.find("."+b+"-today"),input:d(a)};this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+q._instance++,parts:{date:null!==this.c.format.match(/[YMD]|L(?!T)|l/),time:null!==this.c.format.match(/[Hhm]|LT|LTS/),seconds:-1!==this.c.format.indexOf("s"),hours12:null!==this.c.format.match(/[haA]/)}};this.dom.container.append(this.dom.date).append(this.dom.time).append(this.dom.error);
|
|
17
|
+
this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar);this._constructor()};d.extend(q.prototype,{destroy:function(){this._hide(!0);this.dom.container.off().empty();this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(a){var b=this.dom.error;a?b.html(a):b.empty();return this},hide:function(){this._hide();return this},max:function(a){this.c.maxDate="string"===typeof a?new Date(a):a;this._optionsTitle();this._setCalander();return this},min:function(a){this.c.minDate=
|
|
18
|
+
"string"===typeof a?new Date(a):a;this._optionsTitle();this._setCalander();return this},owns:function(a){return 0<d(a).parents().filter(this.dom.container).length},val:function(a,b){if(a===m)return this.s.d;if(a instanceof Date)this.s.d=this._dateToUtc(a);else if(null===a||""===a)this.s.d=null;else if("--now"===a)this.s.d=new Date;else if("string"===typeof a)if(g&&g==f.luxon){var c=g.DateTime.fromFormat(a,this.c.format);this.s.d=c.isValid?c.toJSDate():null}else g?(c=g.utc(a,this.c.format,this.c.locale,
|
|
19
|
+
this.c.strict),this.s.d=c.isValid()?c.toDate():null):(c=a.match(/(\d{4})\-(\d{2})\-(\d{2})/),this.s.d=c?new Date(Date.UTC(c[1],c[2]-1,c[3])):null);if(b||b===m)this.s.d?this._writeOutput():this.dom.input.val(a);this.s.display=this.s.d?new Date(this.s.d.toString()):new Date;this.s.display.setUTCDate(1);this._setTitle();this._setCalander();this._setTime();return this},_constructor:function(){var a=this,b=this.c.classPrefix,c=this.dom.input.val(),k=function(){var e=a.dom.input.val();e!==c&&(a.c.onChange.call(a,
|
|
20
|
+
e,a.s.d,a.dom.input),c=e)};this.s.parts.date||this.dom.date.css("display","none");this.s.parts.time||this.dom.time.css("display","none");this.s.parts.seconds||(this.dom.time.children("div."+b+"-seconds").remove(),this.dom.time.children("span").eq(1).remove());this.c.buttons.clear||this.dom.clear.css("display","none");this.c.buttons.today||this.dom.today.css("display","none");this._optionsTitle();d(l).on("i18n.dt",function(e,h){h.oLanguage.datetime&&(d.extend(!0,a.c.i18n,h.oLanguage.datetime),a._optionsTitle())});
|
|
21
|
+
"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show());c&&this.val(c,!1);this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){a.dom.container.is(":visible")||a.dom.input.is(":disabled")||(a.val(a.dom.input.val(),!1),a._show())}).on("keyup.datetime",function(){a.dom.container.is(":visible")&&a.val(a.dom.input.val(),!1)});this.dom.container.on("change","select",function(){var e=
|
|
22
|
+
d(this),h=e.val();e.hasClass(b+"-month")?(a._correctMonth(a.s.display,h),a._setTitle(),a._setCalander()):e.hasClass(b+"-year")?(a.s.display.setUTCFullYear(h),a._setTitle(),a._setCalander()):e.hasClass(b+"-hours")||e.hasClass(b+"-ampm")?(a.s.parts.hours12?(e=1*d(a.dom.container).find("."+b+"-hours").val(),h="pm"===d(a.dom.container).find("."+b+"-ampm").val(),a.s.d.setUTCHours(12!==e||h?h&&12!==e?e+12:e:0)):a.s.d.setUTCHours(h),a._setTime(),a._writeOutput(!0),k()):e.hasClass(b+"-minutes")?(a.s.d.setUTCMinutes(h),
|
|
23
|
+
a._setTime(),a._writeOutput(!0),k()):e.hasClass(b+"-seconds")&&(a.s.d.setSeconds(h),a._setTime(),a._writeOutput(!0),k());a.dom.input.focus();a._position()}).on("click",function(e){var h=a.s.d;h=e.target.nodeName.toLowerCase();var r="span"===h?e.target.parentNode:e.target;h=r.nodeName.toLowerCase();if("select"!==h)if(e.stopPropagation(),"a"===h&&(e.preventDefault(),d(r).hasClass(b+"-clear")?(a.s.d=null,a.dom.input.val(""),a._writeOutput(),a._setCalander(),a._setTime(),k()):d(r).hasClass(b+"-today")&&
|
|
24
|
+
(a.s.display=new Date,a._setTitle(),a._setCalander())),"button"===h){var p=d(r);e=p.parent();if(e.hasClass("disabled")&&!e.hasClass("range"))p.blur();else if(e.hasClass(b+"-iconLeft"))a.s.display.setUTCMonth(a.s.display.getUTCMonth()-1),a._setTitle(),a._setCalander(),a.dom.input.focus();else if(e.hasClass(b+"-iconRight"))a._correctMonth(a.s.display,a.s.display.getUTCMonth()+1),a._setTitle(),a._setCalander(),a.dom.input.focus();else{if(p.parents("."+b+"-time").length){r=p.data("value");p=p.data("unit");
|
|
25
|
+
h=a._needValue();if("minutes"===p){if(e.hasClass("disabled")&&e.hasClass("range")){a.s.minutesRange=r;a._setTime();return}a.s.minutesRange=null}if("seconds"===p){if(e.hasClass("disabled")&&e.hasClass("range")){a.s.secondsRange=r;a._setTime();return}a.s.secondsRange=null}if("am"===r)if(12<=h.getUTCHours())r=h.getUTCHours()-12;else return;else if("pm"===r)if(12>h.getUTCHours())r=h.getUTCHours()+12;else return;h["hours"===p?"setUTCHours":"minutes"===p?"setUTCMinutes":"setSeconds"](r);a._setTime();a._writeOutput(!0)}else h=
|
|
26
|
+
a._needValue(),h.setUTCDate(1),h.setUTCFullYear(p.data("year")),h.setUTCMonth(p.data("month")),h.setUTCDate(p.data("day")),a._writeOutput(!0),a.s.parts.time?a._setCalander():setTimeout(function(){a._hide()},10);k()}}else a.dom.input.focus()})},_compareDates:function(a,b){return g&&g==f.luxon?g.DateTime.fromJSDate(a).toISODate()===g.DateTime.fromJSDate(b).toISODate():this._dateToUtcString(a)===this._dateToUtcString(b)},_correctMonth:function(a,b){var c=this._daysInMonth(a.getUTCFullYear(),b),k=a.getUTCDate()>
|
|
27
|
+
c;a.setUTCMonth(b);k&&(a.setUTCDate(c),a.setUTCMonth(b))},_daysInMonth:function(a,b){return[31,0!==a%4||0===a%100&&0!==a%400?28:29,31,30,31,30,31,31,30,31,30,31][b]},_dateToUtc:function(a){return new Date(Date.UTC(a.getFullYear(),a.getMonth(),a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds()))},_dateToUtcString:function(a){return g&&g==f.luxon?g.DateTime.fromJSDate(a).toISODate():a.getUTCFullYear()+"-"+this._pad(a.getUTCMonth()+1)+"-"+this._pad(a.getUTCDate())},_hide:function(a){if(a||"hidden"!==
|
|
28
|
+
this.dom.input.attr("type"))a=this.s.namespace,this.dom.container.detach(),d(f).off("."+a),d(l).off("keydown."+a),d("div.dataTables_scrollBody").off("scroll."+a),d("div.DTE_Body_Content").off("scroll."+a),d("body").off("click."+a),d(this.dom.input[0].offsetParent).off("."+a)},_hours24To12:function(a){return 0===a?12:12<a?a-12:a},_htmlDay:function(a){if(a.empty)return'<td class="empty"></td>';var b=["selectable"],c=this.c.classPrefix;a.disabled&&b.push("disabled");a.today&&b.push("now");a.selected&&
|
|
29
|
+
b.push("selected");return'<td data-day="'+a.day+'" class="'+b.join(" ")+'"><button class="'+c+"-button "+c+'-day" type="button" data-year="'+a.year+'" data-month="'+a.month+'" data-day="'+a.day+'"><span>'+a.day+"</span></button></td>"},_htmlMonth:function(a,b){var c=this._dateToUtc(new Date),k=this._daysInMonth(a,b),e=(new Date(Date.UTC(a,b,1))).getUTCDay(),h=[],r=[];0<this.c.firstDay&&(e-=this.c.firstDay,0>e&&(e+=7));for(var p=k+e,u=p;7<u;)u-=7;p+=7-u;var w=this.c.minDate;u=this.c.maxDate;w&&(w.setUTCHours(0),
|
|
30
|
+
w.setUTCMinutes(0),w.setSeconds(0));u&&(u.setUTCHours(23),u.setUTCMinutes(59),u.setSeconds(59));for(var n=0,t=0;n<p;n++){var x=new Date(Date.UTC(a,b,1+(n-e))),A=this.s.d?this._compareDates(x,this.s.d):!1,v=this._compareDates(x,c),B=n<e||n>=k+e,z=w&&x<w||u&&x>u,y=this.c.disableDays;Array.isArray(y)&&-1!==d.inArray(x.getUTCDay(),y)?z=!0:"function"===typeof y&&!0===y(x)&&(z=!0);r.push(this._htmlDay({day:1+(n-e),month:b,year:a,selected:A,today:v,disabled:z,empty:B}));7===++t&&(this.c.showWeekNumber&&
|
|
31
|
+
r.unshift(this._htmlWeekOfYear(n-e,b,a)),h.push("<tr>"+r.join("")+"</tr>"),r=[],t=0)}c=this.c.classPrefix;k=c+"-table";this.c.showWeekNumber&&(k+=" weekNumber");w&&(w=w>=new Date(Date.UTC(a,b,1,0,0,0)),this.dom.title.find("div."+c+"-iconLeft").css("display",w?"none":"block"));u&&(a=u<new Date(Date.UTC(a,b+1,1,0,0,0)),this.dom.title.find("div."+c+"-iconRight").css("display",a?"none":"block"));return'<table class="'+k+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+h.join("")+"</tbody></table>"},
|
|
32
|
+
_htmlMonthHead:function(){var a=[],b=this.c.firstDay,c=this.c.i18n,k=function(h){for(h+=b;7<=h;)h-=7;return c.weekdays[h]};this.c.showWeekNumber&&a.push("<th></th>");for(var e=0;7>e;e++)a.push("<th>"+k(e)+"</th>");return a.join("")},_htmlWeekOfYear:function(a,b,c){a=new Date(c,b,a,0,0,0,0);a.setDate(a.getDate()+4-(a.getDay()||7));return'<td class="'+this.c.classPrefix+'-week">'+Math.ceil(((a-new Date(c,0,1))/864E5+1)/7)+"</td>"},_needValue:function(){this.s.d||(this.s.d=this._dateToUtc(new Date));
|
|
33
|
+
return this.s.d},_options:function(a,b,c){c||(c=b);a=this.dom.container.find("select."+this.c.classPrefix+"-"+a);a.empty();for(var k=0,e=b.length;k<e;k++)a.append('<option value="'+b[k]+'">'+c[k]+"</option>")},_optionSet:function(a,b){var c=this.dom.container.find("select."+this.c.classPrefix+"-"+a);a=c.parent().children("span");c.val(b);b=c.find("option:selected");a.html(0!==b.length?b.text():this.c.i18n.unknown)},_optionsTime:function(a,b,c,k,e){var h=this.c.classPrefix,r=this.dom.container.find("div."+
|
|
34
|
+
h+"-"+a),p=12===b?function(v){return v}:this._pad;h=this.c.classPrefix;var u=h+"-table",w=this.c.i18n;if(r.length){var n="";var t=10;var x=function(v,B,z){12===b&&"number"===typeof v&&(12<=c&&(v+=12),12==v?v=0:24==v&&(v=12));var y=c===v||"am"===v&&12>c||"pm"===v&&12<=c?"selected":"";k&&-1===d.inArray(v,k)&&(y+=" disabled");z&&(y+=" "+z);return'<td class="selectable '+y+'"><button class="'+h+"-button "+h+'-day" type="button" data-unit="'+a+'" data-value="'+v+'"><span>'+B+"</span></button></td>"};if(12===
|
|
35
|
+
b){n+="<tr>";for(e=1;6>=e;e++)n+=x(e,p(e));n+=x("am",w.amPm[0]);n+="</tr><tr>";for(e=7;12>=e;e++)n+=x(e,p(e));n+=x("pm",w.amPm[1]);n+="</tr>";t=7}else{if(24===b){var A=0;for(t=0;4>t;t++){n+="<tr>";for(e=0;6>e;e++)n+=x(A,p(A)),A++;n+="</tr>"}}else{n+="<tr>";for(t=0;60>t;t+=10)n+=x(t,p(t),"range");e=null!==e?e:10*Math.floor(c/10);n=n+'</tr></tbody></thead><table class="'+(u+" "+u+'-nospace"><tbody><tr>');for(t=e+1;t<e+10;t++)n+=x(t,p(t));n+="</tr>"}t=6}r.empty().append('<table class="'+u+'"><thead><tr><th colspan="'+
|
|
36
|
+
t+'">'+w[a]+"</th></tr></thead><tbody>"+n+"</tbody></table>")}},_optionsTitle:function(){var a=this.c.i18n,b=this.c.minDate,c=this.c.maxDate;b=b?b.getFullYear():null;c=c?c.getFullYear():null;b=null!==b?b:(new Date).getFullYear()-this.c.yearRange;c=null!==c?c:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),a.months);this._options("year",this._range(b,c))},_pad:function(a){return 10>a?"0"+a:a},_position:function(){var a="input"===this.c.attachTo?this.dom.input.position():
|
|
37
|
+
this.dom.input.offset(),b=this.dom.container,c=this.dom.input.outerHeight();if(b.hasClass("inline"))b.insertAfter(this.dom.input);else{this.s.parts.date&&this.s.parts.time&&550<d(f).width()?b.addClass("horizontal"):b.removeClass("horizontal");"input"===this.c.attachTo?b.css({top:a.top+c,left:a.left}).insertAfter(this.dom.input):b.css({top:a.top+c,left:a.left}).appendTo("body");var k=b.outerHeight(),e=b.outerWidth(),h=d(f).scrollTop();a.top+c+k-h>d(f).height()&&(c=a.top-k,b.css("top",0>c?0:c));e+a.left>
|
|
38
|
+
d(f).width()&&(a=d(f).width()-e,"input"===this.c.attachTo&&(a-=d(b).offsetParent().offset().left),b.css("left",0>a?0:a))}},_range:function(a,b,c){var k=[];for(c||(c=1);a<=b;a+=c)k.push(a);return k},_setCalander:function(){this.s.display&&this.dom.calendar.empty().append(this._htmlMonth(this.s.display.getUTCFullYear(),this.s.display.getUTCMonth()))},_setTitle:function(){this._optionSet("month",this.s.display.getUTCMonth());this._optionSet("year",this.s.display.getUTCFullYear())},_setTime:function(){var a=
|
|
39
|
+
this,b=this.s.d,c=null;g&&g==f.luxon&&(c=g.DateTime.fromJSDate(b));var k=null!=c?c.hour:b?b.getUTCHours():0,e=function(h){return a.c[h+"Available"]?a.c[h+"Available"]:a._range(0,59,a.c[h+"Increment"])};this._optionsTime("hours",this.s.parts.hours12?12:24,k,this.c.hoursAvailable);this._optionsTime("minutes",60,null!=c?c.minute:b?b.getUTCMinutes():0,e("minutes"),this.s.minutesRange);this._optionsTime("seconds",60,null!=c?c.second:b?b.getSeconds():0,e("seconds"),this.s.secondsRange)},_show:function(){var a=
|
|
40
|
+
this,b=this.s.namespace;this._position();d(f).on("scroll."+b+" resize."+b,function(){a._position()});d("div.DTE_Body_Content").on("scroll."+b,function(){a._position()});d("div.dataTables_scrollBody").on("scroll."+b,function(){a._position()});var c=this.dom.input[0].offsetParent;if(c!==l.body)d(c).on("scroll."+b,function(){a._position()});d(l).on("keydown."+b,function(k){9!==k.keyCode&&27!==k.keyCode&&13!==k.keyCode||a._hide()});setTimeout(function(){d("body").on("click."+b,function(k){d(k.target).parents().filter(a.dom.container).length||
|
|
41
|
+
k.target===a.dom.input[0]||a._hide()})},10)},_writeOutput:function(a){var b=this.s.d,c="";b&&(c=g&&g==f.luxon?g.DateTime.fromJSDate(this.s.d).toFormat(this.c.format):g?g.utc(b,m,this.c.locale,this.c.strict).format(this.c.format):b.getUTCFullYear()+"-"+this._pad(b.getUTCMonth()+1)+"-"+this._pad(b.getUTCDate()));this.dom.input.val(c).trigger("change",{write:b});"hidden"===this.dom.input.attr("type")&&this.val(c,!1);a&&this.dom.input.focus()}});q.use=function(a){g=a};q._instance=0;q.defaults={attachTo:"body",
|
|
42
|
+
buttons:{clear:!1,today:!1},classPrefix:"dt-datetime",disableDays:null,firstDay:1,format:"YYYY-MM-DD",hoursAvailable:null,i18n:{clear:"Clear",previous:"Previous",next:"Next",months:"January February March April May June July August September October November December".split(" "),weekdays:"Sun Mon Tue Wed Thu Fri Sat".split(" "),amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",
|
|
43
|
+
onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25};q.version="1.1.2";f.DateTime||(f.DateTime=q);d.fn.dtDateTime=function(a){return this.each(function(){new q(this,a)})};d.fn.dataTable&&(d.fn.dataTable.DateTime=q,d.fn.DataTable.DateTime=q,d.fn.dataTable.Editor&&(d.fn.dataTable.Editor.DateTime=q));return q});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>DateTime.use()</name>
|
|
4
|
+
<summary>Set the formatting / parsing library to use.</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>DateTime.use()</signature>
|
|
9
|
+
<description>Change or apply the formatting / parsing date and time library that the DateTime picker will use.</description>
|
|
10
|
+
<returns type="undefined">No return value.</returns>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<description>
|
|
14
|
+
This static class method can be used to assign the date / time formatting and parsing library to be used. At this time it can be one of:
|
|
15
|
+
|
|
16
|
+
* [Moment](https://momentjs.com/)
|
|
17
|
+
* [Luxon](https://moment.github.io/luxon/)
|
|
18
|
+
* [DayJS](https://github.com/iamkun/dayjs)
|
|
19
|
+
|
|
20
|
+
By default DateTime will attempt to detect which library you have installed, but if one is not available (e.g. it is loaded after the DateTime library), you can use this static method to assign the formatting library to use.
|
|
21
|
+
</description>
|
|
22
|
+
|
|
23
|
+
<example title="Use Moment"><![CDATA[
|
|
24
|
+
|
|
25
|
+
DateTime.use(moment);
|
|
26
|
+
|
|
27
|
+
let el = document.getElementById('example');
|
|
28
|
+
let dt = new DateTime(el);
|
|
29
|
+
|
|
30
|
+
]]></example>
|
|
31
|
+
|
|
32
|
+
</dt-api>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>destroy()</name>
|
|
4
|
+
<summary>Destroy a DateTime control.</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>destroy()</signature>
|
|
9
|
+
<description>Destroy a DateTime control.</description>
|
|
10
|
+
<returns type="undefined">No return value</returns>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<description>
|
|
14
|
+
Destroys the given DateTime control, hiding and removing it from the dom and also stripping any event listeners that are in place.
|
|
15
|
+
|
|
16
|
+
This example is a somewhat redundant since it creates the input element only to immediately destroy it. In a real application you would destroy the DateTime instance if you no longer require it and wish to release any memory allocated to it and its event handlers.
|
|
17
|
+
</description>
|
|
18
|
+
|
|
19
|
+
<example title="Destroy DateTime instance"><![CDATA[
|
|
20
|
+
|
|
21
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
22
|
+
|
|
23
|
+
// Then sometime later, destroy it...
|
|
24
|
+
dt.destroy();
|
|
25
|
+
|
|
26
|
+
]]></example>
|
|
27
|
+
|
|
28
|
+
</dt-api>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>errorMsg()</name>
|
|
4
|
+
<summary>Either sets the error message or removes it</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>errorMsg()</signature>
|
|
9
|
+
<description>Empties the error message.</description>
|
|
10
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
11
|
+
</type>
|
|
12
|
+
<type type="function">
|
|
13
|
+
<signature>errorMsg(msg)</signature>
|
|
14
|
+
<description>Sets the error message.</description>
|
|
15
|
+
<parameter type="string" name="msg" optional="true">
|
|
16
|
+
Message to be displayed.
|
|
17
|
+
</parameter>
|
|
18
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
19
|
+
</type>
|
|
20
|
+
|
|
21
|
+
<description>
|
|
22
|
+
Either sets the error message or removes it depending on if the `msg` parameter is passed or not.
|
|
23
|
+
|
|
24
|
+
This is useful for providing custom error messages when an error occurs.
|
|
25
|
+
</description>
|
|
26
|
+
|
|
27
|
+
<example title="Set Error Message"><![CDATA[
|
|
28
|
+
|
|
29
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
30
|
+
|
|
31
|
+
dt.errMsg('Oops an error occurred!');
|
|
32
|
+
|
|
33
|
+
]]></example>
|
|
34
|
+
|
|
35
|
+
<example title="Basic validation - set and clear an error message"><![CDATA[
|
|
36
|
+
|
|
37
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
38
|
+
|
|
39
|
+
el.addEventListener('change', function () {
|
|
40
|
+
if (dt.val()) {
|
|
41
|
+
// There is a value - clear the error message
|
|
42
|
+
dt.errMsg();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// No value - error
|
|
46
|
+
dt.errMsg('oops an error occurred!);
|
|
47
|
+
}
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
]]></example>
|
|
51
|
+
|
|
52
|
+
</dt-api>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>hide()</name>
|
|
4
|
+
<summary>Hides the DateTime instance</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>hide()</signature>
|
|
9
|
+
<description>Hides the DateTime instance.</description>
|
|
10
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<description>
|
|
14
|
+
This method detaches the DateTime picker element from the DOM, effectively leaving just the original `-tag input` element in the document.
|
|
15
|
+
|
|
16
|
+
This can be useful in cases where a container that holds the `-tag input` for the DateTime is removed from the display (e.g. a modal form). Calling this method will ensure that the date / time picker is hidden, regardless of its focus state.
|
|
17
|
+
</description>
|
|
18
|
+
|
|
19
|
+
<example title="Hide an instance of DateTime"><![CDATA[
|
|
20
|
+
|
|
21
|
+
var dt = new DateTime(document.getElementById('#dtInput'));
|
|
22
|
+
dt.hide();
|
|
23
|
+
|
|
24
|
+
]]></example>
|
|
25
|
+
|
|
26
|
+
<example title="Ensure the date picker is hidden when closing a Bootstrap 4 modal"><![CDATA[
|
|
27
|
+
|
|
28
|
+
var dt = new DateTime($('#dtInput'));
|
|
29
|
+
|
|
30
|
+
$('#myModal').on('hide.bs.modal', function (event) {
|
|
31
|
+
dt.hide();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
]]></example>
|
|
35
|
+
|
|
36
|
+
</dt-api>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>max()</name>
|
|
4
|
+
<summary>Set the max date for the DateTime instance</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>max(date)</signature>
|
|
9
|
+
<description>Set the max date for the DateTime instance.</description>
|
|
10
|
+
<parameter type="string" name="date">
|
|
11
|
+
Date as a string that is to be the max date for this instance of DateTime.
|
|
12
|
+
</parameter>
|
|
13
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
14
|
+
</type>
|
|
15
|
+
<type type="function">
|
|
16
|
+
<signature>max(date)</signature>
|
|
17
|
+
<description>Set the max date for the DateTime instance.</description>
|
|
18
|
+
<parameter type="Date" name="date">
|
|
19
|
+
Date that is to be the max date for this instance of DateTime.
|
|
20
|
+
</parameter>
|
|
21
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
22
|
+
</type>
|
|
23
|
+
|
|
24
|
+
<description>
|
|
25
|
+
This method sets the max date for the DateTime instance. It takes either a Date instance directly or a string representing a date that is then parsed into a date.
|
|
26
|
+
</description>
|
|
27
|
+
|
|
28
|
+
<example title="Set the max date for DateTime"><![CDATA[
|
|
29
|
+
|
|
30
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
31
|
+
dt.max("2025-12-31");
|
|
32
|
+
|
|
33
|
+
]]></example>
|
|
34
|
+
|
|
35
|
+
</dt-api>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>min()</name>
|
|
4
|
+
<summary>Set the min date for the DateTime instance.</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>min(date)</signature>
|
|
9
|
+
<description>Set the min date for the DateTime instance.</description>
|
|
10
|
+
<parameter type="string" name="date">
|
|
11
|
+
Date as a string that is to be the min date for this instance of DateTime.
|
|
12
|
+
</parameter>
|
|
13
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
14
|
+
</type>
|
|
15
|
+
<type type="function">
|
|
16
|
+
<signature>min(date)</signature>
|
|
17
|
+
<description>Set the min date for the DateTime instance.</description>
|
|
18
|
+
<parameter type="Date" name="date">
|
|
19
|
+
Date that is to be the min date for this instance of DateTime.
|
|
20
|
+
</parameter>
|
|
21
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
22
|
+
</type>
|
|
23
|
+
|
|
24
|
+
<description>
|
|
25
|
+
This method sets the min date for the DateTime instance. It takes either a Date instance directly or a string representing a date that is then parsed into a date.
|
|
26
|
+
</description>
|
|
27
|
+
|
|
28
|
+
<example title="Set the min date for DateTime"><![CDATA[
|
|
29
|
+
|
|
30
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
31
|
+
dt.min("2015-12-31");
|
|
32
|
+
|
|
33
|
+
]]></example>
|
|
34
|
+
|
|
35
|
+
</dt-api>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>owns()</name>
|
|
4
|
+
<summary>Check if an element belongs to this control.</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>owns(node)</signature>
|
|
9
|
+
<description>Check if an element belongs to this control.</description>
|
|
10
|
+
<parameter type="node" name="node">
|
|
11
|
+
Element to check.
|
|
12
|
+
</parameter>
|
|
13
|
+
<returns type="boolean">`true` if owned by this control, `false` otherwise.</returns>
|
|
14
|
+
</type>
|
|
15
|
+
|
|
16
|
+
<description>
|
|
17
|
+
This method takes a node as a parameter and returns `true` if it belongs to this control, `false` if not. It can be useful to know this information when creating a form that has multiple click event handlers and you might need to know if a click happens inside the date picker, or elsewhere in your form.
|
|
18
|
+
</description>
|
|
19
|
+
|
|
20
|
+
<example title=""><![CDATA[
|
|
21
|
+
|
|
22
|
+
var dt = new DateTime(document.getElementById('example'));
|
|
23
|
+
|
|
24
|
+
if(dt.owns(document.getElementByClassName('dt-datetime-date'))) {
|
|
25
|
+
console.log("It is owned");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
]]></example>
|
|
29
|
+
|
|
30
|
+
</dt-api>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-api library="DateTime">
|
|
3
|
+
<name>val()</name>
|
|
4
|
+
<summary>Get / set the value of the DateTime instance.</summary>
|
|
5
|
+
<since>1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="function">
|
|
8
|
+
<signature>val()</signature>
|
|
9
|
+
<description>Get the value of the DateTime instance.</description>
|
|
10
|
+
<returns type="Date">Date instance representing the current date selected within the DateTime instance.</returns>
|
|
11
|
+
</type>
|
|
12
|
+
<type type="function">
|
|
13
|
+
<signature>val(set)</signature>
|
|
14
|
+
<description>Set the value of the DateTime instance.</description>
|
|
15
|
+
<parameter type="string|Date" name="set">
|
|
16
|
+
The value to be set.
|
|
17
|
+
</parameter>
|
|
18
|
+
<returns type="DateTime">Self for chaining.</returns>
|
|
19
|
+
</type>
|
|
20
|
+
|
|
21
|
+
<description>
|
|
22
|
+
Get or set the value for the DateTime instance. If the set parameter is provided then a DateTime instance is provided for chaining. If not then the value stored within DateTime is returned as a Date.
|
|
23
|
+
</description>
|
|
24
|
+
|
|
25
|
+
<example title="Get a value from the input"><![CDATA[
|
|
26
|
+
|
|
27
|
+
let el = document.getElementById('example');
|
|
28
|
+
let dt = new DateTime(el);
|
|
29
|
+
|
|
30
|
+
el.addEventListener('change', function () {
|
|
31
|
+
console.log('Selected value is: ', dt.val());
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
]]></example>
|
|
35
|
+
|
|
36
|
+
<example title="Set a value into the input"><![CDATA[
|
|
37
|
+
|
|
38
|
+
let dt = new DateTime(document.getElementById('example'));
|
|
39
|
+
|
|
40
|
+
dt.val("2021-12-31");
|
|
41
|
+
|
|
42
|
+
]]></example>
|
|
43
|
+
|
|
44
|
+
</dt-api>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>buttons.clear</name>
|
|
4
|
+
<summary>Enable button to clear the value</summary>
|
|
5
|
+
<since>DateTime 1.1.0</since>
|
|
6
|
+
|
|
7
|
+
<default value="false">
|
|
8
|
+
Button will not be shown.
|
|
9
|
+
</default>
|
|
10
|
+
|
|
11
|
+
<description>
|
|
12
|
+
When enabled, this option will cause DateTime to show a _clear_ button (text set by `de-init i18n.clear`) which they user can activate to clear the input's value.
|
|
13
|
+
</description>
|
|
14
|
+
|
|
15
|
+
<example title="Enable clear button"><![CDATA[
|
|
16
|
+
|
|
17
|
+
new DateTime(document.getElementById('test'), {
|
|
18
|
+
buttons: {
|
|
19
|
+
clear: true
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
]]></example>
|
|
24
|
+
|
|
25
|
+
<related>de-init buttons.today</related>
|
|
26
|
+
|
|
27
|
+
</dt-option>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>buttons.today</name>
|
|
4
|
+
<summary>Enable button move "today" into view</summary>
|
|
5
|
+
<since>DateTime 1.1.0</since>
|
|
6
|
+
|
|
7
|
+
<default value="false">
|
|
8
|
+
Button will not be shown.
|
|
9
|
+
</default>
|
|
10
|
+
|
|
11
|
+
<description>
|
|
12
|
+
When enabled, this option will cause DateTime to show a button (text set by `dt-init i18n.today`) which the end user can activate to shift the calendar view to show today's date.
|
|
13
|
+
|
|
14
|
+
Note that the value of the field does not change when activating this button.
|
|
15
|
+
</description>
|
|
16
|
+
|
|
17
|
+
<example title="Enable today button"><![CDATA[
|
|
18
|
+
|
|
19
|
+
new DateTime(document.getElementById('test'), {
|
|
20
|
+
buttons: {
|
|
21
|
+
today: true
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
]]></example>
|
|
26
|
+
|
|
27
|
+
<related>de-init buttons.clear</related>
|
|
28
|
+
|
|
29
|
+
</dt-option>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>buttons</name>
|
|
4
|
+
<summary>Container for navigation buttons</summary>
|
|
5
|
+
<since>DateTime 1.1.0</since>
|
|
6
|
+
|
|
7
|
+
<description>
|
|
8
|
+
This property is an object that contains the navigation helper properties:
|
|
9
|
+
|
|
10
|
+
* `de-init buttons.clear`
|
|
11
|
+
* `de-init buttons.today`
|
|
12
|
+
</description>
|
|
13
|
+
|
|
14
|
+
<example title="Enable clear and today buttons"><![CDATA[
|
|
15
|
+
|
|
16
|
+
new DateTime(document.getElementById('test'), {
|
|
17
|
+
buttons: {
|
|
18
|
+
today: true,
|
|
19
|
+
clear: true
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
]]></example>
|
|
24
|
+
|
|
25
|
+
<related>de-init buttons.clear</related>
|
|
26
|
+
<related>de-init buttons.today</related>
|
|
27
|
+
|
|
28
|
+
</dt-option>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>disableDays</name>
|
|
4
|
+
<summary>Specify days that cannot be selected.</summary>
|
|
5
|
+
<since>DateTime 1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="null">
|
|
8
|
+
<description>
|
|
9
|
+
When this option is `null` any and all of the days of the week can be selected.
|
|
10
|
+
</description>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<type type="number[]">
|
|
14
|
+
<description>
|
|
15
|
+
When this option is an array of numbers, any of the days indexes (0 indexed starting from Sunday) that are present here will not be selectable within the DateTime picker.
|
|
16
|
+
</description>
|
|
17
|
+
</type>
|
|
18
|
+
|
|
19
|
+
<type type="function">
|
|
20
|
+
<signature>disableDays(day)</signature>
|
|
21
|
+
<parameter type="number" name="day">The index of the day to check if it is disabled or not.</parameter>
|
|
22
|
+
<returns type="boolean"/>
|
|
23
|
+
<description>
|
|
24
|
+
If this option is a function it should take one parameter, a number representing the index of the day being checked (again, 0 indexed starting from Sunday) if that day should be selectable it returns `true`, otherwise `false`.
|
|
25
|
+
</description>
|
|
26
|
+
</type>
|
|
27
|
+
|
|
28
|
+
<default value="null">
|
|
29
|
+
As default, all of the days can be selected.
|
|
30
|
+
</default>
|
|
31
|
+
<description>
|
|
32
|
+
<![CDATA[
|
|
33
|
+
This option allows for certain days to be unselectable. This is done by either setting this option to an array or function as detailed below.
|
|
34
|
+
]]>
|
|
35
|
+
</description>
|
|
36
|
+
|
|
37
|
+
<example title="Disable selection of Saturdays and Sundays"><![CDATA[
|
|
38
|
+
$(document).ready(function() {
|
|
39
|
+
new DateTime(document.getElementById('test'), {
|
|
40
|
+
disableDays: [5,6]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
]]></example>
|
|
44
|
+
|
|
45
|
+
</dt-option>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>firstDay</name>
|
|
4
|
+
<summary>Change which day of the week is first on the calendar.</summary>
|
|
5
|
+
<since>DateTime 1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="number">
|
|
8
|
+
<description>
|
|
9
|
+
This value represents which day of the week should be in the first column of datetime.
|
|
10
|
+
</description>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<default value="1">
|
|
14
|
+
The default value of 0 represents Sunday - the days are 0 indexed starting from Sunday:
|
|
15
|
+
|
|
16
|
+
* 0 - Sunday
|
|
17
|
+
* 1 - Monday
|
|
18
|
+
* 2 - Tuesday
|
|
19
|
+
* 3 - Wednesday
|
|
20
|
+
* 4 - Thursday
|
|
21
|
+
* 5 - Friday
|
|
22
|
+
* 6 - Saturday
|
|
23
|
+
</default>
|
|
24
|
+
<description>
|
|
25
|
+
This option allows for the "first" day to be changed to any of the days of the week as desired.
|
|
26
|
+
</description>
|
|
27
|
+
|
|
28
|
+
<example title="Change first day to Saturday"><![CDATA[
|
|
29
|
+
new DateTime(document.getElementById('test'), {
|
|
30
|
+
firstDay: 6
|
|
31
|
+
});
|
|
32
|
+
]]></example>
|
|
33
|
+
|
|
34
|
+
</dt-option>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>format</name>
|
|
4
|
+
<summary>The format of the date data.</summary>
|
|
5
|
+
<since>DateTime 1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="string">
|
|
8
|
+
<description>
|
|
9
|
+
This string is used to represent the structure of the date that is being used by DateTime.
|
|
10
|
+
</description>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<default value="'YYYY-MM-DD'">
|
|
14
|
+
The default value for format is to use the ISO-8601 format.
|
|
15
|
+
</default>
|
|
16
|
+
|
|
17
|
+
<description>
|
|
18
|
+
<, [Luxon](https://moment.github.io/luxon/) or [DayJS](https://github.com/iamkun/dayjs) depending on which is in use.
|
|
20
|
+
]]>
|
|
21
|
+
</description>
|
|
22
|
+
|
|
23
|
+
<example title="Change format to use '/' instead of '-'."><![CDATA[
|
|
24
|
+
|
|
25
|
+
new DateTime(document.getElementById('test'), {
|
|
26
|
+
format: 'YYYY/MM/DD
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
]]></example>
|
|
30
|
+
|
|
31
|
+
</dt-option>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<dt-option library="DateTime">
|
|
3
|
+
<name>hoursAvailable</name>
|
|
4
|
+
<summary>Sets which hours are selectable.</summary>
|
|
5
|
+
<since>DateTime 1.0.0</since>
|
|
6
|
+
|
|
7
|
+
<type type="null">
|
|
8
|
+
<description>
|
|
9
|
+
When this option is `null` all of the hours are selectable.
|
|
10
|
+
</description>
|
|
11
|
+
</type>
|
|
12
|
+
|
|
13
|
+
<type type="number[]">
|
|
14
|
+
<description>
|
|
15
|
+
When this option is an array, any value for the hour that is in this array will be selectable and all others will not.
|
|
16
|
+
</description>
|
|
17
|
+
</type>
|
|
18
|
+
|
|
19
|
+
<default value="null">
|
|
20
|
+
As default, all of the hours are selectable.
|
|
21
|
+
</default>
|
|
22
|
+
<description>
|
|
23
|
+
<![CDATA[
|
|
24
|
+
This option allows the user to restrict which hours the user is able to select. Any values that are placed within the array are going to be selectable while all others will not.
|
|
25
|
+
]]>
|
|
26
|
+
</description>
|
|
27
|
+
|
|
28
|
+
<example title="Restrict the user to select either 8, 9 or 10"><![CDATA[
|
|
29
|
+
$(document).ready(function() {
|
|
30
|
+
new DateTime(document.getElementById('test'), {
|
|
31
|
+
hoursAvailable: [8, 9, 10]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
]]></example>
|
|
35
|
+
|
|
36
|
+
</dt-option>
|