|
1 | 1 | /**
|
2 |
| -* @version: 1.3.7 |
| 2 | +* @version: 1.3.8 |
3 | 3 | * @author: Dan Grossman http://www.dangrossman.info/
|
4 |
| -* @date: 2014-04-29 |
| 4 | +* @date: 2014-07-10 |
5 | 5 | * @copyright: Copyright (c) 2012-2014 Dan Grossman. All rights reserved.
|
6 | 6 | * @license: Licensed under Apache License v2.0. See http://www.apache.org/licenses/LICENSE-2.0
|
7 | 7 | * @website: http://www.improvely.com/
|
|
16 | 16 | //element that triggered the date range picker
|
17 | 17 | this.element = $(element);
|
18 | 18 |
|
| 19 | + //tracks visible state |
| 20 | + this.isShowing = false; |
| 21 | + |
19 | 22 | //create the picker HTML object
|
20 | 23 | var DRPTemplate = '<div class="daterangepicker dropdown-menu">' +
|
21 | 24 | '<div class="calendar left"></div>' +
|
|
501 | 504 | },
|
502 | 505 |
|
503 | 506 | show: function (e) {
|
| 507 | + if (this.isShowing) return; |
| 508 | + |
504 | 509 | this.element.addClass('active');
|
505 | 510 | this.container.show();
|
506 | 511 | this.move();
|
|
515 | 520 | // and also close when focus changes to outside the picker (eg. tabbing between controls)
|
516 | 521 | .on('focusin.daterangepicker', this._outsideClickProxy);
|
517 | 522 |
|
| 523 | + this.isShowing = true; |
518 | 524 | this.element.trigger('show.daterangepicker', this);
|
519 | 525 | },
|
520 | 526 |
|
|
531 | 537 | },
|
532 | 538 |
|
533 | 539 | hide: function (e) {
|
| 540 | + if (!this.isShowing) return; |
| 541 | + |
534 | 542 | $(document)
|
535 |
| - .off('mousedown.daterangepicker', this._outsideClickProxy) |
536 |
| - .off('click.daterangepicker', this._outsideClickProxy) |
537 |
| - .off('focusin.daterangepicker', this._outsideClickProxy); |
| 543 | + .off('mousedown.daterangepicker') |
| 544 | + .off('click.daterangepicker', '[data-toggle=dropdown]') |
| 545 | + .off('focusin.daterangepicker'); |
538 | 546 |
|
539 | 547 | this.element.removeClass('active');
|
540 | 548 | this.container.hide();
|
|
545 | 553 | this.oldStartDate = this.startDate.clone();
|
546 | 554 | this.oldEndDate = this.endDate.clone();
|
547 | 555 |
|
| 556 | + this.isShowing = false; |
548 | 557 | this.element.trigger('hide.daterangepicker', this);
|
549 | 558 | },
|
550 | 559 |
|
|
0 commit comments