tether-shepherd
Advanced tools
Comparing version 1.7.0 to 1.8.0
{ | ||
"name": "tether-shepherd", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"homepage": "https://github.com/HubSpot/shepherd", | ||
@@ -10,3 +10,4 @@ "authors": [ | ||
"maintainers": [ | ||
"Nicholas Hwang <nick.joosung.hwang@gmail.com>" | ||
"Nicholas Hwang <nick.joosung.hwang@gmail.com>", | ||
"Geoff Daigle <geoffreydaigle@gmail.com>" | ||
], | ||
@@ -13,0 +14,0 @@ "description": "Guide your users through a tour of your app.", |
@@ -0,3 +1,29 @@ | ||
## v1.7.0 | ||
- Fixes bug where `buttons: false` resulted in the default Next button instead of showing the desired result of no buttons. | ||
## v1.6.0 & v1.6.2 | ||
- Patches issue where Tether anchor reference was being cached instead of reset when step is shown. | ||
## v1.5.2 | ||
- Adds functionality to pass an object `{element: el, on: tetherPositionString}` to tour step `attachTo` parameter. | ||
## v1.5.1 | ||
- Exposes `scrollTo` option in Eager | ||
## v1.5.0 | ||
- Positioning string parse improvements with regex | ||
- Installation support for dynamically rendered pages in Eager | ||
- Live updates for eager / creation of `tour.removeStep` | ||
## v1.2.2 | ||
- Moves `Tether.js` out of `bower_components` and into `dist` for supoort in Eager | ||
## v1.2.1 | ||
- Exposes tour object on eager install | ||
## v1.2.0 | ||
- Adds `showOn` for conditonally showing tour steps | ||
## v1.1.4 | ||
- Install helper now checks for the presence of first attach node before starting | ||
- Eager - Install helper now checks for the presence of first attach node before starting | ||
@@ -8,3 +34,3 @@ ## v1.1.2 & v1.1.3 | ||
## v1.1.1 | ||
- Pointer event none for arros | ||
- Pointer event none for arrows | ||
@@ -11,0 +37,0 @@ ## v1.1.0 |
@@ -1,2 +0,2 @@ | ||
/*! tether-shepherd 1.7.0 */ | ||
/*! tether-shepherd 1.8.0 */ | ||
@@ -52,2 +52,11 @@ (function(root, factory) { | ||
var ATTACHMENT = { | ||
'top right': 'bottom left', | ||
'top left': 'bottom right', | ||
'top center': 'bottom center', | ||
'middle right': 'middle left', | ||
'middle left': 'middle right', | ||
'middle center': 'middle center', | ||
'bottom left': 'top right', | ||
'bottom right': 'top left', | ||
'bottom center': 'top center', | ||
'top': 'bottom center', | ||
@@ -57,3 +66,4 @@ 'left': 'middle right', | ||
'bottom': 'top center', | ||
'center': 'middle center' | ||
'center': 'middle center', | ||
'middle': 'middle center' | ||
}; | ||
@@ -270,3 +280,3 @@ | ||
var opts = this.getAttachTo(); | ||
var attachment = ATTACHMENT[opts.on || 'right'] || opts.on; | ||
var attachment = ATTACHMENT[opts.on] || ATTACHMENT.right; | ||
if (isUndefined(opts.element)) { | ||
@@ -273,0 +283,0 @@ opts.element = 'viewport'; |
@@ -1,1 +0,1 @@ | ||
!function(n,i){"function"==typeof define&&define.amd?define(["tether"],i):"object"==typeof exports?module.exports=i(require("tether")):n.Shepherd=i(n.Tether)}(this,function(Tether){"use strict";function n(n,i){if(!(n instanceof i))throw new TypeError("Cannot call a class as a function")}function i(n,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i&&(Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=i)}function s(n){return"undefined"==typeof n}function o(n){return n&&n.constructor===Array}function c(n){return n&&n.constructor===Object}function a(n){return"object"==typeof n}function u(n){var i=document.createElement("div");return i.innerHTML=n,i.children[0]}function l(n,i){var o=void 0;return s(n.matches)?s(n.matchesSelector)?s(n.msMatchesSelector)?s(n.webkitMatchesSelector)?s(n.mozMatchesSelector)?s(n.oMatchesSelector)||(o=n.oMatchesSelector):o=n.mozMatchesSelector:o=n.webkitMatchesSelector:o=n.msMatchesSelector:o=n.matchesSelector:o=n.matches,o.call(n,i)}function p(n){if(a(n))return n.hasOwnProperty("element")&&n.hasOwnProperty("on")?n:null;var i=C.exec(n);if(!i)return null;var s=i[2];return"["===s[0]&&(s=s.substring(1,s.length-1)),{element:i[1],on:s}}function d(n,i){if(null===n||s(n))return n;if(a(n))return n;for(var o=n.split(" "),c={},u=i.length-1,l=o.length-1;l>=0;l--){if(0===u){c[i[u]]=o.slice(0,l+1).join(" ");break}c[i[u]]=o[l],u--}return c}var f=function(){function n(n,i){for(var s=0;s<i.length;s++){var o=i[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(n,o.key,o)}}return function(i,s,o){return s&&n(i.prototype,s),o&&n(i,o),i}}(),v=function(n,i,s){for(var o=!0;o;){var c=n,a=i,u=s;o=!1,null===c&&(c=Function.prototype);var l=Object.getOwnPropertyDescriptor(c,a);if(void 0!==l){if("value"in l)return l.value;var p=l.get;if(void 0===p)return;return p.call(u)}var d=Object.getPrototypeOf(c);if(null===d)return;n=d,i=a,s=u,o=!0,l=d=void 0}},m=Tether.Utils,y=m.Evented,g=m.addClass,b=m.extend,w=m.hasClass,k=m.removeClass,S=m.uniqueId,O=new y,x={top:"bottom center",left:"middle right",right:"middle left",bottom:"top center",center:"middle center"},C=/^(.+) (top|left|right|bottom|center|\[[a-z ]+\])$/,E=function(a){function m(i,s){return n(this,m),v(Object.getPrototypeOf(m.prototype),"constructor",this).call(this,i,s),this.tour=i,this.bindMethods(),this.setOptions(s),this}return i(m,a),f(m,[{key:"bindMethods",value:function(){var n=this,i=["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy","render"];i.map(function(i){n[i]=n[i].bind(n)})}},{key:"setOptions",value:function(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=n,this.destroy(),this.id=this.options.id||this.id||"step-"+S();var i=this.options.when;if(i)for(var a in i)if({}.hasOwnProperty.call(i,a)){var u=i[a];this.on(a,u,this)}var l=JSON.stringify(this.options.buttons),p=s(l)||"true"===l,d="{}"===l||"[]"===l||"null"===l||"false"===l,f=!p&&o(this.options.buttons),v=!p&&c(this.options.buttons);p?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:!d&&v?this.options.buttons=[this.options.buttons]:(d||!f)&&(this.options.buttons=!1)}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var n=this,i=d(this.options.advanceOn,["selector","event"]),o=i.event,c=i.selector,a=function(e){n.isOpen()&&(s(c)?n.el&&e.target===n.el&&n.tour.next():l(e.target,c)&&n.tour.next())};document.body.addEventListener(o,a),this.on("destroy",function(){return document.body.removeEventListener(o,a)})}},{key:"getAttachTo",value:function(){var n=p(this.options.attachTo)||{},i=b({},n);return"string"==typeof n.element&&(i.element=document.querySelector(n.element),i.element||console.error("The element for this Shepherd step was not found "+n.element)),i}},{key:"setupTether",value:function(){if(s(Tether))throw new Error("Using the attachment feature of Shepherd requires the Tether library");var n=this.getAttachTo(),i=x[n.on||"right"]||n.on;s(n.element)&&(n.element="viewport",i="middle center");var o={classPrefix:"shepherd",element:this.el,constraints:[{to:"window",pin:!0,attachment:"together"}],target:n.element,offset:n.offset||"0 0",attachment:i};this.tether&&this.tether.destroy(),this.tether=new Tether(b(o,this.options.tetherOptions))}},{key:"show",value:function(){var n=this;if(!s(this.options.beforeShowPromise)){var i=this.options.beforeShowPromise();if(!s(i))return i.then(function(){return n._show()})}this._show()}},{key:"_show",value:function(){var n=this;this.trigger("before-show"),this.el||this.render(),g(this.el,"shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupTether(),this.options.scrollTo&&setTimeout(function(){n.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),k(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 this.el&&w(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 n=this.getAttachTo(),i=n.element;s(this.options.scrollToHandler)?s(i)||i.scrollIntoView():this.options.scrollToHandler(i)}},{key:"destroy",value:function(){!s(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("destroy")}},{key:"render",value:function(){var n=this;s(this.el)||this.destroy(),this.el=u("<div class='shepherd-step "+(this.options.classes||"")+"' data-id='"+this.id+"' "+(this.options.idAttribute?'id="'+this.options.idAttribute+'"':"")+"></div>");var i=document.createElement("div");i.className="shepherd-content",this.el.appendChild(i);var o=document.createElement("header");if(i.appendChild(o),this.options.title&&(o.innerHTML+="<h3 class='shepherd-title'>"+this.options.title+"</h3>",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var c=u("<a href class='shepherd-cancel-link'>ā</a>");o.appendChild(c),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(c)}s(this.options.text)||!function(){var s=u("<div class='shepherd-text'></div>"),o=n.options.text;"function"==typeof o&&(o=o.call(n,s)),o instanceof HTMLElement?s.appendChild(o):("string"==typeof o&&(o=[o]),o.map(function(n){s.innerHTML+="<p>"+n+"</p>"})),i.appendChild(s)}(),this.options.buttons&&!function(){var s=document.createElement("footer"),o=u("<ul class='shepherd-buttons'></ul>");n.options.buttons.map(function(i){var s=u("<li><a class='shepherd-button "+(i.classes||"")+"'>"+i.text+"</a>");o.appendChild(s),n.bindButtonEvents(i,s.querySelector("a"))}),s.appendChild(o),i.appendChild(s)}(),document.body.appendChild(this.el),this.setupTether(),this.options.advanceOn&&this.bindAdvance()}},{key:"bindCancelLink",value:function(n){var i=this;n.addEventListener("click",function(e){e.preventDefault(),i.cancel()})}},{key:"bindButtonEvents",value:function(n,i){var o=this;n.events=n.events||{},s(n.action)||(n.events.click=n.action);for(var c in n.events)if({}.hasOwnProperty.call(n.events,c)){var a=n.events[c];"string"==typeof a&&!function(){var n=a;a=function(){return o.tour.show(n)}}(),i.addEventListener(c,a)}this.on("destroy",function(){for(var s in n.events)if({}.hasOwnProperty.call(n.events,s)){var o=n.events[s];i.removeEventListener(s,o)}})}}]),m}(y),M=function(o){function c(){var i=this,s=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];n(this,c),v(Object.getPrototypeOf(c.prototype),"constructor",this).call(this,s),this.bindMethods(),this.options=s,this.steps=this.options.steps||[];var o=["complete","cancel","hide","start","show","active","inactive"];return o.map(function(n){!function(e){i.on(e,function(n){n=n||{},n.tour=i,O.trigger(e,n)})}(n)}),this}return i(c,o),f(c,[{key:"bindMethods",value:function(){var n=this,i=["next","back","cancel","complete","hide"];i.map(function(i){n[i]=n[i].bind(n)})}},{key:"addStep",value:function(n,i){return s(i)&&(i=n),i instanceof E?i.tour=this:(("string"==typeof n||"number"==typeof n)&&(i.id=n.toString()),i=b({},this.options.defaults,i),i=new E(this,i)),this.steps.push(i),this}},{key:"removeStep",value:function(n){for(var i=this.getCurrentStep(),s=0;s<this.steps.length;++s){var o=this.steps[s];if(o.id===n){o.hide(),o.destroy(),this.steps.splice(s,1);break}}i&&i.id===n&&(this.currentStep=void 0,this.steps.length?this.show(0):this.hide())}},{key:"getById",value:function(n){for(var i=0;i<this.steps.length;++i){var s=this.steps[i];if(s.id===n)return s}}},{key:"getCurrentStep",value:function(){return this.currentStep}},{key:"next",value:function(){var n=this.steps.indexOf(this.currentStep);n===this.steps.length-1?(this.hide(n),this.trigger("complete"),this.done()):this.show(n+1,!0)}},{key:"back",value:function(){var n=this.steps.indexOf(this.currentStep);this.show(n-1,!1)}},{key:"cancel",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("cancel"),this.done()}},{key:"complete",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("complete"),this.done()}},{key:"hide",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("hide"),this.done()}},{key:"done",value:function(){O.activeTour=null,k(document.body,"shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0],i=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];this.currentStep?this.currentStep.hide():(g(document.body,"shepherd-active"),this.trigger("active",{tour:this})),O.activeTour=this;var o=void 0;if(o="string"==typeof n?this.getById(n):this.steps[n])if(s(o.options.showOn)||o.options.showOn())this.trigger("show",{step:o,previous:this.currentStep}),this.currentStep&&this.currentStep.hide(),this.currentStep=o,o.show();else{var c=this.steps.indexOf(o),a=i?c+1:c-1;this.show(a,i)}}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),c}(y);return b(O,{Tour:M,Step:E,Evented:y}),O}); | ||
!function(t,e){"function"==typeof define&&define.amd?define(["tether"],e):"object"==typeof exports?module.exports=e(require("tether")):t.Shepherd=e(t.Tether)}(this,function(t){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){return"undefined"==typeof t}function r(t){return t&&t.constructor===Array}function o(t){return t&&t.constructor===Object}function s(t){return"object"==typeof t}function h(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}function c(t,e){var n=void 0;return i(t.matches)?i(t.matchesSelector)?i(t.msMatchesSelector)?i(t.webkitMatchesSelector)?i(t.mozMatchesSelector)?i(t.oMatchesSelector)||(n=t.oMatchesSelector):n=t.mozMatchesSelector:n=t.webkitMatchesSelector:n=t.msMatchesSelector:n=t.matchesSelector:n=t.matches,n.call(t,e)}function l(t){if(s(t))return t.hasOwnProperty("element")&&t.hasOwnProperty("on")?t:null;var e=S.exec(t);if(!e)return null;var n=e[2];return"["===n[0]&&(n=n.substring(1,n.length-1)),{element:e[1],on:n}}function a(t,e){if(null===t||i(t))return t;if(s(t))return t;for(var n=t.split(" "),r={},o=e.length-1,h=n.length-1;h>=0;h--){if(0===o){r[e[o]]=n.slice(0,h+1).join(" ");break}r[e[o]]=n[h],o--}return r}var u=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),d=function(t,e,n){for(var i=!0;i;){var r=t,o=e,s=n;i=!1,null===r&&(r=Function.prototype);var h=Object.getOwnPropertyDescriptor(r,o);if(void 0!==h){if("value"in h)return h.value;var c=h.get;if(void 0===c)return;return c.call(s)}var l=Object.getPrototypeOf(r);if(null===l)return;t=l,e=o,n=s,i=!0,h=l=void 0}},p=t.Utils,f=p.Evented,v=p.addClass,m=p.extend,y=p.hasClass,g=p.removeClass,b=p.uniqueId,w=new f,k={"top right":"bottom left","top left":"bottom right","top center":"bottom center","middle right":"middle left","middle left":"middle right","middle center":"middle center","bottom left":"top right","bottom right":"top left","bottom center":"top center",top:"bottom center",left:"middle right",right:"middle left",bottom:"top center",center:"middle center",middle:"middle center"},S=/^(.+) (top|left|right|bottom|center|\[[a-z ]+\])$/,O=function(s){function p(t,n){return e(this,p),d(Object.getPrototypeOf(p.prototype),"constructor",this).call(this,t,n),this.tour=t,this.bindMethods(),this.setOptions(n),this}return n(p,s),u(p,[{key:"bindMethods",value:function(){var t=this,e=["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy","render"];e.map(function(e){t[e]=t[e].bind(t)})}},{key:"setOptions",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=t,this.destroy(),this.id=this.options.id||this.id||"step-"+b();var e=this.options.when;if(e)for(var n in e)if({}.hasOwnProperty.call(e,n)){var s=e[n];this.on(n,s,this)}var h=JSON.stringify(this.options.buttons),c=i(h)||"true"===h,l="{}"===h||"[]"===h||"null"===h||"false"===h,a=!c&&r(this.options.buttons),u=!c&&o(this.options.buttons);c?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:!l&&u?this.options.buttons=[this.options.buttons]:!l&&a||(this.options.buttons=!1)}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var t=this,e=a(this.options.advanceOn,["selector","event"]),n=e.event,r=e.selector,o=function(e){t.isOpen()&&(i(r)?t.el&&e.target===t.el&&t.tour.next():c(e.target,r)&&t.tour.next())};document.body.addEventListener(n,o),this.on("destroy",function(){return document.body.removeEventListener(n,o)})}},{key:"getAttachTo",value:function(){var t=l(this.options.attachTo)||{},e=m({},t);return"string"==typeof t.element&&(e.element=document.querySelector(t.element),e.element||console.error("The element for this Shepherd step was not found "+t.element)),e}},{key:"setupTether",value:function(){if(i(t))throw new Error("Using the attachment feature of Shepherd requires the Tether library");var e=this.getAttachTo(),n=k[e.on]||k.right;i(e.element)&&(e.element="viewport",n="middle center");var r={classPrefix:"shepherd",element:this.el,constraints:[{to:"window",pin:!0,attachment:"together"}],target:e.element,offset:e.offset||"0 0",attachment:n};this.tether&&this.tether.destroy(),this.tether=new t(m(r,this.options.tetherOptions))}},{key:"show",value:function(){var t=this;if(!i(this.options.beforeShowPromise)){var e=this.options.beforeShowPromise();if(!i(e))return e.then(function(){return t._show()})}this._show()}},{key:"_show",value:function(){var t=this;this.trigger("before-show"),this.el||this.render(),v(this.el,"shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupTether(),this.options.scrollTo&&setTimeout(function(){t.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),g(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 this.el&&y(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 t=this.getAttachTo(),e=t.element;i(this.options.scrollToHandler)?i(e)||e.scrollIntoView():this.options.scrollToHandler(e)}},{key:"destroy",value:function(){!i(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.tether&&this.tether.destroy(),this.tether=null,this.trigger("destroy")}},{key:"render",value:function(){var t=this;i(this.el)||this.destroy(),this.el=h("<div class='shepherd-step "+(this.options.classes||"")+"' data-id='"+this.id+"' "+(this.options.idAttribute?'id="'+this.options.idAttribute+'"':"")+"></div>");var e=document.createElement("div");e.className="shepherd-content",this.el.appendChild(e);var n=document.createElement("header");if(e.appendChild(n),this.options.title&&(n.innerHTML+="<h3 class='shepherd-title'>"+this.options.title+"</h3>",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var r=h("<a href class='shepherd-cancel-link'>ā</a>");n.appendChild(r),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(r)}i(this.options.text)||!function(){var n=h("<div class='shepherd-text'></div>"),i=t.options.text;"function"==typeof i&&(i=i.call(t,n)),i instanceof HTMLElement?n.appendChild(i):("string"==typeof i&&(i=[i]),i.map(function(t){n.innerHTML+="<p>"+t+"</p>"})),e.appendChild(n)}(),this.options.buttons&&!function(){var n=document.createElement("footer"),i=h("<ul class='shepherd-buttons'></ul>");t.options.buttons.map(function(e){var n=h("<li><a class='shepherd-button "+(e.classes||"")+"'>"+e.text+"</a>");i.appendChild(n),t.bindButtonEvents(e,n.querySelector("a"))}),n.appendChild(i),e.appendChild(n)}(),document.body.appendChild(this.el),this.setupTether(),this.options.advanceOn&&this.bindAdvance()}},{key:"bindCancelLink",value:function(t){var e=this;t.addEventListener("click",function(t){t.preventDefault(),e.cancel()})}},{key:"bindButtonEvents",value:function(t,e){var n=this;t.events=t.events||{},i(t.action)||(t.events.click=t.action);for(var r in t.events)if({}.hasOwnProperty.call(t.events,r)){var o=t.events[r];"string"==typeof o&&!function(){var t=o;o=function(){return n.tour.show(t)}}(),e.addEventListener(r,o)}this.on("destroy",function(){for(var n in t.events)if({}.hasOwnProperty.call(t.events,n)){var i=t.events[n];e.removeEventListener(n,i)}})}}]),p}(f),T=function(t){function r(){var t=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];e(this,r),d(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,n),this.bindMethods(),this.options=n,this.steps=this.options.steps||[];var i=["complete","cancel","hide","start","show","active","inactive"];return i.map(function(e){!function(e){t.on(e,function(n){n=n||{},n.tour=t,w.trigger(e,n)})}(e)}),this}return n(r,t),u(r,[{key:"bindMethods",value:function(){var t=this,e=["next","back","cancel","complete","hide"];e.map(function(e){t[e]=t[e].bind(t)})}},{key:"addStep",value:function(t,e){return i(e)&&(e=t),e instanceof O?e.tour=this:("string"!=typeof t&&"number"!=typeof t||(e.id=t.toString()),e=m({},this.options.defaults,e),e=new O(this,e)),this.steps.push(e),this}},{key:"removeStep",value:function(t){for(var e=this.getCurrentStep(),n=0;n<this.steps.length;++n){var i=this.steps[n];if(i.id===t){i.hide(),i.destroy(),this.steps.splice(n,1);break}}e&&e.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.hide())}},{key:"getById",value:function(t){for(var e=0;e<this.steps.length;++e){var n=this.steps[e];if(n.id===t)return n}}},{key:"getCurrentStep",value:function(){return this.currentStep}},{key:"next",value:function(){var t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?(this.hide(t),this.trigger("complete"),this.done()):this.show(t+1,!0)}},{key:"back",value:function(){var t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}},{key:"cancel",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("cancel"),this.done()}},{key:"complete",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("complete"),this.done()}},{key:"hide",value:function(){this.currentStep&&this.currentStep.hide(),this.trigger("hide"),this.done()}},{key:"done",value:function(){w.activeTour=null,g(document.body,"shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var t=arguments.length<=0||void 0===arguments[0]?0:arguments[0],e=arguments.length<=1||void 0===arguments[1]?!0:arguments[1];this.currentStep?this.currentStep.hide():(v(document.body,"shepherd-active"),this.trigger("active",{tour:this})),w.activeTour=this;var n=void 0;if(n="string"==typeof t?this.getById(t):this.steps[t])if(i(n.options.showOn)||n.options.showOn())this.trigger("show",{step:n,previous:this.currentStep}),this.currentStep&&this.currentStep.hide(),this.currentStep=n,n.show();else{var r=this.steps.indexOf(n),o=e?r+1:r-1;this.show(o,e)}}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),r}(f);return m(w,{Tour:T,Step:O,Evented:f}),w}); |
@@ -16,3 +16,3 @@ <link rel="stylesheet" href="/shepherd/dist/css/shepherd-theme-arrows.css" /> | ||
The easiest way to add a Shepherd tour to your site is with [Eager](http://eager.io). | ||
Click Install to create a tour write on your site with no coding required. | ||
Click Install to create a tour right on your site with no coding required. | ||
@@ -19,0 +19,0 @@ <iframe style="height: 48px; width: 180px" src="//install.eager.io?appId=AalP5veMma6s" allowtransparency="true" scroll="no" frameBorder="0"></iframe> |
@@ -47,7 +47,3 @@ var del = require('del'); | ||
// Minified | ||
.pipe(uglify({ | ||
mangle: { | ||
except: 'Tether' | ||
} | ||
})) | ||
.pipe(uglify()) | ||
.pipe(rename({suffix: '.min'})) | ||
@@ -54,0 +50,0 @@ .pipe(gulp.dest(distDir + '/js')); |
@@ -27,2 +27,6 @@ { | ||
"execute": "ShepherdInstallHelper.setOptions(INSTALL_OPTIONS)" | ||
}, | ||
{ | ||
"options": ["theme"], | ||
"reload": true | ||
} | ||
@@ -29,0 +33,0 @@ ] |
{ | ||
"name": "tether-shepherd", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "Guide your users through a tour of your app.", | ||
@@ -10,3 +10,4 @@ "authors": [ | ||
"maintainers": [ | ||
"Nicholas Hwang <nick.joosung.hwang@gmail.com>" | ||
"Nicholas Hwang <nick.joosung.hwang@gmail.com>", | ||
"Geoff Daigle <geoffreydaigle@gmail.com>" | ||
], | ||
@@ -13,0 +14,0 @@ "scripts": { |
@@ -31,2 +31,11 @@ /* global Tether */ | ||
const ATTACHMENT = { | ||
'top right': 'bottom left', | ||
'top left': 'bottom right', | ||
'top center': 'bottom center', | ||
'middle right': 'middle left', | ||
'middle left': 'middle right', | ||
'middle center': 'middle center', | ||
'bottom left': 'top right', | ||
'bottom right': 'top left', | ||
'bottom center': 'top center', | ||
'top': 'bottom center', | ||
@@ -36,3 +45,4 @@ 'left': 'middle right', | ||
'bottom': 'top center', | ||
'center': 'middle center' | ||
'center': 'middle center', | ||
'middle': 'middle center' | ||
}; | ||
@@ -243,3 +253,3 @@ | ||
let opts = this.getAttachTo(); | ||
let attachment = ATTACHMENT[opts.on || 'right'] || opts.on; | ||
let attachment = ATTACHMENT[opts.on] || ATTACHMENT.right; | ||
if (isUndefined(opts.element)) { | ||
@@ -246,0 +256,0 @@ opts.element = 'viewport'; |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
347852
39
4796