diff --git a/dist/driver.min.js b/dist/driver.min.js index 4dec43c53ae445d327ace207d643375a8a5fce81..cb113bfcd68a924430f5065f5822ca79ba416b7d 100644 --- a/dist/driver.min.js +++ b/dist/driver.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Driver=e():t.Driver=e()}(window,function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=8)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.OVERLAY_OPACITY=.75,e.OVERLAY_PADDING=10,e.OVERLAY_ANIMATE=!0,e.OVERLAY_ZINDEX="999999999",e.ESC_KEY_CODE=27,e.LEFT_KEY_CODE=37,e.RIGHT_KEY_CODE=39,e.ID_OVERLAY="driver-canvas-overlay";var o=e.ID_POPOVER="driver-popover-item",n=e.CLASS_POPOVER_TIP="driver-popover-tip",s=e.CLASS_POPOVER_TITLE="driver-popover-title",h=e.CLASS_POPOVER_DESCRIPTION="driver-popover-description",r=e.CLASS_POPOVER_FOOTER="driver-popover-footer",l=e.CLASS_CLOSE_BTN="driver-close-btn",a=e.CLASS_NEXT_STEP_BTN="driver-next-btn",d=e.CLASS_PREV_STEP_BTN="driver-prev-btn";e.CLASS_BTN_DISABLED="driver-disabled",e.POPOVER_HTML='\n
\n
\n
Popover Title
\n
Popover Description
\n
\n Close\n \n ← Previous\n Next →\n \n
\n
'},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i=this.window.pageYOffset&&e>=this.window.pageXOffset&&t+o<=this.window.pageYOffset+this.window.innerHeight&&e+i<=this.window.pageXOffset+this.window.innerWidth}},{key:"scrollManually",value:function(){var t=this.node.getBoundingClientRect().top+this.window.pageYOffset-this.window.innerHeight/2;this.window.scrollTo(0,t)}},{key:"bringInView",value:function(){if(!this.isInView())if(this.node.scrollIntoView)try{this.node.scrollIntoView(this.options.scrollIntoViewOptions||{behavior:"smooth",block:"center"})}catch(t){this.scrollManually()}else this.scrollManually()}},{key:"getCalculatedPosition",value:function(){var t=this.getScreenCoordinates(),e=new h.default({left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:0,bottom:0});return"number"==typeof t.x&&"number"==typeof t.y&&(this.node.offsetWidth>0||this.node.offsetHeight>0)&&(e.left=Math.min(e.left,t.x),e.top=Math.min(e.top,t.y),e.right=Math.max(e.right,t.x+this.node.offsetWidth),e.bottom=Math.max(e.bottom,t.y+this.node.offsetHeight)),e}},{key:"onDeselected",value:function(){this.hidePopover(),this.highlightFinished=!1,this.options.onDeselected&&this.options.onDeselected(this)}},{key:"onHighlightStarted",value:function(){this.showPopover(),this.highlightFinished=!1,this.options.onHighlightStarted&&this.options.onHighlightStarted(this)}},{key:"onHighlighted",value:function(){this.showPopover(),this.highlightFinished=!0;var t=this.overlay.getLastHighlightedElement(),e=this.popover;this.node!==(t&&t.node)&&(e&&!e.isInView()&&e.bringInView(),this.isInView()||this.bringInView()),this.options.onHighlighted&&this.options.onHighlighted(this)}},{key:"getNode",value:function(){return this.node}},{key:"hidePopover",value:function(){this.popover&&this.popover.hide()}},{key:"showPopover",value:function(){if(this.popover){var t=this.getCalculatedPosition();this.popover.show(t)}}},{key:"getFullPageSize",value:function(){var t=this.document.body,e=this.document.documentElement;return{height:Math.max(t.scrollHeight,t.offsetHeight,e.scrollHeight,e.offsetHeight),width:Math.max(t.scrollWidth,t.offsetWidth,e.scrollWidth,e.offsetWidth)}}}]),t}();e.default=r,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{},i=e.left,o=void 0===i?0:i,n=e.top,s=void 0===n?0:n,h=e.right,r=void 0===h?0:h,l=e.bottom,a=void 0===l?0:l;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.left=o,this.right=r,this.top=s,this.bottom=a}return o(t,[{key:"canHighlight",value:function(){return this.left=o?this.positionOnTop(t):this.positionOnBottom(t)}}],[{key:"createFromString",value:function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}}]),e}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1])||arguments[1];if(t&&t.node){t.onHighlightStarted(),this.highlightedElement&&this.highlightedElement.onDeselected();var i=t.getCalculatedPosition();i.canHighlight()&&(this.lastHighlightedElement=this.highlightedElement,this.highlightedElement=t,this.positionToHighlight=i,this.options.animate&&e||(this.highlightedPosition=this.positionToHighlight),this.draw())}else console.warn("Invalid element to highlight. Must be an instance of `Element`")}},{key:"getHighlightedElement",value:function(){return this.highlightedElement}},{key:"getLastHighlightedElement",value:function(){return this.lastHighlightedElement}},{key:"clear",value:function(){this.positionToHighlight=new h.default,this.highlightedElement&&this.highlightedElement.onDeselected(),this.highlightedElement=null,this.lastHighlightedElement=null,this.draw()}},{key:"draw",value:function(){var t=this.positionToHighlight.canHighlight();this.removeCloak(),this.addCloak();var e=this.overlayAlpha<.1;t&&(e?this.highlightedPosition=this.positionToHighlight:(this.highlightedPosition.left+=.18*(this.positionToHighlight.left-this.highlightedPosition.left),this.highlightedPosition.top+=.18*(this.positionToHighlight.top-this.highlightedPosition.top),this.highlightedPosition.right+=.18*(this.positionToHighlight.right-this.highlightedPosition.right),this.highlightedPosition.bottom+=.18*(this.positionToHighlight.bottom-this.highlightedPosition.bottom))),this.removeCloak({posX:this.highlightedPosition.left-this.window.scrollX-this.options.padding,posY:this.highlightedPosition.top-this.window.scrollY-this.options.padding,width:this.highlightedPosition.right-this.highlightedPosition.left+2*this.options.padding,height:this.highlightedPosition.bottom-this.highlightedPosition.top+2*this.options.padding}),t?this.options.animate?this.overlayAlpha+=.08*(this.options.opacity-this.overlayAlpha):this.overlayAlpha=this.options.opacity:this.overlayAlpha=Math.max(.85*this.overlayAlpha-.02,0),this.window.cancelAnimationFrame(this.redrawAnimation),t||this.overlayAlpha>0?(this.overlay.parentNode||this.document.body.appendChild(this.overlay),this.hasPositionHighlighted()?!this.options.animate&&e?this.redrawAnimation=this.window.requestAnimationFrame(this.draw):this.highlightedElement.onHighlighted():this.redrawAnimation=this.window.requestAnimationFrame(this.draw)):this.overlay.parentNode&&this.document.body.removeChild(this.overlay)}},{key:"hasPositionHighlighted",value:function(){return this.positionToHighlight.equals(this.highlightedPosition)&&this.overlayAlpha>this.options.opacity-.05}},{key:"removeCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.clearRect(i,n,h,l)}},{key:"addCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.fillStyle="rgba( 0, 0, 0, "+this.overlayAlpha+" )",this.context.fillRect(i,n,h,l)}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.overlay.width=t||this.window.innerWidth,this.overlay.height=e||this.window.innerHeight}},{key:"refresh",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.setSize(),this.highlightedElement&&(this.window.cancelAnimationFrame(this.redrawAnimation),this.highlight(this.highlightedElement,t),this.highlightedElement.onHighlighted())}}]),t}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=Object.assign({animate:r.OVERLAY_ANIMATE,opacity:r.OVERLAY_OPACITY,padding:r.OVERLAY_PADDING,scrollIntoViewOptions:null,onHighlightStarted:function(){},onHighlighted:function(){},onDeselected:function(){}},e),this.document=document,this.window=window,this.isActivated=!1,this.overlay=new n.default(this.options,this.window,this.document),this.steps=[],this.currentStep=0,this.onScroll=this.onScroll.bind(this),this.onResize=this.onResize.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onClick=this.onClick.bind(this),this.bind()}return o(t,[{key:"bind",value:function(){this.document.addEventListener("scroll",this.onScroll,!1),this.document.addEventListener("DOMMouseScroll",this.onScroll,!1),this.window.addEventListener("resize",this.onResize,!1),this.window.addEventListener("keyup",this.onKeyUp,!1),this.window.addEventListener("click",this.onClick,!1)}},{key:"onClick",value:function(t){if(this.hasHighlightedElement()&&this.isActivated){var e=this.overlay.getHighlightedElement(),i=this.document.getElementById(r.ID_POPOVER),o=e.node.contains(t.target),n=i&&i.contains(t.target);if(o||n){var s=t.target.classList.contains(r.CLASS_NEXT_STEP_BTN),h=t.target.classList.contains(r.CLASS_PREV_STEP_BTN);t.target.classList.contains(r.CLASS_CLOSE_BTN)?this.reset():s?this.moveNext():h&&this.movePrevious()}else this.reset()}}},{key:"movePrevious",value:function(){this.currentStep-=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"moveNext",value:function(){this.currentStep+=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"hasNextStep",value:function(){return!!this.steps[this.currentStep+1]}},{key:"hasPreviousStep",value:function(){return!!this.steps[this.currentStep-1]}},{key:"reset",value:function(){this.currentStep=0,this.isActivated=!1,this.overlay.clear()}},{key:"hasHighlightedElement",value:function(){var t=this.overlay.getHighlightedElement();return t&&t.node&&t.highlightFinished}},{key:"getHighlightedElement",value:function(){return this.overlay.getHighlightedElement()}},{key:"getLastHighlightedElement",value:function(){return this.overlay.getLastHighlightedElement()}},{key:"onScroll",value:function(){this.isActivated&&this.overlay.refresh(!1)}},{key:"onResize",value:function(){this.isActivated&&this.overlay.refresh(!0)}},{key:"onKeyUp",value:function(t){this.isActivated&&(t.keyCode===r.ESC_KEY_CODE?this.reset():t.keyCode===r.RIGHT_KEY_CODE?this.moveNext():t.keyCode===r.LEFT_KEY_CODE&&this.movePrevious())}},{key:"defineSteps",value:function(t){var e=this;this.steps=[],t.forEach(function(i,o){if(!i.element||"string"!=typeof i.element)throw new Error("Element (query selector string) missing in step "+o);var n=e.prepareElementFromStep(i,t,o);n&&e.steps.push(n)})}},{key:"prepareElementFromStep",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o="",n={};"string"==typeof t?o=t:(o=t.element,n=Object.assign({},this.options,t));var r=this.document.querySelector(o);if(!r)return console.warn("Element to highlight "+o+" not found"),null;var l=null;if(n.popover&&n.popover.description){var a=Object.assign({},this.options,n.popover,{totalCount:e.length,currentIndex:i,isFirst:0===i,isLast:i===e.length-1});l=new h.default(a,this.window,this.document)}return new s.default(r,n,l,this.overlay,this.window,this.document)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!this.steps||0===this.steps.length)throw new Error("There are no steps defined to iterate");this.isActivated=!0,this.currentStep=t,this.overlay.highlight(this.steps[t])}},{key:"highlight",value:function(t){this.isActivated=!0;var e=this.prepareElementFromStep(t);e&&this.overlay.highlight(e)}}]),t}();e.default=a,t.exports=e.default},function(t,e){},function(t,e,i){i(7),t.exports=i(6)}])}); +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Driver=e():t.Driver=e()}(window,function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=8)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.OVERLAY_OPACITY=.75,e.OVERLAY_PADDING=10,e.OVERLAY_ANIMATE=!0,e.OVERLAY_ZINDEX="999999999",e.ESC_KEY_CODE=27,e.LEFT_KEY_CODE=37,e.RIGHT_KEY_CODE=39,e.ID_OVERLAY="driver-canvas-overlay";var o=e.ID_POPOVER="driver-popover-item",n=e.CLASS_POPOVER_TIP="driver-popover-tip",s=e.CLASS_POPOVER_TITLE="driver-popover-title",h=e.CLASS_POPOVER_DESCRIPTION="driver-popover-description",r=e.CLASS_POPOVER_FOOTER="driver-popover-footer",l=e.CLASS_CLOSE_BTN="driver-close-btn",a=e.CLASS_NEXT_STEP_BTN="driver-next-btn",d=e.CLASS_PREV_STEP_BTN="driver-prev-btn";e.CLASS_BTN_DISABLED="driver-disabled",e.POPOVER_HTML='\n
\n
\n
Popover Title
\n
Popover Description
\n
\n Close\n \n ← Previous\n Next →\n \n
\n
'},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i=this.window.pageYOffset&&e>=this.window.pageXOffset&&t+o<=this.window.pageYOffset+this.window.innerHeight&&e+i<=this.window.pageXOffset+this.window.innerWidth}},{key:"scrollManually",value:function(){var t=this.node.getBoundingClientRect().top+this.window.pageYOffset-this.window.innerHeight/2;this.window.scrollTo(0,t)}},{key:"bringInView",value:function(){if(!this.isInView())if(this.node.scrollIntoView)try{this.node.scrollIntoView(this.options.scrollIntoViewOptions||{behavior:"smooth",block:"center"})}catch(t){this.scrollManually()}else this.scrollManually()}},{key:"getCalculatedPosition",value:function(){var t=this.getScreenCoordinates(),e=new h.default({left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:0,bottom:0});return"number"==typeof t.x&&"number"==typeof t.y&&(this.node.offsetWidth>0||this.node.offsetHeight>0)&&(e.left=Math.min(e.left,t.x),e.top=Math.min(e.top,t.y),e.right=Math.max(e.right,t.x+this.node.offsetWidth),e.bottom=Math.max(e.bottom,t.y+this.node.offsetHeight)),e}},{key:"onDeselected",value:function(){this.hidePopover(),this.highlightFinished=!1,this.options.onDeselected&&this.options.onDeselected(this)}},{key:"onHighlightStarted",value:function(){this.showPopover(),this.highlightFinished=!1,this.options.onHighlightStarted&&this.options.onHighlightStarted(this)}},{key:"onHighlighted",value:function(){this.showPopover(),this.highlightFinished=!0;var t=this.overlay.getLastHighlightedElement(),e=this.popover;this.node!==(t&&t.node)&&(e&&!e.isInView()&&e.bringInView(),this.isInView()||this.bringInView()),this.options.onHighlighted&&this.options.onHighlighted(this)}},{key:"getNode",value:function(){return this.node}},{key:"hidePopover",value:function(){this.popover&&this.popover.hide()}},{key:"showPopover",value:function(){if(this.popover){var t=this.getCalculatedPosition();this.popover.show(t)}}},{key:"getFullPageSize",value:function(){var t=this.document.body,e=this.document.documentElement;return{height:Math.max(t.scrollHeight,t.offsetHeight,e.scrollHeight,e.offsetHeight),width:Math.max(t.scrollWidth,t.offsetWidth,e.scrollWidth,e.offsetWidth)}}}]),t}();e.default=r,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{},i=e.left,o=void 0===i?0:i,n=e.top,s=void 0===n?0:n,h=e.right,r=void 0===h?0:h,l=e.bottom,a=void 0===l?0:l;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.left=o,this.right=r,this.top=s,this.bottom=a}return o(t,[{key:"canHighlight",value:function(){return this.left=o?this.positionOnTop(t):this.positionOnBottom(t)}}],[{key:"createFromString",value:function(t){var e=document.createElement("div");return e.innerHTML=t.trim(),e.firstChild}}]),e}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o,n=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1])||arguments[1];if(t&&t.node){this.setSize(),t.onHighlightStarted(),this.highlightedElement&&this.highlightedElement.onDeselected();var i=t.getCalculatedPosition();i.canHighlight()&&(this.lastHighlightedElement=this.highlightedElement,this.highlightedElement=t,this.positionToHighlight=i,this.options.animate&&e||(this.highlightedPosition=this.positionToHighlight),this.draw())}else console.warn("Invalid element to highlight. Must be an instance of `Element`")}},{key:"getHighlightedElement",value:function(){return this.highlightedElement}},{key:"getLastHighlightedElement",value:function(){return this.lastHighlightedElement}},{key:"clear",value:function(){this.positionToHighlight=new h.default,this.highlightedElement&&this.highlightedElement.onDeselected(),this.highlightedElement=null,this.lastHighlightedElement=null,this.draw()}},{key:"draw",value:function(){var t=this.positionToHighlight.canHighlight();this.removeCloak(),this.addCloak();var e=this.overlayAlpha<.1;t&&(e?this.highlightedPosition=this.positionToHighlight:(this.highlightedPosition.left+=.18*(this.positionToHighlight.left-this.highlightedPosition.left),this.highlightedPosition.top+=.18*(this.positionToHighlight.top-this.highlightedPosition.top),this.highlightedPosition.right+=.18*(this.positionToHighlight.right-this.highlightedPosition.right),this.highlightedPosition.bottom+=.18*(this.positionToHighlight.bottom-this.highlightedPosition.bottom))),this.removeCloak({posX:this.highlightedPosition.left-this.window.scrollX-this.options.padding,posY:this.highlightedPosition.top-this.window.scrollY-this.options.padding,width:this.highlightedPosition.right-this.highlightedPosition.left+2*this.options.padding,height:this.highlightedPosition.bottom-this.highlightedPosition.top+2*this.options.padding}),t?this.options.animate?this.overlayAlpha+=.08*(this.options.opacity-this.overlayAlpha):this.overlayAlpha=this.options.opacity:this.overlayAlpha=Math.max(.85*this.overlayAlpha-.02,0),this.window.cancelAnimationFrame(this.redrawAnimation),t||this.overlayAlpha>0?(this.overlay.parentNode||this.document.body.appendChild(this.overlay),this.hasPositionHighlighted()?!this.options.animate&&e?this.redrawAnimation=this.window.requestAnimationFrame(this.draw):this.highlightedElement.onHighlighted():this.redrawAnimation=this.window.requestAnimationFrame(this.draw)):this.overlay.parentNode&&this.document.body.removeChild(this.overlay)}},{key:"hasPositionHighlighted",value:function(){return this.positionToHighlight.equals(this.highlightedPosition)&&this.overlayAlpha>this.options.opacity-.05}},{key:"removeCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.clearRect(i,n,h,l)}},{key:"addCloak",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.posX,i=void 0===e?0:e,o=t.posY,n=void 0===o?0:o,s=t.width,h=void 0===s?this.overlay.width:s,r=t.height,l=void 0===r?this.overlay.height:r;this.context.fillStyle="rgba( 0, 0, 0, "+this.overlayAlpha+" )",this.context.fillRect(i,n,h,l)}},{key:"setSize",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.overlay.width=t||this.window.innerWidth,this.overlay.height=e||this.window.innerHeight}},{key:"refresh",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.setSize(),this.highlightedElement&&(this.window.cancelAnimationFrame(this.redrawAnimation),this.highlight(this.highlightedElement,t),this.highlightedElement.onHighlighted())}}]),t}();e.default=l,t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t,e){for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.options=Object.assign({animate:r.OVERLAY_ANIMATE,opacity:r.OVERLAY_OPACITY,padding:r.OVERLAY_PADDING,scrollIntoViewOptions:null,onHighlightStarted:function(){},onHighlighted:function(){},onDeselected:function(){}},e),this.document=document,this.window=window,this.isActivated=!1,this.overlay=new n.default(this.options,this.window,this.document),this.steps=[],this.currentStep=0,this.onScroll=this.onScroll.bind(this),this.onResize=this.onResize.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onClick=this.onClick.bind(this),this.bind()}return o(t,[{key:"bind",value:function(){this.document.addEventListener("scroll",this.onScroll,!1),this.document.addEventListener("DOMMouseScroll",this.onScroll,!1),this.window.addEventListener("resize",this.onResize,!1),this.window.addEventListener("keyup",this.onKeyUp,!1),this.window.addEventListener("click",this.onClick,!1)}},{key:"onClick",value:function(t){if(this.hasHighlightedElement()&&this.isActivated){var e=this.overlay.getHighlightedElement(),i=this.document.getElementById(r.ID_POPOVER),o=e.node.contains(t.target),n=i&&i.contains(t.target);if(o||n){var s=t.target.classList.contains(r.CLASS_NEXT_STEP_BTN),h=t.target.classList.contains(r.CLASS_PREV_STEP_BTN);t.target.classList.contains(r.CLASS_CLOSE_BTN)?this.reset():s?this.moveNext():h&&this.movePrevious()}else this.reset()}}},{key:"movePrevious",value:function(){this.currentStep-=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"moveNext",value:function(){this.currentStep+=1,this.steps[this.currentStep]?this.overlay.highlight(this.steps[this.currentStep]):this.reset()}},{key:"hasNextStep",value:function(){return!!this.steps[this.currentStep+1]}},{key:"hasPreviousStep",value:function(){return!!this.steps[this.currentStep-1]}},{key:"reset",value:function(){this.currentStep=0,this.isActivated=!1,this.overlay.clear()}},{key:"hasHighlightedElement",value:function(){var t=this.overlay.getHighlightedElement();return t&&t.node&&t.highlightFinished}},{key:"getHighlightedElement",value:function(){return this.overlay.getHighlightedElement()}},{key:"getLastHighlightedElement",value:function(){return this.overlay.getLastHighlightedElement()}},{key:"onScroll",value:function(){this.isActivated&&this.overlay.refresh(!1)}},{key:"onResize",value:function(){this.isActivated&&this.overlay.refresh(!0)}},{key:"onKeyUp",value:function(t){this.isActivated&&(t.keyCode===r.ESC_KEY_CODE?this.reset():t.keyCode===r.RIGHT_KEY_CODE?this.moveNext():t.keyCode===r.LEFT_KEY_CODE&&this.movePrevious())}},{key:"defineSteps",value:function(t){var e=this;this.steps=[],t.forEach(function(i,o){if(!i.element||"string"!=typeof i.element)throw new Error("Element (query selector string) missing in step "+o);var n=e.prepareElementFromStep(i,t,o);n&&e.steps.push(n)})}},{key:"prepareElementFromStep",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o="",n={};"string"==typeof t?o=t:(o=t.element,n=Object.assign({},this.options,t));var r=this.document.querySelector(o);if(!r)return console.warn("Element to highlight "+o+" not found"),null;var l=null;if(n.popover&&n.popover.description){var a=Object.assign({},this.options,n.popover,{totalCount:e.length,currentIndex:i,isFirst:0===i,isLast:i===e.length-1});l=new h.default(a,this.window,this.document)}return new s.default(r,n,l,this.overlay,this.window,this.document)}},{key:"start",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!this.steps||0===this.steps.length)throw new Error("There are no steps defined to iterate");this.isActivated=!0,this.currentStep=t,this.overlay.highlight(this.steps[t])}},{key:"highlight",value:function(t){this.isActivated=!0;var e=this.prepareElementFromStep(t);e&&this.overlay.highlight(e)}}]),t}();e.default=a,t.exports=e.default},function(t,e){},function(t,e,i){i(7),t.exports=i(6)}])}); //# sourceMappingURL=driver.min.js.map \ No newline at end of file diff --git a/package.json b/package.json index ddd98deead8e4101317836aaa21ac4eeaaee1828..44ddfb2ae6d9e28116daf6376ca482817c6dcd3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "driver.js", - "version": "0.1.5", + "version": "0.1.6", "description": "A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page", "main": "./assets/scripts/dist/driver.min.js", "scripts": {