diff --git a/bower.json b/bower.json index 5f199e876..19981650f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tether-shepherd", - "version": "1.5.1", + "version": "1.5.2", "homepage": "https://github.com/HubSpot/shepherd", "authors": [ "Zack Bloom ", diff --git a/dist/js/shepherd.js b/dist/js/shepherd.js index c0c74280a..e2a0ce394 100644 --- a/dist/js/shepherd.js +++ b/dist/js/shepherd.js @@ -67,6 +67,14 @@ 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; + } + return null; + } + var matches = positionRe.exec(str); if (!matches) { return null; diff --git a/dist/js/shepherd.min.js b/dist/js/shepherd.min.js index bd0a3ce95..f586a1bb4 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 s(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){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={},s=t.length-1,r=n.length-1;r>=0;r--){if(0===s){i[t[s]]=n.slice(0,r+1).join(" ");break}i[t[s]]=n[r],s--}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 s=i("");n.appendChild(s),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(s)}"undefined"!=typeof this.options.text&&!function(){var n=i("
"),s=e.options.text;"function"==typeof s&&(s=s.call(e,n)),s instanceof HTMLElement?n.appendChild(s):("string"==typeof s&&(s=[s]),s.map(function(e){n.innerHTML+="

"+e+"

"})),t.appendChild(n)}();var r=document.createElement("footer");this.options.buttons&&!function(){var t=i("");e.options.buttons.map(function(n){var s=i("
  • "+n.text+"");t.appendChild(s),e.bindButtonEvents(n,s.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 s=e.events[i];"string"==typeof s&&!function(){var e=s;s=function(){return n.tour.show(e)}}(),t.addEventListener(i,s)}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 s=["complete","cancel","hide","start","show","active","inactive"];return s.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", diff --git a/src/js/shepherd.js b/src/js/shepherd.js index 9b5d612c7..fc064ef64 100644 --- a/src/js/shepherd.js +++ b/src/js/shepherd.js @@ -46,7 +46,15 @@ function matchesSelector (el, sel) { const positionRe = /^(.+) (top|left|right|bottom|center|\[[a-z ]+\])$/ function parsePosition (str) { - let matches = positionRe.exec(str) + + if (typeof(str) === 'object') { + if (str.hasOwnProperty("element") && str.hasOwnProperty("on")) { + return str; + } + return null; + } + + let matches = positionRe.exec(str); if (!matches) { return null; }