+function ($) { 'use strict'; // TOUR CLASS DEFINITION // ===================== var Tour = function (element, options) { this.$element = $(element); this.options = $.extend({}, Tour.DEFAULTS, options); this.$active = false; this.$interval = null; this.$timeout = null; this.$totalItems = this.options.items.length; this.initCurrentItem(); this.init(); }; if (!$.fn.popover) throw new Error('Tour requires popover.js'); Tour.VERSION = '1.0.0'; Tour.OFFSET = 200; Tour.DEFAULTS = { buttonClass: 'btn btn-size-s', delay: 3000, items: [], manual: true, onMissCallback: function (item) {}, onShowCallback: function (item) {}, onShownCallback: function (item) {}, parent: 'html, body', skip: true, storage: false, storageKey: 'storage.bs.tour', text: { end: 'End', endTour: 'End Tour', next: 'Next', prev: 'Prev', stop: 'Stop' } }; Tour.prototype.constructor = Tour; Tour.prototype.init = function () { var _self = this; this.$element.click(function () { if (_self.$totalItems === 0) return this; if (_self.$active) { _self.endTour(); } else { _self.startTour(); if (!_self.options.manual) _self.cycleItems(); } }); $('body') .on('click', '[data-tour="next"]', function () { _self.nextItem(); }) .on('click', '[data-tour="prev"]', function () { _self.prevItem(); }) .on('click', '[data-tour="stop"]', function () { _self.stopCycling(); $(this).remove(); }) .on('click', '[data-tour="end"]', function () { _self.endTour(); }); }; Tour.prototype.startTour = function () { this.nextItem(); this.$startText = this.$element.text(); this.$element.text(this.options.text.endTour); this.$active = true; }; Tour.prototype.nextItem = function () { this.incr(); this.displayItem(this.getItem()); }; Tour.prototype.prevItem = function () { this.decr(); this.displayItem(this.getItem()); }; Tour.prototype.endTour = function () { this.stopCycling(); this.removeItems(); this.$currentItem = 0; this.$active = false; this.setCurrentItem(); this.$element.text(this.$startText); this.$element.scrollToItem(this.options.parent, 'top'); }; Tour.prototype.incr = function () { if (this.$currentItem < this.$totalItems) this.$currentItem++; this.setCurrentItem(); }; Tour.prototype.decr = function () { if (this.$currentItem > 1) this.$currentItem--; this.setCurrentItem(); }; Tour.prototype.popoverTemplate = function () { var stopBtn = ''; var prevBtn = ''; var nextBtn = ''; var endBtn = ''; var btnGroup = $('
'); var navigation = $('
'); var popover = $('