|
1 | 1 | /*!
|
2 | 2 | * knockout-daterangepicker
|
3 |
| - * version: 0.0.4 |
| 3 | + * version: 0.0.5 |
4 | 4 | * authors: Sensor Tower team
|
5 | 5 | * license: MIT
|
6 | 6 | * https://sensortower.github.io/daterangepicker
|
|
20 | 20 |
|
21 | 21 | MomentUtil.setFirstDayOfTheWeek = function(dow) {
|
22 | 22 | var offset;
|
| 23 | + dow = (dow % 7 + 7) % 7; |
23 | 24 | if (moment.localeData().firstDayOfWeek() !== dow) {
|
24 | 25 | offset = dow - moment.localeData().firstDayOfWeek();
|
25 | 26 | return this.patchCurrentLocale({
|
|
429 | 430 | };
|
430 | 431 |
|
431 | 432 | Config.prototype._dateObservable = function(val, mode, minBoundary, maxBoundary) {
|
432 |
| - var computed, observable; |
| 433 | + var computed, fitMax, fitMin, observable; |
433 | 434 | observable = ko.observable();
|
434 | 435 | computed = ko.computed({
|
435 | 436 | read: function() {
|
|
447 | 448 | })(this)
|
448 | 449 | });
|
449 | 450 | computed.mode = mode || 'inclusive';
|
450 |
| - computed.fit = (function(_this) { |
| 451 | + fitMin = (function(_this) { |
451 | 452 | return function(val) {
|
452 |
| - var max, min; |
453 |
| - val = MomentUtil.tz(val, _this.timeZone()); |
| 453 | + var min; |
454 | 454 | if (minBoundary) {
|
455 | 455 | min = minBoundary();
|
456 | 456 | switch (minBoundary.mode) {
|
457 | 457 | case 'extended':
|
458 | 458 | min = min.clone().startOf(_this.period());
|
459 | 459 | break;
|
460 | 460 | case 'exclusive':
|
461 |
| - min = min.clone().endOf(_this.period()).subtract(1, 'millisecond'); |
| 461 | + min = min.clone().endOf(_this.period()).add(1, 'millisecond'); |
462 | 462 | }
|
463 | 463 | val = moment.max(min, val);
|
464 | 464 | }
|
| 465 | + return val; |
| 466 | + }; |
| 467 | + })(this); |
| 468 | + fitMax = (function(_this) { |
| 469 | + return function(val) { |
| 470 | + var max; |
465 | 471 | if (maxBoundary) {
|
466 | 472 | max = maxBoundary();
|
467 | 473 | switch (maxBoundary.mode) {
|
|
476 | 482 | return val;
|
477 | 483 | };
|
478 | 484 | })(this);
|
| 485 | + computed.fit = (function(_this) { |
| 486 | + return function(val) { |
| 487 | + val = MomentUtil.tz(val, _this.timeZone()); |
| 488 | + return fitMax(fitMin(val)); |
| 489 | + }; |
| 490 | + })(this); |
479 | 491 | computed(val);
|
480 | 492 | computed.clone = (function(_this) {
|
481 | 493 | return function() {
|
|
525 | 537 | };
|
526 | 538 |
|
527 | 539 | Config.prototype._parentElement = function(val) {
|
528 |
| - if (this.standalone()) { |
529 |
| - return this.anchorElement; |
530 |
| - } else { |
531 |
| - return $(val || 'body'); |
532 |
| - } |
| 540 | + return $(val || (this.standalone() ? this.anchorElement : 'body')); |
533 | 541 | };
|
534 | 542 |
|
535 | 543 | Config.prototype._callback = function(val) {
|
|
0 commit comments