shepherd.js
Advanced tools
Comparing version 2.0.0-beta.5 to 2.0.0-beta.6
@@ -1,2 +0,2 @@ | ||
/*! shepherd.js 2.0.0-beta.5 */ | ||
/*! shepherd.js 2.0.0-beta.6 */ | ||
@@ -622,3 +622,3 @@ (function(root, factory) { | ||
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); | ||
@@ -788,3 +788,3 @@ this.el.className += ' shepherd-has-cancel-link'; | ||
this.steps.push(step); | ||
return this; | ||
return step; | ||
} | ||
@@ -928,7 +928,2 @@ }, { | ||
}); | ||
if (this.currentStep) { | ||
this.currentStep.hide(); | ||
} | ||
this.currentStep = next; | ||
@@ -935,0 +930,0 @@ next.show(); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"function"==typeof define&&define.amd?define(["popper"],e):"object"==typeof exports?module.exports=e(require("popper")):t.Shepherd=e(t.Popper)}(this,function(t){"use strict";function e(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?o(t):e}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),t}function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var p,l=(p=0,function(){return++p});function u(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}function d(t){return void 0===t}function f(t){return"object"===c(t)}function v(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}var y=/^(.+) (top|left|right|bottom|center)$/;var b=function(){function t(){r(this,t)}return a(t,[{key:"on",value:function(t,e,i){var n=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];void 0===this.bindings&&(this.bindings={}),void 0===this.bindings[t]&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:i,once:n})}},{key:"once",value:function(t,e,i){this.on(t,e,i,!0)}},{key:"off",value:function(t,e){if(void 0!==this.bindings&&void 0!==this.bindings[t])if(void 0===e)delete this.bindings[t];else for(var i=0;i<this.bindings[t].length;)this.bindings[t][i].handler===e?this.bindings[t].splice(i,1):++i}},{key:"trigger",value:function(t){if(void 0!==this.bindings&&this.bindings[t]){for(var e=arguments.length,i=Array(e>1?e-1:0),n=0,s=1;s<e;s++)i[s-1]=arguments[s];for(;n<this.bindings[t].length;){var o=this.bindings[t][n],r=o.ctx,h=o.handler,a=o.once,c=r;void 0===c&&(c=this),h.apply(c,i),a?this.bindings[t].splice(n,1):++n}}}}]),t}(),g=function(s){function h(t,n){var s;return r(this,h),(s=e(this,i(h).call(this,t,n))).tour=t,s.bindMethods(),s.setOptions(n),e(s,o(o(s)))}return n(h,b),a(h,[{key:"bindMethods",value:function(){var t=this;["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy","render"].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-".concat(l());var e=this.options.when;if(e)for(var i in e)if({}.hasOwnProperty.call(e,i)){var n=e[i];this.on(i,n,this)}var s,o=JSON.stringify(this.options.buttons),r=d(o)||"true"===o,h="{}"===o||"[]"===o||"null"===o||"false"===o,a=!r&&((s=this.options.buttons)&&s.constructor===Array),c=!r&&function(t){return t&&t.constructor===Object}(this.options.buttons);r?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:!h&&c?this.options.buttons=[this.options.buttons]:!h&&a||(this.options.buttons=!1)}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var t=this,e=function(t,e){if(null===t||d(t))return t;if(f(t))return t;for(var i=t.split(" "),n={},s=e.length-1,o=i.length-1;o>=0;o--){if(0===s){n[e[s]]=i.slice(0,o+1).join(" ");break}n[e[s]]=i[o],s--}return n}(this.options.advanceOn,["selector","event"]),i=e.event,n=e.selector,s=function(e){var i,s,o;t.isOpen()&&(d(n)?t.el&&e.target===t.el&&t.tour.next():(i=e.target,s=n,d(i.matches)?d(i.matchesSelector)?d(i.msMatchesSelector)?d(i.webkitMatchesSelector)?d(i.mozMatchesSelector)?d(i.oMatchesSelector)||(o=i.oMatchesSelector):o=i.mozMatchesSelector:o=i.webkitMatchesSelector:o=i.msMatchesSelector:o=i.matchesSelector:o=i.matches,o.call(i,s)&&t.tour.next()))};document.body.addEventListener(i,s),this.on("destroy",function(){return document.body.removeEventListener(i,s)})}},{key:"getAttachTo",value:function(){var t=function(t){if(f(t))return t.hasOwnProperty("element")&&t.hasOwnProperty("on")?t:null;var e=y.exec(t);if(!e)return null;var i=e[2];return"["===i[0]&&(i=i.substring(1,i.length-1)),{element:e[1],on:i}}(this.options.attachTo)||{},e=u({},t);if("string"==typeof t.element){try{e.element=document.querySelector(t.element)}catch(t){}e.element||console.error("The element for this Shepherd step was not found ".concat(t.element))}return e}},{key:"setupPopper",value:function(){if(d(t))throw new Error("Using the attachment feature of Shepherd requires the Popper.js library");var e=this.getAttachTo();e.modifiers=e.modifiers||{};var i=e.on||"right";e.positionFixed=!1,d(e.element)&&(e.element=document.body,i="top",e.modifiers=u({applyStyle:{enabled:!1},flip:{enabled:!1},hide:{enabled:!1},inner:{enabled:!1},keepTogether:{enabled:!1},preventOverflow:{enabled:!1,padding:0}},e.modifiers),e.positionFixed=!0);var n=u({},{placement:i,arrowElement:this.el.querySelector(".popper__arrow"),modifiers:e.modifiers,positionFixed:e.positionFixed},this.options.popperOptions);this.popper&&this.popper.destroy(),this.el.classList.add("shepherd-element"),this.popper=new t(e.element,this.el,n),void 0===this.options.attachTo&&(this.popper.popper.style.position="fixed",this.popper.popper.style.left="50%",this.popper.popper.style.top="50%",this.popper.popper.style.transform="translate(-50%, -50%)"),this.target=e.element,this.target.classList.add("shepherd-target"),this.target.classList.add("shepherd-enabled")}},{key:"show",value:function(){var t=this;if(!d(this.options.beforeShowPromise)){var e=this.options.beforeShowPromise();if(!d(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(),this.el.classList.add("shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupPopper(),this.options.scrollTo&&setTimeout(function(){t.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),this.el.classList.remove("shepherd-open"),document.body.removeAttribute("data-shepherd-step"),this.target&&this.target.classList.remove("shepherd-enabled"),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("hide")}},{key:"isOpen",value:function(){return this.el&&this.el.classList.hasClass("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().element;d(this.options.scrollToHandler)?d(t)||t.scrollIntoView():this.options.scrollToHandler(t)}},{key:"destroy",value:function(){!d(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("destroy")}},{key:"render",value:function(){var t=this;d(this.el)||this.destroy(),this.el=v("<div class='shepherd-step ".concat(this.options.classes||"","' data-id='").concat(this.id,"' ").concat(this.options.idAttribute?'id="'.concat(this.options.idAttribute,'"'):"",">")),this.options.attachTo&&this.el.appendChild(v('<div class="popper__arrow" x-arrow></div>'));var e=document.createElement("div");e.className="shepherd-content",this.el.appendChild(e);var i=document.createElement("header");if(e.appendChild(i),this.options.title&&(i.innerHTML+="<h3 class='shepherd-title'>".concat(this.options.title,"</h3>"),this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var n=v("<a href class='shepherd-cancel-link'>ā</a>");i.appendChild(n),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(n)}if(!d(this.options.text)){var s=v("<div class='shepherd-text'></div>"),o=this.options.text;"function"==typeof o&&(o=o.call(this,s)),o instanceof HTMLElement?s.appendChild(o):("string"==typeof o&&(o=[o]),o.map(function(t){s.innerHTML+="<p>".concat(t,"</p>")})),e.appendChild(s)}if(this.options.buttons){var r=document.createElement("footer"),h=v("<ul class='shepherd-buttons'></ul>");this.options.buttons.map(function(e){var i=v("<li><a class='shepherd-button ".concat(e.classes||"","'>").concat(e.text,"</a>"));h.appendChild(i),t.bindButtonEvents(e,i.querySelector("a"))}),r.appendChild(h),e.appendChild(r)}document.body.appendChild(this.el),this.setupPopper(),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 i=this;for(var n in t.events=t.events||{},d(t.action)||(t.events.click=t.action),t.events)if({}.hasOwnProperty.call(t.events,n)){var s=t.events[n];"string"==typeof s&&function(){var t=s;s=function(){return i.tour.show(t)}}(),e.addEventListener(n,s)}this.on("destroy",function(){for(var i in t.events)if({}.hasOwnProperty.call(t.events,i)){var n=t.events[i];e.removeEventListener(i,n)}})}}]),h}(),m=function(t){function s(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,s),(t=e(this,i(s).call(this,n))).bindMethods(),t.options=n,t.steps=t.options.steps||[];return["complete","cancel","hide","start","show","active","inactive"].map(function(e){var i;i=e,t.on(i,function(e){(e=e||{}).tour=o(o(t)),w.trigger(i,e)})}),e(t,o(o(t)))}return n(s,b),a(s,[{key:"bindMethods",value:function(){var t=this;["next","back","cancel","complete","hide"].map(function(e){t[e]=t[e].bind(t)})}},{key:"addStep",value:function(t,e){return d(e)&&(e=t),e instanceof g?e.tour=this:("string"!=typeof t&&"number"!=typeof t||(e.id=t.toString()),e=u({},this.options.defaults,e),e=new g(this,e)),this.steps.push(e),this}},{key:"removeStep",value:function(t){for(var e=this.getCurrentStep(),i=0;i<this.steps.length;++i){var n=this.steps[i];if(n.id===t){n.isOpen()&&n.hide(),n.destroy(),this.steps.splice(i,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 i=this.steps[e];if(i.id===t)return i}}},{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,document.body.classList.remove("shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.currentStep?this.currentStep.hide():(document.body.classList.add("shepherd-active"),this.trigger("active",{tour:this})),w.activeTour=this,t="string"==typeof e?this.getById(e):this.steps[e])if(d(t.options.showOn)||t.options.showOn())this.trigger("show",{step:t,previous:this.currentStep}),this.currentStep&&this.currentStep.hide(),this.currentStep=t,t.show();else{var n=this.steps.indexOf(t),s=i?n+1:n-1;this.show(s,i)}}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),s}(),w=new b;return u(w,{Tour:m,Step:g,Evented:b}),w}); | ||
!function(t,e){"function"==typeof define&&define.amd?define(["popper"],e):"object"==typeof exports?module.exports=e(require("popper")):t.Shepherd=e(t.Popper)}(this,function(t){"use strict";function e(t,e){return!e||"object"!==c(e)&&"function"!=typeof e?s(t):e}function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(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)}}function a(t,e,n){return e&&h(t.prototype,e),n&&h(t,n),t}function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var p,l=(p=0,function(){return++p});function u(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(e[o]=i[o])}return e}function d(t){return void 0===t}function f(t){return"object"===c(t)}function v(t){var e=document.createElement("div");return e.innerHTML=t,e.children[0]}var y=/^(.+) (top|left|right|bottom|center)$/;var b=function(){function t(){r(this,t)}return a(t,[{key:"on",value:function(t,e,n){var i=!(arguments.length<=3||void 0===arguments[3])&&arguments[3];void 0===this.bindings&&(this.bindings={}),void 0===this.bindings[t]&&(this.bindings[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:i})}},{key:"once",value:function(t,e,n){this.on(t,e,n,!0)}},{key:"off",value:function(t,e){if(void 0!==this.bindings&&void 0!==this.bindings[t])if(void 0===e)delete this.bindings[t];else for(var n=0;n<this.bindings[t].length;)this.bindings[t][n].handler===e?this.bindings[t].splice(n,1):++n}},{key:"trigger",value:function(t){if(void 0!==this.bindings&&this.bindings[t]){for(var e=arguments.length,n=Array(e>1?e-1:0),i=0,o=1;o<e;o++)n[o-1]=arguments[o];for(;i<this.bindings[t].length;){var s=this.bindings[t][i],r=s.ctx,h=s.handler,a=s.once,c=r;void 0===c&&(c=this),h.apply(c,n),a?this.bindings[t].splice(i,1):++i}}}}]),t}(),g=function(o){function h(t,i){var o;return r(this,h),(o=e(this,n(h).call(this,t,i))).tour=t,o.bindMethods(),o.setOptions(i),e(o,s(s(o)))}return i(h,b),a(h,[{key:"bindMethods",value:function(){var t=this;["_show","show","hide","isOpen","cancel","complete","scrollTo","destroy","render"].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-".concat(l());var e=this.options.when;if(e)for(var n in e)if({}.hasOwnProperty.call(e,n)){var i=e[n];this.on(n,i,this)}var o,s=JSON.stringify(this.options.buttons),r=d(s)||"true"===s,h="{}"===s||"[]"===s||"null"===s||"false"===s,a=!r&&((o=this.options.buttons)&&o.constructor===Array),c=!r&&function(t){return t&&t.constructor===Object}(this.options.buttons);r?this.options.buttons=[{text:"Next",action:this.tour.next,classes:"btn"}]:!h&&c?this.options.buttons=[this.options.buttons]:!h&&a||(this.options.buttons=!1)}},{key:"getTour",value:function(){return this.tour}},{key:"bindAdvance",value:function(){var t=this,e=function(t,e){if(null===t||d(t))return t;if(f(t))return t;for(var n=t.split(" "),i={},o=e.length-1,s=n.length-1;s>=0;s--){if(0===o){i[e[o]]=n.slice(0,s+1).join(" ");break}i[e[o]]=n[s],o--}return i}(this.options.advanceOn,["selector","event"]),n=e.event,i=e.selector,o=function(e){var n,o,s;t.isOpen()&&(d(i)?t.el&&e.target===t.el&&t.tour.next():(n=e.target,o=i,d(n.matches)?d(n.matchesSelector)?d(n.msMatchesSelector)?d(n.webkitMatchesSelector)?d(n.mozMatchesSelector)?d(n.oMatchesSelector)||(s=n.oMatchesSelector):s=n.mozMatchesSelector:s=n.webkitMatchesSelector:s=n.msMatchesSelector:s=n.matchesSelector:s=n.matches,s.call(n,o)&&t.tour.next()))};document.body.addEventListener(n,o),this.on("destroy",function(){return document.body.removeEventListener(n,o)})}},{key:"getAttachTo",value:function(){var t=function(t){if(f(t))return t.hasOwnProperty("element")&&t.hasOwnProperty("on")?t:null;var e=y.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}}(this.options.attachTo)||{},e=u({},t);if("string"==typeof t.element){try{e.element=document.querySelector(t.element)}catch(t){}e.element||console.error("The element for this Shepherd step was not found ".concat(t.element))}return e}},{key:"setupPopper",value:function(){if(d(t))throw new Error("Using the attachment feature of Shepherd requires the Popper.js library");var e=this.getAttachTo();e.modifiers=e.modifiers||{};var n=e.on||"right";e.positionFixed=!1,d(e.element)&&(e.element=document.body,n="top",e.modifiers=u({applyStyle:{enabled:!1},flip:{enabled:!1},hide:{enabled:!1},inner:{enabled:!1},keepTogether:{enabled:!1},preventOverflow:{enabled:!1,padding:0}},e.modifiers),e.positionFixed=!0);var i=u({},{placement:n,arrowElement:this.el.querySelector(".popper__arrow"),modifiers:e.modifiers,positionFixed:e.positionFixed},this.options.popperOptions);this.popper&&this.popper.destroy(),this.el.classList.add("shepherd-element"),this.popper=new t(e.element,this.el,i),void 0===this.options.attachTo&&(this.popper.popper.style.position="fixed",this.popper.popper.style.left="50%",this.popper.popper.style.top="50%",this.popper.popper.style.transform="translate(-50%, -50%)"),this.target=e.element,this.target.classList.add("shepherd-target"),this.target.classList.add("shepherd-enabled")}},{key:"show",value:function(){var t=this;if(!d(this.options.beforeShowPromise)){var e=this.options.beforeShowPromise();if(!d(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(),this.el.classList.add("shepherd-open"),document.body.setAttribute("data-shepherd-step",this.id),this.setupPopper(),this.options.scrollTo&&setTimeout(function(){t.scrollTo()}),this.trigger("show")}},{key:"hide",value:function(){this.trigger("before-hide"),this.el.classList.remove("shepherd-open"),document.body.removeAttribute("data-shepherd-step"),this.target&&this.target.classList.remove("shepherd-enabled"),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("hide")}},{key:"isOpen",value:function(){return this.el&&this.el.classList.hasClass("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().element;d(this.options.scrollToHandler)?d(t)||t.scrollIntoView():this.options.scrollToHandler(t)}},{key:"destroy",value:function(){!d(this.el)&&this.el.parentNode&&(this.el.parentNode.removeChild(this.el),delete this.el),this.popper&&this.popper.destroy(),this.popper=null,this.trigger("destroy")}},{key:"render",value:function(){var t=this;d(this.el)||this.destroy(),this.el=v("<div class='shepherd-step ".concat(this.options.classes||"","' data-id='").concat(this.id,"' ").concat(this.options.idAttribute?'id="'.concat(this.options.idAttribute,'"'):"",">")),this.options.attachTo&&this.el.appendChild(v('<div class="popper__arrow" x-arrow></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'>".concat(this.options.title,"</h3>"),this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var i=v('<a href class="shepherd-cancel-link"></a>');n.appendChild(i),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(i)}if(!d(this.options.text)){var o=v("<div class='shepherd-text'></div>"),s=this.options.text;"function"==typeof s&&(s=s.call(this,o)),s instanceof HTMLElement?o.appendChild(s):("string"==typeof s&&(s=[s]),s.map(function(t){o.innerHTML+="<p>".concat(t,"</p>")})),e.appendChild(o)}if(this.options.buttons){var r=document.createElement("footer"),h=v("<ul class='shepherd-buttons'></ul>");this.options.buttons.map(function(e){var n=v("<li><a class='shepherd-button ".concat(e.classes||"","'>").concat(e.text,"</a>"));h.appendChild(n),t.bindButtonEvents(e,n.querySelector("a"))}),r.appendChild(h),e.appendChild(r)}document.body.appendChild(this.el),this.setupPopper(),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;for(var i in t.events=t.events||{},d(t.action)||(t.events.click=t.action),t.events)if({}.hasOwnProperty.call(t.events,i)){var o=t.events[i];"string"==typeof o&&function(){var t=o;o=function(){return n.tour.show(t)}}(),e.addEventListener(i,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)}})}}]),h}(),m=function(t){function o(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,o),(t=e(this,n(o).call(this,i))).bindMethods(),t.options=i,t.steps=t.options.steps||[];return["complete","cancel","hide","start","show","active","inactive"].map(function(e){var n;n=e,t.on(n,function(e){(e=e||{}).tour=s(s(t)),w.trigger(n,e)})}),e(t,s(s(t)))}return i(o,b),a(o,[{key:"bindMethods",value:function(){var t=this;["next","back","cancel","complete","hide"].map(function(e){t[e]=t[e].bind(t)})}},{key:"addStep",value:function(t,e){return d(e)&&(e=t),e instanceof g?e.tour=this:("string"!=typeof t&&"number"!=typeof t||(e.id=t.toString()),e=u({},this.options.defaults,e),e=new g(this,e)),this.steps.push(e),e}},{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.isOpen()&&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,document.body.classList.remove("shepherd-active"),this.trigger("inactive",{tour:this})}},{key:"show",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.currentStep?this.currentStep.hide():(document.body.classList.add("shepherd-active"),this.trigger("active",{tour:this})),w.activeTour=this,t="string"==typeof e?this.getById(e):this.steps[e])if(d(t.options.showOn)||t.options.showOn())this.trigger("show",{step:t,previous:this.currentStep}),this.currentStep=t,t.show();else{var i=this.steps.indexOf(t),o=n?i+1:i-1;this.show(o,n)}}},{key:"start",value:function(){this.trigger("start"),this.currentStep=null,this.next()}}]),o}(),w=new b;return u(w,{Tour:m,Step:g,Evented:b}),w}); |
@@ -6,5 +6,4 @@ const del = require('del'); | ||
const coffee = require('gulp-coffee'); | ||
const gulpSequence = require('gulp-sequence'); | ||
const header = require('gulp-header'); | ||
const hljs = require('highlight.js'); | ||
const markdown = require('gulp-markdown'); | ||
const prefixer = require('gulp-autoprefixer'); | ||
@@ -59,3 +58,3 @@ const rename = require('gulp-rename'); | ||
gulp.task('css', function() { | ||
gulp.src('./src/css/**/*.sass') | ||
gulp.src('./src/css/**/*.scss') | ||
.pipe(sass()) | ||
@@ -66,25 +65,4 @@ .pipe(prefixer()) | ||
gulp.task('markdown:docs', () => { | ||
gulp.src('./docs/intro.md') | ||
.pipe( | ||
markdown({ | ||
highlight: function(code, lang) { | ||
if (!lang) { | ||
return code; | ||
} | ||
return hljs.highlight(lang, code).value; | ||
} | ||
}) | ||
) | ||
.pipe(rename(function(path) { | ||
path.extname = '.html'; | ||
})) | ||
.pipe(gulp.dest('./docs/')); | ||
gulp.src('./node_modules/highlight.js/styles/ocean.css') | ||
.pipe(gulp.dest('./docs')); | ||
}); | ||
gulp.task('css:docs', function() { | ||
gulp.src('./docs/welcome/sass/*.sass') | ||
gulp.src('./docs/welcome/sass/*.scss') | ||
.pipe(sass()) | ||
@@ -95,4 +73,2 @@ .pipe(prefixer()) | ||
gulp.task('docs', ['css:docs', 'markdown:docs']); | ||
// Make a copy of popper available to those not using bundling | ||
@@ -136,4 +112,4 @@ gulp.task('copy-popper', function() { | ||
// Defaults | ||
gulp.task('build', ['js', 'css', 'eager', 'copy-popper', 'docs']); | ||
gulp.task('build', ['js', 'css', 'eager', 'copy-popper']); | ||
gulp.task('docs', gulpSequence('build', 'css:docs')); | ||
gulp.task('default', ['build']); | ||
{ | ||
"name": "shepherd.js", | ||
"version": "2.0.0-beta.5", | ||
"version": "2.0.0-beta.6", | ||
"repository": { | ||
@@ -20,2 +20,3 @@ "type": "git", | ||
"build": "gulp build", | ||
"docs": "gulp docs", | ||
"lint": "eslint ./src/js/shepherd.js" | ||
@@ -44,8 +45,7 @@ }, | ||
"gulp-header": "^2.0.5", | ||
"gulp-markdown": "^2.0.1", | ||
"gulp-rename": "^1.3.0", | ||
"gulp-sass": "^4.0.1", | ||
"gulp-sequence": "^1.0.0", | ||
"gulp-uglify-es": "^1.0.4", | ||
"gulp-wrap-umd": "^0.2.1", | ||
"highlight.js": "^9.12.0" | ||
"gulp-wrap-umd": "^0.2.1" | ||
}, | ||
@@ -52,0 +52,0 @@ "engines": { |
@@ -530,3 +530,3 @@ /* global Popper */ | ||
if (this.options.showCancelLink) { | ||
const link = createFromHTML('<a href class=\'shepherd-cancel-link\'>ā</a>'); | ||
const link = createFromHTML('<a href class="shepherd-cancel-link"></a>'); | ||
header.appendChild(link); | ||
@@ -674,3 +674,3 @@ | ||
this.steps.push(step); | ||
return this; | ||
return step; | ||
} | ||
@@ -793,6 +793,2 @@ | ||
if (this.currentStep) { | ||
this.currentStep.hide(); | ||
} | ||
this.currentStep = next; | ||
@@ -799,0 +795,0 @@ next.show(); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
16
0
246794
34
5076