PageSourceSearch

https://news.playtika.com/js/wd_wai_datepicker_day.js

js playtika.com collected 2026-10-01 09:08:48 UTC 4,111 bytes, 186 lines download raw bytes

1/*
2*   This content is licensed according to the W3C Software License at
3*   https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
4*
5*   File:   datepickerDay.js
6*/
7
8var DatePickerDay = function (domNode, datepicker, index, row, column) {
9
10  this.index = index;
11  this.row = row;
12  this.column = column;
13
14  this.day = new Date();
15
16  this.domNode = domNode;
17  this.datepicker = datepicker;
18
19  this.keyCode = Object.freeze({
20    'TAB': 9,
21    'ENTER': 13,
22    'ESC': 27,
23    'SPACE': 32,
24    'PAGEUP': 33,
25    'PAGEDOWN': 34,
26    'END': 35,
27    'HOME': 36,
28    'LEFT': 37,
29    'UP': 38,
30    'RIGHT': 39,
31    'DOWN': 40
32  });
33};
34
35DatePickerDay.prototype.init = function () {
36  this.domNode.setAttribute('tabindex', '-1');
37  this.domNode.addEventListener('mousedown', this.handleMouseDown.bind(this));
38  this.domNode.addEventListener('keydown', this.handleKeyDown.bind(this));
39  this.domNode.addEventListener('focus', this.handleFocus.bind(this));
40
41  this.domNode.innerHTML = '-1';
42
43};
44
45DatePickerDay.prototype.isDisabled = function () {
46  return this.domNode.classList.contains('disabled');
47};
48
49DatePickerDay.prototype.updateDay = function (disable, day) {
50
51  if (disable) {
52    this.domNode.classList.add('disabled');
53  }
54  else {
55    this.domNode.classList.remove('disabled');
56  }
57
58  this.day = new Date(day);
59
60  this.domNode.innerHTML = this.day.getDate();
61  this.domNode.setAttribute('tabindex', '-1');
62  this.domNode.removeAttribute('aria-selected');
63
64  var d = this.day.getDate().toString();
65  if (this.day.getDate() < 9) {
66    d = '0' + d;
67  }
68
69  var m = this.day.getMonth() + 1;
70  if (this.day.getMonth() < 9) {
71    m = '0' + m;
72  }
73
74  this.domNode.setAttribute('data-date', this.day.getFullYear() + '-' + m + '-' + d);
75
76};
77
78DatePickerDay.prototype.handleKeyDown = function (event) {
79  var flag = false;
80
81  switch (event.keyCode) {
82
83    case this.keyCode.ESC:
84      this.datepicker.hide();
85      break;
86
87    case this.keyCode.TAB:
88      this.datepicker.cancelButtonNode.focus();
89      if (event.shiftKey) {
90        this.datepicker.nextYearNode.focus();
91      }
92      //this.datepicker.setMessage('');
93      flag = true;
94      break;
95
96    case this.keyCode.ENTER:
97    case this.keyCode.SPACE:
98      this.datepicker.setTextboxDate(this.day);
99	  if(this.datepicker.isStaticDisplay) 
100		this.datepicker.moveFocusToDay(this.day);
101	  else 
102		this.datepicker.hide();
103      flag = true;
104      break;
105
106    case this.keyCode.RIGHT: 
107	 console.log('dayddd' + flag);
108      this.datepicker.moveFocusToNextDay();
109      flag = true;
110      break;
111
112    case this.keyCode.LEFT:
113      this.datepicker.moveFocusToPreviousDay();
114      flag = true;
115      break;
116
117    case this.keyCode.DOWN:
118      this.datepicker.moveFocusToNextWeek();
119      flag = true;
120      break;
121
122    case this.keyCode.UP:
123      this.datepicker.moveFocusToPreviousWeek();
124      flag = true;
125      break;
126
127    case this.keyCode.PAGEUP:
128      if (event.shiftKey) {
129        this.datepicker.moveToPreviousYear();
130      }
131      else {
132        this.datepicker.moveToPreviousMonth();
133      }
134      flag = true;
135      break;
136
137    case this.keyCode.PAGEDOWN:
138      if (event.shiftKey) {
139        this.datepicker.moveToNextYear();
140      }
141      else {
142        this.datepicker.moveToNextMonth();
143      }
144      flag = true;
145      break;
146
147    case this.keyCode.HOME:
148      this.datepicker.moveFocusToFirstDayOfWeek();
149      flag = true;
150      break;
151
152    case this.keyCode.END:
153      this.datepicker.moveFocusToLastDayOfWeek();
154      flag = true;
155      break;
156  } 
157		
158  if (flag) {
159    event.stopPropagation();
160    event.preventDefault();
161  }
162
163};
164
165DatePickerDay.prototype.handleMouseDown = function (event) {
166 
167  if (this.isDisabled()) {
168    this.datepicker.moveFocusToDay(this.date);
169  }
170  else {
171    this.datepicker.setTextboxDate(this.day);
172    if(this.datepicker.isStaticDisplay) {
173		this.datepicker.moveFocusToDay(this.day);
174	} else  
175		this.datepicker.hide();
176  }
177
178  event.stopPropagation();
179  event.preventDefault();
180
181};
182
183DatePickerDay.prototype.handleFocus = function () {
184  //this.datepicker.setMessage(this.datepicker.messageCursorKeys);
185};
186

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.