datatables.net-datetime 1.4.0 → 1.5.0

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.
@@ -1,6 +1,6 @@
1
- /*! DateTime picker for DataTables.net v1.4.0
1
+ /*! DateTime picker for DataTables.net v1.5.0
2
2
  *
3
3
  * © SpryMedia Ltd, all rights reserved.
4
4
  * License: MIT datatables.net/license/mit
5
5
  */
6
- import $ from"jquery";var dateLib,DateTime=function(t,e){if(DateTime.factory(t,e))return DateTime;void 0===dateLib&&(dateLib=window.moment||window.dayjs||window.luxon||null),this.c=$.extend(!0,{},DateTime.defaults,e);e=this.c.classPrefix;this.c.i18n;if(!dateLib&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"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));var s=$('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:$(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+DateTime._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),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this._constructor()};$.extend(DateTime.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeAttr("autocomplete").off(".datetime")},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<$(t).parents().filter(this.dom.container).length},val:function(t,e){return void 0===t?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._dateToUtc(this._convert(t,this.c.format,null))),!e&&void 0!==e||(this.s.d?this._writeOutput():this.dom.input.val(t)),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(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function n(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,d=this.c.classPrefix,e=this.dom.input.val();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."+d+"-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(),$(document).on("i18n.dt",function(t,e){e.oLanguage.datetime&&($.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=$(this),i=s.val();s.hasClass(d+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(d+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(d+"-hours")||s.hasClass(d+"-ampm")?(o.s.parts.hours12?(t=+$(o.dom.container).find("."+d+"-hours").val(),e="pm"===$(o.dom.container).find("."+d+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),n()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),$(s).hasClass(d+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),n()):$(s).hasClass(d+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=$(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(d+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(d+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+d+"-time").length){var s=t.data("value"),a=t.data("unit"),e=o._needValue();if("minutes"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===a?"setUTCHours":"minutes"===a?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);n()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate()===dateLib.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert(t,e,s){var i;return t&&(dateLib?this._isLuxon()?(i=t instanceof Date?dateLib.DateTime.fromJSDate(t).toUTC():dateLib.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):i.toJSDate():null:(i=t instanceof Date?dateLib.utc(t,void 0,this.c.locale,this.c.strict):dateLib(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(i[1],i[2]-1,i[3]):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return t&&new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),$(window).off("."+t),$(document).off("keydown."+t),$("div.dataTables_scrollBody").off("scroll."+t),$("div.DTE_Body_Content").off("scroll."+t),$("body").off("click."+t),$(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),a=new Date(Date.UTC(t,e,1)).getUTCDay(),n=[],o=[],d=(0<this.c.firstDay&&(a-=this.c.firstDay)<0&&(a+=7),i+a),r=d;7<r;)r-=7;d+=7-r;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<d;c++){var m=new Date(Date.UTC(t,e,c-a+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),T=c<a||i+a<=c,y=l&&m<l||h&&h<m,_=this.c.disableDays,f={day:c-a+1,month:e,year:t,selected:f,today:p,disabled:y=Array.isArray(_)&&-1!==$.inArray(m.getUTCDay(),_)||"function"==typeof _&&!0===_(m)?!0:y,empty:T};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-a,e,t)),n.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var v,D=this.c.classPrefix,b=D+"-table";return this.c.showWeekNumber&&(b+=" weekNumber"),l&&(v=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",v?"none":"block")),h&&(v=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",v?"none":"block")),'<table class="'+b+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+n.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(dateLib&&dateLib.DateTime&&dateLib.Duration&&dateLib.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var a=0,n=e.length;a<n;a++)i.append('<option value="'+e[a]+'">'+s[a]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(a,n,o,d,t){var e,r=this.c.classPrefix,s=this.dom.container.find("div."+r+"-"+a),i=12===n?function(t){return t}:this._pad,l=(r=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){function c(t,e,s){12===n&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&d&&-1===$.inArray(t,d)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+r+"-button "+r+'-day" type="button" data-unit="'+a+'" data-value="'+t+'"><span>'+e+"</span></button></td>"}var u="",m=10;if(12===n){for(u+="<tr>",e=1;e<=6;e++)u+=c(e,i(e));for(u=(u+=c("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)u+=c(e,i(e));u=u+c("pm",h.amPm[1])+"</tr>",m=7}else{if(24===n)for(var f=0,p=0;p<4;p++){for(u+="<tr>",e=0;e<6;e++)u+=c(f,i(f)),f++;u+="</tr>"}else{for(u+="<tr>",p=0;p<60;p+=10)u+=c(p,i(p),"range");var u=u+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),T=null!==t?t:-1===o?0:10*Math.floor(o/10);for(u+="<tr>",p=T+1;p<T+10;p++)u+=c(p,i(p));u+="</tr>"}m=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+m+'">'+h[a]+"</th></tr></thead><tbody>"+u+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),a=this.dom.container,n=this.dom.input.outerHeight();a.hasClass("inline")?a.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<$(window).width()?a.addClass("horizontal"):a.removeClass("horizontal"),"input"===this.c.attachTo?a.css({top:i.top+n,left:i.left}).insertAfter(this.dom.input):a.css({top:i.top+n,left:i.left}).appendTo("body"),t=a.outerHeight(),e=a.outerWidth(),s=$(window).scrollTop(),i.top+n+t-s>$(window).height()&&(n=i.top-t,a.css("top",n<0?0:n)),e+i.left>$(window).width()&&(s=$(window).width()-e,"input"===this.c.attachTo&&(s-=$(a).offsetParent().offset().left),a.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var a=t;a<=e;a+=s)i.push(a);return i},_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(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,a=null!=(i=this._isLuxon()?dateLib.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,a,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),$(window).on("scroll."+t+" resize."+t,function(){e._position()}),$("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),$("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==document.body&&$(s).on("scroll."+t,function(){e._position()}),$(document).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){$("body").on("click."+t,function(t){$(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="";e&&(s=this._convert(e,null,this.c.format)),this.dom.input.val(s).trigger("change",{write:e}),"hidden"===this.dom.input.attr("type")&&this.val(s,!1),t&&this.dom.input.focus()}}),DateTime.use=function(t){dateLib=t},DateTime._instance=0,DateTime.defaults={attachTo:"body",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"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},DateTime.version="1.4.0",DateTime.factory=function(t,e){var s=!1;return t&&t.document&&(window=t,document=t.document),e&&e.fn&&e.fn.jquery&&($=e,s=!0),s},window.DateTime||(window.DateTime=DateTime),window.DataTable&&(window.DataTable.DateTime=DateTime),$.fn.dtDateTime=function(t){return this.each(function(){new DateTime(this,t)})},$.fn.dataTable&&($.fn.dataTable.DateTime=DateTime,$.fn.DataTable.DateTime=DateTime,$.fn.dataTable.Editor)&&($.fn.dataTable.Editor.DateTime=DateTime);export default DateTime;
6
+ import jQuery from"jquery";let $=jQuery;var dateLib,DateTime=function(t,e){if(DateTime.factory(t,e))return DateTime;void 0===dateLib&&(dateLib=window.moment||window.dayjs||window.luxon||null),this.c=$.extend(!0,{},DateTime.defaults,e);e=this.c.classPrefix;this.c.i18n;if(!dateLib&&"YYYY-MM-DD"!==this.c.format)throw"DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used";"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));var s=$('<div class="'+e+'"><div class="'+e+'-date"><div class="'+e+'-title"><div class="'+e+'-iconLeft"><button type="button"></button></div><div class="'+e+'-iconRight"><button type="button"></button></div><div class="'+e+'-label"><span></span><select class="'+e+'-month"></select></div><div class="'+e+'-label"><span></span><select class="'+e+'-year"></select></div></div><div class="'+e+'-buttons"><a class="'+e+'-clear"></a><a class="'+e+'-today"></a></div><div class="'+e+'-calendar"></div></div><div class="'+e+'-time"><div class="'+e+'-hours"></div><div class="'+e+'-minutes"></div><div class="'+e+'-seconds"></div></div><div class="'+e+'-error"></div></div>');this.dom={container:s,date:s.find("."+e+"-date"),title:s.find("."+e+"-title"),calendar:s.find("."+e+"-calendar"),time:s.find("."+e+"-time"),error:s.find("."+e+"-error"),buttons:s.find("."+e+"-buttons"),clear:s.find("."+e+"-clear"),today:s.find("."+e+"-today"),previous:s.find("."+e+"-iconLeft"),next:s.find("."+e+"-iconRight"),input:$(t)},this.s={d:null,display:null,minutesRange:null,secondsRange:null,namespace:"dateime-"+DateTime._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),this.dom.date.append(this.dom.title).append(this.dom.buttons).append(this.dom.calendar),this.dom.input.addClass("dt-datetime"),this._constructor()};$.extend(DateTime.prototype,{destroy:function(){this._hide(!0),this.dom.container.off().empty(),this.dom.input.removeClass("dt-datetime").removeAttr("autocomplete").off(".datetime")},display:function(t,e){return void 0!==t&&this.s.display.setUTCFullYear(t),void 0!==e&&this.s.display.setUTCMonth(e-1),void 0!==t||void 0!==e?(this._setTitle(),this._setCalander(),this):{month:this.s.display.getUTCMonth()+1,year:this.s.display.getUTCFullYear()}},errorMsg:function(t){var e=this.dom.error;return t?e.html(t):e.empty(),this},hide:function(){return this._hide(),this},max:function(t){return this.c.maxDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},min:function(t){return this.c.minDate="string"==typeof t?new Date(t):t,this._optionsTitle(),this._setCalander(),this},owns:function(t){return 0<$(t).parents().filter(this.dom.container).length},val:function(t,e){return void 0===t?this.s.d:(t instanceof Date?this.s.d=this._dateToUtc(t):null===t||""===t?this.s.d=null:"--now"===t?this.s.d=this._dateToUtc(new Date):"string"==typeof t&&(this.s.d=this._dateToUtc(this._convert(t,this.c.format,null))),!e&&void 0!==e||(this.s.d?this._writeOutput():this.dom.input.val(t)),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(),this)},valFormat:function(t,e){return e?(this.val(this._convert(e,t,null)),this):this._convert(this.val(),null,t)},_constructor:function(){function n(){var t=o.dom.input.val();t!==e&&(o.c.onChange.call(o,t,o.s.d,o.dom.input),e=t)}var o=this,d=this.c.classPrefix,e=this.dom.input.val();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."+d+"-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(),$(document).on("i18n.dt",function(t,e){e.oLanguage.datetime&&($.extend(!0,o.c.i18n,e.oLanguage.datetime),o._optionsTitle())}),"hidden"===this.dom.input.attr("type")&&(this.dom.container.addClass("inline"),this.c.attachTo="input",this.val(this.dom.input.val(),!1),this._show()),e&&this.val(e,!1),this.dom.input.attr("autocomplete","off").on("focus.datetime click.datetime",function(){o.dom.container.is(":visible")||o.dom.input.is(":disabled")||(o.val(o.dom.input.val(),!1),o._show())}).on("keyup.datetime",function(){o.dom.container.is(":visible")&&o.val(o.dom.input.val(),!1)}),this.dom.container.on("change","select",function(){var t,e,s=$(this),i=s.val();s.hasClass(d+"-month")?(o._correctMonth(o.s.display,i),o._setTitle(),o._setCalander()):s.hasClass(d+"-year")?(o.s.display.setUTCFullYear(i),o._setTitle(),o._setCalander()):s.hasClass(d+"-hours")||s.hasClass(d+"-ampm")?(o.s.parts.hours12?(t=+$(o.dom.container).find("."+d+"-hours").val(),e="pm"===$(o.dom.container).find("."+d+"-ampm").val(),o.s.d.setUTCHours(12!=t||e?e&&12!=t?12+t:t:0)):o.s.d.setUTCHours(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-minutes")?(o.s.d.setUTCMinutes(i),o._setTime(),o._writeOutput(!0),n()):s.hasClass(d+"-seconds")&&(o.s.d.setSeconds(i),o._setTime(),o._writeOutput(!0),n()),o.dom.input.focus(),o._position()}).on("click",function(t){var e=o.s.d,s="span"===t.target.nodeName.toLowerCase()?t.target.parentNode:t.target,i=s.nodeName.toLowerCase();if("select"!==i)if(t.stopPropagation(),"a"===i&&(t.preventDefault(),$(s).hasClass(d+"-clear")?(o.s.d=null,o.dom.input.val(""),o._writeOutput(),o._setCalander(),o._setTime(),n()):$(s).hasClass(d+"-today")&&(o.s.display=new Date,o._setTitle(),o._setCalander())),"button"===i){t=$(s),i=t.parent();if(i.hasClass("disabled")&&!i.hasClass("range"))t.blur();else if(i.hasClass(d+"-iconLeft"))o.s.display.setUTCMonth(o.s.display.getUTCMonth()-1),o._setTitle(),o._setCalander(),o.dom.input.focus();else if(i.hasClass(d+"-iconRight"))o._correctMonth(o.s.display,o.s.display.getUTCMonth()+1),o._setTitle(),o._setCalander(),o.dom.input.focus();else{if(t.parents("."+d+"-time").length){var s=t.data("value"),a=t.data("unit"),e=o._needValue();if("minutes"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.minutesRange=s,void o._setTime();o.s.minutesRange=null}if("seconds"===a){if(i.hasClass("disabled")&&i.hasClass("range"))return o.s.secondsRange=s,void o._setTime();o.s.secondsRange=null}if("am"===s){if(!(12<=e.getUTCHours()))return;s=e.getUTCHours()-12}else if("pm"===s){if(!(e.getUTCHours()<12))return;s=e.getUTCHours()+12}e["hours"===a?"setUTCHours":"minutes"===a?"setUTCMinutes":"setSeconds"](s),o._setCalander(),o._setTime(),o._writeOutput(!0)}else(e=o._needValue()).setUTCDate(1),e.setUTCFullYear(t.data("year")),e.setUTCMonth(t.data("month")),e.setUTCDate(t.data("day")),o._writeOutput(!0),o.s.parts.time?(o._setCalander(),o._setTime()):setTimeout(function(){o._hide()},10);n()}}else o.dom.input.focus()})},_compareDates:function(t,e){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate()===dateLib.DateTime.fromJSDate(e).toUTC().toISODate():this._dateToUtcString(t)===this._dateToUtcString(e)},_convert:function(t,e,s){var i;return t&&(dateLib?this._isLuxon()?(i=t instanceof Date?dateLib.DateTime.fromJSDate(t).toUTC():dateLib.DateTime.fromFormat(t,e)).isValid?s?i.toFormat(s):i.toJSDate():null:(i=t instanceof Date?dateLib.utc(t,void 0,this.c.locale,this.c.strict):dateLib(t,e,this.c.locale,this.c.strict)).isValid()?s?i.format(s):i.toDate():null:!e&&!s||e&&s?t:e?(i=t.match(/(\d{4})\-(\d{2})\-(\d{2})/))?new Date(i[1],i[2]-1,i[3]):null:t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate()))},_correctMonth:function(t,e){var s=this._daysInMonth(t.getUTCFullYear(),e),i=t.getUTCDate()>s;t.setUTCMonth(e),i&&(t.setUTCDate(s),t.setUTCMonth(e))},_daysInMonth:function(t,e){return[31,t%4==0&&(t%100!=0||t%400==0)?29:28,31,30,31,30,31,31,30,31,30,31][e]},_dateToUtc:function(t){return t&&new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()))},_dateToUtcString:function(t){return this._isLuxon()?dateLib.DateTime.fromJSDate(t).toUTC().toISODate():t.getUTCFullYear()+"-"+this._pad(t.getUTCMonth()+1)+"-"+this._pad(t.getUTCDate())},_hide:function(t){!t&&"hidden"===this.dom.input.attr("type")||(t=this.s.namespace,this.dom.container.detach(),$(window).off("."+t),$(document).off("keydown."+t),$("div.dataTables_scrollBody").off("scroll."+t),$("div.DTE_Body_Content").off("scroll."+t),$("body").off("click."+t),$(this.dom.input[0].offsetParent).off("."+t))},_hours24To12:function(t){return 0===t?12:12<t?t-12:t},_htmlDay:function(t){var e,s;return t.empty?'<td class="empty"></td>':(e=["selectable"],s=this.c.classPrefix,t.disabled&&e.push("disabled"),t.today&&e.push("now"),t.selected&&e.push("selected"),'<td data-day="'+t.day+'" class="'+e.join(" ")+'"><button class="'+s+"-button "+s+'-day" type="button" data-year="'+t.year+'" data-month="'+t.month+'" data-day="'+t.day+'"><span>'+t.day+"</span></button></td>")},_htmlMonth:function(t,e){for(var s=this._dateToUtc(new Date),i=this._daysInMonth(t,e),a=new Date(Date.UTC(t,e,1)).getUTCDay(),n=[],o=[],d=(0<this.c.firstDay&&(a-=this.c.firstDay)<0&&(a+=7),i+a),r=d;7<r;)r-=7;d+=7-r;var l=this.c.minDate,h=this.c.maxDate;l&&(l.setUTCHours(0),l.setUTCMinutes(0),l.setSeconds(0)),h&&(h.setUTCHours(23),h.setUTCMinutes(59),h.setSeconds(59));for(var c=0,u=0;c<d;c++){var m=new Date(Date.UTC(t,e,c-a+1)),f=!!this.s.d&&this._compareDates(m,this.s.d),p=this._compareDates(m,s),T=c<a||i+a<=c,y=l&&m<l||h&&h<m,v=this.c.disableDays,f={day:c-a+1,month:e,year:t,selected:f,today:p,disabled:y=Array.isArray(v)&&-1!==$.inArray(m.getUTCDay(),v)||"function"==typeof v&&!0===v(m)?!0:y,empty:T};o.push(this._htmlDay(f)),7==++u&&(this.c.showWeekNumber&&o.unshift(this._htmlWeekOfYear(c-a,e,t)),n.push("<tr>"+o.join("")+"</tr>"),o=[],u=0)}var _,D=this.c.classPrefix,b=D+"-table";return this.c.showWeekNumber&&(b+=" weekNumber"),l&&(_=l>=new Date(Date.UTC(t,e,1,0,0,0)),this.dom.title.find("div."+D+"-iconLeft").css("display",_?"none":"block")),h&&(_=h<new Date(Date.UTC(t,e+1,1,0,0,0)),this.dom.title.find("div."+D+"-iconRight").css("display",_?"none":"block")),'<table class="'+b+'"><thead>'+this._htmlMonthHead()+"</thead><tbody>"+n.join("")+"</tbody></table>"},_htmlMonthHead:function(){var t=[],e=this.c.firstDay,s=this.c.i18n;this.c.showWeekNumber&&t.push("<th></th>");for(var i=0;i<7;i++)t.push("<th>"+function(t){for(t+=e;7<=t;)t-=7;return s.weekdays[t]}(i)+"</th>");return t.join("")},_htmlWeekOfYear:function(t,e,s){e=new Date(s,e,t,0,0,0,0),e.setDate(e.getDate()+4-(e.getDay()||7)),t=new Date(s,0,1),s=Math.ceil(((e-t)/864e5+1)/7);return'<td class="'+this.c.classPrefix+'-week">'+s+"</td>"},_isLuxon:function(){return!!(dateLib&&dateLib.DateTime&&dateLib.Duration&&dateLib.Settings)},_needValue:function(){return this.s.d||(this.s.d=this._dateToUtc(new Date),this.s.parts.time)||(this.s.d.setUTCHours(0),this.s.d.setUTCMinutes(0),this.s.d.setSeconds(0),this.s.d.setMilliseconds(0)),this.s.d},_options:function(t,e,s){s=s||e;var i=this.dom.container.find("select."+this.c.classPrefix+"-"+t);i.empty();for(var a=0,n=e.length;a<n;a++)i.append('<option value="'+e[a]+'">'+s[a]+"</option>")},_optionSet:function(t,e){var t=this.dom.container.find("select."+this.c.classPrefix+"-"+t),s=t.parent().children("span"),e=(t.val(e),t.find("option:selected"));s.html(0!==e.length?e.text():this.c.i18n.unknown)},_optionsTime:function(a,n,o,d,t){var e,r=this.c.classPrefix,s=this.dom.container.find("div."+r+"-"+a),i=12===n?function(t){return t}:this._pad,l=(r=this.c.classPrefix)+"-table",h=this.c.i18n;if(s.length){function c(t,e,s){12===n&&"number"==typeof t&&(12<=o&&(t+=12),12==t?t=0:24==t&&(t=12));var i=o===t||"am"===t&&o<12||"pm"===t&&12<=o?"selected":"";return"number"==typeof t&&d&&-1===$.inArray(t,d)&&(i+=" disabled"),s&&(i+=" "+s),'<td class="selectable '+i+'"><button class="'+r+"-button "+r+'-day" type="button" data-unit="'+a+'" data-value="'+t+'"><span>'+e+"</span></button></td>"}var u="",m=10;if(12===n){for(u+="<tr>",e=1;e<=6;e++)u+=c(e,i(e));for(u=(u+=c("am",h.amPm[0]))+"</tr>"+"<tr>",e=7;e<=12;e++)u+=c(e,i(e));u=u+c("pm",h.amPm[1])+"</tr>",m=7}else{if(24===n)for(var f=0,p=0;p<4;p++){for(u+="<tr>",e=0;e<6;e++)u+=c(f,i(f)),f++;u+="</tr>"}else{for(u+="<tr>",p=0;p<60;p+=10)u+=c(p,i(p),"range");var u=u+"</tr>"+('</tbody></thead><table class="'+l+" "+l+'-nospace"><tbody>'),T=null!==t?t:-1===o?0:10*Math.floor(o/10);for(u+="<tr>",p=T+1;p<T+10;p++)u+=c(p,i(p));u+="</tr>"}m=6}s.empty().append('<table class="'+l+'"><thead><tr><th colspan="'+m+'">'+h[a]+"</th></tr></thead><tbody>"+u+"</tbody></table>")}},_optionsTitle:function(){var t=this.c.i18n,e=this.c.minDate,s=this.c.maxDate,e=e?e.getFullYear():null,s=s?s.getFullYear():null,e=null!==e?e:(new Date).getFullYear()-this.c.yearRange,s=null!==s?s:(new Date).getFullYear()+this.c.yearRange;this._options("month",this._range(0,11),t.months),this._options("year",this._range(e,s)),this.dom.today.text(t.today).text(t.today),this.dom.clear.text(t.clear).text(t.clear),this.dom.previous.attr("title",t.previous).children("button").text(t.previous),this.dom.next.attr("title",t.next).children("button").text(t.next)},_pad:function(t){return t<10?"0"+t:t},_position:function(){var t,e,s,i="input"===this.c.attachTo?this.dom.input.position():this.dom.input.offset(),a=this.dom.container,n=this.dom.input.outerHeight();a.hasClass("inline")?a.insertAfter(this.dom.input):(this.s.parts.date&&this.s.parts.time&&550<$(window).width()?a.addClass("horizontal"):a.removeClass("horizontal"),"input"===this.c.attachTo?a.css({top:i.top+n,left:i.left}).insertAfter(this.dom.input):a.css({top:i.top+n,left:i.left}).appendTo("body"),t=a.outerHeight(),e=a.outerWidth(),s=$(window).scrollTop(),i.top+n+t-s>$(window).height()&&(n=i.top-t,a.css("top",n<0?0:n)),e+i.left>$(window).width()&&(s=$(window).width()-e,"input"===this.c.attachTo&&(s-=$(a).offsetParent().offset().left),a.css("left",s<0?0:s)))},_range:function(t,e,s){var i=[];s=s||1;for(var a=t;a<=e;a+=s)i.push(a);return i},_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(){function t(t){return e.c[t+"Available"]||e._range(0,59,e.c[t+"Increment"])}var e=this,s=this.s.d,i=null,a=null!=(i=this._isLuxon()?dateLib.DateTime.fromJSDate(s).toUTC():i)?i.hour:s?s.getUTCHours():-1;this._optionsTime("hours",this.s.parts.hours12?12:24,a,this.c.hoursAvailable),this._optionsTime("minutes",60,null!=i?i.minute:s?s.getUTCMinutes():-1,t("minutes"),this.s.minutesRange),this._optionsTime("seconds",60,null!=i?i.second:s?s.getSeconds():-1,t("seconds"),this.s.secondsRange)},_show:function(){var e=this,t=this.s.namespace,s=(this._position(),$(window).on("scroll."+t+" resize."+t,function(){e._position()}),$("div.DTE_Body_Content").on("scroll."+t,function(){e._position()}),$("div.dataTables_scrollBody").on("scroll."+t,function(){e._position()}),this.dom.input[0].offsetParent);s!==document.body&&$(s).on("scroll."+t,function(){e._position()}),$(document).on("keydown."+t,function(t){9!==t.keyCode&&27!==t.keyCode&&13!==t.keyCode||e._hide()}),setTimeout(function(){$("body").on("click."+t,function(t){$(t.target).parents().filter(e.dom.container).length||t.target===e.dom.input[0]||e._hide()})},10)},_writeOutput:function(t){var e=this.s.d,s="",i=this.dom.input,e=(e&&(s=this._convert(e,null,this.c.format)),i.val(s),new Event("change",{bubbles:!0}));i[0].dispatchEvent(e),"hidden"===i.attr("type")&&this.val(s,!1),t&&i.focus()}}),DateTime.use=function(t){dateLib=t},DateTime._instance=0,DateTime.type="DateTime",DateTime.defaults={attachTo:"body",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"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],amPm:["am","pm"],hours:"Hour",minutes:"Minute",seconds:"Second",unknown:"-",today:"Today"},maxDate:null,minDate:null,minutesAvailable:null,minutesIncrement:1,strict:!0,locale:"en",onChange:function(){},secondsAvailable:null,secondsIncrement:1,showWeekNumber:!1,yearRange:25},DateTime.version="1.5.0",DateTime.factory=function(t,e){var s=!1;return t&&t.document&&(window=t,document=t.document),e&&e.fn&&e.fn.jquery&&($=e,s=!0),s},window.DateTime||(window.DateTime=DateTime),window.DataTable&&(window.DataTable.DateTime=DateTime),$.fn.dtDateTime=function(t){return this.each(function(){new DateTime(this,t)})},$.fn.dataTable&&($.fn.dataTable.DateTime=DateTime,$.fn.DataTable.DateTime=DateTime,$.fn.dataTable.Editor)&&($.fn.dataTable.Editor.DateTime=DateTime);export default DateTime;
@@ -1,15 +1,18 @@
1
- /*! DateTime picker for DataTables.net v1.4.0
1
+ /*! DateTime picker for DataTables.net v1.5.0
2
2
  *
3
3
  * © SpryMedia Ltd, all rights reserved.
4
4
  * License: MIT datatables.net/license/mit
5
5
  */
6
6
 
7
- import $ from 'jquery';
7
+ import jQuery from 'jquery';
8
+
9
+ // Allow reassignment of the $ variable
10
+ let $ = jQuery;
8
11
 
9
12
 
10
13
  /**
11
14
  * @summary DateTime picker for DataTables.net
12
- * @version 1.4.0
15
+ * @version 1.5.0
13
16
  * @file dataTables.dateTime.js
14
17
  * @author SpryMedia Ltd
15
18
  * @contact www.datatables.net/contact
@@ -158,6 +161,8 @@ var DateTime = function ( input, opts ) {
158
161
  .append( this.dom.buttons )
159
162
  .append( this.dom.calendar );
160
163
 
164
+ this.dom.input.addClass('dt-datetime');
165
+
161
166
  this._constructor();
162
167
  };
163
168
 
@@ -173,10 +178,33 @@ $.extend( DateTime.prototype, {
173
178
  this._hide(true);
174
179
  this.dom.container.off().empty();
175
180
  this.dom.input
181
+ .removeClass('dt-datetime')
176
182
  .removeAttr('autocomplete')
177
183
  .off('.datetime');
178
184
  },
179
185
 
186
+ display: function (year, month) {
187
+ if (year !== undefined) {
188
+ this.s.display.setUTCFullYear(year);
189
+ }
190
+
191
+ if (month !== undefined) {
192
+ this.s.display.setUTCMonth(month - 1);
193
+ }
194
+
195
+ if (year !== undefined || month !== undefined) {
196
+ this._setTitle();
197
+ this._setCalander();
198
+
199
+ return this;
200
+ }
201
+
202
+ return {
203
+ month: this.s.display.getUTCMonth() + 1,
204
+ year: this.s.display.getUTCFullYear()
205
+ };
206
+ },
207
+
180
208
  errorMsg: function ( msg ) {
181
209
  var error = this.dom.error;
182
210
 
@@ -645,7 +673,7 @@ $.extend( DateTime.prototype, {
645
673
  * @param {string|null} to Format to convert to. If null a `Date` will be returned
646
674
  * @returns {string|Date} Converted value
647
675
  */
648
- _convert(val, from, to) {
676
+ _convert: function(val, from, to) {
649
677
  if (! val) {
650
678
  return val;
651
679
  }
@@ -1512,21 +1540,25 @@ $.extend( DateTime.prototype, {
1512
1540
  _writeOutput: function ( focus ) {
1513
1541
  var date = this.s.d;
1514
1542
  var out = '';
1543
+ var input = this.dom.input;
1515
1544
 
1516
1545
  if (date) {
1517
1546
  out = this._convert(date, null, this.c.format);
1518
1547
  }
1519
1548
 
1520
- this.dom.input
1521
- .val( out )
1522
- .trigger('change', {write: date});
1549
+ input.val( out );
1550
+
1551
+ // Create a DOM synthetic event. Can't use $().trigger() as
1552
+ // that doesn't actually trigger non-jQuery event listeners
1553
+ var event = new Event('change', {bubbles: true});
1554
+ input[0].dispatchEvent(event);
1523
1555
 
1524
- if ( this.dom.input.attr('type') === 'hidden' ) {
1556
+ if ( input.attr('type') === 'hidden' ) {
1525
1557
  this.val(out, false);
1526
1558
  }
1527
1559
 
1528
1560
  if ( focus ) {
1529
- this.dom.input.focus();
1561
+ input.focus();
1530
1562
  }
1531
1563
  }
1532
1564
  } );
@@ -1546,6 +1578,11 @@ DateTime.use = function (lib) {
1546
1578
  */
1547
1579
  DateTime._instance = 0;
1548
1580
 
1581
+ /**
1582
+ * To indicate to DataTables what type of library this is
1583
+ */
1584
+ DateTime.type = 'DateTime';
1585
+
1549
1586
  /**
1550
1587
  * Defaults for the date time picker
1551
1588
  *
@@ -1611,7 +1648,7 @@ DateTime.defaults = {
1611
1648
  yearRange: 25
1612
1649
  };
1613
1650
 
1614
- DateTime.version = '1.4.0';
1651
+ DateTime.version = '1.5.0';
1615
1652
 
1616
1653
  /**
1617
1654
  * CommonJS factory function pass through. Matches DataTables.
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <dt-api library="DateTime">
3
+ <name>display()</name>
4
+ <summary>Get / set the month and year for the current display.</summary>
5
+ <since>1.5.0</since>
6
+
7
+ <type type="function">
8
+ <signature>display()</signature>
9
+ <description>Get the month and year of the calendar that is currently shown to the end user.</description>
10
+ <returns type="object">Object containing `month` and `year` properties. Note that `month` starts at 1 for January.</returns>
11
+ </type>
12
+ <type type="function">
13
+ <signature>display(year, month)</signature>
14
+ <description>Set the month / year calender to be shown to the end user.</description>
15
+ <parameter type="number" name="year">
16
+ The year to show a calendar for.
17
+ </parameter>
18
+ <parameter type="number" name="month">
19
+ The month to show a calendar for. Note that the range is 1-12 - i.e. January is 1, December is 12.
20
+ </parameter>
21
+ <returns type="DateTime">Self for chaining.</returns>
22
+ </type>
23
+
24
+ <description>
25
+ This method is used to programmatically control the calendar month that is shown to the end user. That can be useful for jumping around long time periods, or encouraging users to enter data in a specific month.
26
+
27
+ It might typically be used with a `change` or `focus` event listener. The get value should only relied upon when the calendar display is shown (field has focus), and the setter will only have an affect under the same condition.
28
+ </description>
29
+ </dt-api>
@@ -3,6 +3,7 @@
3
3
 
4
4
  <title lib="DateTime">DateTime Picker</title>
5
5
 
6
+ <js lib="jquery" />
6
7
  <info><![CDATA[
7
8
 
8
9
  This is the section that shows the key configuration options for the DateTime Picker.
@@ -6,18 +6,29 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- new DateTime(document.getElementById('test'), {
11
- buttons: {
12
- today: true,
13
- clear: true
14
- }
15
- });
9
+ $('#test').dtDateTime({
10
+ buttons: {
11
+ today: true,
12
+ clear: true
13
+ }
16
14
  });
17
15
 
18
16
  ]]>
19
17
  </js>
20
18
 
19
+ <js-vanilla>
20
+ <![CDATA[
21
+
22
+ new DateTime(document.getElementById('test'), {
23
+ buttons: {
24
+ today: true,
25
+ clear: true
26
+ }
27
+ });
28
+
29
+ ]]>
30
+ </js-vanilla>
31
+
21
32
  <title lib="DateTime">Action buttons (today and clear)</title>
22
33
 
23
34
  <info><![CDATA[
@@ -6,15 +6,23 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- window.d = new DateTime(document.getElementById('test'), {
11
- format: 'D MMM YYYY HH:mm'
12
- });
9
+ $('#test').dtDateTime({
10
+ format: 'D MMM YYYY HH:mm'
13
11
  });
14
12
 
15
13
  ]]>
16
14
  </js>
17
15
 
16
+ <js-vanilla>
17
+ <![CDATA[
18
+
19
+ new DateTime(document.getElementById('test'), {
20
+ format: 'D MMM YYYY HH:mm'
21
+ });
22
+
23
+ ]]>
24
+ </js-vanilla>
25
+
18
26
  <title lib="DateTime">Date and time</title>
19
27
 
20
28
  <info><![CDATA[
@@ -11,14 +11,26 @@
11
11
  dayjs.extend(dayjs_plugin_utc);
12
12
  dayjs.extend(dayjs_plugin_customParseFormat);
13
13
 
14
- $(document).ready(function() {
15
- window.allan = new DateTime(document.getElementById('test'), {
16
- format: 'D/M/YYYY'
17
- });
14
+ $('#test').dtDateTime({
15
+ format: 'D/M/YYYY'
18
16
  });
17
+
19
18
  ]]>
20
19
  </js>
21
20
 
21
+ <js-vanilla>
22
+ <![CDATA[
23
+
24
+ dayjs.extend(dayjs_plugin_utc);
25
+ dayjs.extend(dayjs_plugin_customParseFormat);
26
+
27
+ new DateTime(document.getElementById('test'), {
28
+ format: 'D/M/YYYY'
29
+ });
30
+
31
+ ]]>
32
+ </js-vanilla>
33
+
22
34
  <title lib="DateTime">DayJS formatting</title>
23
35
 
24
36
  <info><![CDATA[
@@ -6,18 +6,24 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- new DateTime(document.getElementById('test'));
11
- });
9
+ $('#test').dtDateTime();
12
10
 
13
11
  ]]>
14
12
  </js>
15
13
 
14
+ <js-vanilla>
15
+ <![CDATA[
16
+
17
+ new DateTime(document.getElementById('test'));
18
+
19
+ ]]>
20
+ </js-vanilla>
21
+
16
22
  <title lib="DateTime">Hidden input</title>
17
23
 
18
24
  <info><![CDATA[
19
25
 
20
- This is the `-init dateTime`extension for DataTables. It is used to select dates throughtout DataTables and it's extensions.
26
+ This example demonstrates DateTime being used with a hidden `-tag input`. The picker is shown on the page rather than being toggled by the click on an `-tag input` element.
21
27
 
22
28
  ]]></info>
23
29
 
@@ -6,20 +6,59 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- new DateTime(document.getElementById('test'), {
11
- i18n: {
12
- previous: 'Précédent',
13
- next: 'Premier',
14
- months: [ 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre' ],
15
- weekdays: [ 'Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam' ]
16
- }
17
- });
9
+ $('#test').dtDateTime({
10
+ i18n: {
11
+ previous: 'Précédent',
12
+ next: 'Premier',
13
+ months: [
14
+ 'Janvier',
15
+ 'Février',
16
+ 'Mars',
17
+ 'Avril',
18
+ 'Mai',
19
+ 'Juin',
20
+ 'Juillet',
21
+ 'Août',
22
+ 'Septembre',
23
+ 'Octobre',
24
+ 'Novembre',
25
+ 'Décembre'
26
+ ],
27
+ weekdays: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam']
28
+ }
18
29
  });
19
30
 
20
31
  ]]>
21
32
  </js>
22
33
 
34
+ <js-vanilla>
35
+ <![CDATA[
36
+
37
+ new DateTime(document.getElementById('test'), {
38
+ i18n: {
39
+ previous: 'Précédent',
40
+ next: 'Premier',
41
+ months: [
42
+ 'Janvier',
43
+ 'Février',
44
+ 'Mars',
45
+ 'Avril',
46
+ 'Mai',
47
+ 'Juin',
48
+ 'Juillet',
49
+ 'Août',
50
+ 'Septembre',
51
+ 'Octobre',
52
+ 'Novembre',
53
+ 'Décembre'
54
+ ],
55
+ weekdays: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam']
56
+ }
57
+ });
58
+
59
+ ]]>
60
+ </js-vanilla>
61
+
23
62
  <title lib="DateTime">Internationalisation</title>
24
63
 
25
64
  <info><![CDATA[
@@ -3,6 +3,7 @@
3
3
 
4
4
  <title lib="DateTime">DateTime Picker</title>
5
5
 
6
+ <js lib="jquery" />
6
7
  <info><![CDATA[
7
8
 
8
9
  This is the section that shows the key configuration options for the DateTime Picker.
@@ -6,14 +6,23 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- window.allan = new DateTime(document.getElementById('test'), {
11
- format: 'd/M/yyyy, HH:mm'
12
- });
9
+ new DateTime(document.getElementById('test'), {
10
+ format: 'd/M/yyyy, HH:mm'
13
11
  });
12
+
14
13
  ]]>
15
14
  </js>
16
15
 
16
+ <js-vanilla>
17
+ <![CDATA[
18
+
19
+ new DateTime(document.getElementById('test'), {
20
+ format: 'd/M/yyyy, HH:mm'
21
+ });
22
+
23
+ ]]>
24
+ </js-vanilla>
25
+
17
26
  <title lib="DateTime">Luxon formatting</title>
18
27
 
19
28
  <info><![CDATA[
@@ -5,15 +5,23 @@
5
5
  <js lib="jquery moment datetime">
6
6
  <![CDATA[
7
7
 
8
- $(document).ready(function() {
9
- new DateTime(document.getElementById('test'), {
10
- format: 'D/M/YYYY'
11
- });
8
+ new DateTime(document.getElementById('test'), {
9
+ format: 'D/M/YYYY'
12
10
  });
13
11
 
14
12
  ]]>
15
13
  </js>
16
14
 
15
+ <js-vanilla>
16
+ <![CDATA[
17
+
18
+ new DateTime(document.getElementById('test'), {
19
+ format: 'D/M/YYYY'
20
+ });
21
+
22
+ ]]>
23
+ </js-vanilla>
24
+
17
25
  <title lib="DateTime">Moment formatting</title>
18
26
 
19
27
  <info><![CDATA[
@@ -6,18 +6,24 @@
6
6
  <js lib="jquery datetime">
7
7
  <![CDATA[
8
8
 
9
- $(document).ready(function() {
10
- new DateTime(document.getElementById('test'));
11
- });
9
+ $('#test').dtDateTime();
12
10
 
13
11
  ]]>
14
12
  </js>
15
13
 
14
+ <js-vanilla>
15
+ <![CDATA[
16
+
17
+ new DateTime(document.getElementById('test'));
18
+
19
+ ]]>
20
+ </js-vanilla>
21
+
16
22
  <title lib="DateTime">Basic initialisation</title>
17
23
 
18
24
  <info><![CDATA[
19
25
 
20
- This is the `de-init dateTime` extension for DataTables. It is used to select dates throughtout DataTables and it's extensions.
26
+ This is the `de-init dateTime` extension for DataTables. It is used to select dates throughout DataTables and it's extensions.
21
27
 
22
28
  See other examples for more detail.
23
29