1 2var dropdown_flag = false; 3var calender_base_url=''; 4var date_format=''; 5var picker = ''; 6var currentDate = new Date(); 7var current_day= currentDate.getDate(); 8var flag=true; 9 10if(typeof parameters != "undefined") 11{ 12 for (param in parameters) { 13 if (parameters[param]=='') { 14 alert(param+' is missing'); 15 flag=false; 16 } 17 } 18 19var calender_month_id = document.getElementById(parameters['calender_month_div_id']); 20if (calender_month_id==null) { 21 alert('calender month div not found '); 22 flag=false; 23} 24 25var calender_year_id = document.getElementById(parameters['calender_year_div_id']); 26if (calender_year_id==null) { 27 alert('calender year div not found '); 28 flag=false; 29} 30 31var calender_div_id = document.getElementById(parameters['calender_div_id']); 32if (calender_div_id==null) { 33 alert('calender div not found '); 34 flag=false; 35} 36 37if(flag) { 38 // add click listener 39 var calender_div = document.getElementById(parameters['calender_div_id']); 40 calender_div.addEventListener("click", function() { 41 show_calender(); 42 }); 43} 44 45(function (root, factory) { 46 'use strict'; 47 48 var moment; 49 if (typeof exports === 'object') { 50 // CommonJS module 51 // Load moment.js as an optional dependency 52 try { moment = require('moment'); } catch (e) {} 53 module.exports = factory(moment); 54 } else if (typeof define === 'function' && define.amd) { 55 // AMD. Register as an anonymous module. 56 define(function (req) 57 { 58 // Load moment.js as an optional dependency 59 var id = 'moment'; 60 try { moment = req(id); } catch (e) {} 61 return factory(moment); 62 }); 63 } else { 64 root.Pikaday = factory(root.moment); 65 } 66}(this, function (moment) 67{ 68 'use strict'; 69 70 /** 71 * feature detection and helper functions 72 */ 73 var hasMoment = typeof moment === 'function', 74 75 hasEventListeners = !!window.addEventListener, 76 77 document = window.document, 78 79 sto = window.setTimeout, 80 81 addEvent = function(el, e, callback, capture) 82 { 83 if (hasEventListeners) { 84 el.addEventListener(e, callback, !!capture); 85 } else { 86 el.attachEvent('on' + e, callback); 87 } 88 }, 89 90 removeEvent = function(el, e, callback, capture) 91 { 92 if (hasEventListeners) { 93 el.removeEventListener(e, callback, !!capture); 94 } else { 95 el.detachEvent('on' + e, callback); 96 } 97 }, 98 99 fireEvent = function(el, eventName, data) 100 { 101 var ev; 102 103 if (document.createEvent) { 104 ev = document.createEvent('HTMLEvents'); 105 ev.initEvent(eventName, true, false); 106 ev = extend(ev, data); 107 el.dispatchEvent(ev); 108 } else if (document.createEventObject) { 109 ev = document.createEventObject(); 110 ev = extend(ev, data); 111 el.fireEvent('on' + eventName, ev); 112 } 113 }, 114 115 trim = function(str) 116 { 117 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,''); 118 }, 119 120 hasClass = function(el, cn) 121 { 122 return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1; 123 }, 124 125 addClass = function(el, cn) 126 { 127 if (!hasClass(el, cn)) { 128 el.className = (el.className === '') ? cn : el.className + ' ' + cn; 129 } 130 }, 131 132 removeClass = function(el, cn) 133 { 134 el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' ')); 135 }, 136 137 isArray = function(obj) 138 { 139 return (/Array/).test(Object.prototype.toString.call(obj)); 140 }, 141 142 isDate = function(obj) 143 { 144 return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime()); 145 }, 146 147 isWeekend = function(date) 148 { 149 var day = date.getDay(); 150 return day === 0 || day === 6; 151 }, 152 153 isLeapYear = function(year) 154 { 155 // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951 156 return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0; 157 }, 158 159 getDaysInMonth = function(year, month) 160 { 161 return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; 162 }, 163 164 setToStartOfDay = function(date) 165 { 166 if (isDate(date)) date.setHours(0,0,0,0); 167 }, 168 169 compareDates = function(a,b) 170 { 171 // weak date comparison (use setToStartOfDay(date) to ensure correct result) 172 return a.getTime() === b.getTime(); 173 }, 174 175 extend = function(to, from, overwrite) 176 { 177 var prop, hasProp; 178 for (prop in from) { 179 hasProp = to[prop] !== undefined; 180 if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) { 181 if (isDate(from[prop])) { 182 if (overwrite) { 183 to[prop] = new Date(from[prop].getTime()); 184 } 185 } 186 else if (isArray(from[prop])) { 187 if (overwrite) { 188 to[prop] = from[prop].slice(0); 189 } 190 } else { 191 to[prop] = extend({}, from[prop], overwrite); 192 } 193 } else if (overwrite || !hasProp) { 194 to[prop] = from[prop]; 195 } 196 } 197 return to; 198 }, 199 200 adjustCalendar = function(calendar) { 201 if (calendar.month < 0) { 202 calendar.year -= Math.ceil(Math.abs(calendar.month)/12); 203 calendar.month += 12; 204 } 205 if (calendar.month > 11) { 206 calendar.year += Math.floor(Math.abs(calendar.month)/12); 207 calendar.month -= 12; 208 } 209 return calendar; 210 }, 211 212 /** 213 * defaults and localisation 214 */ 215 defaults = { 216 217 // bind the picker to a form field 218 field: null, 219 220 // automatically show/hide the picker on `field` focus (default `true` if `field` is set) 221 bound: undefined, 222 223 // position of the datepicker, relative to the field (default to bottom & left) 224 // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position) 225 position: 'bottom left', 226 227 // automatically fit in the viewport even if it means repositioning from the position option 228 reposition: true, 229 230 // the default output format for `.toString()` and `field` value 231 format: 'YYYY-MM-DD', 232 233 // the initial date to view when first opened 234 defaultDate: null, 235 236 // make the `defaultDate` the initial selected value 237 setDefaultDate: false, 238 239 // first day of week (0: Sunday, 1: Monday etc) 240 firstDay: 0, 241 242 // the minimum/earliest date that can be selected 243 minDate: null, 244 // the maximum/latest date that can be selected 245 maxDate: null, 246 247 // number of years either side, or array of upper/lower range 248 yearRange: 10, 249 250 // show week numbers at head of row 251 showWeekNumber: false, 252 253 // used internally (don't config outside) 254 minYear: 0, 255 maxYear: 9999, 256 minMonth: undefined, 257 maxMonth: undefined, 258 259 startRange: null, 260 endRange: null, 261 262 isRTL: false, 263 264 // Additional text to append to the year in the calendar title 265 yearSuffix: '', 266 267 // Render the month after year in the calendar title 268 showMonthAfterYear: false, 269 270 // how many months are visible 271 numberOfMonths: 1, 272 273 // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`) 274 // only used for the first display or when a selected date is not visible 275 mainCalendar: 'left', 276 277 // Specify a DOM element to render the calendar in 278 container: undefined, 279 280 // internationalization 281 i18n: { 282 previousMonth : 'Previous Month', 283 nextMonth : 'Next Month', 284 months : ['January','February','March','April','May','June','July','August','September','October','November','December'], 285 weekdays : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], 286 weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'] 287 }, 288 289 // Theme Classname 290 theme: null, 291 292 // callback function 293 onSelect: null, 294 onOpen: null, 295 onClose: null, 296 onDraw: null 297 }, 298 299 300 /** 301 * templating functions to abstract HTML rendering 302 */ 303 renderDayName = function(opts, day, abbr) 304 { 305 day += opts.firstDay; 306 while (day >= 7) { 307 day -= 7; 308 } 309 return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day]; 310 }, 311 312 renderDay = function(opts) 313 { 314 if (opts.isEmpty) { 315 return '<td class="is-empty"></td>'; 316 } 317 var arr = []; 318 if (opts.isDisabled) { 319 arr.push('is-disabled'); 320 } 321 if (opts.isToday) { 322 arr.push('is-today'); 323 } 324 if (opts.isSelected) { 325 arr.push('is-selected'); 326 } 327 if (opts.isInRange) { 328 arr.push('is-inrange'); 329 } 330 if (opts.isStartRange) { 331 arr.push('is-startrange'); 332 } 333 if (opts.isEndRange) { 334 arr.push('is-endrange'); 335 } 336 return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '">' + 337 '<button onclick = "open_url(this);" id="day_' + opts.day + '" class="pika-button pika-day" type="button" ' + 338 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' + 339 opts.day + 340 '</button>' + 341 '</td>'; 342 }, 343 344 renderWeek = function (d, m, y) { 345 // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified. 346 var onejan = new Date(y, 0, 1),
347 weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay()+1)/7); 348 return '<td class="pika-week">' + weekNum + '</td>'; 349 }, 350 351 renderRow = function(days, isRTL) 352 { 353 return '<tr>' + (isRTL ? days.reverse() : days).join('') + '</tr>'; 354 }, 355 356 renderBody = function(rows) 357 { 358 return '<tbody>' + rows.join('') + '</tbody>'; 359 }, 360 361 renderHead = function(opts) 362 { 363 var i, arr = []; 364 if (opts.showWeekNumber) { 365 arr.push('<th></th>'); 366 } 367 for (i = 0; i < 7; i++) { 368 arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>'); 369 } 370 return '<thead>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</thead>'; 371 }, 372 373 renderTitle = function(instance, c, year, month, refYear) 374 { 375 var i, j, arr, 376 opts = instance._o, 377 isMinYear = year === opts.minYear, 378 isMaxYear = year === opts.maxYear, 379 html = '<div class="pika-title">', 380 monthHtml, 381 yearHtml, 382 prev = true, 383 next = true; 384 385 for (arr = [], i = 0; i < 12; i++) { 386 arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' + 387 (i === month ? ' selected': '') + 388 ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled' : '') + '>' + 389 opts.i18n.months[i] + '</option>'); 390 } 391 monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '</div>'; 392 393 if (isArray(opts.yearRange)) { 394 i = opts.yearRange[0]; 395 j = opts.yearRange[1] + 1; 396 } else { 397 i = year - opts.yearRange; 398 j = 1 + year + opts.yearRange; 399 } 400 401// for (arr = []; i < j && i <= opts.maxYear; i++) { 402// if (i >= opts.minYear) { 403// arr.push('<option value="' + i + '"' + (i === year ? ' selected': '') + '>' + (i) + '</option>'); 404// } 405// } 406 yearHtml = '<div class="pika-label">' + year + opts.yearSuffix +'</div>'; 407 408 if (opts.showMonthAfterYear) { 409 html += yearHtml + monthHtml; 410 } else { 411 html += monthHtml + yearHtml; 412 } 413 414 if (isMinYear && (month === 0 || opts.minMonth >= month)) { 415 prev = false; 416 } 417 418 if (isMaxYear && (month === 11 || opts.maxMonth <= month)) { 419 next = false; 420 } 421 422 if (c === 0) { 423 //html += '<button class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>'; 424 } 425 if (c === (instance._o.numberOfMonths - 1) ) { 426 // html += '<button class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>'; 427 } 428 429 return html += '</div>'; 430 }, 431 432 renderTable = function(opts, data) 433 { 434 return '<table cellpadding="0" cellspacing="0" class="pika-table">' + renderHead(opts) + renderBody(data) + '</table>'; 435 }, 436 437 438 /** 439 * Pikaday constructor 440 */ 441 Pikaday = function(options) 442 { 443 var self = this, 444 opts = self.config(options); 445 446 self._onMouseDown = function(e) 447 { 448 if (!self._v) { 449 return; 450 } 451 e = e || window.event; 452 var target = e.target || e.srcElement; 453 if (!target) { 454 return; 455 } 456 457 if (!hasClass(target.parentNode, 'is-disabled')) { 458 if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty')) { 459 // hide dropdowns 460 document.getElementById("calender_month_div_id").style.display = 'none'; 461 document.getElementById("calender_year_div_id").style.display = 'none'; 462 var date_string = new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')); 463 date_string=date_string.format(date_format); 464 // open link of that date 465 window.open(calender_base_url+date_string,'_blank'); 466 //document.getElementById("j_calender_div_id").style.display = 'none'; 467 self.adjustPosition(); 468 self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day'))); 469 if (opts.bound) { 470 sto(function() { 471 self.hide(); 472 if (opts.field) { 473 opts.field.blur(); 474 } 475 }, 100); 476 } 477 } 478 else if (hasClass(target, 'pika-prev')) { 479 self.prevMonth(); 480 } 481 else if (hasClass(target, 'pika-next')) { 482 self.nextMonth(); 483 } 484 } 485 if (!hasClass(target, 'pika-select')) { 486 // if this is touch event prevent mouse events emulation 487 if (e.preventDefault) { 488 e.preventDefault(); 489 } else { 490 e.returnValue = false;
vendor: 10,748 bytes, lines 491-834
491 return false; 492 } 493 } else { 494 self._c = true; 495 } 496 }; 497 498 self._onChange = function(e) 499 { 500 e = e || window.event; 501 var target = e.target || e.srcElement; 502 if (!target) { 503 return; 504 } 505 if (hasClass(target, 'pika-select-month')) { 506 self.gotoMonth(target.value); 507 } 508 else if (hasClass(target, 'pika-select-year')) { 509 self.gotoYear(target.value); 510 } 511 }; 512 513 self._onInputChange = function(e) 514 { 515 var date; 516 517 if (e.firedBy === self) { 518 return; 519 } 520 if (hasMoment) { 521 date = moment(opts.field.value, opts.format); 522 date = (date && date.isValid()) ? date.toDate() : null; 523 } 524 else { 525 date = new Date(Date.parse(opts.field.value)); 526 } 527 if (isDate(date)) { 528 self.setDate(date); 529 } 530 if (!self._v) { 531 self.show(); 532 } 533 }; 534 535 self._onInputFocus = function() 536 { 537 self.show(); 538 }; 539 540 self._onInputClick = function() 541 { 542 self.show(); 543 }; 544 545 self._onInputBlur = function() 546 { 547 // IE allows pika div to gain focus; catch blur the input field 548 var pEl = document.activeElement; 549 do { 550 if (hasClass(pEl, 'pika-single')) { 551 return; 552 } 553 } 554 while ((pEl = pEl.parentNode)); 555 556 if (!self._c) { 557 self._b = sto(function() { 558 self.hide(); 559 }, 50); 560 } 561 self._c = false; 562 }; 563 564 self._onClick = function(e) 565 { 566 e = e || window.event; 567 var target = e.target || e.srcElement, 568 pEl = target; 569 if (!target) { 570 return; 571 } 572 if (!hasEventListeners && hasClass(target, 'pika-select')) { 573 if (!target.onchange) { 574 target.setAttribute('onchange', 'return;'); 575 addEvent(target, 'change', self._onChange); 576 } 577 } 578 do { 579 if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) { 580 return; 581 } 582 } 583 while ((pEl = pEl.parentNode)); 584 if (self._v && target !== opts.trigger && pEl !== opts.trigger) { 585 self.hide(); 586 } 587 }; 588 589 self.el = document.createElement('div'); 590 self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : ''); 591 self.el.id = 'j_calender_div_id'; 592 addEvent(self.el, 'mousedown', self._onMouseDown, true); 593 addEvent(self.el, 'touchend', self._onMouseDown, true); 594 addEvent(self.el, 'change', self._onChange); 595 596 if (opts.field) { 597 if (opts.container) { 598 opts.container.appendChild(self.el); 599 } else if (opts.bound) { 600 document.body.appendChild(self.el); 601 } else { 602 opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling); 603 } 604 addEvent(opts.field, 'change', self._onInputChange); 605 606 if (!opts.defaultDate) { 607 if (hasMoment && opts.field.value) { 608 opts.defaultDate = moment(opts.field.value, opts.format).toDate(); 609 } else { 610 opts.defaultDate = new Date(Date.parse(opts.field.value)); 611 } 612 opts.setDefaultDate = true; 613 } 614 } 615 616 var defDate = opts.defaultDate; 617 618 if (isDate(defDate)) { 619 if (opts.setDefaultDate) { 620 self.setDate(defDate, true); 621 } else { 622 self.gotoDate(defDate); 623 } 624 } else { 625 self.gotoDate(new Date()); 626 } 627 628 if (opts.bound) { 629 this.hide(); 630 self.el.className += ' is-bound'; 631 addEvent(opts.trigger, 'click', self._onInputClick); 632 addEvent(opts.trigger, 'focus', self._onInputFocus); 633 addEvent(opts.trigger, 'blur', self._onInputBlur); 634 } else { 635 this.show(); 636 } 637 }; 638 639 640 /** 641 * public Pikaday API 642 */ 643 Pikaday.prototype = { 644 645 646 /** 647 * configure functionality 648 */ 649 config: function(options) 650 { 651 if (!this._o) { 652 this._o = extend({}, defaults, true); 653 } 654 655 var opts = extend(this._o, options, true); 656 657 opts.isRTL = !!opts.isRTL; 658 659 opts.field = (opts.field && opts.field.nodeName) ? opts.field : null; 660 661 opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null; 662 663 opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field); 664 665 opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field; 666 667 opts.disableWeekends = !!opts.disableWeekends; 668 669 opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null; 670 671 var nom = parseInt(opts.numberOfMonths, 10) || 1; 672 opts.numberOfMonths = nom > 4 ? 4 : nom; 673 674 if (!isDate(opts.minDate)) { 675 opts.minDate = false; 676 } 677 if (!isDate(opts.maxDate)) { 678 opts.maxDate = false; 679 } 680 if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) { 681 opts.maxDate = opts.minDate = false; 682 } 683 if (opts.minDate) { 684 this.setMinDate(opts.minDate); 685 } 686 if (opts.maxDate) { 687 setToStartOfDay(opts.maxDate); 688 opts.maxYear = opts.maxDate.getFullYear(); 689 opts.maxMonth = opts.maxDate.getMonth(); 690 } 691 692 if (isArray(opts.yearRange)) { 693 var fallback = new Date().getFullYear() - 10; 694 opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback; 695 opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback; 696 } else { 697 opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange; 698 if (opts.yearRange > 100) { 699 opts.yearRange = 100; 700 } 701 } 702 703 return opts; 704 }, 705 706 /** 707 * return a formatted string of the current selection (using Moment.js if available) 708 */ 709 toString: function(format) 710 { 711 return !isDate(this._d) ? '' : hasMoment ? moment(this._d).format(format || this._o.format) : this._d.toDateString(); 712 }, 713 714 /** 715 * return a Moment.js object of the current selection (if available) 716 */ 717 getMoment: function() 718 { 719 return hasMoment ? moment(this._d) : null; 720 }, 721 722 /** 723 * set the current selection from a Moment.js object (if available) 724 */ 725 setMoment: function(date, preventOnSelect) 726 { 727 if (hasMoment && moment.isMoment(date)) { 728 this.setDate(date.toDate(), preventOnSelect); 729 } 730 }, 731 732 /** 733 * return a Date object of the current selection 734 */ 735 getDate: function() 736 { 737 return isDate(this._d) ? new Date(this._d.getTime()) : null; 738 }, 739 740 /** 741 * set the current selection 742 */ 743 setDate: function(date, preventOnSelect) 744 { 745 if (!date) { 746 this._d = null; 747 748 if (this._o.field) { 749 this._o.field.value = ''; 750 fireEvent(this._o.field, 'change', { firedBy: this }); 751 } 752 753 return this.draw(); 754 } 755 if (typeof date === 'string') { 756 date = new Date(Date.parse(date)); 757 } 758 if (!isDate(date)) { 759 return; 760 } 761 762 var min = this._o.minDate, 763 max = this._o.maxDate; 764 765 if (isDate(min) && date < min) { 766 date = min; 767 } else if (isDate(max) && date > max) { 768 date = max; 769 } 770 771 this._d = new Date(date.getTime()); 772 setToStartOfDay(this._d); 773 this.gotoDate(this._d); 774 775 if (this._o.field) { 776 this._o.field.value = this.toString(); 777 fireEvent(this._o.field, 'change', { firedBy: this }); 778 } 779 if (!preventOnSelect && typeof this._o.onSelect === 'function') { 780 this._o.onSelect.call(this, this.getDate()); 781 } 782 }, 783 784 /** 785 * change view to a specific date 786 */ 787 gotoDate: function(date) 788 { 789 var newCalendar = true; 790 791 if (!isDate(date)) { 792 return; 793 } 794 795 if (this.calendars) { 796 var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), 797 lastVisibleDate = new Date(this.calendars[this.calendars.length-1].year, this.calendars[this.calendars.length-1].month, 1), 798 visibleDate = date.getTime(); 799 // get the end of the month 800 lastVisibleDate.setMonth(lastVisibleDate.getMonth()+1); 801 lastVisibleDate.setDate(lastVisibleDate.getDate()-1); 802 newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate); 803 } 804 805 if (newCalendar) { 806 this.calendars = [{ 807 month: date.getMonth(), 808 year: date.getFullYear() 809 }]; 810 if (this._o.mainCalendar === 'right') { 811 this.calendars[0].month += 1 - this._o.numberOfMonths; 812 } 813 } 814 815 this.adjustCalendars(); 816 }, 817 818 adjustCalendars: function() { 819 this.calendars[0] = adjustCalendar(this.calendars[0]); 820 for (var c = 1; c < this._o.numberOfMonths; c++) { 821 this.calendars[c] = adjustCalendar({ 822 month: this.calendars[0].month + c, 823 year: this.calendars[0].year 824 }); 825 } 826 this.draw(); 827 }, 828 829 gotoToday: function() 830 { 831 this.gotoDate(new Date()); 832 }, 833 834 /**
835 * change view to a specific month (zero-index, e.g. 0: January) 836 */ 837 gotoMonth: function(month) 838 { 839 if (!isNaN(month)) { 840 this.calendars[0].month = parseInt(month, 10); 841 this.adjustCalendars(); 842 } 843 }, 844 845 nextMonth: function() 846 { 847 this.calendars[0].month++; 848 this.adjustCalendars(); 849 }, 850 851 prevMonth: function() 852 { 853 this.calendars[0].month--; 854 this.adjustCalendars(); 855 }, 856 857 /** 858 * change view to a specific full year (e.g. "2012") 859 */ 860 gotoYear: function(year) 861 { 862 if (!isNaN(year)) { 863 this.calendars[0].year = parseInt(year, 10); 864 this.adjustCalendars(); 865 } 866 }, 867 868 /** 869 * change the minDate 870 */ 871 setMinDate: function(value) 872 { 873 setToStartOfDay(value); 874 this._o.minDate = value; 875 this._o.minYear = value.getFullYear(); 876 this._o.minMonth = value.getMonth(); 877 }, 878 879 /** 880 * change the maxDate 881 */ 882 setMaxDate: function(value) 883 { 884 this._o.maxDate = value; 885 }, 886 887 setStartRange: function(value) 888 { 889 this._o.startRange = value; 890 }, 891 892 setEndRange: function(value) 893 { 894 this._o.endRange = value; 895 }, 896 897 /** 898 * refresh the HTML 899 */ 900 draw: function(force) 901 { 902 if (!this._v && !force) { 903 return; 904 } 905 var opts = this._o, 906 minYear = opts.minYear, 907 maxYear = opts.maxYear, 908 minMonth = opts.minMonth, 909 maxMonth = opts.maxMonth, 910 html = ''; 911 912 if (this._y <= minYear) { 913 this._y = minYear; 914 if (!isNaN(minMonth) && this._m < minMonth) { 915 this._m = minMonth; 916 } 917 } 918 if (this._y >= maxYear) { 919 this._y = maxYear; 920 if (!isNaN(maxMonth) && this._m > maxMonth) { 921 this._m = maxMonth; 922 } 923 } 924 925 for (var c = 0; c < opts.numberOfMonths; c++) { 926 html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year) + this.render(this.calendars[c].year, this.calendars[c].month) + '</div>'; 927 } 928 929 this.el.innerHTML = html; 930 931 if (opts.bound) { 932 if(opts.field.type !== 'hidden') { 933 sto(function() { 934 opts.trigger.focus(); 935 }, 1); 936 } 937 } 938 939 if (typeof this._o.onDraw === 'function') { 940 var self = this; 941 sto(function() { 942 self._o.onDraw.call(self); 943 }, 0); 944 } 945 }, 946 947 adjustPosition: function() 948 { 949 var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect; 950 951 if (this._o.container) return; 952 953 //this.el.style.position = ''; 954 955 field = this._o.trigger; 956 pEl = field; 957 width = this.el.offsetWidth; 958 height = this.el.offsetHeight; 959 viewportWidth = window.innerWidth || document.documentElement.clientWidth; 960 viewportHeight = window.innerHeight || document.documentElement.clientHeight; 961 scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; 962 963 if (typeof field.getBoundingClientRect === 'function') { 964 clientRect = field.getBoundingClientRect(); 965 left = clientRect.left + window.pageXOffset; 966 top = clientRect.bottom + window.pageYOffset; 967 } else { 968 left = pEl.offsetLeft; 969 top = pEl.offsetTop + pEl.offsetHeight; 970 while((pEl = pEl.offsetParent)) { 971 left += pEl.offsetLeft; 972 top += pEl.offsetTop; 973 } 974 } 975 976 // default position is bottom & left 977 if ((this._o.reposition && left + width > viewportWidth) || 978 ( 979 this._o.position.indexOf('right') > -1 &&
980 left - width + field.offsetWidth > 0 981 ) 982 ) { 983 left = left - width + field.offsetWidth; 984 } 985 if ((this._o.reposition && top + height > viewportHeight + scrollTop) || 986 ( 987 this._o.position.indexOf('top') > -1 && 988 top - height - field.offsetHeight > 0 989 ) 990 ) { 991 top = top - height - field.offsetHeight; 992 } 993 994 //this.el.style.left = left + 'px'; 995 //top=top+28; 996 // this.el.style.top = top + 'px'; 997 }, 998 999 /** 1000 * render HTML for a particular month 1001 */ 1002 render: function(year, month) 1003 { 1004 var opts = this._o, 1005 now = new Date(), 1006 days = getDaysInMonth(year, month), 1007 before = new Date(year, month, 1).getDay(), 1008 data = [], 1009 row = []; 1010 setToStartOfDay(now); 1011 if (opts.firstDay > 0) { 1012 before -= opts.firstDay; 1013 if (before < 0) { 1014 before += 7; 1015 } 1016 } 1017 var cells = days + before, 1018 after = cells; 1019 while(after > 7) { 1020 after -= 7; 1021 } 1022 cells += 7 - after; 1023 for (var i = 0, r = 0; i < cells; i++) 1024 { 1025 var day = new Date(year, month, 1 + (i - before)), 1026 isSelected = isDate(this._d) ? compareDates(day, this._d) : false, 1027 isToday = compareDates(day, now), 1028 isEmpty = i < before || i >= (days + before), 1029 isStartRange = opts.startRange && compareDates(opts.startRange, day), 1030 isEndRange = opts.endRange && compareDates(opts.endRange, day), 1031 isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange, 1032 isDisabled = (opts.minDate && day < opts.minDate) || 1033 (opts.maxDate && day > opts.maxDate) || 1034 (opts.disableWeekends && isWeekend(day)) || 1035 (opts.disableDayFn && opts.disableDayFn(day)), 1036 dayConfig = { 1037 day: 1 + (i - before), 1038 month: month, 1039 year: year, 1040 isSelected: isSelected, 1041 isToday: isToday, 1042 isDisabled: isDisabled, 1043 isEmpty: isEmpty, 1044 isStartRange: isStartRange, 1045 isEndRange: isEndRange, 1046 isInRange: isInRange 1047 }; 1048 1049 row.push(renderDay(dayConfig)); 1050 1051 if (++r === 7) { 1052 if (opts.showWeekNumber) { 1053 row.unshift(renderWeek(i - before, month, year)); 1054 } 1055 data.push(renderRow(row, opts.isRTL)); 1056 row = []; 1057 r = 0; 1058 } 1059 } 1060 return renderTable(opts, data); 1061 }, 1062 1063 isVisible: function() 1064 { 1065 return this._v; 1066 }, 1067 1068 show: function() 1069 { 1070 if (!this._v) { 1071 removeClass(this.el, 'is-hidden'); 1072 this._v = true; 1073 this.draw(); 1074 if (this._o.bound) { 1075 // addEvent(document, 'click', this._onClick); 1076 this.adjustPosition(); 1077 } 1078 if (typeof this._o.onOpen === 'function') { 1079 this._o.onOpen.call(this); 1080 } 1081 } 1082 //console.log(this.el.outerHTML); 1083 var calender_div = document.getElementById(parameters['calender_div_id']); 1084 var calender_html = document.getElementById('j_calender_div_id'); 1085 calender_html.parentNode.removeChild(calender_html); 1086 calender_div.innerHTML = this.el.outerHTML; 1087 }, 1088 1089 hide: function() 1090 { 1091 var v = this._v; 1092 if (v !== false) { 1093 if (this._o.bound) { 1094 removeEvent(document, 'click', this._onClick); 1095 } 1096// this.el.style.position = 'static'; // reset 1097// this.el.style.left = 'auto'; 1098// this.el.style.top = 'auto'; 1099 addClass(this.el, 'is-hidden'); 1100 this._v = false;
1101 if (v !== undefined && typeof this._o.onClose === 'function') { 1102 this._o.onClose.call(this); 1103 } 1104 } 1105 }, 1106 1107 /** 1108 * GAME OVER 1109 */ 1110 destroy: function() 1111 { 1112 this.hide(); 1113 removeEvent(this.el, 'mousedown', this._onMouseDown, true); 1114 removeEvent(this.el, 'touchend', this._onMouseDown, true); 1115 removeEvent(this.el, 'change', this._onChange); 1116 if (this._o.field) { 1117 removeEvent(this._o.field, 'change', this._onInputChange); 1118 if (this._o.bound) { 1119 removeEvent(this._o.trigger, 'click', this._onInputClick); 1120 removeEvent(this._o.trigger, 'focus', this._onInputFocus); 1121 removeEvent(this._o.trigger, 'blur', this._onInputBlur); 1122 } 1123 } 1124 if (this.el.parentNode) { 1125 this.el.parentNode.removeChild(this.el); 1126 } 1127 } 1128 1129 }; 1130 1131 return Pikaday; 1132 1133})); 1134/* 1135 * Date Format 1.2.3 1136 * (c) 2007-2009 Steven Levithan <stevenlevithan.com> 1137 * MIT license 1138 * 1139 * Includes enhancements by Scott Trenda <scott.trenda.net> 1140 * and Kris Kowal <cixar.com/~kris.kowal/> 1141 * 1142 * Accepts a date, a mask, or a date and a mask. 1143 * Returns a formatted version of the given date. 1144 * The date defaults to the current date/time. 1145 * The mask defaults to dateFormat.masks.default. 1146 */ 1147 1148var dateFormat = function () { 1149 var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, 1150 timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, 1151 timezoneClip = /[^-+\dA-Z]/g, 1152 pad = function (val, len) { 1153 val = String(val); 1154 len = len || 2; 1155 while (val.length < len) val = "0" + val; 1156 return val; 1157 }; 1158 1159 // Regexes and supporting functions are cached through closure 1160 return function (date, mask, utc) { 1161 var dF = dateFormat; 1162 1163 // You can't provide utc if you skip other args (use the "UTC:" mask prefix) 1164 if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { 1165 mask = date; 1166 date = undefined; 1167 } 1168 1169 // Passing date through Date applies Date.parse, if necessary 1170 date = date ? new Date(date) : new Date; 1171 if (isNaN(date)) throw SyntaxError("invalid date"); 1172 1173 mask = String(dF.masks[mask] || mask || dF.masks["default"]); 1174 1175 // Allow setting the utc argument via the mask 1176 if (mask.slice(0, 4) == "UTC:") { 1177 mask = mask.slice(4); 1178 utc = true; 1179 } 1180 1181 var _ = utc ? "getUTC" : "get", 1182 d = date[_ + "Date"](), 1183 D = date[_ + "Day"](), 1184 m = date[_ + "Month"](), 1185 y = date[_ + "FullYear"](), 1186 H = date[_ + "Hours"](), 1187 M = date[_ + "Minutes"](), 1188 s = date[_ + "Seconds"](), 1189 L = date[_ + "Milliseconds"](), 1190 o = utc ? 0 : date.getTimezoneOffset(), 1191 flags = { 1192 d: d, 1193 dd: pad(d), 1194 ddd: dF.i18n.dayNames[D], 1195 dddd: dF.i18n.dayNames[D + 7], 1196 m: m + 1, 1197 mm: pad(m + 1), 1198 mmm: dF.i18n.monthNames[m], 1199 mmmm: dF.i18n.monthNames[m + 12], 1200 yy: String(y).slice(2), 1201 yyyy: y, 1202 h: H % 12 || 12, 1203 hh: pad(H % 12 || 12), 1204 H: H, 1205 HH: pad(H), 1206 M: M, 1207 MM: pad(M), 1208 s: s, 1209 ss: pad(s), 1210 l: pad(L, 3), 1211 L: pad(L > 99 ? Math.round(L / 10) : L), 1212 t: H < 12 ? "a" : "p", 1213 tt: H < 12 ? "am" : "pm", 1214 T: H < 12 ? "A" : "P", 1215 TT: H < 12 ? "AM" : "PM", 1216 Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), 1217 o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), 1218 S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] 1219 }; 1220 1221 return mask.replace(token, function ($0) { 1222 return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); 1223 }); 1224 }; 1225}(); 1226 1227// Some common format strings 1228dateFormat.masks = { 1229 "default": "ddd mmm dd yyyy HH:MM:ss", 1230 shortDate: "m/d/yy", 1231 mediumDate: "mmm d, yyyy", 1232 longDate: "mmmm d, yyyy", 1233 fullDate: "dddd, mmmm d, yyyy", 1234 shortTime: "h:MM TT", 1235 mediumTime: "h:MM:ss TT", 1236 longTime: "h:MM:ss TT Z", 1237 isoDate: "yyyy-mm-dd", 1238 isoTime: "HH:MM:ss", 1239 isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", 1240 isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" 1241}; 1242 1243// Internationalization strings 1244dateFormat.i18n = { 1245 dayNames: [ 1246 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 1247 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" 1248 ], 1249 monthNames: [ 1250 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 1251 "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "
1251November", "December" 1252 ] 1253}; 1254 1255// For convenience... 1256Date.prototype.format = function (mask, utc) { 1257 return dateFormat(this, mask, utc); 1258}; 1259 1260// user defined functions 1261function show_calender () { 1262 if(!dropdown_flag) 1263 { 1264 if(flag) 1265 { 1266 var currentTime = new Date(); 1267 // returns the month (from 0 to 11) 1268 var current_month = currentTime.getMonth() + 1; 1269 // returns the year (four digits) 1270 var current_year = currentTime.getFullYear(); 1271 // set calender properties 1272 picker = new Pikaday( 1273 { 1274 field: document.getElementById(parameters['calender_div_id']), 1275 format: parameters['date_format'] 1276 }); 1277 calender_base_url = parameters['base_url']; 1278 date_format = parameters['date_format']; 1279 dropdown_flag = true; 1280 document.getElementById(parameters['calender_month_div_id']).style.display = 'block'; 1281 document.getElementById(parameters['calender_year_div_id']).style.display = 'block'; 1282 picker.setMaxDate(currentDate); 1283 picker.show(); 1284 1285 var month = document.getElementById(parameters['calender_month_div_id']); 1286 1287 month.addEventListener("change", function() { 1288 calender_widget(); 1289 }); 1290 var year = document.getElementById(parameters['calender_year_div_id']); 1291 1292 year.addEventListener("change", function() { 1293 calender_widget(); 1294 }); 1295 } 1296 } 1297 else 1298 { 1299 document.getElementById(parameters['calender_month_div_id']).style.display = 'block'; 1300 document.getElementById(parameters['calender_year_div_id']).style.display = 'block'; 1301 document.getElementById("j_calender_div_id").style.display = 'block'; 1302 } 1303} 1304 1305function calender_widget() { 1306 var month = document.getElementById(parameters['calender_month_div_id']);
1307 month = month.value; 1308 month=month-1; 1309 var year = document.getElementById(parameters['calender_year_div_id']); 1310 year =year.value; 1311 picker.setDate(new Date(year, month, current_day)); 1312 picker.show(); 1313} 1314 1315if(flag) { 1316 show_calender(); 1317} 1318 1319 function open_url(ele) 1320 { 1321 var calender_type = parameters['calender_type']; 1322 var date_string = new Date(picker.calendars[0].year, picker.calendars[0].month,ele.getAttribute("data-pika-day")); 1323 date_string = date_string.format(date_format); 1324 var page_number = parameters['page_number']; 1325 if (calender_type !== null && calender_type !== undefined && calender_type === 'todays-paper') { 1326 window.open(calender_base_url+'archives/'+date_string,'_self'); 1327 } 1328 else if(calender_type !== null && calender_type !== undefined && calender_type === 'epaper' ){ 1329 var edition = document.getElementById(parameters['epaper_edition']); 1330 var selected_edition = edition.options[edition.selectedIndex].value; 1331 var no_wrapper = location.search.split('?')[1] ? location.search.split('?')[1] : ''; 1332 if ( no_wrapper === '' ){ 1333 window.open(calender_base_url+'E-Paper/'+selected_edition+'/'+date_string+'/page-1','_self'); 1334 }else{ 1335 window.open(calender_base_url+'E-Paper/'+selected_edition+'/'+date_string+'/page-1?no-wrapper','_self'); 1336 } 1337 } 1338 else if(calender_type !== null && calender_type !== undefined && calender_type === 'category'){ 1339 var category_name = parameters['category_name']; 1340 window.open(calender_base_url+'archives/'+date_string+'/'+category_name,'_self'); 1341 } 1342 else if(calender_type !== null && calender_type !== undefined && calender_type === 'category_archives'){ 1343 var category_name = parameters['category_name']; 1344 window.open(calender_base_url+'archives/'+date_string+'/'+category_name,'_self'); 1345 } 1346 else if(calender_type !== null && calender_type !== undefined && calender_type === 'archives'){ 1347 window.open(calender_base_url+'archives/'+date_string,'_self'); 1348 } 1349 1350 var day_id = $(ele).attr('id'); 1351 setTimeout(function(){ 1352 $('#'+day_id).addClass('pick_aday_hover_class'); 1353 },50); 1354 } 1355}
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.