diff options
author | fat <fat@folders.local> | 2015-05-13 22:48:34 +0300 |
---|---|---|
committer | fat <fat@folders.local> | 2015-05-13 22:48:34 +0300 |
commit | f8b2569ec8956a1f4d09fe6fc9865bd200ecde43 (patch) | |
tree | 190263c441212d1ba91507d385fe3e6bc33e2614 /js/dist/carousel.js | |
parent | dafdd180cd54a2e238fe715d8aeb83c07f385a18 (diff) |
implement global dispose method
Diffstat (limited to 'js/dist/carousel.js')
-rw-r--r-- | js/dist/carousel.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/js/dist/carousel.js b/js/dist/carousel.js index 0d78153be1..87b5cc086f 100644 --- a/js/dist/carousel.js +++ b/js/dist/carousel.js @@ -22,6 +22,8 @@ var Carousel = (function ($) { var NAME = 'carousel'; var VERSION = '4.0.0'; var DATA_KEY = 'bs.carousel'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 600; @@ -39,10 +41,13 @@ var Carousel = (function ($) { }; var Event = { - SLIDE: 'slide.bs.carousel', - SLID: 'slid.bs.carousel', - CLICK: 'click.bs.carousel.data-api', - LOAD: 'load' + SLIDE: 'slide' + EVENT_KEY, + SLID: 'slid' + EVENT_KEY, + KEYDOWN: 'keydown' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY, + LOAD_DATA_API: 'load' + EVENT_KEY + '' + DATA_API_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY }; var ClassName = { @@ -167,17 +172,32 @@ var Carousel = (function ($) { this._slide(direction, this._items[index]); } }, { + key: 'dispose', + value: function dispose() { + $(this._element).off(EVENT_KEY); + $.removeData(this._element, DATA_KEY); + + this._items = null; + this._config = null; + this._element = null; + this._interval = null; + this._isPaused = null; + this._isSliding = null; + this._activeElement = null; + this._indicatorsElement = null; + } + }, { key: '_addEventListeners', // private value: function _addEventListeners() { if (this._config.keyboard) { - $(this._element).on('keydown.bs.carousel', $.proxy(this._keydown, this)); + $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this)); } if (this._config.pause == 'hover' && !('ontouchstart' in document.documentElement)) { - $(this._element).on('mouseenter.bs.carousel', $.proxy(this.pause, this)).on('mouseleave.bs.carousel', $.proxy(this.cycle, this)); + $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this)); } } }, { @@ -404,9 +424,9 @@ var Carousel = (function ($) { * ------------------------------------------------------------------------ */ - $(document).on(Event.CLICK, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); + $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); - $(window).on(Event.LOAD, function () { + $(window).on(Event.LOAD_DATA_API, function () { $(Selector.DATA_RIDE).each(function () { var $carousel = $(this); Carousel._jQueryInterface.call($carousel, $carousel.data()); |