Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

tether-shepherd

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tether-shepherd - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

2

bower.json
{
"name": "tether-shepherd",
"version": "1.1.3",
"version": "1.2.0",
"homepage": "https://github.com/HubSpot/shepherd",

@@ -5,0 +5,0 @@ "authors": [

@@ -0,1 +1,4 @@

## v1.1.4
- Install helper now checks for the presence of first attach node before starting
## v1.1.2 & v1.1.3

@@ -2,0 +5,0 @@ - Fix stacking event listeners

(function() {
var ShepherdInstallHelper, addEventListener, ready;
var ShepherdInstallHelper, addEventListener, firstStepSelector, ready;

@@ -28,2 +28,4 @@ addEventListener = function(el, eventName, handler) {

firstStepSelector = void 0;
ShepherdInstallHelper = {

@@ -56,2 +58,5 @@ init: function(options) {

step = steps[i];
if (i === 0) {
firstStepSelector = step.attachToSelector;
}
stepOptions = {

@@ -61,3 +66,3 @@ title: step.title,

showCancelLink: step.showCancelLink,
attachTo: (step.attachToSelector || 'body') + ' ' + step.attachToDirection
attachTo: step.attachToSelector + ' ' + step.attachToDirection
};

@@ -96,3 +101,3 @@ stepOptions.buttons = [];

tour.start();
} else if (((ref5 = window.localStorage) != null ? ref5.eagerShepherdHasRun : void 0) !== 'true') {
} else if (document.querySelector(firstStepSelector) && ((ref5 = window.localStorage) != null ? ref5.eagerShepherdHasRun : void 0) !== 'true') {
if (typeof localStorage !== "undefined" && localStorage !== null) {

@@ -99,0 +104,0 @@ localStorage.eagerShepherdHasRun = 'true';

@@ -1,2 +0,2 @@

/*! tether-shepherd 1.1.3 */
/*! tether-shepherd 1.2.0 */

@@ -19,7 +19,7 @@ (function(root, factory) {

var _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x5, _x6, _x7) { var _again = true; _function: while (_again) { var object = _x5, property = _x6, receiver = _x7; desc = parent = getter = undefined; _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; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
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) subClass.__proto__ = superClass; }
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; }

@@ -93,2 +93,4 @@ var _Tether$Utils = Tether.Utils;

var Step = (function (_Evented) {
_inherits(Step, _Evented);
function Step(tour, options) {

@@ -104,4 +106,2 @@ _classCallCheck(this, Step);

_inherits(Step, _Evented);
_createClass(Step, [{

@@ -120,3 +120,3 @@ key: 'bindMethods',

value: function setOptions() {
var options = arguments[0] === undefined ? {} : arguments[0];
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -204,3 +204,3 @@ this.options = options;

if (typeof Tether === 'undefined') {
throw new Error('Using the attachment feature of Shepherd requires the Tether library');
throw new Error("Using the attachment feature of Shepherd requires the Tether library");
}

@@ -359,3 +359,3 @@

if (this.options.showCancelLink) {
var link = createFromHTML('<a href class=\'shepherd-cancel-link\'>āœ•</a>');
var link = createFromHTML("<a href class='shepherd-cancel-link'>āœ•</a>");
header.appendChild(link);

@@ -370,3 +370,3 @@

(function () {
var text = createFromHTML('<div class=\'shepherd-text\'></div>');
var text = createFromHTML("<div class='shepherd-text'></div>");
var paragraphs = _this5.options.text;

@@ -398,3 +398,3 @@

(function () {
var buttons = createFromHTML('<ul class=\'shepherd-buttons\'></ul>');
var buttons = createFromHTML("<ul class='shepherd-buttons'></ul>");

@@ -472,6 +472,8 @@ _this5.options.buttons.map(function (cfg) {

var Tour = (function (_Evented2) {
_inherits(Tour, _Evented2);
function Tour() {
var _this8 = this;
var options = arguments[0] === undefined ? {} : arguments[0];
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

@@ -500,4 +502,2 @@ _classCallCheck(this, Tour);

_inherits(Tour, _Evented2);
_createClass(Tour, [{

@@ -558,3 +558,3 @@ key: 'bindMethods',

} else {
this.show(index + 1);
this.show(index + 1, true);
}

@@ -566,3 +566,3 @@ }

var index = this.steps.indexOf(this.currentStep);
this.show(index - 1);
this.show(index - 1, false);
}

@@ -606,3 +606,4 @@ }, {

value: function show() {
var key = arguments[0] === undefined ? 0 : arguments[0];
var key = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
var forward = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];

@@ -619,2 +620,3 @@ if (this.currentStep) {

var next = undefined;
if (typeof key === 'string') {

@@ -627,9 +629,15 @@ next = this.getById(key);

if (next) {
this.trigger('show', {
step: next,
previous: this.currentStep
});
if (typeof next.options.showOn !== 'undefined' && !next.options.showOn()) {
var index = this.steps.indexOf(next);
var nextIndex = forward ? index + 1 : index - 1;
this.show(nextIndex, forward);
} else {
this.trigger('show', {
step: next,
previous: this.currentStep
});
this.currentStep = next;
next.show();
this.currentStep = next;
next.show();
}
}

@@ -636,0 +644,0 @@ }

@@ -1,1 +0,1 @@

!function(e,t){"function"==typeof define&&define.amd?define(["tether"],t):"object"==typeof exports?module.exports=t(require("tether")):e.Shepherd=t(e.Tether)}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=document.createElement("div");return t.innerHTML=e,t.children[0]}function o(e,t){var n=void 0;return"undefined"!=typeof e.matches?n=e.matches:"undefined"!=typeof e.matchesSelector?n=e.matchesSelector:"undefined"!=typeof e.msMatchesSelector?n=e.msMatchesSelector:"undefined"!=typeof e.webkitMatchesSelector?n=e.webkitMatchesSelector:"undefined"!=typeof e.mozMatchesSelector?n=e.mozMatchesSelector:"undefined"!=typeof e.oMatchesSelector&&(n=e.oMatchesSelector),n.call(e,t)}function r(e,t){if(null===e||"undefined"==typeof e)return e;if("object"==typeof e)return e;var n=e.split(" "),i=n.length,o=t.length;i>o&&(n[0]=n.slice(0,i-o+1).join(" "),n.splice(1,o));for(var r={},s=0;o>s;++s){var h=t[s];r[h]=n[s]}return r}var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),h=function(e,t,n){for(var i=!0;i;){var o=e,r=t,s=n;h=c=u=void 0,i=!1;var h=Object.getOwnPropertyDescriptor(o,r);if(void 0!==h){if("value"in h)return h.value;var u=h.get;return void 0===u?void 0:u.call(s)}var c=Object.getPrototypeOf(o);if(null===c)return void 0;e=c,t=r,n=s,i=!0}},u=e.Utils,c=u.Evented,a=u.addClass,d=u.extend,l=u.hasClass,p=u.removeClass,f=u.uniqueId,v=new c,y={top:"bottom center",left:"middle right",right:"middle left",bottom:"top center",center:"middle center"},m=function(u){function c(e,n){return t(this,c),h(Object.getPrototypeOf(c.prototype),"constructor",this).call(this,e,n),this.tour=e,this.bindMethods(),this.setOptions(n),this}return n(c,u),s(c,[{key:"bindMethods",value:function(){var e=this,t=["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy"];t.map(function(t){e[t]=e[t].bind(e)})}},{key:"setOptions",value:function(){var e=void 0===arguments[0]?{}:arguments[0];this.options=e,this.destroy(),this.id=this.options.id||this.id||"step-"+f();var t=this.options.when;if(t)for(var n in t)if({}.hasOwnProperty.call(t,n)){var i=t[n];this.on(n,i,this)}this.options.buttons||(this.options.buttons=[{text:"Next",action:this.tour.next}])}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var e=this,t=r(this.options.advanceOn,["selector","event"]),n=t.event,i=t.selector,s=function(t){e.isOpen()&&("undefined"!=typeof i?o(t.target,i)&&e.tour.next():e.el&&t.target===e.el&&e.tour.next())};document.body.addEventListener(n,s),this.on("destroy",function(){return document.body.removeEventListener(n,s)})}},{key:"getAttachTo",value:function(){var e=r(this.options.attachTo,["element","on"])||{},t=e.element;if("string"==typeof t&&(e.element=document.querySelector(t),!e.element))throw new Error("The element for this Shepherd step was not found "+t);return e}},{key:"setupTether",value:function(){if("undefined"==typeof e)throw new Error("Using the attachment feature of Shepherd requires the Tether library");var t=this.getAttachTo(),n=y[t.on||"right"];"undefined"==typeof t.element&&(t.element="viewport",n="middle center");var i={classPrefix:"shepherd",element:this.el,constraints:[{to:"window",pin:!0,attachment:"together"}],target:t.element,offset:t.offset||"0 0",attachment:n};this.tether&&this.tether.destroy(),this.tether=new e(d(i,this.options.tetherOptions))}},{key:"show",value:function(){var e=this;if("undefined"!=typeof this.options.beforeShowPromise){var t=this.options.beforeShowPromise();if("undefined"!=typeof t)return t.then(function(){return e._show()})}this._show()}},{key:"_show",value:function(){var e=this;this.trigger("before-show"),this.el||this.render(),a(this.el,"shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupTether(),this.options.scrollTo&&setTimeout(function(){e.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),p(this.el,"shepherd-open"),document.body.removeAttribute("data-shepherd-step"),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("hide")}},{key:"isOpen",value:function(){return l(this.el,"shepherd-open")}},{key:"cancel",value:function(){this.tour.cancel(),this.trigger("cancel")}},{key:"complete",value:function(){this.tour.complete(),this.trigger("complete")}},{key:"scrollTo",value:function(){var e=this.getAttachTo(),t=e.element;"undefined"!=typeof this.options.scrollToHandler?this.options.scrollToHandler(t):"undefined"!=typeof t&&t.scrollIntoView()}},{key:"destroy",value:function(){"undefined"!=typeof this.el&&(document.body.removeChild(this.el),delete this.el),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("destroy")}},{key:"render",value:function(){var e=this;"undefined"!=typeof this.el&&this.destroy(),this.el=i("<div class='shepherd-step "+(this.options.classes||"")+"' data-id='"+this.id+"' "+(this.options.idAttribute?'id="'+this.options.idAttribute+'"':"")+"></div>");var t=document.createElement("div");t.className="shepherd-content",this.el.appendChild(t);var n=document.createElement("header");if(t.appendChild(n),"undefined"!=typeof this.options.title&&(n.innerHTML+="<h3 class='shepherd-title'>"+this.options.title+"</h3>",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var o=i("<a href class='shepherd-cancel-link'>āœ•</a>");n.appendChild(o),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(o)}"undefined"!=typeof this.options.text&&!function(){var n=i("<div class='shepherd-text'></div>"),o=e.options.text;"function"==typeof o&&(o=o.call(e,n)),o instanceof HTMLElement?n.appendChild(o):("string"==typeof o&&(o=[o]),o.map(function(e){n.innerHTML+="<p>"+e+"</p>"})),t.appendChild(n)}();var r=document.createElement("footer");this.options.buttons&&!function(){var t=i("<ul class='shepherd-buttons'></ul>");e.options.buttons.map(function(n){var o=i("<li><a class='shepherd-button "+(n.classes||"")+"'>"+n.text+"</a>");t.appendChild(o),e.bindButtonEvents(n,o.querySelector("a"))}),r.appendChild(t)}(),t.appendChild(r),document.body.appendChild(this.el),this.setupTether(),this.options.advanceOn&&this.bindAdvance()}},{key:"bindCancelLink",value:function(e){var t=this;e.addEventListener("click",function(e){e.preventDefault(),t.cancel()})}},{key:"bindButtonEvents",value:function(e,t){var n=this;e.events=e.events||{},"undefined"!=typeof e.action&&(e.events.click=e.action);for(var i in e.events)if({}.hasOwnProperty.call(e.events,i)){var o=e.events[i];"string"==typeof o&&!function(){var e=o;o=function(){return n.tour.show(e)}}(),t.addEventListener(i,o)}this.on("destroy",function(){for(var n in e.events)if({}.hasOwnProperty.call(e.events,n)){var i=e.events[n];t.removeEventListener(n,i)}})}}]),c}(c),g=function(e){function i(){var e=this,n=void 0===arguments[0]?{}:arguments[0];t(this,i),h(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,n),this.bindMethods(),this.options=n,this.steps=this.options.steps||[];var o=["complete","cancel","hide","start","show","active","inactive"];return o.map(function(t){!function(t){e.on(t,function(n){n=n||{},n.tour=e,v.trigger(t,n)})}(t)}),this}return n(i,e),s(i,[{key:"bindMethods",value:function(){var e=this,t=["next","back","cancel","complete","hide"];t.map(function(t){e[t]=e[t].bind(e)})}},{key:"addStep",value:function(e,t){return"undefined"==typeof t&&(t=e),t instanceof m?t.tour=this:(("string"==typeof e||"number"==typeof e)&&(t.id=e.toString()),t=d({},this.options.defaults,t),t=new m(this,t)),this.steps.push(t),this}},{key:"getById",value:function(e){for(var t=0;t<this.steps.length;++t){var n=this.steps[t];if(n.id===e)return n}}},{key:"getCurrentStep",value:function(){return this.currentStep}},{key:"next",value:function(){var e=this.steps.indexOf(this.currentStep);e===this.steps.length-1?(this.hide(e),this.trigger("complete"),this.done()):this.show(e+1)}},{key:"back",value:function(){var e=this.steps.indexOf(this.currentStep);this.show(e-1)}},{key:"cancel",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("cancel"),this.done()}},{key:"complete",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("complete"),this.done()}},{key:"hide",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("hide"),this.done()}},{key:"done",value:function(){v.activeTour=null,p(document.body,"shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var e=void 0===arguments[0]?0:arguments[0];this.currentStep?this.currentStep.hide():(a(document.body,"shepherd-active"),this.trigger("active",{tour:this})),v.activeTour=this;var t=void 0;t="string"==typeof e?this.getById(e):this.steps[e],t&&(this.trigger("show",{step:t,previous:this.currentStep}),this.currentStep=t,t.show())}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),i}(c);return d(v,{Tour:g,Step:m,Evented:c}),v});
!function(e,t){"function"==typeof define&&define.amd?define(["tether"],t):"object"==typeof exports?module.exports=t(require("tether")):e.Shepherd=t(e.Tether)}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){var t=document.createElement("div");return t.innerHTML=e,t.children[0]}function o(e,t){var n=void 0;return"undefined"!=typeof e.matches?n=e.matches:"undefined"!=typeof e.matchesSelector?n=e.matchesSelector:"undefined"!=typeof e.msMatchesSelector?n=e.msMatchesSelector:"undefined"!=typeof e.webkitMatchesSelector?n=e.webkitMatchesSelector:"undefined"!=typeof e.mozMatchesSelector?n=e.mozMatchesSelector:"undefined"!=typeof e.oMatchesSelector&&(n=e.oMatchesSelector),n.call(e,t)}function s(e,t){if(null===e||"undefined"==typeof e)return e;if("object"==typeof e)return e;var n=e.split(" "),i=n.length,o=t.length;i>o&&(n[0]=n.slice(0,i-o+1).join(" "),n.splice(1,o));for(var s={},r=0;o>r;++r){var h=t[r];s[h]=n[r]}return s}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),h=function(e,t,n){for(var i=!0;i;){var o=e,s=t,r=n;h=a=u=void 0,i=!1,null===o&&(o=Function.prototype);var h=Object.getOwnPropertyDescriptor(o,s);if(void 0!==h){if("value"in h)return h.value;var u=h.get;return void 0===u?void 0:u.call(r)}var a=Object.getPrototypeOf(o);if(null===a)return void 0;e=a,t=s,n=r,i=!0}},u=e.Utils,a=u.Evented,c=u.addClass,d=u.extend,l=u.hasClass,p=u.removeClass,f=u.uniqueId,v=new a,y={top:"bottom center",left:"middle right",right:"middle left",bottom:"top center",center:"middle center"},m=function(u){function a(e,n){return t(this,a),h(Object.getPrototypeOf(a.prototype),"constructor",this).call(this,e,n),this.tour=e,this.bindMethods(),this.setOptions(n),this}return n(a,u),r(a,[{key:"bindMethods",value:function(){var e=this,t=["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy"];t.map(function(t){e[t]=e[t].bind(e)})}},{key:"setOptions",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=e,this.destroy(),this.id=this.options.id||this.id||"step-"+f();var t=this.options.when;if(t)for(var n in t)if({}.hasOwnProperty.call(t,n)){var i=t[n];this.on(n,i,this)}this.options.buttons||(this.options.buttons=[{text:"Next",action:this.tour.next}])}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var e=this,t=s(this.options.advanceOn,["selector","event"]),n=t.event,i=t.selector,r=function(t){e.isOpen()&&("undefined"!=typeof i?o(t.target,i)&&e.tour.next():e.el&&t.target===e.el&&e.tour.next())};document.body.addEventListener(n,r),this.on("destroy",function(){return document.body.removeEventListener(n,r)})}},{key:"getAttachTo",value:function(){var e=s(this.options.attachTo,["element","on"])||{},t=e.element;if("string"==typeof t&&(e.element=document.querySelector(t),!e.element))throw new Error("The element for this Shepherd step was not found "+t);return e}},{key:"setupTether",value:function(){if("undefined"==typeof e)throw new Error("Using the attachment feature of Shepherd requires the Tether library");var t=this.getAttachTo(),n=y[t.on||"right"];"undefined"==typeof t.element&&(t.element="viewport",n="middle center");var i={classPrefix:"shepherd",element:this.el,constraints:[{to:"window",pin:!0,attachment:"together"}],target:t.element,offset:t.offset||"0 0",attachment:n};this.tether&&this.tether.destroy(),this.tether=new e(d(i,this.options.tetherOptions))}},{key:"show",value:function(){var e=this;if("undefined"!=typeof this.options.beforeShowPromise){var t=this.options.beforeShowPromise();if("undefined"!=typeof t)return t.then(function(){return e._show()})}this._show()}},{key:"_show",value:function(){var e=this;this.trigger("before-show"),this.el||this.render(),c(this.el,"shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupTether(),this.options.scrollTo&&setTimeout(function(){e.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),p(this.el,"shepherd-open"),document.body.removeAttribute("data-shepherd-step"),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("hide")}},{key:"isOpen",value:function(){return l(this.el,"shepherd-open")}},{key:"cancel",value:function(){this.tour.cancel(),this.trigger("cancel")}},{key:"complete",value:function(){this.tour.complete(),this.trigger("complete")}},{key:"scrollTo",value:function(){var e=this.getAttachTo(),t=e.element;"undefined"!=typeof this.options.scrollToHandler?this.options.scrollToHandler(t):"undefined"!=typeof t&&t.scrollIntoView()}},{key:"destroy",value:function(){"undefined"!=typeof this.el&&(document.body.removeChild(this.el),delete this.el),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("destroy")}},{key:"render",value:function(){var e=this;"undefined"!=typeof this.el&&this.destroy(),this.el=i("<div class='shepherd-step "+(this.options.classes||"")+"' data-id='"+this.id+"' "+(this.options.idAttribute?'id="'+this.options.idAttribute+'"':"")+"></div>");var t=document.createElement("div");t.className="shepherd-content",this.el.appendChild(t);var n=document.createElement("header");if(t.appendChild(n),"undefined"!=typeof this.options.title&&(n.innerHTML+="<h3 class='shepherd-title'>"+this.options.title+"</h3>",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var o=i("<a href class='shepherd-cancel-link'>āœ•</a>");n.appendChild(o),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(o)}"undefined"!=typeof this.options.text&&!function(){var n=i("<div class='shepherd-text'></div>"),o=e.options.text;"function"==typeof o&&(o=o.call(e,n)),o instanceof HTMLElement?n.appendChild(o):("string"==typeof o&&(o=[o]),o.map(function(e){n.innerHTML+="<p>"+e+"</p>"})),t.appendChild(n)}();var s=document.createElement("footer");this.options.buttons&&!function(){var t=i("<ul class='shepherd-buttons'></ul>");e.options.buttons.map(function(n){var o=i("<li><a class='shepherd-button "+(n.classes||"")+"'>"+n.text+"</a>");t.appendChild(o),e.bindButtonEvents(n,o.querySelector("a"))}),s.appendChild(t)}(),t.appendChild(s),document.body.appendChild(this.el),this.setupTether(),this.options.advanceOn&&this.bindAdvance()}},{key:"bindCancelLink",value:function(e){var t=this;e.addEventListener("click",function(e){e.preventDefault(),t.cancel()})}},{key:"bindButtonEvents",value:function(e,t){var n=this;e.events=e.events||{},"undefined"!=typeof e.action&&(e.events.click=e.action);for(var i in e.events)if({}.hasOwnProperty.call(e.events,i)){var o=e.events[i];"string"==typeof o&&!function(){var e=o;o=function(){return n.tour.show(e)}}(),t.addEventListener(i,o)}this.on("destroy",function(){for(var n in e.events)if({}.hasOwnProperty.call(e.events,n)){var i=e.events[n];t.removeEventListener(n,i)}})}}]),a}(a),g=function(e){function i(){var e=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];t(this,i),h(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,n),this.bindMethods(),this.options=n,this.steps=this.options.steps||[];var o=["complete","cancel","hide","start","show","active","inactive"];return o.map(function(t){!function(t){e.on(t,function(n){n=n||{},n.tour=e,v.trigger(t,n)})}(t)}),this}return n(i,e),r(i,[{key:"bindMethods",value:function(){var e=this,t=["next","back","cancel","complete","hide"];t.map(function(t){e[t]=e[t].bind(e)})}},{key:"addStep",value:function(e,t){return"undefined"==typeof t&&(t=e),t instanceof m?t.tour=this:(("string"==typeof e||"number"==typeof e)&&(t.id=e.toString()),t=d({},this.options.defaults,t),t=new m(this,t)),this.steps.push(t),this}},{key:"getById",value:function(e){for(var t=0;t<this.steps.length;++t){var n=this.steps[t];if(n.id===e)return n}}},{key:"getCurrentStep",value:function(){return this.currentStep}},{key:"next",value:function(){var e=this.steps.indexOf(this.currentStep);e===this.steps.length-1?(this.hide(e),this.trigger("complete"),this.done()):this.show(e+1,!0)}},{key:"back",value:function(){var e=this.steps.indexOf(this.currentStep);this.show(e-1,!1)}},{key:"cancel",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("cancel"),this.done()}},{key:"complete",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("complete"),this.done()}},{key:"hide",value:function(){"undefined"!=typeof this.currentStep&&this.currentStep.hide(),this.trigger("hide"),this.done()}},{key:"done",value:function(){v.activeTour=null,p(document.body,"shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var e=arguments.length<=0||void 0===arguments[0]?0:arguments[0],t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];this.currentStep?this.currentStep.hide():(c(document.body,"shepherd-active"),this.trigger("active",{tour:this})),v.activeTour=this;var n=void 0;if(n="string"==typeof e?this.getById(e):this.steps[e])if("undefined"==typeof n.options.showOn||n.options.showOn())this.trigger("show",{step:n,previous:this.currentStep}),this.currentStep=n,n.show();else{var i=this.steps.indexOf(n),o=t?i+1:i-1;this.show(o,t)}}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),i}(a);return d(v,{Tour:g,Step:m,Evented:a}),v});

@@ -63,3 +63,10 @@ var del = require('del');

gulp.task('css:docs', function() {
gulp.src('./docs/welcome/sass/*.sass')
.pipe(sass())
.pipe(prefixer())
.pipe(gulp.dest('./docs/welcome/css'));
});
// Eager

@@ -94,4 +101,4 @@ gulp.task('eager', function() {

// Defaults
gulp.task('build', ['js', 'css', 'eager'])
gulp.task('default', ['build'])
gulp.task('build', ['js', 'css', 'eager']);
gulp.task('default', ['build']);
{
"name": "tether-shepherd",
"version": "1.1.3",
"version": "1.2.0",
"description": "Guide your users through a tour of your app.",

@@ -5,0 +5,0 @@ "authors": [

@@ -473,3 +473,3 @@ /* global Tether */

} else {
this.show(index + 1);
this.show(index + 1, true);
}

@@ -480,3 +480,3 @@ }

const index = this.steps.indexOf(this.currentStep);
this.show(index - 1);
this.show(index - 1, false);
}

@@ -514,3 +514,3 @@

show(key=0) {
show(key=0, forward=true) {
if (this.currentStep) {

@@ -526,2 +526,3 @@ this.currentStep.hide();

let next;
if (typeof key === 'string') {

@@ -534,9 +535,15 @@ next = this.getById(key);

if (next) {
this.trigger('show', {
step: next,
previous: this.currentStep
});
if (typeof next.options.showOn !== 'undefined' && !next.options.showOn()) {
const index = this.steps.indexOf(next);
const nextIndex = forward ? index + 1 : index - 1;
this.show(nextIndex, forward);
} else {
this.trigger('show', {
step: next,
previous: this.currentStep
});
this.currentStep = next;
next.show();
this.currentStep = next;
next.show();
}
}

@@ -543,0 +550,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc