[3930] | 1 | /*global getData */ |
---|
| 2 | /*exported datePicker */ |
---|
[3706] | 3 | 'use strict'; |
---|
[2566] | 4 | |
---|
[3706] | 5 | function datePicker(target) { |
---|
| 6 | if (!document.getElementById) { |
---|
| 7 | return; |
---|
| 8 | } |
---|
[2566] | 9 | |
---|
[3706] | 10 | if (!target || target.nodeName.toLowerCase() != 'input') { |
---|
| 11 | return; |
---|
| 12 | } |
---|
[2566] | 13 | |
---|
[3706] | 14 | this.target = target; |
---|
| 15 | this.oTable = document.createElement('table'); |
---|
| 16 | this.oBody = document.createElement('tbody'); |
---|
| 17 | this.oDates = []; |
---|
| 18 | this.oMonth = document.createElement('span'); |
---|
| 19 | this.oYear = document.createElement('span'); |
---|
| 20 | this.oHour = document.createElement('input'); |
---|
| 21 | this.oMinute = document.createElement('input'); |
---|
| 22 | this.oTable.id = 'dc_datepicker_' + target.id; |
---|
| 23 | this.oTable.className = 'date-picker'; |
---|
[2566] | 24 | |
---|
[3880] | 25 | let cur = 1; |
---|
| 26 | let oRow; |
---|
| 27 | let oHeading; |
---|
| 28 | let oSpan; |
---|
[2566] | 29 | |
---|
[3706] | 30 | // Set title |
---|
| 31 | oRow = document.createElement('tr'); |
---|
[2566] | 32 | |
---|
[3706] | 33 | // Month block |
---|
| 34 | oHeading = document.createElement('th'); |
---|
| 35 | oHeading.colSpan = 4; |
---|
| 36 | oHeading.className = 'date-picker-month'; |
---|
[2566] | 37 | |
---|
[3880] | 38 | let nav = document.createElement('span'); |
---|
[3706] | 39 | nav.appendChild(document.createTextNode(String.fromCharCode(171))); |
---|
| 40 | nav.fn = this.changeMonth; |
---|
| 41 | nav.obj = this; |
---|
| 42 | nav.onclick = function() { |
---|
| 43 | this.fn.call(this.obj, -1); |
---|
| 44 | }; |
---|
| 45 | nav.className = 'date-picker-control'; |
---|
| 46 | oHeading.appendChild(nav); |
---|
[2566] | 47 | |
---|
[3706] | 48 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
[2566] | 49 | |
---|
[3706] | 50 | nav = document.createElement('span'); |
---|
| 51 | nav.appendChild(document.createTextNode(String.fromCharCode(187))); |
---|
| 52 | nav.fn = this.changeMonth; |
---|
| 53 | nav.obj = this; |
---|
| 54 | nav.onclick = function() { |
---|
| 55 | this.fn.call(this.obj, +1); |
---|
| 56 | }; |
---|
| 57 | nav.className = 'date-picker-control'; |
---|
| 58 | oHeading.appendChild(nav); |
---|
[2566] | 59 | |
---|
[3706] | 60 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
[2566] | 61 | |
---|
[3706] | 62 | oHeading.appendChild(this.oMonth); |
---|
[2566] | 63 | |
---|
[3706] | 64 | oRow.appendChild(oHeading); |
---|
[2566] | 65 | |
---|
[3706] | 66 | // Year block |
---|
| 67 | oHeading = document.createElement('th'); |
---|
| 68 | oHeading.colSpan = 3; |
---|
| 69 | oHeading.className = 'date-picker-year'; |
---|
[2566] | 70 | |
---|
[3706] | 71 | oHeading.appendChild(this.oYear); |
---|
[2566] | 72 | |
---|
[3706] | 73 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
[2566] | 74 | |
---|
[3706] | 75 | nav = document.createElement('span'); |
---|
| 76 | nav.appendChild(document.createTextNode(String.fromCharCode(171))); |
---|
| 77 | nav.fn = this.changeYear; |
---|
| 78 | nav.obj = this; |
---|
| 79 | nav.onclick = function() { |
---|
| 80 | this.fn.call(this.obj, -1); |
---|
| 81 | }; |
---|
| 82 | nav.className = 'date-picker-control'; |
---|
| 83 | oHeading.appendChild(nav); |
---|
[2566] | 84 | |
---|
[3706] | 85 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
[2566] | 86 | |
---|
[3706] | 87 | nav = document.createElement('span'); |
---|
| 88 | nav.appendChild(document.createTextNode(String.fromCharCode(187))); |
---|
| 89 | nav.fn = this.changeYear; |
---|
| 90 | nav.obj = this; |
---|
| 91 | nav.onclick = function() { |
---|
| 92 | this.fn.call(this.obj, +1); |
---|
| 93 | }; |
---|
| 94 | nav.className = 'date-picker-control'; |
---|
| 95 | oHeading.appendChild(nav); |
---|
[2566] | 96 | |
---|
[3706] | 97 | oRow.appendChild(oHeading); |
---|
[2566] | 98 | |
---|
[3706] | 99 | this.oBody.appendChild(oRow); |
---|
[2566] | 100 | |
---|
[3706] | 101 | // Create legend |
---|
| 102 | oRow = document.createElement('tr'); |
---|
[3880] | 103 | for (let i = 0; i < this.days.length; i++) { |
---|
| 104 | const cday = this.days[i].substring(0, 1).toUpperCase(); |
---|
[3706] | 105 | oHeading = document.createElement('th'); |
---|
| 106 | oHeading.appendChild(document.createTextNode(cday)); |
---|
| 107 | oHeading.setAttribute('title', this.days[i]); |
---|
| 108 | oRow.appendChild(oHeading); |
---|
| 109 | } |
---|
| 110 | this.oBody.appendChild(oRow); |
---|
[2566] | 111 | |
---|
[3706] | 112 | // Create 6 rows of 7 cols for days |
---|
[3880] | 113 | for (let i = 0; i < 6; i++) { |
---|
[3706] | 114 | oRow = document.createElement('tr'); |
---|
[2566] | 115 | |
---|
[3880] | 116 | for (let j = 0; j < 7; j++) { |
---|
[3706] | 117 | this.oDates[cur] = document.createElement('td'); |
---|
| 118 | this.oDates[cur].appendChild(document.createTextNode( |
---|
| 119 | String.fromCharCode(160))); |
---|
| 120 | oRow.appendChild(this.oDates[cur]); |
---|
| 121 | cur++; |
---|
| 122 | } |
---|
[2566] | 123 | |
---|
[3706] | 124 | this.oBody.appendChild(oRow); |
---|
| 125 | } |
---|
[2566] | 126 | |
---|
[3706] | 127 | // Time controls |
---|
| 128 | oRow = document.createElement('tr'); |
---|
[2566] | 129 | |
---|
[3706] | 130 | oHeading = document.createElement('th'); |
---|
| 131 | oHeading.className = 'date-picker-control'; |
---|
| 132 | oHeading.appendChild(document.createTextNode('!')); |
---|
| 133 | oHeading.setAttribute('title', this.now_msg); |
---|
| 134 | oHeading.fn = this.sendNow; |
---|
| 135 | oHeading.obj = this; |
---|
| 136 | oHeading.onclick = function() { |
---|
| 137 | this.fn.call(this.obj); |
---|
| 138 | }; |
---|
[2566] | 139 | |
---|
[3706] | 140 | oRow.appendChild(oHeading); |
---|
[2566] | 141 | |
---|
[3706] | 142 | oHeading = document.createElement('th'); |
---|
| 143 | oHeading.colSpan = 5; |
---|
[2566] | 144 | |
---|
[3706] | 145 | oSpan = document.createElement('span'); |
---|
| 146 | oSpan.className = 'date-picker-control'; |
---|
| 147 | oSpan.appendChild(document.createTextNode('-')); |
---|
| 148 | oSpan.fn = this.changeHour; |
---|
| 149 | oSpan.obj = this; |
---|
| 150 | oSpan.onclick = function() { |
---|
| 151 | this.fn.call(this.obj, -1); |
---|
| 152 | }; |
---|
| 153 | oHeading.appendChild(oSpan); |
---|
| 154 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
| 155 | oSpan = document.createElement('span'); |
---|
| 156 | oSpan.className = 'date-picker-control'; |
---|
| 157 | oSpan.appendChild(document.createTextNode('+')); |
---|
| 158 | oSpan.fn = this.changeHour; |
---|
| 159 | oSpan.obj = this; |
---|
| 160 | oSpan.onclick = function() { |
---|
| 161 | this.fn.call(this.obj, +1); |
---|
| 162 | }; |
---|
| 163 | oHeading.appendChild(oSpan); |
---|
| 164 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
[2566] | 165 | |
---|
[3706] | 166 | this.oHour.size = 2; |
---|
| 167 | oHeading.appendChild(this.oHour); |
---|
[2566] | 168 | |
---|
[3706] | 169 | oHeading.appendChild(document.createTextNode(' : ')); |
---|
[2566] | 170 | |
---|
[3706] | 171 | this.oMinute.size = 2; |
---|
| 172 | oHeading.appendChild(this.oMinute); |
---|
[2566] | 173 | |
---|
[3706] | 174 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
| 175 | oSpan = document.createElement('span'); |
---|
| 176 | oSpan.className = 'date-picker-control'; |
---|
| 177 | oSpan.appendChild(document.createTextNode('-')); |
---|
| 178 | oSpan.fn = this.changeMinute; |
---|
| 179 | oSpan.obj = this; |
---|
| 180 | oSpan.onclick = function() { |
---|
| 181 | this.fn.call(this.obj, -1); |
---|
| 182 | }; |
---|
| 183 | oHeading.appendChild(oSpan); |
---|
| 184 | oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); |
---|
| 185 | oSpan = document.createElement('span'); |
---|
| 186 | oSpan.className = 'date-picker-control'; |
---|
| 187 | oSpan.appendChild(document.createTextNode('+')); |
---|
| 188 | oSpan.fn = this.changeMinute; |
---|
| 189 | oSpan.obj = this; |
---|
| 190 | oSpan.onclick = function() { |
---|
| 191 | this.fn.call(this.obj, +1); |
---|
| 192 | }; |
---|
[2566] | 193 | |
---|
[3706] | 194 | oHeading.appendChild(oSpan); |
---|
[2566] | 195 | |
---|
[3706] | 196 | oRow.appendChild(oHeading); |
---|
[2566] | 197 | |
---|
[3706] | 198 | // Close control |
---|
| 199 | oHeading = document.createElement('th'); |
---|
| 200 | oHeading.className = 'date-picker-control'; |
---|
| 201 | oHeading.appendChild(document.createTextNode('x')); |
---|
| 202 | oHeading.setAttribute('title', this.close_msg); |
---|
| 203 | oHeading.fn = this.close; |
---|
| 204 | oHeading.obj = this; |
---|
| 205 | oHeading.onclick = function() { |
---|
| 206 | this.fn.call(this.obj); |
---|
| 207 | }; |
---|
[2566] | 208 | |
---|
[3706] | 209 | oRow.appendChild(oHeading); |
---|
| 210 | |
---|
| 211 | this.oBody.appendChild(oRow); |
---|
| 212 | } |
---|
[0] | 213 | |
---|
| 214 | datePicker.prototype = { |
---|
[3706] | 215 | year: 0, |
---|
| 216 | month: 0, |
---|
| 217 | day: 0, |
---|
| 218 | hour: 0, |
---|
| 219 | minute: 0, |
---|
[2566] | 220 | |
---|
[3706] | 221 | img_src: '', |
---|
| 222 | img_top: '0.2em', |
---|
| 223 | now_msg: 'now', |
---|
| 224 | close_msg: 'close', |
---|
[2566] | 225 | |
---|
[3706] | 226 | days: new Array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', |
---|
| 227 | 'Saturday', 'Sunday'), |
---|
[2566] | 228 | |
---|
[3706] | 229 | months: new Array('January', 'February', 'March', 'April', 'May', 'June', |
---|
| 230 | 'July', 'August', 'September', 'October', 'November', 'December'), |
---|
[2566] | 231 | |
---|
[3706] | 232 | setDate: function() { |
---|
| 233 | if (this.numberOfDays() < this.day) { |
---|
| 234 | this.day = this.numberOfDays(); |
---|
| 235 | } |
---|
[2566] | 236 | |
---|
[3706] | 237 | while (this.oYear.hasChildNodes()) { |
---|
| 238 | this.oYear.removeChild(this.oYear.firstChild); |
---|
| 239 | } |
---|
| 240 | this.oYear.appendChild(document.createTextNode(this.year)); |
---|
[2566] | 241 | |
---|
[3706] | 242 | while (this.oMonth.hasChildNodes()) { |
---|
| 243 | this.oMonth.removeChild(this.oMonth.firstChild); |
---|
| 244 | } |
---|
| 245 | this.oMonth.appendChild(document.createTextNode( |
---|
| 246 | this.months[this.month - 1])); |
---|
[2566] | 247 | |
---|
[3880] | 248 | const firstDay = this.firstDay(); |
---|
| 249 | const nbDays = this.numberOfDays(); |
---|
[2566] | 250 | |
---|
[3706] | 251 | // Empty days |
---|
[3880] | 252 | for (let i = 1; i <= 42; i++) { |
---|
[3706] | 253 | while (this.oDates[i].hasChildNodes()) { |
---|
| 254 | this.oDates[i].removeChild(this.oDates[i].firstChild); |
---|
| 255 | } |
---|
| 256 | this.oDates[i].appendChild(document.createTextNode('-')); |
---|
| 257 | this.oDates[i].className = ''; |
---|
| 258 | this.oDates[i].onclick = function() { |
---|
| 259 | return; |
---|
| 260 | }; |
---|
| 261 | } |
---|
[2566] | 262 | |
---|
[3706] | 263 | // Insert days from the first day to the last |
---|
[3880] | 264 | for (let i = 1; i <= nbDays; i++) { |
---|
| 265 | const j = firstDay + i - 1; |
---|
[2566] | 266 | |
---|
[3706] | 267 | while (this.oDates[j].hasChildNodes()) { |
---|
| 268 | this.oDates[j].removeChild(this.oDates[j].firstChild); |
---|
| 269 | } |
---|
[2566] | 270 | |
---|
[3706] | 271 | this.oDates[j].appendChild(document.createTextNode(i)); |
---|
| 272 | this.oDates[j].index = i; |
---|
| 273 | this.oDates[j].fn = this.sendDate; |
---|
| 274 | this.oDates[j].obj = this; |
---|
| 275 | this.oDates[j].onclick = function() { |
---|
| 276 | this.fn.call(this.obj, this.index); |
---|
| 277 | }; |
---|
| 278 | if (i == this.day) { |
---|
| 279 | this.oDates[j].className = 'date-picker-today'; |
---|
| 280 | } else { |
---|
| 281 | this.oDates[j].className = 'date-picker-day'; |
---|
| 282 | } |
---|
| 283 | } |
---|
[2566] | 284 | |
---|
[3706] | 285 | // Set time |
---|
| 286 | this.setHour(this.hour); |
---|
| 287 | this.setMinute(this.minute); |
---|
| 288 | }, |
---|
[2566] | 289 | |
---|
[3706] | 290 | setHour: function(h) { |
---|
| 291 | if (h < 0) { |
---|
| 292 | h = 23; |
---|
| 293 | } |
---|
| 294 | if (h > 23) { |
---|
| 295 | h = 0; |
---|
| 296 | } |
---|
| 297 | if (h < 10) { |
---|
| 298 | h = '0' + h; |
---|
| 299 | } |
---|
[2566] | 300 | |
---|
[3706] | 301 | this.hour = h * 1; |
---|
| 302 | this.oHour.value = h; |
---|
| 303 | }, |
---|
[2566] | 304 | |
---|
[3706] | 305 | setMinute: function(m) { |
---|
| 306 | if (m < 0) { |
---|
| 307 | m = 59; |
---|
| 308 | } |
---|
| 309 | if (m > 59) { |
---|
| 310 | m = 0; |
---|
| 311 | } |
---|
| 312 | if (m < 10) { |
---|
| 313 | m = '0' + m; |
---|
| 314 | } |
---|
[2566] | 315 | |
---|
[3706] | 316 | this.minute = m * 1; |
---|
| 317 | this.oMinute.value = m; |
---|
| 318 | }, |
---|
[2566] | 319 | |
---|
[3706] | 320 | changeMonth: function(dir) { |
---|
[3880] | 321 | const m = this.month + dir; |
---|
[2566] | 322 | |
---|
[3706] | 323 | if (m > 12) { |
---|
| 324 | this.month = 1; |
---|
| 325 | this.year++; |
---|
| 326 | } else if (m < 1) { |
---|
| 327 | this.month = 12; |
---|
| 328 | this.year--; |
---|
| 329 | } else { |
---|
| 330 | this.month = m; |
---|
| 331 | } |
---|
[2566] | 332 | |
---|
[3706] | 333 | this.setDate(); |
---|
| 334 | }, |
---|
[2566] | 335 | |
---|
[3706] | 336 | changeYear: function(dir) { |
---|
| 337 | this.year = this.year + dir; |
---|
| 338 | this.setDate(); |
---|
| 339 | }, |
---|
[2566] | 340 | |
---|
[3706] | 341 | changeHour: function(dir) { |
---|
| 342 | this.setHour(this.hour * 1 + dir); |
---|
| 343 | }, |
---|
[2566] | 344 | |
---|
[3706] | 345 | changeMinute: function(dir) { |
---|
| 346 | this.setMinute(this.minute * 1 + dir); |
---|
| 347 | }, |
---|
[2566] | 348 | |
---|
[3706] | 349 | sendDate: function(d) { |
---|
[3880] | 350 | let m = this.month; |
---|
| 351 | let hour = this.oHour.value * 1; |
---|
| 352 | let minute = this.oMinute.value * 1; |
---|
[2566] | 353 | |
---|
[3706] | 354 | if (hour < 0 || hour > 23 || isNaN(hour)) { |
---|
| 355 | hour = 0; |
---|
| 356 | } |
---|
| 357 | if (minute < 0 || minute > 59 || isNaN(minute)) { |
---|
| 358 | minute = 0; |
---|
| 359 | } |
---|
[2566] | 360 | |
---|
[3706] | 361 | if (m < 10) { |
---|
| 362 | m = '0' + m; |
---|
| 363 | } |
---|
| 364 | if (d < 10) { |
---|
| 365 | d = '0' + d; |
---|
| 366 | } |
---|
| 367 | if (hour < 10) { |
---|
| 368 | hour = '0' + hour; |
---|
| 369 | } |
---|
| 370 | if (minute < 10) { |
---|
| 371 | minute = '0' + minute; |
---|
| 372 | } |
---|
[2566] | 373 | |
---|
[3880] | 374 | this.target.value = `${this.year}-${m}-${d} ${hour}:${minute}`; |
---|
[3706] | 375 | this.close(); |
---|
| 376 | }, |
---|
[2566] | 377 | |
---|
[3706] | 378 | sendNow: function() { |
---|
[3880] | 379 | let dt = new Date(); |
---|
| 380 | const y = dt.getFullYear(); |
---|
| 381 | let m = dt.getMonth() + 1; |
---|
| 382 | let d = dt.getDate(); |
---|
| 383 | let h = dt.getHours(); |
---|
| 384 | let i = dt.getMinutes(); |
---|
[2566] | 385 | |
---|
[3706] | 386 | if (m < 10) { |
---|
| 387 | m = '0' + m; |
---|
| 388 | } |
---|
| 389 | if (d < 10) { |
---|
| 390 | d = '0' + d; |
---|
| 391 | } |
---|
| 392 | if (h < 10) { |
---|
| 393 | h = '0' + h; |
---|
| 394 | } |
---|
| 395 | if (i < 10) { |
---|
| 396 | i = '0' + i; |
---|
| 397 | } |
---|
[2566] | 398 | |
---|
[3880] | 399 | this.target.value = `${y}-${m}-${d} ${h}:${i}`; |
---|
[3706] | 400 | this.close(); |
---|
| 401 | }, |
---|
[2566] | 402 | |
---|
[3706] | 403 | close: function() { |
---|
| 404 | document.body.removeChild(this.oTable); |
---|
| 405 | }, |
---|
[2566] | 406 | |
---|
[3706] | 407 | numberOfDays: function() { |
---|
[3880] | 408 | let res = 31; |
---|
[3706] | 409 | if (this.month == 4 || this.month == 6 || this.month == 9 || |
---|
| 410 | this.month == 11) { |
---|
| 411 | res = 30; |
---|
| 412 | } else if (this.month == 2) { |
---|
| 413 | res = 28; |
---|
| 414 | if (this.year % 4 == 0 && (this.year % 100 != 0 || |
---|
| 415 | this.year % 400 == 0)) { |
---|
| 416 | res = 29; |
---|
| 417 | } |
---|
| 418 | } |
---|
[2566] | 419 | |
---|
[3706] | 420 | return res; |
---|
| 421 | }, |
---|
[2566] | 422 | |
---|
[3706] | 423 | firstDay: function() { |
---|
[3880] | 424 | let dt = new Date(this.year, this.month - 1, 1); |
---|
| 425 | let res = dt.getDay(); |
---|
[2566] | 426 | |
---|
[3706] | 427 | if (res == 0) { |
---|
| 428 | res = 7; |
---|
| 429 | } |
---|
[2566] | 430 | |
---|
[3706] | 431 | return res; |
---|
| 432 | }, |
---|
[2566] | 433 | |
---|
[3706] | 434 | show: function() { |
---|
| 435 | // Parsing target value |
---|
[3880] | 436 | const re = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})/; |
---|
| 437 | const match = re.exec(this.target.value); |
---|
[3706] | 438 | if (match) { |
---|
| 439 | this.year = match[1] * 1; |
---|
| 440 | this.month = match[2] * 1; |
---|
| 441 | this.day = match[3] * 1; |
---|
| 442 | this.hour = match[4] * 1; |
---|
| 443 | this.minute = match[5] * 1; |
---|
| 444 | } else { |
---|
[3880] | 445 | let dt = new Date(); |
---|
[3706] | 446 | this.year = dt.getFullYear(); |
---|
| 447 | this.month = dt.getMonth() + 1; |
---|
| 448 | this.day = dt.getDate(); |
---|
| 449 | this.hour = dt.getHours(); |
---|
| 450 | this.minute = dt.getMinutes(); |
---|
| 451 | } |
---|
[2566] | 452 | |
---|
[3706] | 453 | this.oTable.appendChild(this.oBody); |
---|
| 454 | this.setDate(); |
---|
| 455 | this.setPosition(); |
---|
| 456 | document.body.appendChild(this.oTable); |
---|
| 457 | this.oHour.focus(); |
---|
| 458 | }, |
---|
[2566] | 459 | |
---|
[3706] | 460 | setPosition: function() { |
---|
[3880] | 461 | const t_x = this.findPosX(this.target); |
---|
| 462 | const t_y = this.findPosY(this.target); |
---|
[2566] | 463 | |
---|
[3706] | 464 | this.oTable.style.position = 'absolute'; |
---|
| 465 | this.oTable.style.zIndex = '100'; |
---|
| 466 | this.oTable.style.top = t_y + 'px'; |
---|
| 467 | this.oTable.style.left = t_x + 'px'; |
---|
| 468 | }, |
---|
[2566] | 469 | |
---|
[3706] | 470 | findPosX: function(obj) { |
---|
[3880] | 471 | let curleft = 0; |
---|
[3706] | 472 | if (obj.offsetParent) { |
---|
| 473 | while (1) { |
---|
| 474 | curleft += obj.offsetLeft; |
---|
| 475 | if (!obj.offsetParent) { |
---|
| 476 | break; |
---|
| 477 | } |
---|
| 478 | obj = obj.offsetParent; |
---|
| 479 | } |
---|
| 480 | } else if (obj.x) { |
---|
| 481 | curleft += obj.x; |
---|
| 482 | } |
---|
| 483 | return curleft; |
---|
| 484 | }, |
---|
[2566] | 485 | |
---|
[3706] | 486 | findPosY: function(obj) { |
---|
[3880] | 487 | let curtop = 0; |
---|
[3706] | 488 | if (obj.offsetParent) { |
---|
| 489 | while (1) { |
---|
| 490 | curtop += obj.offsetTop; |
---|
| 491 | if (!obj.offsetParent) { |
---|
| 492 | break; |
---|
| 493 | } |
---|
| 494 | obj = obj.offsetParent; |
---|
| 495 | } |
---|
| 496 | } else if (obj.y) { |
---|
| 497 | curtop += obj.y; |
---|
| 498 | } |
---|
| 499 | return curtop; |
---|
| 500 | }, |
---|
[2566] | 501 | |
---|
[3706] | 502 | draw: function() { |
---|
[3880] | 503 | const imgE = document.createElement('img'); |
---|
[3706] | 504 | imgE.src = this.img_src; |
---|
| 505 | imgE.alt = this.img_alt; |
---|
| 506 | imgE.style.position = 'absolute'; |
---|
| 507 | imgE.style.top = this.img_top; |
---|
| 508 | imgE.style.left = (this.target.clientWidth + 4) + 'px'; |
---|
| 509 | imgE.obj = this; |
---|
| 510 | imgE.fn = this.show; |
---|
| 511 | imgE.onclick = function() { |
---|
| 512 | this.fn.apply(this.obj); |
---|
| 513 | }; |
---|
[2566] | 514 | |
---|
[3706] | 515 | this.target.parentNode.style.position = 'relative'; |
---|
| 516 | this.target.parentNode.insertBefore(imgE, this.target.nextSibling); |
---|
| 517 | } |
---|
[0] | 518 | }; |
---|
[3922] | 519 | |
---|
| 520 | // Get some DATA |
---|
| 521 | Object.assign(datePicker.prototype, getData('date_picker')); |
---|