diff --git a/dist/js/shepherd.js b/dist/js/shepherd.js index e2a0ce394..bfdd49202 100644 --- a/dist/js/shepherd.js +++ b/dist/js/shepherd.js @@ -1,4 +1,4 @@ -/*! tether-shepherd 1.5.1 */ +/*! tether-shepherd 1.5.2 */ (function(root, factory) { if (typeof define === 'function' && define.amd) { @@ -67,7 +67,6 @@ function matchesSelector(el, sel) { var positionRe = /^(.+) (top|left|right|bottom|center|\[[a-z ]+\])$/; function parsePosition(str) { - if (typeof str === 'object') { if (str.hasOwnProperty("element") && str.hasOwnProperty("on")) { return str; @@ -208,17 +207,18 @@ var Step = (function (_Evented) { key: 'getAttachTo', value: function getAttachTo() { var opts = parsePosition(this.options.attachTo) || {}; - var selector = opts.element; - - if (typeof selector === 'string') { - opts.element = document.querySelector(selector); - - if (!opts.element) { - throw new Error('The element for this Shepherd step was not found ' + selector); + var returnOpts = extend({}, opts); + + if (typeof opts.element === 'string') { + // Can't override the element in user opts reference because we can't + // guarantee that the element will exist in the future. + returnOpts.element = document.querySelector(opts.element); + if (!returnOpts.element) { + console.error('The element for this Shepherd step was not found ' + opts.element); } } - return opts; + return returnOpts; } }, { key: 'setupTether', diff --git a/dist/js/shepherd.min.js b/dist/js/shepherd.min.js index f586a1bb4..2feb99393 100644 --- a/dist/js/shepherd.min.js +++ b/dist/js/shepherd.min.js @@ -1 +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&&(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 r(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){if("object"==typeof e)return e.hasOwnProperty("element")&&e.hasOwnProperty("on")?e:null;var t=g.exec(e);if(!t)return null;var n=t[2];return"["===n[0]&&(n=n.substring(1,n.length-1)),{element:t[1],on:n}}function o(e,t){if(null===e||"undefined"==typeof e)return e;if("object"==typeof e)return e;for(var n=e.split(" "),i={},r=t.length-1,s=n.length-1;s>=0;s--){if(0===r){i[t[r]]=n.slice(0,s+1).join(" ");break}i[t[r]]=n[s],r--}return i}var h=function(){function e(e,t){for(var n=0;n");var t=document.createElement("div");t.className="shepherd-content",this.el.appendChild(t);var n=document.createElement("header");if(t.appendChild(n),this.options.title&&(n.innerHTML+="

"+this.options.title+"

",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var r=i("");n.appendChild(r),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(r)}"undefined"!=typeof this.options.text&&!function(){var n=i("
"),r=e.options.text;"function"==typeof r&&(r=r.call(e,n)),r instanceof HTMLElement?n.appendChild(r):("string"==typeof r&&(r=[r]),r.map(function(e){n.innerHTML+="

"+e+"

"})),t.appendChild(n)}();var s=document.createElement("footer");this.options.buttons&&!function(){var t=i("");e.options.buttons.map(function(n){var r=i("
  • "+n.text+"");t.appendChild(r),e.bindButtonEvents(n,r.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 r=e.events[i];"string"==typeof r&&!function(){var e=r;r=function(){return n.tour.show(e)}}(),t.addEventListener(i,r)}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),w=function(e){function i(){var e=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];t(this,i),u(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,n),this.bindMethods(),this.options=n,this.steps=this.options.steps||[];var r=["complete","cancel","hide","start","show","active","inactive"];return r.map(function(t){!function(t){e.on(t,function(n){n=n||{},n.tour=e,y.trigger(t,n)})}(t)}),this}return n(i,e),h(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 b?t.tour=this:(("string"==typeof e||"number"==typeof e)&&(t.id=e.toString()),t=d({},this.options.defaults,t),t=new b(this,t)),this.steps.push(t),this}},{key:"removeStep",value:function(e){for(var t=this.getCurrentStep(),n=0;n=0;s--){if(0===r){i[t[r]]=n.slice(0,s+1).join(" ");break}i[t[r]]=n[s],r--}return i}var h=function(){function e(e,t){for(var n=0;n");var t=document.createElement("div");t.className="shepherd-content",this.el.appendChild(t);var n=document.createElement("header");if(t.appendChild(n),this.options.title&&(n.innerHTML+="

    "+this.options.title+"

    ",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var r=i("");n.appendChild(r),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(r)}"undefined"!=typeof this.options.text&&!function(){var n=i("
    "),r=e.options.text;"function"==typeof r&&(r=r.call(e,n)),r instanceof HTMLElement?n.appendChild(r):("string"==typeof r&&(r=[r]),r.map(function(e){n.innerHTML+="

    "+e+"

    "})),t.appendChild(n)}();var s=document.createElement("footer");this.options.buttons&&!function(){var t=i("
      ");e.options.buttons.map(function(n){var r=i("
    • "+n.text+"");t.appendChild(r),e.bindButtonEvents(n,r.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 r=e.events[i];"string"==typeof r&&!function(){var e=r;r=function(){return n.tour.show(e)}}(),t.addEventListener(i,r)}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),w=function(e){function i(){var e=this,n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];t(this,i),u(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,n),this.bindMethods(),this.options=n,this.steps=this.options.steps||[];var r=["complete","cancel","hide","start","show","active","inactive"];return r.map(function(t){!function(t){e.on(t,function(n){n=n||{},n.tour=e,y.trigger(t,n)})}(t)}),this}return n(i,e),h(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 b?t.tour=this:(("string"==typeof e||"number"==typeof e)&&(t.id=e.toString()),t=d({},this.options.defaults,t),t=new b(this,t)),this.steps.push(t),this}},{key:"removeStep",value:function(e){for(var t=this.getCurrentStep(),n=0;n