1/** 2 * @preserve jQuery DateTimePicker plugin v2.3.4 3 * @homepage http://xdsoft.net/jqplugins/datetimepicker/ 4 * (c) 2014, Chupurnov Valeriy. 5 */ 6(function( $ ) { 7 'use strict'; 8 var default_options = { 9 i18n:{ 10 bg:{ // Bulgarian 11 months:[ 12 "ЯнÑаÑи", "ФевÑÑаÑи", "ÐаÑÑ", "ÐпÑил", "Ðай", "Юни", "Юли", "ÐвгÑÑÑ", "СепÑемвÑи", "ÐкÑомвÑи", "ÐоемвÑи", "ÐекемвÑи" 13 ], 14 dayOfWeek:[ 15 "Ðд", "Ðн", "ÐÑ", "СÑ", "ЧÑ", "ÐÑ", "Сб" 16 ] 17 }, 18 fa:{ // Persian/Farsi 19 months:[ 20 'ÙØ±ÙردÛÙ', 'Ø§Ø±Ø¯ÛØ¨Ùشت', 'خرداد', 'ØªÛØ±', '٠رداد', 'Ø´ÙØ±ÛÙØ±', 'Ù ÙØ±', 'آباÙ', 'آذر', 'دÛ', 'بÙÙ Ù', 'اسÙÙØ¯' 21 ], 22 dayOfWeek:[ 23 'ÛÚ©Ø´ÙØ¨Ù', 'Ø¯ÙØ´ÙبÙ', 'Ø³Ù Ø´ÙØ¨Ù', 'ÚÙØ§Ø±Ø´ÙبÙ', 'Ù¾ÙØ¬Ø´ÙبÙ', 'ج٠عÙ', 'Ø´ÙØ¨Ù' 24 ] 25 }, 26 ru:{ // Russian 27 months:[ 28 'ЯнваÑÑ','ФевÑалÑ','ÐаÑÑ','ÐпÑелÑ','Ðай','ÐÑнÑ','ÐÑлÑ','ÐвгÑÑÑ','СенÑÑбÑÑ','ÐкÑÑбÑÑ','ÐоÑбÑÑ','ÐекабÑÑ' 29 ], 30 dayOfWeek:[ 31 "ÐÑк", "Ðн", "ÐÑ", "СÑ", "ЧÑ", "ÐÑ", "Сб" 32 ] 33 }, 34 uk:{ // Ukrainian 35 months:[ 36 'СÑÑенÑ','ÐÑÑий','ÐеÑезенÑ','ÐвÑÑенÑ','ТÑавенÑ','ЧеÑвенÑ','ÐипенÑ','СеÑпенÑ','ÐеÑеÑенÑ','ÐовÑенÑ','ÐиÑÑопад','ÐÑÑденÑ' 37 ], 38 dayOfWeek:[ 39 "Ðдл", "Ðнд", "ÐÑÑ", "СÑд", "ЧÑв", "ÐÑн", "СбÑ" 40 ] 41 }, 42 en:{ // English 43 months: [ 44 "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
44November", "December" 45 ], 46 dayOfWeek: [ 47 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 48 ] 49 }, 50 el:{ // Îλληνικά 51 months: [ 52 "ÎÎ±Î½Î¿Ï Î¬ÏιοÏ", "ΦεβÏÎ¿Ï Î¬ÏιοÏ", "ÎάÏÏιοÏ", "ÎÏÏίλιοÏ", "ÎάιοÏ", "ÎοÏνιοÏ", "ÎοÏλιοÏ", "ÎÏÎ³Î¿Ï ÏÏοÏ", "ΣεÏÏÎμβÏιοÏ", "ÎκÏÏβÏιοÏ", "ÎοÎμβÏιοÏ", "ÎεκÎμβÏιοÏ" 53 ], 54 dayOfWeek: [ 55 "ÎÏ Ï", "ÎÎµÏ ", "ΤÏι", "ΤεÏ", "Πεμ", "ΠαÏ", "Σαβ" 56 ] 57 }, 58 de:{ // German 59 months:[ 60 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember' 61 ], 62 dayOfWeek:[ 63 "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa" 64 ] 65 }, 66 nl:{ // Dutch 67 months:[ 68 "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december" 69 ], 70 dayOfWeek:[ 71 "zo", "ma", "di", "wo", "do", "vr", "za" 72 ] 73 }, 74 tr:{ // Turkish 75 months:[ 76 "Ocak", "Åubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "AÄustos", "Eylül", "Ekim", "Kasım", "Aralık" 77 ], 78 dayOfWeek:[ 79 "Paz", "Pts", "Sal", "Ãar", "Per", "Cum", "Cts" 80 ] 81 }, 82 fr:{ //French 83 months:[ 84 "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" 85 ], 86 dayOfWeek:[ 87 "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" 88 ] 89 }, 90 es:{ // Spanish 91 months: [ 92 "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" 93 ], 94 dayOfWeek: [ 95 "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb" 96 ] 97 }, 98 th:{ // Thai 99 months:[ 100 'มà¸à¸£à¸²à¸à¸¡','à¸à¸¸à¸¡à¸ าà¸à¸±à¸à¸à¹','มีà¸à¸²à¸à¸¡','à¹à¸¡à¸©à¸²à¸¢à¸','à¸à¸¤à¸©à¸ าà¸à¸¡','มิà¸à¸¸à¸à¸²à¸¢à¸','à¸à¸£à¸à¸à¸²à¸à¸¡','สิà¸à¸«à¸²à¸à¸¡','à¸à¸±à¸à¸¢à¸²à¸¢à¸','à¸à¸¸à¸¥à¸²à¸à¸¡','à¸à¸¤à¸¨à¸à¸´à¸à¸²à¸¢à¸','à¸à¸±à¸à¸§à¸²à¸à¸¡' 101 ], 102 dayOfWeek:[ 103 'à¸à¸².','à¸.','à¸.','à¸.','à¸à¸¤.','ศ.','ส.' 104 ] 105 }, 106 pl:{ // Polish 107 months: [ 108 "styczeÅ", "luty", "marzec", "kwiecieÅ", "maj", "czerwiec", "lipiec", "sierpieÅ", "wrzesieÅ", "październik", "listopad", "grudzieÅ" 109 ], 110 dayOfWeek: [ 111 "nd", "pn", "wt", "År", "cz", "pt", "sb" 112 ] 113 }, 114 pt:{ // Portuguese 115 months: [ 116 "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" 117 ], 118 dayOfWeek: [ 119 "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab" 120 ] 121 }, 122 ch:{ // Simplified Chinese 123 months: [ 124 "䏿","äºæ","䏿","åæ","äºæ","å æ","䏿","å «æ","乿","åæ","å䏿","åäºæ" 125 ], 126 dayOfWeek: [ 127 "æ¥", "ä¸","äº","ä¸","å","äº","å " 128 ] 129 }, 130 se:{ // Swedish 131 months: [ 132 "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September","Oktober", "November", "December" 133 ], 134 dayOfWeek: [ 135 "Sön", "MÃ¥n", "Tis", "Ons", "Tor", "Fre", "Lör" 136 ] 137 }, 138 kr:{ // Korean 139 months: [ 140 "1ì", "2ì", "3ì", "4ì", "5ì", "6ì", "7ì", "8ì", "9ì", "10ì", "11ì", "12ì" 141 ], 142 dayOfWeek: [ 143 "ì¼", "ì", "í", "ì", "목", "ê¸", "í " 144 ] 145 }, 146 it:{ // Italian 147 months: [ 148 "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" 149 ], 150 dayOfWeek: [ 151 "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab" 152 ] 153 }, 154 da:{ // Dansk 155 months: [ 156 "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December" 157 ], 158 dayOfWeek: [ 159 "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør" 160 ] 161 }, 162 no:{ // Norwegian 163 months: [ 164 "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember" 165 ], 166 dayOfWeek: [ 167 "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør" 168 ] 169 }, 170 ja:{ // Japanese 171 months: [ 172 "1æ", "2æ", "3æ", "4æ", "5æ", "6æ", "7æ", "8æ", "9æ", "10æ", "11æ", "12æ" 173 ], 174 dayOfWeek: [ 175 "æ¥", "æ", "ç«", "æ°´", "æ¨", "é", "å" 176 ] 177 }, 178 vi:{ // Vietnamese 179 months: [ 180 "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12" 181 ], 182 dayOfWeek: [ 183 "CN", "T2", "T3", "T4", "T5", "T6", "T7" 184 ] 185 }, 186 sl:{ // SlovenÅ¡Äina 187 months: [ 188 "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "
188November", "December" 189 ], 190 dayOfWeek: [ 191 "Ned", "Pon", "Tor", "Sre", "Äet", "Pet", "Sob" 192 ] 193 }, 194 cs:{ // ÄeÅ¡tina 195 months: [ 196 "Leden", "Ãnor", "BÅezen", "Duben", "KvÄten", "Äerven", "Äervenec", "Srpen", "ZáÅÃ", "ÅÃjen", "Listopad", "Prosinec" 197 ], 198 dayOfWeek: [ 199 "Ne", "Po", "Ãt", "St", "Ät", "Pá", "So" 200 ] 201 }, 202 hu:{ // Hungarian 203 months: [ 204 "Január", "Február", "Március", "Ãprilis", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December" 205 ], 206 dayOfWeek: [ 207 "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo" 208 ] 209 } 210 }, 211 value:'', 212 lang:'en', 213 214 format: 'Y/m/d H:i', 215 formatTime: 'H:i', 216 formatDate: 'Y/m/d', 217 218 startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05', 219 220 step:60, 221 monthChangeSpinner:true, 222 closeOnDateSelect:false, 223 closeOnWithoutClick:true, 224 closeOnInputClick: true, 225 226 timepicker:true, 227 datepicker:true, 228 weeks:false, 229 230 defaultTime:false, // use formatTime format (ex. '10:00' for formatTime: 'H:i') 231 defaultDate:false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05') 232 233 minDate:false, 234 maxDate:false, 235 minTime:false, 236 maxTime:false, 237 238 allowTimes:[], 239 opened:false, 240 initTime:true, 241 inline:false, 242 243 onSelectDate:function() {}, 244 onSelectTime:function() {}, 245 onChangeMonth:function() {}, 246 onChangeDateTime:function() {}, 247 onShow:function() {}, 248 onClose:function() {}, 249 onGenerate:function() {}, 250 251 withoutCopyright:true, 252 253 inverseButton:false, 254 hours12:false, 255 next: 'xdsoft_next', 256 prev : 'xdsoft_prev', 257 dayOfWeekStart:0, 258 259 timeHeightInTimePicker:25, 260 timepickerScrollbar:true, 261 262 todayButton:true, // 2.1.0 263 defaultSelect:true, // 2.1.0 264 265 scrollMonth:true, 266 scrollTime:true, 267 scrollInput:true, 268 269 lazyInit:false, 270 271 mask:false, 272 validateOnBlur:true, 273 allowBlank:true, 274 275 yearStart:1950, 276 yearEnd:2050, 277 278 style:'', 279 id:'', 280 281 fixed: false, 282 283 roundTime:'round', // ceil, floor 284 className:'', 285 286 weekends : [], 287 yearOffset:0, 288 beforeShowDay: null 289 }; 290 291 // fix for ie8 292 if ( !Array.prototype.indexOf ) { 293 Array.prototype.indexOf = function(obj, start) { 294 for (var i = (start || 0), j = this.length; i < j; i++) { 295 if (this[i] === obj) { return i; } 296 } 297 return -1; 298 } 299 } 300 301 Date.prototype.countDaysInMonth = function(){ 302 return new Date(this.getFullYear(), this.getMonth()+1, 0).getDate(); 303 }; 304 305 $.fn.xdsoftScroller = function( _percent ) { 306 return this.each(function() { 307 var timeboxparent = $(this); 308 if( !$(this).hasClass('xdsoft_scroller_box') ) { 309 var pointerEventToXY = function( e ) { 310 var out = {x:0, y:0}; 311 if( e.type == 'touchstart' || e.type == 'touchmove' || e.type == 'touchend' || e.type == 'touchcancel' ) { 312 var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; 313 out.x = touch.pageX; 314 out.y = touch.pageY; 315 }else if (e.type == 'mousedown' || e.type == 'mouseup' || e.type == 'mousemove' || e.type == 'mouseover'|| e.type=='mouseout' || e.type=='mouseenter' || e.type=='mouseleave') { 316 out.x = e.pageX; 317 out.y = e.pageY; 318 } 319 return out; 320 }, 321 move = 0, 322 timebox = timeboxparent.children().eq(0), 323 parentHeight = timeboxparent[0].clientHeight, 324 height = timebox[0].offsetHeight, 325 scrollbar = $('<div class="xdsoft_scrollbar"></div>'), 326 scroller = $('<div class="xdsoft_scroller"></div>'), 327 maximumOffset = 100, 328 start = false;
329 330 scrollbar.append(scroller); 331 332 timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar); 333 scroller.on('mousedown.xdsoft_scroller',function ( event ) { 334 if( !parentHeight ) 335 timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]); 336 var pageY = event.pageY, 337 top = parseInt(scroller.css('margin-top')), 338 h1 = scrollbar[0].offsetHeight; 339 $(document.body).addClass('xdsoft_noselect'); 340 $([document.body,window]).on('mouseup.xdsoft_scroller',function arguments_callee() { 341 $([document.body,window]).off('mouseup.xdsoft_scroller',arguments_callee) 342 .off('mousemove.xdsoft_scroller',move) 343 .removeClass('xdsoft_noselect'); 344 }); 345 $(document.body).on('mousemove.xdsoft_scroller',move = function(event) { 346 var offset = event.pageY-pageY+top; 347 if( offset<0 ) 348 offset = 0; 349 if( offset+scroller[0].offsetHeight>h1 ) 350 offset = h1-scroller[0].offsetHeight; 351 timeboxparent.trigger('scroll_element.xdsoft_scroller',[maximumOffset?offset/maximumOffset:0]); 352 }); 353 }); 354 355 timeboxparent 356 .on('scroll_element.xdsoft_scroller',function( event,percent ) { 357 if( !parentHeight ) 358 timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percent,true]); 359 percent = percent>1?1:(percent<0||isNaN(percent))?0:percent; 360 scroller.css('margin-top',maximumOffset*percent); 361 timebox.css('marginTop',-parseInt((height-parentHeight)*percent)) 362 }) 363 .on('resize_scroll.xdsoft_scroller',function( event,_percent,noTriggerScroll ) { 364 parentHeight = timeboxparent[0].clientHeight; 365 height = timebox[0].offsetHeight; 366 var percent = parentHeight/height, 367 sh = percent*scrollbar[0].offsetHeight; 368 if( percent>1 ) 369 scroller.hide(); 370 else{ 371 scroller.show(); 372 scroller.css('height',parseInt(sh>10?sh:10)); 373 maximumOffset = scrollbar[0].offsetHeight-scroller[0].offsetHeight; 374 if( noTriggerScroll!==true ) 375 timeboxparent.trigger('scroll_element.xdsoft_scroller',[_percent?_percent:Math.abs(parseInt(timebox.css('marginTop')))/(height-parentHeight)]); 376 } 377 }); 378 timeboxparent.mousewheel&&timeboxparent.mousewheel(function(event, delta, deltaX, deltaY) { 379 var top = Math.abs(parseInt(timebox.css('marginTop'))); 380 timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-delta*20)/(height-parentHeight)]); 381 event.stopPropagation(); 382 return false; 383 }); 384 timeboxparent.on('touchstart',function( event ) { 385 start = pointerEventToXY(event); 386 }); 387 timeboxparent.on('touchmove',function( event ) { 388 if( start ) { 389 var coord = pointerEventToXY(event), top = Math.abs(parseInt(timebox.css('marginTop'))); 390 timeboxparent.trigger('scroll_element.xdsoft_scroller',[(top-(coord.y-start.y))/(height-parentHeight)]); 391 event.stopPropagation(); 392 event.preventDefault(); 393 start = pointerEventToXY(event); 394 } 395 }); 396 timeboxparent.on('touchend touchcancel',function( event ) { 397 start = false;
398 }); 399 } 400 timeboxparent.trigger('resize_scroll.xdsoft_scroller',[_percent]); 401 }); 402 }; 403 $.fn.datetimepicker = function( opt ) { 404 var KEY0 = 48, 405 KEY9 = 57, 406 _KEY0 = 96, 407 _KEY9 = 105, 408 CTRLKEY = 17, 409 DEL = 46, 410 ENTER = 13, 411 ESC = 27, 412 BACKSPACE = 8, 413 ARROWLEFT = 37, 414 ARROWUP = 38, 415 ARROWRIGHT = 39, 416 ARROWDOWN = 40, 417 TAB = 9, 418 F5 = 116, 419 AKEY = 65, 420 CKEY = 67, 421 VKEY = 86, 422 ZKEY = 90, 423 YKEY = 89, 424 ctrlDown = false, 425 options = ($.isPlainObject(opt)||!opt)?$.extend(true,{},default_options,opt):$.extend({},default_options), 426 427 lazyInitTimer = 0, 428 429 lazyInit = function( input ){ 430 input 431 .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function initOnActionCallback(event) { 432 if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||input.data( 'xdsoft_datetimepicker') ) 433 return; 434 435 clearTimeout(lazyInitTimer); 436 437 lazyInitTimer = setTimeout(function() { 438 439 if( !input.data( 'xdsoft_datetimepicker') ) 440 createDateTimePicker(input); 441 442 input 443 .off('open.xdsoft focusin.xdsoft mousedown.xdsoft',initOnActionCallback) 444 .trigger('open.xdsoft'); 445 },100); 446 447 }); 448 }, 449 450 createDateTimePicker = function( input ) { 451 452 var datetimepicker = $('<div '+(options.id?'id="'+options.id+'"':'')+' '+(options.style?'style="'+options.style+'"':'')+' class="xdsoft_datetimepicker xdsoft_noselect '+(options.weeks?' xdsoft_showweeks':'')+options.className+'"></div>'), 453 xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'), 454 datepicker = $('<div class="xdsoft_datepicker active"></div>'), 455 mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button><div class="xdsoft_label xdsoft_month"><span></span></div><div class="xdsoft_label xdsoft_year"><span></span></div><button type="button" class="xdsoft_next"></button></div>'), 456 calendar = $('<div class="xdsoft_calendar"></div>'), 457 timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'), 458 timeboxparent = timepicker.find('.xdsoft_time_box').eq(0), 459 timebox = $('<div class="xdsoft_time_variant"></div>'), 460 scrollbar = $('<div class="xdsoft_scrollbar"></div>'), 461 scroller = $('<div class="xdsoft_scroller"></div>'), 462 monthselect =$('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'), 463 yearselect =$('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'); 464 465 //constructor lego 466 mounth_picker 467 .find('.xdsoft_month span') 468 .after(monthselect); 469 mounth_picker 470 .find('.xdsoft_year span') 471 .after(yearselect); 472 473 mounth_picker 474 .find('.xdsoft_month,.xdsoft_year') 475 .on('mousedown.xdsoft',function(event) { 476 mounth_picker 477 .find('.xdsoft_select') 478 .hide(); 479 480 var select = $(this).find('.xdsoft_select').eq(0), 481 val = 0, 482 top = 0; 483 484 if( _xdsoft_datetime.currentTime ) 485 val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear'](); 486 487 select.show(); 488 489 for(var items = select.find('div.xdsoft_option'),i = 0;i<items.length;i++) { 490 if( items.eq(i).data('value')==val ) { 491 break; 492 }else top+=items[0].offsetHeight; 493 } 494
495 select.xdsoftScroller(top/(select.children()[0].offsetHeight-(select[0].clientHeight))); 496 event.stopPropagation(); 497 498 return false; 499 }); 500 501 mounth_picker 502 .find('.xdsoft_select') 503 .xdsoftScroller() 504 .on('mousedown.xdsoft',function( event ) { 505 event.stopPropagation(); 506 event.preventDefault(); 507 }) 508 .on('mousedown.xdsoft','.xdsoft_option',function( event ) { 509 if( _xdsoft_datetime&&_xdsoft_datetime.currentTime ) 510 _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect')?'setMonth':'setFullYear']($(this).data('value')); 511 512 $(this).parent().parent().hide(); 513 514 datetimepicker.trigger('xchange.xdsoft'); 515 options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 516 }); 517 518 519 // set options 520 datetimepicker.setOptions = function( _options ) { 521 options = $.extend(true,{},options,_options); 522 523 if( _options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length ){ 524 options['allowTimes'] = $.extend(true,[],_options.allowTimes); 525 } 526 527 if( _options.weekends && $.isArray(_options.weekends) && _options.weekends.length ){ 528 options['weekends'] = $.extend(true,[],_options.weekends); 529 } 530 531 if( (options.open||options.opened)&&(!options.inline) ) { 532 input.trigger('open.xdsoft'); 533 } 534 535 if( options.inline ) { 536 triggerAfterOpen = true; 537 datetimepicker.addClass('xdsoft_inline'); 538 input.after(datetimepicker).hide(); 539 } 540 541 if( options.inverseButton ) { 542 options.next = 'xdsoft_prev'; 543 options.prev = 'xdsoft_next'; 544 } 545 546 if( options.datepicker ) 547 datepicker.addClass('active'); 548 else 549 datepicker.removeClass('active'); 550 551 if( options.timepicker ) 552 timepicker.addClass('active'); 553 else 554 timepicker.removeClass('active'); 555 556 if( options.value ){ 557 input&&input.val&&input.val(options.value); 558 _xdsoft_datetime.setCurrentTime(options.value); 559 } 560 561 if( isNaN(options.dayOfWeekStart) ) 562 options.dayOfWeekStart = 0; 563 else 564 options.dayOfWeekStart = parseInt(options.dayOfWeekStart)%7; 565 566 if( !options.timepickerScrollbar ) 567 scrollbar.hide(); 568
569 if( options.minDate && /^-(.*)$/.test(options.minDate) ){ 570 options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat( options.formatDate ); 571 } 572 573 if( options.maxDate && /^\+(.*)$/.test(options.maxDate) ) { 574 options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat( options.formatDate ); 575 } 576 577 mounth_picker 578 .find('.xdsoft_today_button') 579 .css('visibility',!options.todayButton?'hidden':'visible'); 580 581 if( options.mask ) { 582 var e, 583 getCaretPos = function ( input ) { 584 try{ 585 if ( document.selection && document.selection.createRange ) { 586 var range = document.selection.createRange(); 587 return range.getBookmark().charCodeAt(2) - 2; 588 }else 589 if ( input.setSelectionRange ) 590 return input.selectionStart; 591 }catch(e) { 592 return 0; 593 } 594 }, 595 setCaretPos = function ( node,pos ) { 596 node = (typeof node == "string" || node instanceof String) ? document.getElementById(node) : node; 597 if(!node) { 598 return false; 599 }else if(node.createTextRange) { 600 var textRange = node.createTextRange(); 601 textRange.collapse(true); 602 textRange.moveEnd(pos); 603 textRange.moveStart(pos); 604 textRange.select(); 605 return true; 606 }else if(node.setSelectionRange) { 607 node.setSelectionRange(pos,pos); 608 return true; 609 } 610 return false; 611 }, 612 isValidValue = function ( mask,value ) { 613 var reg = mask 614 .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,'\\$1') 615 .replace(/_/g,'{digit+}') 616 .replace(/([0-9]{1})/g,'{digit$1}') 617 .replace(/\{digit([0-9]{1})\}/g,'[0-$1_]{1}') 618 .replace(/\{digit[\+]\}/g,'[0-9_]{1}'); 619 return RegExp(reg).test(value); 620 }; 621 input.off('keydown.xdsoft'); 622 switch(true) { 623 case ( options.mask===true ): 624 625 options.mask = options.format 626 .replace(/Y/g,'9999') 627 .replace(/F/g,'9999') 628 .replace(/m/g,'19') 629 .replace(/d/g,'39') 630 .replace(/H/g,'29') 631 .replace(/i/g,'59') 632 .replace(/s/g,'59'); 633 634 case ( $.type(options.mask) == 'string' ): 635 636 if( !isValidValue( options.mask,input.val() ) ) 637 input.val(options.mask.replace(/[0-9]/g,'_')); 638 639 input.on('keydown.xdsoft',function( event ) { 640 var val = this.value, 641 key = event.which; 642 643 switch(true) { 644 case (( key>=KEY0&&key<=KEY9 )||( key>=_KEY0&&key<=_KEY9 ))||(key==BACKSPACE||key==DEL): 645 var pos = getCaretPos(this), 646 digit = ( key!=BACKSPACE&&key!=DEL )?String.fromCharCode((_KEY0 <= key && key <= _KEY9)? key-KEY0 : key):'_'; 647 648 if( (key==BACKSPACE||key==DEL)&&pos ) { 649 pos--; 650 digit='_'; 651 } 652 653 while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 ) 654 pos+=( key==BACKSPACE||key==DEL )?-1:1; 655 656 val = val.substr(0,pos)+digit+val.substr(pos+1); 657 if( $.trim(val)=='' ){ 658 val = options.mask.replace(/[0-9]/g,'_'); 659 }else{ 660 if( pos==options.mask.length ) 661 break; 662 } 663 664 pos+=(key==BACKSPACE||key==DEL)?0:1; 665 while( /[^0-9_]/.test(options.mask.substr(pos,1))&&pos<options.mask.length&&pos>0 ) 666 pos+=(key==BACKSPACE||key==DEL)?-1:1; 667 668 if( isValidValue( options.mask,val ) ) { 669 this.value = val; 670 setCaretPos(this,pos); 671 }else if( $.trim(val)=='' ) 672 this.value = options.mask.replace(/[0-9]/g,'_'); 673 else{ 674 input.trigger('error_input.xdsoft'); 675 } 676 break; 677 case ( !!~([AKEY,CKEY,VKEY,ZKEY,YKEY].indexOf(key))&&ctrlDown ): 678 case !!~([ESC,ARROWUP,ARROWDOWN,ARROWLEFT,ARROWRIGHT,F5,
678CTRLKEY,TAB,ENTER].indexOf(key)): 679 return true; 680 } 681 event.preventDefault(); 682 return false; 683 }); 684 break; 685 } 686 } 687 if( options.validateOnBlur ) { 688 input 689 .off('blur.xdsoft') 690 .on('blur.xdsoft', function() { 691 if( options.allowBlank && !$.trim($(this).val()).length ) { 692 $(this).val(null); 693 datetimepicker.data('xdsoft_datetime').empty(); 694 }else if( !Date.parseDate( $(this).val(), options.format ) ) { 695 $(this).val((_xdsoft_datetime.now()).dateFormat( options.format )); 696 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); 697 } 698 else{ 699 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); 700 } 701 datetimepicker.trigger('changedatetime.xdsoft'); 702 }); 703 } 704 options.dayOfWeekStartPrev = (options.dayOfWeekStart==0)?6:options.dayOfWeekStart-1; 705 706 datetimepicker 707 .trigger('xchange.xdsoft') 708 .trigger('afterOpen.xdsoft') 709 }; 710 711 datetimepicker 712 .data('options',options) 713 .on('mousedown.xdsoft',function( event ) { 714 event.stopPropagation(); 715 event.preventDefault(); 716 yearselect.hide(); 717 monthselect.hide(); 718 return false; 719 }); 720 721 var scroll_element = timepicker.find('.xdsoft_time_box'); 722 scroll_element.append(timebox); 723 scroll_element.xdsoftScroller(); 724 725 datetimepicker.on('afterOpen.xdsoft',function() { 726 scroll_element.xdsoftScroller(); 727 }); 728 729 datetimepicker 730 .append(datepicker) 731 .append(timepicker); 732 733 if( options.withoutCopyright!==true ) 734 datetimepicker 735 .append(xdsoft_copyright); 736 737 datepicker 738 .append(mounth_picker) 739 .append(calendar); 740 741 $('body').append(datetimepicker); 742 743 var _xdsoft_datetime = new function() { 744 var _this = this; 745 _this.now = function( norecursion ) { 746 var d = new Date(); 747 748 if( !norecursion && options.defaultDate ){ 749 var date = _this.strToDate(options.defaultDate); 750 d.setFullYear( date.getFullYear() ); 751 d.setMonth( date.getMonth() ); 752 d.setDate( date.getDate() ); 753 } 754 755 if( options.yearOffset ){ 756 d.setFullYear(d.getFullYear()+options.yearOffset); 757 } 758 759 if( !norecursion && options.defaultTime ){ 760 var time = _this.strtotime(options.defaultTime); 761 d.setHours( time.getHours() ); 762 d.setMinutes( time.getMinutes() ); 763 } 764 765 return d; 766 }; 767 768 769 _this.isValidDate = function (d) { 770 if ( Object.prototype.toString.call(d) !== "[object Date]" ) 771 return false; 772 return !isNaN(d.getTime()); 773 }; 774 775 _this.setCurrentTime = function( dTime ) { 776 _this.currentTime = (typeof dTime == 'string')? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime: _this.now(); 777 datetimepicker.trigger('xchange.xdsoft'); 778 }; 779 780 _this.empty = function() { 781 _this.currentTime = null; 782 }; 783 784 _this.getCurrentTime = function( dTime) { 785 return _this.currentTime; 786 }; 787 788 _this.nextMonth = function() { 789 var month = _this.currentTime.getMonth()+1; 790 if( month==12 ) { 791 _this.currentTime.setFullYear(_this.currentTime.getFullYear()+1); 792 month = 0; 793 } 794 _this.currentTime.setDate( 795 Math.min( 796 Date.daysInMonth[month], 797 _this.currentTime.getDate() 798 ) 799 ); 800 _this.currentTime.setMonth(month); 801 options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 802 datetimepicker.trigger('xchange.xdsoft'); 803 return month; 804 }; 805 806 _this.prevMonth = function() { 807 var month = _this.currentTime.getMonth()-1; 808 if( month==-1 ) { 809 _this.currentTime.setFullYear(_this.currentTime.getFullYear()-1); 810 month = 11; 811 } 812 _this.currentTime.setDate( 813 Math.min( 814 Date.daysInMonth[month], 815 _this.currentTime.getDate() 816 ) 817 ); 818 _this.currentTime.setMonth(month); 819 options.onChangeMonth&&options.onChangeMonth.call&&options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 820 datetimepicker.trigger('xchange.xdsoft'); 821 return month; 822 }; 823 824 _this.strToDateTime = function( sDateTime ) { 825 if( sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime) ) 826 return sDateTime; 827 828 var tmpDate = [],timeOffset,currentTime; 829 830 if( ( tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime) ) && ( tmpDate[2]=Date.parseDate(tmpDate[2], options.formatDate) ) ) { 831 timeOffset = tmpDate[2].getTime()-(tmpDate[2].getTimezoneOffset())*60000; 832 currentTime = new Date((_xdsoft_datetime.now()).getTime()+parseInt(tmpDate[1]+'1')*timeOffset); 833 }else 834 currentTime = sDateTime?Date.parseDate(sDateTime, options.format):_this.now(); 835 836 if( !_this.isValidDate(currentTime) ) 837 currentTime = _this.now(); 838 839 return currentTime; 840 }; 841 842 _this.strToDate = function( sDate ) { 843 if( sDate && sDate instanceof Date && _this.isValidDate(sDate) ) 844 return sDate; 845 846 var currentTime = sDate?Date.parseDate(sDate, options.formatDate):_this.now(true); 847 if( !_this.isValidDate(currentTime) ) 848 currentTime = _this.now(true); 849 850 return currentTime; 851 }; 852 853 _this.strtotime = function( sTime ) { 854 if( sTime && sTime instanceof Date && _this.isValidDate(sTime) ) 855 return sTime; 856 857 var currentTime = sTime?Date.parseDate(sTime, options.formatTime):_this.now(); 858 if( !_this.isValidDate(currentTime) ) 859 currentTime = _this.now(true); 860 861 return currentTime; 862 }; 863 864 _this.str = function() { 865 return _this.currentTime.dateFormat(options.format); 866 }; 867 868 _this.currentTime = this.now(); 869 }; 870 mounth_picker 871 .find('.xdsoft_today_button') 872 .on('mousedown.xdsoft',function() { 873 datetimepicker.data('changed',true); 874 _xdsoft_datetime.setCurrentTime(0); 875 datetimepicker.trigger('afterOpen.xdsoft'); 876 }).on('dblclick.xdsoft',function(){ 877 input.val( _xdsoft_datetime.str() ); 878 datetimepicker.trigger('close.xdsoft'); 879 }); 880 mounth_picker 881 .find('.xdsoft_prev,.xdsoft_next') 882 .on('mousedown.xdsoft',function() { 883 var $this = $(this), 884 timer = 0, 885 stop = false;
886 887 (function arguments_callee1(v) { 888 var month = _xdsoft_datetime.currentTime.getMonth(); 889 if( $this.hasClass( options.next ) ) { 890 _xdsoft_datetime.nextMonth(); 891 }else if( $this.hasClass( options.prev ) ) { 892 _xdsoft_datetime.prevMonth(); 893 } 894 if (options.monthChangeSpinner) { 895 !stop&&(timer = setTimeout(arguments_callee1,v?v:100)); 896 } 897 })(500); 898 899 $([document.body,window]).on('mouseup.xdsoft',function arguments_callee2() { 900 clearTimeout(timer); 901 stop = true; 902 $([document.body,window]).off('mouseup.xdsoft',arguments_callee2); 903 }); 904 }); 905 906 timepicker 907 .find('.xdsoft_prev,.xdsoft_next') 908 .on('mousedown.xdsoft',function() { 909 var $this = $(this), 910 timer = 0, 911 stop = false, 912 period = 110; 913 (function arguments_callee4(v) { 914 var pheight = timeboxparent[0].clientHeight, 915 height = timebox[0].offsetHeight, 916 top = Math.abs(parseInt(timebox.css('marginTop'))); 917 if( $this.hasClass(options.next) && (height-pheight)- options.timeHeightInTimePicker>=top ) { 918 timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px') 919 }else if( $this.hasClass(options.prev) && top-options.timeHeightInTimePicker>=0 ) { 920 timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px') 921 } 922 timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]); 923 period= ( period>10 )?10:period-10; 924 !stop&&(timer = setTimeout(arguments_callee4,v?v:period)); 925 })(500); 926 $([document.body,window]).on('mouseup.xdsoft',function arguments_callee5() { 927 clearTimeout(timer); 928 stop = true; 929 $([document.body,window]) 930 .off('mouseup.xdsoft',arguments_callee5); 931 }); 932 }); 933 934 var xchangeTimer = 0; 935 // base handler - generating a calendar and timepicker 936 datetimepicker 937 .on('xchange.xdsoft',function( event ) { 938 clearTimeout(xchangeTimer); 939 xchangeTimer = setTimeout(function(){ 940 var table = '', 941 start = new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1, 12, 0, 0), 942 i = 0, 943 today = _xdsoft_datetime.now(); 944 945 while( start.getDay()!=options.dayOfWeekStart ) 946 start.setDate(start.getDate()-1); 947 948 //generate calendar 949 table+='<table><thead><tr>'; 950 951 if(options.weeks) { 952 table+='<th></th>'; 953 } 954 955 // days 956 for(var j = 0; j<7; j++) { 957 table+='<th>'+options.i18n[options.lang].dayOfWeek[(j+options.dayOfWeekStart)%7]+'</th>'; 958 } 959 960 table+='</tr></thead>'; 961 table+='<tbody>'; 962 var maxDate = false, minDate = false; 963 964 if( options.maxDate!==false ) { 965 maxDate = _xdsoft_datetime.strToDate(options.maxDate); 966 maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999); 967 } 968 969 if( options.minDate!==false ) { 970 minDate = _xdsoft_datetime.strToDate(options.minDate); 971 minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate()); 972 } 973 974 var d,y,m,w,classes = [],customDateSettings,newRow=true; 975 976 while( i<_xdsoft_datetime.currentTime.countDaysInMonth()||start.getDay()!=options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()==start.getMonth() ) { 977 classes = []; 978 i++; 979 980 d = start.getDate(); y = start.getFullYear(); m = start.getMonth(); w = start.getWeekOfYear(); 981 982 classes.push('xdsoft_date'); 983 984 if ( options.beforeShowDay && options.beforeShowDay.call ) { 985 customDateSettings = options.beforeShowDay.call(datetimepicker, start); 986 } else { 987 customDateSettings = null; 988 } 989 990 if( ( maxDate!==false && start > maxDate )||( minDate!==false && start < minDate )||(customDateSettings && customDateSettings[0] === false) ){ 991 classes.push('xdsoft_disabled'); 992 } 993 994 if ( customDateSettings && customDateSettings[1] != "" ) { 995 classes.push(customDateSettings[1]); 996 } 997 998 if( _xdsoft_datetime.currentTime.getMonth()!=m ) classes.push('xdsoft_other_month'); 999 1000 if( (options.defaultSelect||datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) { 1001 classes.push('xdsoft_current'); 1002 } 1003 1004 if( today.dateFormat( options.formatDate )==start.dateFormat( options.formatDate ) ) { 1005 classes.push('xdsoft_today'); 1006 } 1007 1008 if( start.getDay()==0||start.getDay()==6||~options.weekends.indexOf(start.dateFormat( options.formatDate )) ) { 1009 classes.push('xdsoft_weekend'); 1010 } 1011 1012 if(options.beforeShowDay && typeof options.beforeShowDay == 'function') { 1013 classes.push(options.beforeShowDay(start)) 1014 } 1015 1016 if(newRow) { 1017 table+='<tr>'; 1018 newRow = false;
1019 1020 if(options.weeks) { 1021 table+='<th>'+w+'</th>'; 1022 } 1023 } 1024 1025 table+='<td data-date="'+d+'" data-month="'+m+'" data-year="'+y+'"'+' class="xdsoft_date xdsoft_day_of_week'+start.getDay()+' '+ classes.join(' ')+'">'+ 1026 '<div>'+d+'</div>'+ 1027 '</td>'; 1028 1029 if( start.getDay()==options.dayOfWeekStartPrev ) { 1030 table+='</tr>'; 1031 newRow = true; 1032 } 1033 1034 start.setDate(d+1); 1035 } 1036 table+='</tbody></table>'; 1037 1038 calendar.html(table); 1039 1040 mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]); 1041 mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear()); 1042 1043 // generate timebox 1044 var time = '', 1045 h = '', 1046 m ='', 1047 line_time = function line_time( h,m ) { 1048 var now = _xdsoft_datetime.now(); 1049 now.setHours(h); 1050 h = parseInt(now.getHours()); 1051 now.setMinutes(m); 1052 m = parseInt(now.getMinutes()); 1053 1054 classes = []; 1055 if( (options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()<now.getTime())||(options.minTime!==false&&_xdsoft_datetime.strtotime(options.minTime).getTime()>now.getTime())) 1056 classes.push('xdsoft_disabled'); 1057 if( (options.initTime||options.defaultSelect||datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours())==parseInt(h)&&(options.step>59||Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes()/options.step)*options.step==parseInt(m))) { 1058 if( options.defaultSelect||datetimepicker.data('changed')) { 1059 classes.push('xdsoft_current'); 1060 } else if( options.initTime ) { 1061 classes.push('xdsoft_init_time'); 1062 } 1063 } 1064 if( parseInt(today.getHours())==parseInt(h)&&parseInt(today.getMinutes())==parseInt(m)) 1065 classes.push('xdsoft_today'); 1066 time+= '<div class="xdsoft_time '+classes.join(' ')+'" data-hour="'+h+'" data-minute="'+m+'">'+now.dateFormat(options.formatTime)+'</div>'; 1067 }; 1068 1069 if( !options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length ) { 1070 for( var i=0,j=0;i<(options.hours12?12:24);i++ ) { 1071 for( j=0;j<60;j+=options.step ) { 1072 h = (i<10?'0':'')+i; 1073 m = (j<10?'0':'')+j; 1074 line_time( h,m ); 1075 } 1076 } 1077 }else{ 1078 for( var i=0;i<options.allowTimes.length;i++ ) { 1079 h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours(); 1080 m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes(); 1081 line_time( h,m ); 1082 } 1083 } 1084 1085 timebox.html(time); 1086 1087 var opt = '', 1088 i = 0; 1089 1090 for( i = parseInt(options.yearStart,10)+options.yearOffset;i<= parseInt(options.yearEnd,10)+options.yearOffset;i++ ) { 1091 opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getFullYear()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+i+'</div>'; 1092 } 1093 yearselect.children().eq(0) 1094 .html(opt); 1095 1096 for( i = 0,opt = '';i<= 11;i++ ) { 1097 opt+='<div class="xdsoft_option '+(_xdsoft_datetime.currentTime.getMonth()==i?'xdsoft_current':'')+'" data-value="'+i+'">'+options.i18n[options.lang].months[i]+'</div>'; 1098 } 1099 monthselect.children().eq(0).html(opt); 1100 $(datetimepicker) 1101 .trigger('generate.xdsoft'); 1102 },10); 1103 event.stopPropagation(); 1104 }) 1105 .on('afterOpen.xdsoft',function() { 1106 if( options.timepicker ) { 1107 var classType; 1108 if( timebox.find('.xdsoft_current').length ) { 1109 classType = '.xdsoft_current'; 1110 } else if( timebox.find('.xdsoft_init_time').length ) { 1111 classType = '.xdsoft_init_time'; 1112 } 1113 1114 if( classType ) { 1115 var pheight = timeboxparent[0].clientHeight, 1116 height = timebox[0].offsetHeight, 1117 top = timebox.find(classType).index()*options.timeHeightInTimePicker+1; 1118 if( (height-pheight)<top ) 1119 top = height-pheight; 1120 timeboxparent.trigger('scroll_element.xdsoft_scroller',[parseInt(top)/(height-pheight)]); 1121 }else{ 1122 timeboxparent.trigger('scroll_element.xdsoft_scroller',[0]); 1123 } 1124 } 1125 }); 1126 1127 var timerclick = 0; 1128
1129 calendar 1130 .on('click.xdsoft', 'td', function (xdevent) { 1131 xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap 1132 timerclick++; 1133 var $this = $(this), 1134 currentTime = _xdsoft_datetime.currentTime; 1135 1136 if( currentTime===undefined||currentTime===null ){ 1137 _xdsoft_datetime.currentTime = _xdsoft_datetime.now(); 1138 currentTime = _xdsoft_datetime.currentTime; 1139 } 1140 1141 if( $this.hasClass('xdsoft_disabled') ) 1142 return false; 1143 1144 currentTime.setDate( 1 ); 1145 currentTime.setFullYear( $this.data('year') ); 1146 currentTime.setMonth( $this.data('month') ); 1147 currentTime.setDate( $this.data('date') ); 1148 1149 datetimepicker.trigger('select.xdsoft',[currentTime]); 1150 1151 input.val( _xdsoft_datetime.str() ); 1152 if( (timerclick>1||(options.closeOnDateSelect===true||( options.closeOnDateSelect===0&&!options.timepicker )))&&!options.inline ) { 1153 datetimepicker.trigger('close.xdsoft'); 1154 } 1155 1156 if( options.onSelectDate && options.onSelectDate.call ) { 1157 options.onSelectDate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 1158 } 1159 1160 datetimepicker.data('changed',true); 1161 datetimepicker.trigger('xchange.xdsoft'); 1162 datetimepicker.trigger('changedatetime.xdsoft'); 1163 setTimeout(function(){ 1164 timerclick = 0; 1165 },200); 1166 }); 1167 1168 timebox 1169 .on('click.xdsoft', 'div', function (xdevent) { 1170 xdevent.stopPropagation(); // NAJ: Prevents closing of Pop-ups, Modals and Flyouts 1171 var $this = $(this), 1172 currentTime = _xdsoft_datetime.currentTime; 1173 1174 if( currentTime===undefined||currentTime===null ){ 1175 _xdsoft_datetime.currentTime = _xdsoft_datetime.now(); 1176 currentTime = _xdsoft_datetime.currentTime; 1177 } 1178 1179 if( $this.hasClass('xdsoft_disabled') ) 1180 return false; 1181 currentTime.setHours($this.data('hour')); 1182 currentTime.setMinutes($this.data('minute')); 1183 datetimepicker.trigger('select.xdsoft',[currentTime]); 1184 1185 datetimepicker.data('input').val( _xdsoft_datetime.str() ); 1186 1187 !options.inline&&datetimepicker.trigger('close.xdsoft'); 1188 1189 if( options.onSelectTime&&options.onSelectTime.call ) { 1190 options.onSelectTime.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 1191 } 1192 datetimepicker.data('changed',true); 1193 datetimepicker.trigger('xchange.xdsoft'); 1194 datetimepicker.trigger('changedatetime.xdsoft'); 1195 }); 1196 1197 datetimepicker.mousewheel&&datepicker.mousewheel(function(event, delta, deltaX, deltaY) { 1198 if( !options.scrollMonth ) 1199 return true; 1200 if( delta<0 ) 1201 _xdsoft_datetime.nextMonth(); 1202 else 1203 _xdsoft_datetime.prevMonth(); 1204 return false; 1205 }); 1206 1207 datetimepicker.mousewheel&&timeboxparent.unmousewheel().mousewheel(function(event, delta, deltaX, deltaY) { 1208 if( !options.scrollTime ) 1209 return true; 1210 var pheight = timeboxparent[0].clientHeight, 1211 height = timebox[0].offsetHeight, 1212 top = Math.abs(parseInt(timebox.css('marginTop'))), 1213 fl = true; 1214 if( delta<0 && (height-pheight)-options.timeHeightInTimePicker>=top ) { 1215 timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px'); 1216 fl = false; 1217 }else if( delta>0&&top-options.timeHeightInTimePicker>=0 ) { 1218 timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px'); 1219 fl = false; 1220 } 1221 timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox.css('marginTop'))/(height-pheight))]); 1222 event.stopPropagation(); 1223 return fl; 1224 }); 1225 1226 var triggerAfterOpen = false; 1227 datetimepicker 1228 .on('changedatetime.xdsoft',function() { 1229 if( options.onChangeDateTime&&options.onChangeDateTime.call ) { 1230 var $input = datetimepicker.data('input'); 1231 options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input); 1232 delete options.value; 1233 $input.trigger('change'); 1234 } 1235 }) 1236 .on('generate.xdsoft',function() { 1237 if( options.onGenerate&&options.onGenerate.call ) 1238 options.onGenerate.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 1239 if( triggerAfterOpen ){ 1240 datetimepicker.trigger('afterOpen.xdsoft'); 1241 triggerAfterOpen = false;
1242 } 1243 }) 1244 .on( 'click.xdsoft', function( xdevent ) 1245 { 1246 xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap 1247 }); 1248 1249 var current_time_index = 0; 1250 input.mousewheel&&input.mousewheel(function( event, delta, deltaX, deltaY ) { 1251 if( !options.scrollInput ) 1252 return true; 1253 if( !options.datepicker && options.timepicker ) { 1254 current_time_index = timebox.find('.xdsoft_current').length?timebox.find('.xdsoft_current').eq(0).index():0; 1255 if( current_time_index+delta>=0&¤t_time_index+delta<timebox.children().length ) 1256 current_time_index+=delta; 1257 timebox.children().eq(current_time_index).length&&timebox.children().eq(current_time_index).trigger('mousedown'); 1258 return false; 1259 }else if( options.datepicker && !options.timepicker ) { 1260 datepicker.trigger( event, [delta, deltaX, deltaY]); 1261 input.val&&input.val( _xdsoft_datetime.str() ); 1262 datetimepicker.trigger('changedatetime.xdsoft'); 1263 return false; 1264 } 1265 }); 1266 var setPos = function() { 1267 var offset = datetimepicker.data('input').offset(), top = offset.top+datetimepicker.data('input')[0].offsetHeight-1, left = offset.left, position = "absolute"; 1268 if (options.fixed) { 1269 top -= $(window).scrollTop(); 1270 left -= $(window).scrollLeft(); 1271 position = "fixed"; 1272 }else { 1273 if( top+datetimepicker[0].offsetHeight>$(window).height()+$(window).scrollTop() ) 1274 top = offset.top-datetimepicker[0].offsetHeight+1; 1275 if (top < 0) 1276 top = 0; 1277 if( left+datetimepicker[0].offsetWidth>$(window).width() ) 1278 left = offset.left-datetimepicker[0].offsetWidth+datetimepicker.data('input')[0].offsetWidth; 1279 } 1280 datetimepicker.css({ 1281 left:left, 1282 top:top, 1283 position: position 1284 }); 1285 }; 1286 datetimepicker 1287 .on('open.xdsoft', function() { 1288 var onShow = true; 1289 if( options.onShow&&options.onShow.call) { 1290 onShow = options.onShow.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 1291 } 1292 if( onShow!==false ) { 1293 datetimepicker.show(); 1294 setPos(); 1295 $(window) 1296 .off('resize.xdsoft',setPos) 1297 .on('resize.xdsoft',setPos); 1298 1299 if( options.closeOnWithoutClick ) { 1300 $([document.body,window]).on('mousedown.xdsoft',function arguments_callee6() { 1301 datetimepicker.trigger('close.xdsoft'); 1302 $([document.body,window]).off('mousedown.xdsoft',arguments_callee6); 1303 }); 1304 } 1305 } 1306 }) 1307 .on('close.xdsoft', function( event ) { 1308 var onClose = true; 1309 if( options.onClose&&options.onClose.call ) { 1310 onClose=options.onClose.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input')); 1311 } 1312 if( onClose!==false&&!options.opened&&!options.inline ) { 1313 datetimepicker.hide(); 1314 } 1315 event.stopPropagation(); 1316 }) 1317 .data('input',input); 1318 1319 var timer = 0, 1320 timer1 = 0; 1321 1322 datetimepicker.data('xdsoft_datetime',_xdsoft_datetime); 1323 datetimepicker.setOptions(options); 1324 1325 function getCurrentValue(){ 1326 1327 var ct = false; 1328 1329 if ( options.startDate ) { 1330 ct = _xdsoft_datetime.strToDate(options.startDate); 1331 } else { 1332 ct = options.value?options.value:(input&&input.val&&input.val())?input.val():''; 1333 if( ct ) { 1334 ct = _xdsoft_datetime.strToDateTime(ct); 1335 } else if ( options.defaultDate ) { 1336 ct = _xdsoft_datetime.strToDate(options.defaultDate); 1337 } 1338 } 1339 1340 if ( ct && _xdsoft_datetime.isValidDate(ct) ) { 1341 datetimepicker.data('changed',true); 1342 } else { 1343 ct = ''; 1344 } 1345 1346 return ct?ct:0; 1347 } 1348 //debugger 1349 _xdsoft_datetime.setCurrentTime( getCurrentValue() ); 1350 1351 input 1352 .data( 'xdsoft_datetimepicker',datetimepicker ) 1353 .on('open.xdsoft focusin.xdsoft mousedown.xdsoft',function(event) { 1354 if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||(input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick) ) 1355 return; 1356 clearTimeout(timer); 1357 timer = setTimeout(function() { 1358 if( input.is(':disabled')||input.is(':hidden')||!input.is(':visible') ) 1359 return; 1360 1361 triggerAfterOpen = true; 1362 _xdsoft_datetime.setCurrentTime(getCurrentValue()); 1363 1364 datetimepicker.trigger('open.xdsoft'); 1365 },100); 1366 }) 1367 .on('keydown.xdsoft',function( event ) { 1368 var val = this.value, 1369 key = event.which; 1370 switch(true) { 1371 case !!~([ENTER].indexOf(key)): 1372 var elementSelector = $("input:visible,textarea:visible"); 1373 datetimepicker.trigger('close.xdsoft'); 1374 elementSelector.eq(elementSelector.index(this) + 1).focus(); 1375 return false;
vendor: 5,126 bytes, lines 1376-1459
1376 case !!~[TAB].indexOf(key): 1377 datetimepicker.trigger('close.xdsoft'); 1378 return true; 1379 } 1380 }); 1381 }, 1382 destroyDateTimePicker = function( input ) { 1383 var datetimepicker = input.data('xdsoft_datetimepicker'); 1384 if( datetimepicker ) { 1385 datetimepicker.data('xdsoft_datetime',null); 1386 datetimepicker.remove(); 1387 input 1388 .data( 'xdsoft_datetimepicker',null ) 1389 .off( 'open.xdsoft focusin.xdsoft focusout.xdsoft mousedown.xdsoft blur.xdsoft keydown.xdsoft' ); 1390 $(window).off('resize.xdsoft'); 1391 $([window,document.body]).off('mousedown.xdsoft'); 1392 input.unmousewheel&&input.unmousewheel(); 1393 } 1394 }; 1395 $(document) 1396 .off('keydown.xdsoftctrl keyup.xdsoftctrl') 1397 .on('keydown.xdsoftctrl',function(e) { 1398 if ( e.keyCode == CTRLKEY ) 1399 ctrlDown = true; 1400 }) 1401 .on('keyup.xdsoftctrl',function(e) { 1402 if ( e.keyCode == CTRLKEY ) 1403 ctrlDown = false; 1404 }); 1405 return this.each(function() { 1406 var datetimepicker; 1407 if( datetimepicker = $(this).data('xdsoft_datetimepicker') ) { 1408 if( $.type(opt) === 'string' ) { 1409 switch(opt) { 1410 case 'show': 1411 $(this).select().focus(); 1412 datetimepicker.trigger( 'open.xdsoft' ); 1413 break; 1414 case 'hide': 1415 datetimepicker.trigger('close.xdsoft'); 1416 break; 1417 case 'destroy': 1418 destroyDateTimePicker($(this)); 1419 break; 1420 case 'reset': 1421 this.value = this.defaultValue; 1422 if(!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) 1423 datetimepicker.data('changed',false); 1424 datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value); 1425 break; 1426 } 1427 }else{ 1428 datetimepicker 1429 .setOptions(opt); 1430 } 1431 return 0; 1432 }else 1433 if( ($.type(opt) !== 'string') ){ 1434 if( !options.lazyInit||options.open||options.inline ){ 1435 createDateTimePicker($(this)); 1436 }else 1437 lazyInit($(this)); 1438 } 1439 }); 1440 }; 1441 $.fn.datetimepicker.defaults = default_options; 1442})( jQuery ); 1443 1444/*! 1445 * jQuery Mousewheel 3.1.13 1446 * 1447 * Copyright 2015 jQuery Foundation and other contributors 1448 * Released under the MIT license. 1449 * http://jquery.org/license 1450 */ 1451!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); 1452 1453// Parse and Format Library 1454//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/ 1455/* 1456 * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org> 1457 * 1458 * This program is free software; you can redistribute it and/or modify it 1459 * under the terms of the GNU Lesser General Public License as published by the
1460 * Free Software Foundation, version 2.1. 1461 * 1462 * This program is distributed in the hope that it will be useful, but WITHOUT 1463 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 1464 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 1465 * details. 1466 */ 1467Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+" = function() {return ";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}eval(code.substring(0,code.length-3)+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,
1467s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.