PluginProbe ʕ •ᴥ•ʔ
UpdraftPlus: WP Backup & Migration Plugin / 1.26.4
UpdraftPlus: WP Backup & Migration Plugin v1.26.4
1.26.4 1.26.3 1.9.19 1.9.25 1.9.26 1.9.30 1.9.31 1.9.32 1.9.4 1.9.40 1.9.41 1.9.42 1.9.43 1.9.44 1.9.45 1.9.46 1.9.5 1.9.50 1.9.51 1.9.60 1.9.62 1.9.63 1.9.64 1.11.12 1.4.8 1.11.15 1.4.9 1.11.17 1.5.16 1.11.18 1.5.20 1.11.2 1.5.21 1.11.20 1.5.22 1.11.23 1.5.5 1.11.24 1.5.6 1.11.25 1.5.7 1.11.26 1.5.8 1.11.27 1.5.9 1.11.28 1.6.1 1.11.3 1.6.17 1.11.4 1.6.2 1.11.5 1.6.46 1.11.8 1.7.0 1.11.9 1.7.1 1.12.0 1.7.18 1.12.1 1.7.20 1.12.12 1.7.3 1.12.13 1.7.34 1.12.15 1.7.35 1.12.17 1.7.39 1.12.2 1.7.40 1.12.20 1.7.41 1.12.23 1.8.1 1.12.24 1.8.11 1.12.25 1.8.12 1.12.28 1.8.13 1.12.29 1.8.2 1.12.30 1.8.5 1.12.32 1.8.8 1.12.34 1.9.0 1.12.35 1.9.13 1.12.37 1.9.15 1.12.39 1.9.17 1.12.4 1.12.40 1.12.6 1.13.1 1.13.11 1.13.12 1.13.15 1.13.16 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.13.7 1.13.8 1.13.9 1.14.10 1.14.11 1.14.12 1.14.13 1.14.2 1.14.3 1.14.4 1.14.5 1.14.7 1.14.9 1.15.0 1.15.2 1.15.3 1.15.5 1.15.6 1.15.7 1.16.0 1.16.10 1.16.11 1.16.12 1.16.13 1.16.14 1.16.15 1.16.16 1.16.17 1.16.20 1.16.21 1.16.22 1.16.23 1.16.24 1.16.25 1.16.26 1.16.28 1.16.29 1.16.32 1.16.34 1.16.35 1.16.36 1.16.37 1.16.4 1.16.40 1.16.41 1.16.42 1.16.43 1.16.44 1.16.45 1.16.46 1.16.47 1.16.48 1.16.49 1.16.5 1.16.50 1.16.51 1.16.53 1.16.55 1.16.56 1.16.59 1.16.6 1.16.60 1.16.61 1.16.62 1.16.63 1.16.64 1.16.65 1.16.66 1.16.67 1.16.68 1.16.69 1.16.7 1.16.8 1.16.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.14 1.2.15 1.2.16 1.2.17 1.2.19 1.2.2 1.2.20 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.33 1.2.35 1.2.36 1.2.38 1.2.39 1.2.4 1.2.40 1.2.41 1.2.42 1.2.43 1.2.44 1.2.45 1.2.46 1.2.5 1.2.7 1.2.8 1.2.9 1.22.1 1.22.10 1.22.11 1.22.12 1.22.14 1.22.15 1.22.16 1.22.17 1.22.18 1.22.19 1.22.20 1.22.21 1.22.22 1.22.23 1.22.24 1.22.3 1.22.4 1.22.5 1.22.6 1.22.7 1.22.8 1.22.9 1.23.1 1.23.10 1.23.11 1.23.12 1.23.13 1.23.15 1.23.16 1.23.2 1.23.3 1.23.4 1.23.5 1.23.6 1.23.7 1.23.8 1.23.9 1.24.1 1.24.10 1.24.11 1.24.12 1.24.2 trunk 1.24.3 0.7.4 1.24.4 0.7.7 1.24.5 0.8.28 1.24.6 0.8.29 1.24.7 0.8.30 1.24.8 0.8.31 1.24.9 0.8.32 1.25.1 0.8.33 1.25.2 0.8.36 1.25.3 0.8.37 1.25.5 0.8.50 1.25.6 0.8.51 1.25.7 0.9.1 1.25.8 0.9.10 1.25.9 0.9.11 1.26.1 0.9.12 1.26.2 0.9.2 1.3.10 0.9.20 1.3.12 0.9.21 1.3.14 0.9.22 1.3.15 1.0.10 1.3.17 1.0.11 1.3.18 1.0.12 1.3.19 1.0.15 1.3.2 1.0.16 1.3.20 1.0.18 1.3.22 1.0.20 1.3.23 1.0.3 1.3.24 1.0.4 1.3.25 1.0.5 1.3.3 1.0.6 1.3.4 1.0.7 1.3.6 1.0.8 1.3.7 1.0.9 1.3.8 1.1.0 1.3.9 1.1.10 1.4.0 1.1.11 1.4.10 1.1.12 1.4.11 1.1.13 1.4.12 1.1.14 1.4.13 1.1.15 1.4.14 1.1.16 1.4.15 1.1.17 1.4.2 1.1.2 1.4.27 1.1.3 1.4.28 1.1.5 1.4.29 1.1.6 1.4.30 1.1.8 1.4.4 1.1.9 1.4.48 1.10.1 1.4.5 1.10.3 1.4.6 1.11.1 1.4.7
updraftplus / includes / tether-shepherd / shepherd.js
updraftplus / includes / tether-shepherd Last commit date
LICENSE 7 years ago shepherd.js 7 years ago shepherd.min.js 7 years ago tether.js 7 years ago
shepherd.js
746 lines
1 /*! tether-shepherd 1.8.1 */
2
3 (function(root, factory) {
4 if (typeof define === 'function' && define.amd) {
5 define(["tether"], factory);
6 } else if (typeof exports === 'object') {
7 module.exports = factory(require('tether'));
8 } else {
9 root.Shepherd = factory(root.Tether);
10 }
11 }(this, function(Tether) {
12
13 /* global Tether */
14
15 'use strict';
16
17 var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
18
19 var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x5 = parent; _x6 = property; _x7 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
20
21 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
22
23 function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
24
25 var _Tether$Utils = Tether.Utils;
26 var Evented = _Tether$Utils.Evented;
27 var addClass = _Tether$Utils.addClass;
28 var extend = _Tether$Utils.extend;
29 var hasClass = _Tether$Utils.hasClass;
30 var removeClass = _Tether$Utils.removeClass;
31 var uniqueId = _Tether$Utils.uniqueId;
32
33 var Shepherd = new Evented();
34
35 function isUndefined(obj) {
36 return typeof obj === 'undefined';
37 };
38
39 function isArray(obj) {
40 return obj && obj.constructor === Array;
41 };
42
43 function isObject(obj) {
44 return obj && obj.constructor === Object;
45 };
46
47 function isObjectLoose(obj) {
48 return typeof obj === 'object';
49 };
50
51 var ATTACHMENT = {
52 'top right': 'bottom left',
53 'top left': 'bottom right',
54 'top center': 'bottom center',
55 'middle right': 'middle left',
56 'middle left': 'middle right',
57 'middle center': 'middle center',
58 'bottom left': 'top right',
59 'bottom right': 'top left',
60 'bottom center': 'top center',
61 'top': 'bottom center',
62 'left': 'middle right',
63 'right': 'middle left',
64 'bottom': 'top center',
65 'center': 'middle center',
66 'middle': 'middle center'
67 };
68
69 function createFromHTML(html) {
70 var el = document.createElement('div');
71 el.innerHTML = html;
72 return el.children[0];
73 }
74
75 function matchesSelector(el, sel) {
76 var matches = undefined;
77 if (!isUndefined(el.matches)) {
78 matches = el.matches;
79 } else if (!isUndefined(el.matchesSelector)) {
80 matches = el.matchesSelector;
81 } else if (!isUndefined(el.msMatchesSelector)) {
82 matches = el.msMatchesSelector;
83 } else if (!isUndefined(el.webkitMatchesSelector)) {
84 matches = el.webkitMatchesSelector;
85 } else if (!isUndefined(el.mozMatchesSelector)) {
86 matches = el.mozMatchesSelector;
87 } else if (!isUndefined(el.oMatchesSelector)) {
88 matches = el.oMatchesSelector;
89 }
90 return matches.call(el, sel);
91 }
92
93 var positionRe = /^(.+) (top|left|right|bottom|center|\[[a-z ]+\])$/;
94
95 function parsePosition(str) {
96 if (isObjectLoose(str)) {
97 if (str.hasOwnProperty("element") && str.hasOwnProperty("on")) {
98 return str;
99 }
100 return null;
101 }
102
103 var matches = positionRe.exec(str);
104 if (!matches) {
105 return null;
106 }
107
108 var on = matches[2];
109 if (on[0] === '[') {
110 on = on.substring(1, on.length - 1);
111 }
112
113 return {
114 'element': matches[1],
115 'on': on
116 };
117 }
118
119 function parseShorthand(obj, props) {
120 if (obj === null || isUndefined(obj)) {
121 return obj;
122 } else if (isObjectLoose(obj)) {
123 return obj;
124 }
125
126 var vals = obj.split(' ');
127 var out = {};
128 var j = props.length - 1;
129 for (var i = vals.length - 1; i >= 0; i--) {
130 if (j === 0) {
131 out[props[j]] = vals.slice(0, i + 1).join(' ');
132 break;
133 } else {
134 out[props[j]] = vals[i];
135 }
136
137 j--;
138 }
139
140 return out;
141 }
142
143 var Step = (function (_Evented) {
144 _inherits(Step, _Evented);
145
146 function Step(tour, options) {
147 _classCallCheck(this, Step);
148
149 _get(Object.getPrototypeOf(Step.prototype), 'constructor', this).call(this, tour, options);
150 this.tour = tour;
151 this.bindMethods();
152 this.setOptions(options);
153 return this;
154 }
155
156 _createClass(Step, [{
157 key: 'bindMethods',
158 value: function bindMethods() {
159 var _this = this;
160
161 var methods = ['_show', 'show', 'hide', 'isOpen', 'cancel', 'complete', 'scrollTo', 'destroy', 'render'];
162 methods.map(function (method) {
163 _this[method] = _this[method].bind(_this);
164 });
165 }
166 }, {
167 key: 'setOptions',
168 value: function setOptions() {
169 var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
170
171 this.options = options;
172 this.destroy();
173
174 this.id = this.options.id || this.id || 'step-' + uniqueId();
175
176 var when = this.options.when;
177 if (when) {
178 for (var _event in when) {
179 if (({}).hasOwnProperty.call(when, _event)) {
180 var handler = when[_event];
181 this.on(_event, handler, this);
182 }
183 }
184 }
185
186 // Button configuration
187
188 var buttonsJson = JSON.stringify(this.options.buttons);
189 var buttonsAreDefault = isUndefined(buttonsJson) || buttonsJson === "true";
190
191 var buttonsAreEmpty = buttonsJson === "{}" || buttonsJson === "[]" || buttonsJson === "null" || buttonsJson === "false";
192
193 var buttonsAreArray = !buttonsAreDefault && isArray(this.options.buttons);
194
195 var buttonsAreObject = !buttonsAreDefault && isObject(this.options.buttons);
196
197 // Show default button if undefined or 'true'
198 if (buttonsAreDefault) {
199 this.options.buttons = [{
200 text: 'Next',
201 action: this.tour.next,
202 classes: 'btn'
203 }];
204
205 // Can pass in an object which will assume asingle button
206 } else if (!buttonsAreEmpty && buttonsAreObject) {
207 this.options.buttons = [this.options.buttons];
208
209 // Falsey/empty values or non-object values prevent buttons from rendering
210 } else if (buttonsAreEmpty || !buttonsAreArray) {
211 this.options.buttons = false;
212 }
213 }
214 }, {
215 key: 'getTour',
216 value: function getTour() {
217 return this.tour;
218 }
219 }, {
220 key: 'bindAdvance',
221 value: function bindAdvance() {
222 var _this2 = this;
223
224 // An empty selector matches the step element
225
226 var _parseShorthand = parseShorthand(this.options.advanceOn, ['selector', 'event']);
227
228 var event = _parseShorthand.event;
229 var selector = _parseShorthand.selector;
230
231 var handler = function handler(e) {
232 if (!_this2.isOpen()) {
233 return;
234 }
235
236 if (!isUndefined(selector)) {
237 if (matchesSelector(e.target, selector)) {
238 _this2.tour.next();
239 }
240 } else {
241 if (_this2.el && e.target === _this2.el) {
242 _this2.tour.next();
243 }
244 }
245 };
246
247 // TODO: this should also bind/unbind on show/hide
248 document.body.addEventListener(event, handler);
249 this.on('destroy', function () {
250 return document.body.removeEventListener(event, handler);
251 });
252 }
253 }, {
254 key: 'getAttachTo',
255 value: function getAttachTo() {
256 var opts = parsePosition(this.options.attachTo) || {};
257 var returnOpts = extend({}, opts);
258
259 if (typeof opts.element === 'string') {
260 // Can't override the element in user opts reference because we can't
261 // guarantee that the element will exist in the future.
262 returnOpts.element = document.querySelector(opts.element);
263 if (!returnOpts.element) {
264 console.error('The element for this Shepherd step was not found ' + opts.element);
265 }
266 }
267
268 return returnOpts;
269 }
270 }, {
271 key: 'setupTether',
272 value: function setupTether() {
273 if (isUndefined(Tether)) {
274 throw new Error("Using the attachment feature of Shepherd requires the Tether library");
275 }
276
277 var opts = this.getAttachTo();
278 var attachment = ATTACHMENT[opts.on] || ATTACHMENT.right;
279 if (isUndefined(opts.element)) {
280 opts.element = 'viewport';
281 attachment = 'middle center';
282 }
283
284 var tetherOpts = {
285 classPrefix: 'shepherd',
286 element: this.el,
287 constraints: [{
288 to: 'window',
289 pin: true,
290 attachment: 'together'
291 }],
292 target: opts.element,
293 offset: opts.offset || '0 0',
294 attachment: attachment
295 };
296
297 if (this.tether) {
298 this.tether.destroy();
299 }
300
301 this.tether = new Tether(extend(tetherOpts, this.options.tetherOptions));
302 }
303 }, {
304 key: 'show',
305 value: function show() {
306 var _this3 = this;
307
308 if (!isUndefined(this.options.beforeShowPromise)) {
309 var beforeShowPromise = this.options.beforeShowPromise();
310 if (!isUndefined(beforeShowPromise)) {
311 return beforeShowPromise.then(function () {
312 return _this3._show();
313 });
314 }
315 }
316 this._show();
317 }
318 }, {
319 key: '_show',
320 value: function _show() {
321 var _this4 = this;
322
323 this.trigger('before-show');
324
325 if (!this.el) {
326 this.render();
327 }
328
329 addClass(this.el, 'shepherd-open');
330
331 document.body.setAttribute('data-shepherd-step', this.id);
332
333 this.setupTether();
334
335 if (this.options.scrollTo) {
336 setTimeout(function () {
337 _this4.scrollTo();
338 });
339 }
340
341 this.trigger('show');
342 }
343 }, {
344 key: 'hide',
345 value: function hide() {
346 this.trigger('before-hide');
347
348 removeClass(this.el, 'shepherd-open');
349
350 document.body.removeAttribute('data-shepherd-step');
351
352 if (this.tether) {
353 this.tether.destroy();
354 }
355 this.tether = null;
356
357 this.trigger('hide');
358 }
359 }, {
360 key: 'isOpen',
361 value: function isOpen() {
362 return this.el && hasClass(this.el, 'shepherd-open');
363 }
364 }, {
365 key: 'cancel',
366 value: function cancel() {
367 this.tour.cancel();
368 this.trigger('cancel');
369 }
370 }, {
371 key: 'complete',
372 value: function complete() {
373 this.tour.complete();
374 this.trigger('complete');
375 }
376 }, {
377 key: 'scrollTo',
378 value: function scrollTo() {
379 var _getAttachTo = this.getAttachTo();
380
381 var element = _getAttachTo.element;
382
383 if (!isUndefined(this.options.scrollToHandler)) {
384 this.options.scrollToHandler(element);
385 } else if (!isUndefined(element)) {
386 element.scrollIntoView();
387 }
388 }
389 }, {
390 key: 'destroy',
391 value: function destroy() {
392 if (!isUndefined(this.el) && this.el.parentNode) {
393 this.el.parentNode.removeChild(this.el);
394 delete this.el;
395 }
396
397 if (this.tether) {
398 this.tether.destroy();
399 }
400 this.tether = null;
401
402 this.trigger('destroy');
403 }
404 }, {
405 key: 'render',
406 value: function render() {
407 var _this5 = this;
408
409 if (!isUndefined(this.el)) {
410 this.destroy();
411 }
412
413 this.el = createFromHTML('<div class=\'shepherd-step ' + (this.options.classes || '') + '\' data-id=\'' + this.id + '\' ' + (this.options.idAttribute ? 'id="' + this.options.idAttribute + '"' : '') + '></div>');
414
415 var content = document.createElement('div');
416 content.className = 'shepherd-content';
417 this.el.appendChild(content);
418
419 var header = document.createElement('header');
420 content.appendChild(header);
421
422 if (this.options.title) {
423 header.innerHTML += '<h3 class=\'shepherd-title\'>' + this.options.title + '</h3>';
424 this.el.className += ' shepherd-has-title';
425 }
426
427 if (this.options.showCancelLink) {
428 var link = createFromHTML("<a href class='shepherd-cancel-link'>✕</a>");
429 header.appendChild(link);
430
431 this.el.className += ' shepherd-has-cancel-link';
432
433 this.bindCancelLink(link);
434 }
435
436 if (!isUndefined(this.options.text)) {
437 (function () {
438 var text = createFromHTML("<div class='shepherd-text'></div>");
439 var paragraphs = _this5.options.text;
440
441 if (typeof paragraphs === 'function') {
442 paragraphs = paragraphs.call(_this5, text);
443 }
444
445 if (paragraphs instanceof HTMLElement) {
446 text.appendChild(paragraphs);
447 } else {
448 if (typeof paragraphs === 'string') {
449 paragraphs = [paragraphs];
450 }
451
452 paragraphs.map(function (paragraph) {
453 text.innerHTML += '<p>' + paragraph + '</p>';
454 });
455 }
456
457 content.appendChild(text);
458 })();
459 }
460
461 if (this.options.buttons) {
462 (function () {
463 var footer = document.createElement('footer');
464 var buttons = createFromHTML("<ul class='shepherd-buttons'></ul>");
465
466 _this5.options.buttons.map(function (cfg) {
467 var button = createFromHTML('<li><a class=\'shepherd-button ' + (cfg.classes || '') + '\'>' + cfg.text + '</a>');
468 buttons.appendChild(button);
469 _this5.bindButtonEvents(cfg, button.querySelector('a'));
470 });
471
472 footer.appendChild(buttons);
473 content.appendChild(footer);
474 })();
475 }
476
477 document.body.appendChild(this.el);
478
479 this.setupTether();
480
481 if (this.options.advanceOn) {
482 this.bindAdvance();
483 }
484 }
485 }, {
486 key: 'bindCancelLink',
487 value: function bindCancelLink(link) {
488 var _this6 = this;
489
490 link.addEventListener('click', function (e) {
491 e.preventDefault();
492 _this6.cancel();
493 });
494 }
495 }, {
496 key: 'bindButtonEvents',
497 value: function bindButtonEvents(cfg, el) {
498 var _this7 = this;
499
500 cfg.events = cfg.events || {};
501 if (!isUndefined(cfg.action)) {
502 // Including both a click event and an action is not supported
503 cfg.events.click = cfg.action;
504 }
505
506 for (var _event2 in cfg.events) {
507 if (({}).hasOwnProperty.call(cfg.events, _event2)) {
508 var handler = cfg.events[_event2];
509 if (typeof handler === 'string') {
510 (function () {
511 var page = handler;
512 handler = function () {
513 return _this7.tour.show(page);
514 };
515 })();
516 }
517 el.addEventListener(_event2, handler);
518 }
519 }
520
521 this.on('destroy', function () {
522 for (var _event3 in cfg.events) {
523 if (({}).hasOwnProperty.call(cfg.events, _event3)) {
524 var handler = cfg.events[_event3];
525 el.removeEventListener(_event3, handler);
526 }
527 }
528 });
529 }
530 }]);
531
532 return Step;
533 })(Evented);
534
535 var Tour = (function (_Evented2) {
536 _inherits(Tour, _Evented2);
537
538 function Tour() {
539 var _this8 = this;
540
541 var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
542
543 _classCallCheck(this, Tour);
544
545 _get(Object.getPrototypeOf(Tour.prototype), 'constructor', this).call(this, options);
546 this.bindMethods();
547 this.options = options;
548 this.steps = this.options.steps || [];
549
550 // Pass these events onto the global Shepherd object
551 var events = ['complete', 'cancel', 'hide', 'start', 'show', 'active', 'inactive'];
552 events.map(function (event) {
553 (function (e) {
554 _this8.on(e, function (opts) {
555 opts = opts || {};
556 opts.tour = _this8;
557 Shepherd.trigger(e, opts);
558 });
559 })(event);
560 });
561
562 return this;
563 }
564
565 _createClass(Tour, [{
566 key: 'bindMethods',
567 value: function bindMethods() {
568 var _this9 = this;
569
570 var methods = ['next', 'back', 'cancel', 'complete', 'hide'];
571 methods.map(function (method) {
572 _this9[method] = _this9[method].bind(_this9);
573 });
574 }
575 }, {
576 key: 'addStep',
577 value: function addStep(name, step) {
578 if (isUndefined(step)) {
579 step = name;
580 }
581
582 if (!(step instanceof Step)) {
583 if (typeof name === 'string' || typeof name === 'number') {
584 step.id = name.toString();
585 }
586 step = extend({}, this.options.defaults, step);
587 step = new Step(this, step);
588 } else {
589 step.tour = this;
590 }
591
592 this.steps.push(step);
593 return this;
594 }
595 }, {
596 key: 'removeStep',
597 value: function removeStep(name) {
598 var current = this.getCurrentStep();
599
600 for (var i = 0; i < this.steps.length; ++i) {
601 var step = this.steps[i];
602 if (step.id === name) {
603 if (step.isOpen()) {
604 step.hide();
605 }
606 step.destroy();
607 this.steps.splice(i, 1);
608 break;
609 }
610 }
611
612 if (current && current.id === name) {
613 this.currentStep = undefined;
614
615 if (this.steps.length) this.show(0);else this.hide();
616 }
617 }
618 }, {
619 key: 'getById',
620 value: function getById(id) {
621 for (var i = 0; i < this.steps.length; ++i) {
622 var step = this.steps[i];
623 if (step.id === id) {
624 return step;
625 }
626 }
627 }
628 }, {
629 key: 'getCurrentStep',
630 value: function getCurrentStep() {
631 return this.currentStep;
632 }
633 }, {
634 key: 'next',
635 value: function next() {
636 var index = this.steps.indexOf(this.currentStep);
637
638 if (index === this.steps.length - 1) {
639 this.hide(index);
640 this.trigger('complete');
641 this.done();
642 } else {
643 this.show(index + 1, true);
644 }
645 }
646 }, {
647 key: 'back',
648 value: function back() {
649 var index = this.steps.indexOf(this.currentStep);
650 this.show(index - 1, false);
651 }
652 }, {
653 key: 'cancel',
654 value: function cancel() {
655 if (this.currentStep) {
656 this.currentStep.hide();
657 }
658 this.trigger('cancel');
659 this.done();
660 }
661 }, {
662 key: 'complete',
663 value: function complete() {
664 if (this.currentStep) {
665 this.currentStep.hide();
666 }
667 this.trigger('complete');
668 this.done();
669 }
670 }, {
671 key: 'hide',
672 value: function hide() {
673 if (this.currentStep) {
674 this.currentStep.hide();
675 }
676 this.trigger('hide');
677 this.done();
678 }
679 }, {
680 key: 'done',
681 value: function done() {
682 Shepherd.activeTour = null;
683 removeClass(document.body, 'shepherd-active');
684 this.trigger('inactive', { tour: this });
685 }
686 }, {
687 key: 'show',
688 value: function show() {
689 var key = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
690 var forward = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
691
692 if (this.currentStep) {
693 this.currentStep.hide();
694 } else {
695 addClass(document.body, 'shepherd-active');
696 this.trigger('active', { tour: this });
697 }
698
699 Shepherd.activeTour = this;
700
701 var next = undefined;
702
703 if (typeof key === 'string') {
704 next = this.getById(key);
705 } else {
706 next = this.steps[key];
707 }
708
709 if (next) {
710 if (!isUndefined(next.options.showOn) && !next.options.showOn()) {
711 var index = this.steps.indexOf(next);
712 var nextIndex = forward ? index + 1 : index - 1;
713 this.show(nextIndex, forward);
714 } else {
715 this.trigger('show', {
716 step: next,
717 previous: this.currentStep
718 });
719
720 if (this.currentStep) {
721 this.currentStep.hide();
722 }
723
724 this.currentStep = next;
725 next.show();
726 }
727 }
728 }
729 }, {
730 key: 'start',
731 value: function start() {
732 this.trigger('start');
733
734 this.currentStep = null;
735 this.next();
736 }
737 }]);
738
739 return Tour;
740 })(Evented);
741
742 extend(Shepherd, { Tour: Tour, Step: Step, Evented: Evented });
743 return Shepherd;
744
745 }));
746