From 1eb8863031c442d38a225844654a01c2287c0969 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 13:28:52 +0100 Subject: [PATCH 01/17] Allow specyfing element to scroll, instead of always using the document body --- enjoyhint.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index a7dea2d..7525b66 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -30,8 +30,10 @@ onEnd: function() {}, onSkip: function() {}, - - onNext: function() {} + + onNext: function () { }, + + elementToScroll: document.body }; var options = $.extend(defaults, _options); @@ -62,7 +64,8 @@ options.onSkip(); skipAll(); }, - fill: SHAPE_BACKGROUND_COLOR + fill: SHAPE_BACKGROUND_COLOR, + elementToScroll: options.elementToScroll }); }; @@ -154,7 +157,7 @@ var isHintInViewport = $(step_data.selector).get(0).getBoundingClientRect(); if(isHintInViewport.top < 0 || isHintInViewport.bottom > (window.innerHeight || document.documentElement.clientHeight)){ hideCurrentHint(); - $(document.body).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); + $(options.elementToScroll).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); } else { // if previous button has been clicked and element are in viewport to prevent custom step scrollAnimationSpeed set scrollSpeed to default @@ -767,7 +770,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); @@ -1437,10 +1440,10 @@ else { distance = initial_distance; ver_button_position = initial_ver_position; - that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? - customBtnProps.nextButton.text : 'Next'); - that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? - customBtnProps.prevButton.text : 'Previous'); + that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? + customBtnProps.nextButton.text : 'Next'); + that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? + customBtnProps.prevButton.text : 'Previous'); } that.$prev_btn.css({ From 5ab8e201a589c259f9c45ec92ef6506f67eb2e07 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 14:51:32 +0100 Subject: [PATCH 02/17] #1 show next button whenever showNext parameter is set to true --- enjoyhint.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/enjoyhint.js b/enjoyhint.js index 7525b66..b04269d 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -189,6 +189,9 @@ if (step_data.showNext !== true) { $body.enjoyhint("hide_next"); } + else { + $body.enjoyhint("show_next"); + } $body.enjoyhint("hide_prev"); From 6466459b02a6f618811ac27155d150e032bcaaa6 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 15:17:48 +0100 Subject: [PATCH 03/17] prevent user interaction within highlighted area preventEvents parameter --- enjoyhint.js | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index a7dea2d..e2b62f7 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -30,7 +30,7 @@ onEnd: function() {}, onSkip: function() {}, - + onNext: function() {} }; @@ -292,7 +292,8 @@ left: step_data.left, right: step_data.right, margin: step_data.margin, - scroll: step_data.scroll + scroll: step_data.scroll, + preventEvents: step_data.preventEvents }; var customBtnProps = { @@ -1103,16 +1104,27 @@ .appendTo(that.enjoyhint); }; - that.disableEventsNearRect = function(rect) { + that.disableEventsNearRect = function(rect, alsoDisableRect) { + var top = rect.top; + var left = rect.left; + var right = rect.right; + var bottom = rect.bottom; + + //to disable events also within highlighted rectable, simply remove the gap + if (alsoDisableRect === true) { + top = bottom; + right = left; + } + $top_dis_events - .css({ - top: "0", - left: "0" - }) - .height(rect.top); + .css({ + top: "0", + left: "0" + }) + .height(top); $bottom_dis_events.css({ - top: rect.bottom + "px", + top: bottom + "px", left: "0" }); @@ -1121,11 +1133,11 @@ top: "0", left: 0 + "px" }) - .width(rect.left); + .width(left); $right_dis_events.css({ top: "0", - left: rect.right + "px" + left: right + "px" }); }; @@ -1437,10 +1449,10 @@ else { distance = initial_distance; ver_button_position = initial_ver_position; - that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? - customBtnProps.nextButton.text : 'Next'); - that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? - customBtnProps.prevButton.text : 'Previous'); + that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? + customBtnProps.nextButton.text : 'Next'); + that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? + customBtnProps.prevButton.text : 'Previous'); } that.$prev_btn.css({ @@ -1481,7 +1493,7 @@ bottom: shape_data.bottom, left: shape_data.left, right: shape_data.right - }); + }, data.preventEvents); that.renderArrow({ x_from: x_from, From 6b2599e37c4a2aa60a9da88f56ab3e744cb3b6ab Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 16:19:41 +0100 Subject: [PATCH 04/17] #2 ensure that duplicated events don't cause steps to be skipped --- enjoyhint.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index 7525b66..e4b2e4c 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -258,13 +258,20 @@ break; } } else { - $event_element.on(event, function(e) { - if (step_data.keyCode && e.keyCode != step_data.keyCode) { - return; - } - - current_step++; - stepAction(); // clicked + var alreadyTriggered = false; + $event_element.one(event, function (e) { //one should ensure that event is handled only once, but that's not always enough + if (alreadyTriggered) //make sure that the step is not changed twice handling the same event + return; + + alreadyTriggered = true; + if (step_data.keyCode && e.keyCode != step_data.keyCode) { + return; + } + + $event_element.off(event); //unregister the event + + current_step++; + stepAction(); //move to the next step }); } From 16977a807b2ecd58d986105cdc5247f55241ae68 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 16:44:30 +0100 Subject: [PATCH 05/17] pause until an element becomes visible or event is triggered --- enjoyhint.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index a7dea2d..6462289 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -23,6 +23,7 @@ var SHAPE_BACKGROUND_COLOR = _options.backgroundColor || "rgba(0,0,0,0.6)"; var body = "body"; // TODO: Is it possible case when we need to define enjoyhint somewhere else? + var elementAvailableEventName = "enjoyhint-element-available"; var defaults = { onStart: function() {}, @@ -97,7 +98,7 @@ $body.enjoyhint("hide_skip"); }; - var stepAction = function() { + var stepAction = function(unpause) { if (!(data && data[current_step])) { $body.enjoyhint("hide"); options.onEnd(); @@ -113,9 +114,63 @@ $enjoyhint.removeClass("enjoyhint-step-" + (current_step + 1)); $enjoyhint.removeClass("enjoyhint-step-" + (current_step + 2)); $enjoyhint.addClass("enjoyhint-step-" + (current_step + 1)); - + var step_data = data[current_step]; + $body.off(elementAvailableEventName); + + //loops waiting until specified element becomes visible + var waitUntilAvailable = function (selector, interval) { + if (interval == null) + interval = 150; + + var triggerIfAvailable = function () { + if ($(selector).is(":visible")) { + $body.trigger(elementAvailableEventName); + } + else { + setTimeout(triggerIfAvailable, interval) + } + }; + + setTimeout(triggerIfAvailable, 0); + } + + //if pausedUntil was specified, hide current overlay and wait until specified event occurs + if (!unpause && step_data.pausedUntil != null && step_data.pausedUntil.event != null) { + //hide current overlay during waiting time + $body.enjoyhint("hide"); + + //if 'available' event was chosen wait for the custom event, which is triggered when the element becomes visible + if (step_data.pausedUntil.event === 'available') { + $body.on(elementAvailableEventName, function () { + stepAction(true); //restart the step without pause + $body.off(elementAvailableEventName); + }); + + //check if element is available every 150ms + waitUntilAvailable(step_data.pausedUntil.selector); + } + else { + //delay the actual action until 'the event' happens on body or selector + if (step_data.pausedUntil.selector == null) { + on(step_data.pausedUntil.event, function () { + stepAction(true); //restart the step without pause + off(step_data.pausedUntil.event); + }); + } + else { + $(step_data.pausedUntil.selector).on(step_data.pausedUntil.event, function () { + stepAction(true); //restart the step without pause + $(step_data.pausedUntil.selector).off(step_data.pausedUntil.event) + }); + } + } + + //the rest of the logic will be executed whenever the step is restarted + return; + } + var scrollSpeed = step_data.scrollAnimationSpeed; if ( From d11119311dc2df4428647d6d2949bf2648b54a2f Mon Sep 17 00:00:00 2001 From: mikocot Date: Mon, 11 Jan 2021 17:51:22 +0100 Subject: [PATCH 06/17] Update README.md fork improvements listed --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b9aca5..7e7b7d4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,20 @@ EnjoyHint **EnjoyHint** is a web-tool that provides the simplest way to create interactive tutorials and hints for your site or web-application. It can also be used to highlight and sign application elements. EnjoyHint is free software distributed under the terms of MIT license. - + +#### Improvements +Comparing to the original library this version was modified to support more advanced scenarios: + +##### Added features +* Pause tour until specified element becomes visible or event is triggered +* Prevent user interaction within highlighted element + +##### Fixed Issues +* Next button not showing with 'click' and 'custom' events +* OnSkip not called when skipping steps programmatically +* Several steps can be skipped at once if triggered event is duplicated + + #### Demo * [TODO app demo](http://xbsoftware.github.io/enjoyhint/) ([downloadable package](http://xbsoftware.github.io/enjoyhint/enjoyhint_todo_demo.zip)) * [A small guide on EnjoyHint](http://xbsoftware.github.io/enjoyhint/example1.html) From 785e6d18d2e6eb8c6333815c336110236ac2e529 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 17:52:39 +0100 Subject: [PATCH 07/17] ensure that onSkip is called also when steps are skipped programmatically --- enjoyhint.js | 1 + 1 file changed, 1 insertion(+) diff --git a/enjoyhint.js b/enjoyhint.js index 8bbd080..fa3e6d2 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -472,6 +472,7 @@ case "skip": skipAll(); + options.onSkip(); break; default: $body.trigger(makeEventName(event_name, true)); From 3fa1bd7ee930f8f85c58e6a6285b6d80ab99df6d Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 18:09:48 +0100 Subject: [PATCH 08/17] propagate changes to the right source file --- enjoyhint.js | 2 +- enjoyhint.min.js | 2 +- src/enjoyhint.js | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index 7525b66..8c35029 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -770,7 +770,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..16766c4 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(l.elementToScroll).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P (window.innerHeight || document.documentElement.clientHeight)){ hideCurrentHint(); - $(document.body).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); + $(options.elementToScroll).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); } else { // if previous button has been clicked and element are in viewport to prevent custom step scrollAnimationSpeed set scrollSpeed to default From d50e21ccff436a7e440b5b807f4b8c180047cb19 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 18:10:57 +0100 Subject: [PATCH 09/17] propagate changes to the right source file --- enjoyhint.js | 2 +- enjoyhint.min.js | 2 +- src/enjoyhint.js | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index b04269d..14a0340 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -773,7 +773,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..1376cb0 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(l.elementToScroll).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext?o.enjoyhint("hide_next"):o.enjoyhint("show_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P (window.innerHeight || document.documentElement.clientHeight)){ hideCurrentHint(); - $(document.body).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); + $(options.elementToScroll).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); } else { // if previous button has been clicked and element are in viewport to prevent custom step scrollAnimationSpeed set scrollSpeed to default @@ -186,6 +189,9 @@ if (step_data.showNext !== true) { $body.enjoyhint("hide_next"); } + else { + $body.enjoyhint("show_next"); + } $body.enjoyhint("hide_prev"); From 54e274cc00d32b58f3c0f74253395a3b36c31291 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 18:12:49 +0100 Subject: [PATCH 10/17] propagate fixes to the right source files --- enjoyhint.js | 2 +- enjoyhint.min.js | 2 +- src/enjoyhint.js | 32 +++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index e4b2e4c..bab5a37 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -777,7 +777,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..6b8cb9e 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(l.elementToScroll).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else{var j=!1;d.one(c,function(a){j||(j=!0,f.keyCode&&a.keyCode!=f.keyCode||(d.off(c),n++,s()))})}var k=Math.max(b.outerWidth(),b.outerHeight()),l=f.radius||Math.round(k/2)+5,m=b.offset(),p=b.outerWidth(),q=b.outerHeight(),t=void 0!==f.margin?f.margin:10,u={x:m.left+Math.round(p/2),y:m.top+Math.round(q/2)-a(document).scrollTop()},v={enjoyHintElementSelector:f.selector,center_x:u.x,center_y:u.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},z={nextButton:f.nextButton,prevButton:f.prevButton};if(0===v.center_x&&0===v.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(v.shape="circle",v.radius=l):(v.radius=0,v.width=p+t,v.height=q+t),o.enjoyhint("render_label_with_shape",v,e.stop,z)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P (window.innerHeight || document.documentElement.clientHeight)){ hideCurrentHint(); - $(document.body).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); + $(options.elementToScroll).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); } else { // if previous button has been clicked and element are in viewport to prevent custom step scrollAnimationSpeed set scrollSpeed to default @@ -255,13 +258,20 @@ break; } } else { - $event_element.on(event, function(e) { - if (step_data.keyCode && e.keyCode != step_data.keyCode) { - return; - } - - current_step++; - stepAction(); // clicked + var alreadyTriggered = false; + $event_element.one(event, function (e) { //one should ensure that event is handled only once, but that's not always enough + if (alreadyTriggered) //make sure that the step is not changed twice handling the same event + return; + + alreadyTriggered = true; + if (step_data.keyCode && e.keyCode != step_data.keyCode) { + return; + } + + $event_element.off(event); //unregister the event + + current_step++; + stepAction(); //move to the next step }); } From 7ea5ebf6677c4fa03fcf3af90ec8db980a902592 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 18:14:15 +0100 Subject: [PATCH 11/17] proapgate changes to the right source file --- enjoyhint.js | 8 +++---- enjoyhint.min.js | 2 +- src/enjoyhint.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index 6462289..aa78a32 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -1492,10 +1492,10 @@ else { distance = initial_distance; ver_button_position = initial_ver_position; - that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? - customBtnProps.nextButton.text : 'Next'); - that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? - customBtnProps.prevButton.text : 'Previous'); + that.$next_btn.html(customBtnProps.nextButton && customBtnProps.nextButton.text ? + customBtnProps.nextButton.text : 'Next'); + that.$prev_btn.html(customBtnProps.prevButton && customBtnProps.prevButton.text ? + customBtnProps.prevButton.text : 'Previous'); } that.$prev_btn.css({ diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..a56fdeb 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(g.selector,g.scrollAnimationSpeed||250,{offset:-200})):i=250,setTimeout(function(){var b=a(g.selector),c=x(g.event);if(p.enjoyhint("show"),d=b,g.event_selector&&(d=a(g.event_selector)),d.off(c),b.off("keydown"),g.event_type||"key"!=g.event||b.keydown(function(a){a.which==g.keyCode&&(o++,t())}),!0!==g.showNext&&p.enjoyhint("hide_next"),p.enjoyhint("hide_prev"),0!==o&&p.enjoyhint("show_prev"),0==g.showPrev&&p.enjoyhint("hide_prev"),0==g.showSkip?p.enjoyhint("hide_skip"):p.enjoyhint("show_skip"),g.nextButton){var f=a(".enjoyhint_next_btn");f.addClass(g.nextButton.className||""),f.text(g.nextButton.text||"Next"),e.nextUserClass=g.nextButton.className}if(g.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(g.prevButton.className||""),h.text(g.prevButton.text||"Previous"),e.prevUserClass=g.prevButton.className}if(g.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(g.skipButton.className||""),i.text(g.skipButton.text||"Skip"),e.skipUserClass=g.skipButton.className}if(g.event_type)switch(g.event_type){case"auto":return b[g.event](),g.event,o++,void t();case"custom":y(g.event,function(){o++,z(g.event),t()});break;case"next":p.enjoyhint("show_next")}else d.on(c,function(a){g.keyCode&&a.keyCode!=g.keyCode||(o++,t())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=g.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),n=b.outerHeight(),q=void 0!==g.margin?g.margin:10,r={x:l.left+Math.round(m/2),y:l.top+Math.round(n/2)-a(document).scrollTop()},u={enjoyHintElementSelector:g.selector,center_x:r.x,center_y:r.y,text:g.description,arrowColor:g.arrowColor,top:g.top,bottom:g.bottom,left:g.left,right:g.right,margin:g.margin,scroll:g.scroll},v={nextButton:g.nextButton,prevButton:g.prevButton};if(0===u.center_x&&0===u.center_y)return p.enjoyhint("hide"),s(),console.log("Error: Element position couldn't be reached");g.shape&&"circle"==g.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=n+q),p.enjoyhint("render_label_with_shape",u,e.stop,v)},i+20||270)},j)},u=function(){o++,t()},v=function(){o--,t()},w=function(){var b=n[o],c=a(b.selector);z(b.event),c.off(x(b.event)),s()},x=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},y=function(a,b){p.on(x(a,!0),b)},z=function(a){p.off(x(a,!0))};window.addEventListener("resize",function(){null!=d&&p.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){w()},e.reRunScript=function(a){o=a,t()},e.runScript=function(){o=0,m.onStart(),t()},e.resumeScript=function(){t()},e.setCurrentStep=function(a){o=a},e.getCurrentStep=function(){return o},e.trigger=function(a){switch(a){case"next":u();break;case"skip":w();break;default:p.trigger(x(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");n=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},q()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P Date: Mon, 11 Jan 2021 18:15:49 +0100 Subject: [PATCH 12/17] propagate bugfix to the source file --- enjoyhint.js | 130 +++++++++-------------------------------------- enjoyhint.min.js | 2 +- src/enjoyhint.js | 1 + 3 files changed, 27 insertions(+), 106 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index fa3e6d2..aa368f1 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -23,7 +23,6 @@ var SHAPE_BACKGROUND_COLOR = _options.backgroundColor || "rgba(0,0,0,0.6)"; var body = "body"; // TODO: Is it possible case when we need to define enjoyhint somewhere else? - var elementAvailableEventName = "enjoyhint-element-available"; var defaults = { onStart: function() {}, @@ -31,10 +30,8 @@ onEnd: function() {}, onSkip: function() {}, - - onNext: function() {}, - - elementToScroll: document.body + + onNext: function() {} }; var options = $.extend(defaults, _options); @@ -65,8 +62,7 @@ options.onSkip(); skipAll(); }, - fill: SHAPE_BACKGROUND_COLOR, - elementToScroll: options.elementToScroll + fill: SHAPE_BACKGROUND_COLOR }); }; @@ -101,7 +97,7 @@ $body.enjoyhint("hide_skip"); }; - var stepAction = function(unpause) { + var stepAction = function() { if (!(data && data[current_step])) { $body.enjoyhint("hide"); options.onEnd(); @@ -117,63 +113,9 @@ $enjoyhint.removeClass("enjoyhint-step-" + (current_step + 1)); $enjoyhint.removeClass("enjoyhint-step-" + (current_step + 2)); $enjoyhint.addClass("enjoyhint-step-" + (current_step + 1)); - + var step_data = data[current_step]; - $body.off(elementAvailableEventName); - - //loops waiting until specified element becomes visible - var waitUntilAvailable = function (selector, interval) { - if (interval == null) - interval = 150; - - var triggerIfAvailable = function () { - if ($(selector).is(":visible")) { - $body.trigger(elementAvailableEventName); - } - else { - setTimeout(triggerIfAvailable, interval) - } - }; - - setTimeout(triggerIfAvailable, 0); - } - - //if pausedUntil was specified, hide current overlay and wait until specified event occurs - if (!unpause && step_data.pausedUntil != null && step_data.pausedUntil.event != null) { - //hide current overlay during waiting time - $body.enjoyhint("hide"); - - //if 'available' event was chosen wait for the custom event, which is triggered when the element becomes visible - if (step_data.pausedUntil.event === 'available') { - $body.on(elementAvailableEventName, function () { - stepAction(true); //restart the step without pause - $body.off(elementAvailableEventName); - }); - - //check if element is available every 150ms - waitUntilAvailable(step_data.pausedUntil.selector); - } - else { - //delay the actual action until 'the event' happens on body or selector - if (step_data.pausedUntil.selector == null) { - on(step_data.pausedUntil.event, function () { - stepAction(true); //restart the step without pause - off(step_data.pausedUntil.event); - }); - } - else { - $(step_data.pausedUntil.selector).on(step_data.pausedUntil.event, function () { - stepAction(true); //restart the step without pause - $(step_data.pausedUntil.selector).off(step_data.pausedUntil.event) - }); - } - } - - //the rest of the logic will be executed whenever the step is restarted - return; - } - var scrollSpeed = step_data.scrollAnimationSpeed; if ( @@ -212,7 +154,7 @@ var isHintInViewport = $(step_data.selector).get(0).getBoundingClientRect(); if(isHintInViewport.top < 0 || isHintInViewport.bottom > (window.innerHeight || document.documentElement.clientHeight)){ hideCurrentHint(); - $(options.elementToScroll).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); + $(document.body).scrollTo(step_data.selector, step_data.scrollAnimationSpeed || 250, {offset: -200}); } else { // if previous button has been clicked and element are in viewport to prevent custom step scrollAnimationSpeed set scrollSpeed to default @@ -244,9 +186,6 @@ if (step_data.showNext !== true) { $body.enjoyhint("hide_next"); } - else { - $body.enjoyhint("show_next"); - } $body.enjoyhint("hide_prev"); @@ -316,20 +255,13 @@ break; } } else { - var alreadyTriggered = false; - $event_element.one(event, function (e) { //one should ensure that event is handled only once, but that's not always enough - if (alreadyTriggered) //make sure that the step is not changed twice handling the same event - return; - - alreadyTriggered = true; - if (step_data.keyCode && e.keyCode != step_data.keyCode) { - return; - } - - $event_element.off(event); //unregister the event - - current_step++; - stepAction(); //move to the next step + $event_element.on(event, function(e) { + if (step_data.keyCode && e.keyCode != step_data.keyCode) { + return; + } + + current_step++; + stepAction(); // clicked }); } @@ -360,8 +292,7 @@ left: step_data.left, right: step_data.right, margin: step_data.margin, - scroll: step_data.scroll, - preventEvents: step_data.preventEvents + scroll: step_data.scroll }; var customBtnProps = { @@ -837,7 +768,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); @@ -1173,27 +1104,16 @@ .appendTo(that.enjoyhint); }; - that.disableEventsNearRect = function(rect, alsoDisableRect) { - var top = rect.top; - var left = rect.left; - var right = rect.right; - var bottom = rect.bottom; - - //to disable events also within highlighted rectable, simply remove the gap - if (alsoDisableRect === true) { - top = bottom; - right = left; - } - + that.disableEventsNearRect = function(rect) { $top_dis_events - .css({ - top: "0", - left: "0" - }) - .height(top); + .css({ + top: "0", + left: "0" + }) + .height(rect.top); $bottom_dis_events.css({ - top: bottom + "px", + top: rect.bottom + "px", left: "0" }); @@ -1202,11 +1122,11 @@ top: "0", left: 0 + "px" }) - .width(left); + .width(rect.left); $right_dis_events.css({ top: "0", - left: right + "px" + left: rect.right + "px" }); }; @@ -1562,7 +1482,7 @@ bottom: shape_data.bottom, left: shape_data.left, right: shape_data.right - }, data.preventEvents); + }); that.renderArrow({ x_from: x_from, diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..268004e 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v(),l.onSkip();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P Date: Mon, 11 Jan 2021 18:24:22 +0100 Subject: [PATCH 13/17] also scroll the right element whenever browser size changes --- enjoyhint.js | 2 +- enjoyhint.min.js | 2 +- src/jquery.enjoyhint.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index 8c35029..7525b66 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -770,7 +770,7 @@ doit = setTimeout(function() { if(boundingClientRect.top < 0 || boundingClientRect.bottom > (window.innerHeight || document.documentElement.clientHeight)){ - $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); diff --git a/enjoyhint.min.js b/enjoyhint.min.js index 16766c4..442aa00 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){},elementToScroll:document.body},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i,elementToScroll:l.elementToScroll})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(l.elementToScroll).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(l.elementToScroll).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(c.options.elementToScroll).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P (window.innerHeight || document.documentElement.clientHeight)){ - $(document.body).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); + $(that.options.elementToScroll).scrollTo(that.stepData.enjoyHintElementSelector, 150, {offset: -200, onAfter:renderAfterResize}); } else renderAfterResize(); }, 150); From b6a4933a94e9a257cecf915f4460a04c1b2dc219 Mon Sep 17 00:00:00 2001 From: "mikolaj.kocot" Date: Mon, 11 Jan 2021 18:30:46 +0100 Subject: [PATCH 14/17] propagate changes to the source files --- enjoyhint.js | 2 +- enjoyhint.min.js | 2 +- src/enjoyhint.js | 5 +++-- src/jquery.enjoyhint.js | 31 +++++++++++++++++++++---------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/enjoyhint.js b/enjoyhint.js index e2b62f7..9e8d31b 100644 --- a/enjoyhint.js +++ b/enjoyhint.js @@ -1133,7 +1133,7 @@ top: "0", left: 0 + "px" }) - .width(left); + .width(left); $right_dis_events.css({ top: "0", diff --git a/enjoyhint.min.js b/enjoyhint.min.js index caf7710..2bfd237 100644 --- a/enjoyhint.min.js +++ b/enjoyhint.min.js @@ -1 +1 @@ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.enjoyhint.js","jquery.scrollto"],a):"function"==typeof require&&"object"==typeof exports?module.exports=a(require("jquery"),require("./jquery.enjoyhint.js"),require("jquery.scrollto")):window.EnjoyHint=a(jQuery)}(function(a){return function(b){function c(){o.enjoyhint("render_circle",[]),a("#enjoyhint_label").remove(),a("#enjoyhint_arrpw_line").remove(),o.enjoyhint("hide_prev"),o.enjoyhint("hide_next"),o.enjoyhint("hide_skip")}var d,e=this,f=b||{},g=f.btnNextText,h=f.btnSkipText,i=f.backgroundColor||"rgba(0,0,0,0.6)",j="body",k={onStart:function(){},onEnd:function(){},onSkip:function(){},onNext:function(){}},l=a.extend(k,f),m=[],n=0,o=a(j),p=function(){a(".enjoyhint")&&a(".enjoyhint").remove(),o.css({overflow:"hidden"}),a(document).on("touchmove",q),o.enjoyhint({onNextClick:function(){t()},onPrevClick:function(){u()},onSkipClick:function(){l.onSkip(),v()},fill:i})},q=function(a){a.preventDefault()},r=function(){a(".enjoyhint").remove(),o.css({overflow:"auto"}),a(document).off("touchmove",q)};e.clear=function(){var b=a(".enjoyhint_next_btn"),c=a(".enjoyhint_skip_btn");a(".enjoyhint_prev_btn").removeClass(e.prevUserClass),b.removeClass(e.nextUserClass),b.text(g),c.removeClass(e.skipUserClass),c.text(h)};var s=function(){if(!m||!m[n])return o.enjoyhint("hide"),l.onEnd(),void r();l.onNext();var b=a(".enjoyhint");b.removeClass("enjoyhint-step-"+n),b.removeClass("enjoyhint-step-"+(n+1)),b.removeClass("enjoyhint-step-"+(n+2)),b.addClass("enjoyhint-step-"+(n+1));var f=m[n],g=f.scrollAnimationSpeed;f.onBeforeStart&&"function"==typeof f.onBeforeStart&&f.onBeforeStart();var h=f.timeout||0;setTimeout(function(){if(!f.selector)for(var b in f)f.hasOwnProperty(b)&&b.split(" ")[1]&&(f.selector=b.split(" ")[1],f.event=b.split(" ")[0],"next"!=b.split(" ")[0]&&"auto"!=b.split(" ")[0]&&"custom"!=b.split(" ")[0]||(f.event_type=b.split(" ")[0]),f.description=f[b]);setTimeout(function(){e.clear()},250);var h=a(f.selector).get(0).getBoundingClientRect();h.top<0||h.bottom>(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a){w.css({top:"0",left:"0"}).height(a.top),x.css({top:a.bottom+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(a.left),z.css({top:"0",left:a.right+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P(window.innerHeight||document.documentElement.clientHeight)?(c(),a(document.body).scrollTo(f.selector,f.scrollAnimationSpeed||250,{offset:-200})):g=250,setTimeout(function(){var b=a(f.selector),c=w(f.event);if(o.enjoyhint("show"),d=b,f.event_selector&&(d=a(f.event_selector)),d.off(c),b.off("keydown"),f.event_type||"key"!=f.event||b.keydown(function(a){a.which==f.keyCode&&(n++,s())}),!0!==f.showNext&&o.enjoyhint("hide_next"),o.enjoyhint("hide_prev"),0!==n&&o.enjoyhint("show_prev"),0==f.showPrev&&o.enjoyhint("hide_prev"),0==f.showSkip?o.enjoyhint("hide_skip"):o.enjoyhint("show_skip"),f.nextButton){var g=a(".enjoyhint_next_btn");g.addClass(f.nextButton.className||""),g.text(f.nextButton.text||"Next"),e.nextUserClass=f.nextButton.className}if(f.prevButton){var h=a(".enjoyhint_prev_btn");h.addClass(f.prevButton.className||""),h.text(f.prevButton.text||"Previous"),e.prevUserClass=f.prevButton.className}if(f.skipButton){var i=a(".enjoyhint_skip_btn");i.addClass(f.skipButton.className||""),i.text(f.skipButton.text||"Skip"),e.skipUserClass=f.skipButton.className}if(f.event_type)switch(f.event_type){case"auto":return b[f.event](),f.event,n++,void s();case"custom":x(f.event,function(){n++,y(f.event),s()});break;case"next":o.enjoyhint("show_next")}else d.on(c,function(a){f.keyCode&&a.keyCode!=f.keyCode||(n++,s())});var j=Math.max(b.outerWidth(),b.outerHeight()),k=f.radius||Math.round(j/2)+5,l=b.offset(),m=b.outerWidth(),p=b.outerHeight(),q=void 0!==f.margin?f.margin:10,t={x:l.left+Math.round(m/2),y:l.top+Math.round(p/2)-a(document).scrollTop()},u={enjoyHintElementSelector:f.selector,center_x:t.x,center_y:t.y,text:f.description,arrowColor:f.arrowColor,top:f.top,bottom:f.bottom,left:f.left,right:f.right,margin:f.margin,scroll:f.scroll,preventEvents:f.preventEvents},v={nextButton:f.nextButton,prevButton:f.prevButton};if(0===u.center_x&&0===u.center_y)return o.enjoyhint("hide"),r(),console.log("Error: Element position couldn't be reached");f.shape&&"circle"==f.shape?(u.shape="circle",u.radius=k):(u.radius=0,u.width=m+q,u.height=p+q),o.enjoyhint("render_label_with_shape",u,e.stop,v)},g+20||270)},h)},t=function(){n++,s()},u=function(){n--,s()},v=function(){var b=m[n],c=a(b.selector);y(b.event),c.off(w(b.event)),r()},w=function(a,b){return a+(b?"custom":"")+".enjoy_hint"},x=function(a,b){o.on(w(a,!0),b)},y=function(a){o.off(w(a,!0))};window.addEventListener("resize",function(){null!=d&&o.enjoyhint("redo_events_near_rect",d[0].getBoundingClientRect())},!1),e.stop=function(){v()},e.reRunScript=function(a){n=a,s()},e.runScript=function(){n=0,l.onStart(),s()},e.resumeScript=function(){s()},e.setCurrentStep=function(a){n=a},e.getCurrentStep=function(){return n},e.trigger=function(a){switch(a){case"next":t();break;case"skip":v();break;default:o.trigger(w(a,!0))}},e.setScript=function(a){if(!(a instanceof Array)&&a.length<1)throw new Error("Configurations list isn't correct.");m=a},e.set=function(a){e.setScript(a)},e.setSteps=function(a){e.setScript(a)},e.run=function(){e.runScript()},e.resume=function(){e.resumeScript()},p()}}),CanvasRenderingContext2D.prototype.roundRect=function(a,b,c,d,e){return c<2*e&&(e=c/2),d<2*e&&(e=d/2),this.beginPath(),this.moveTo(a+e,b),this.arcTo(a+c,b,a+c,b+d,e),this.arcTo(a+c,b+d,a,b+d,e),this.arcTo(a,b+d,a,b,e),this.arcTo(a,b,a+c,b,e),this.closePath(),this},function(a){"function"==typeof define&&define.amd?define(["jquery","kinetic"],a):"undefined"!=typeof module&&module.exports?module.exports=a(require("jquery"),require("kinetic")):a(jQuery,Kinetic)}(function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=window.innerWidth,o=window.innerHeight,p={init:function(p){return this.each(function(){function q(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)c.setAttribute(d,b[d]);return c}var r={onNextClick:function(){},onSkipClick:function(){},onPrevClick:function(){},animation_time:800};this.enjoyhint_obj={},c=this.enjoyhint_obj,c.resetComponentStuff=function(){d=null,e=null,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=window.innerWidth,o=window.innerHeight};var s=a(this);c.options=a.extend(r,p),c.gcl={chooser:"enjoyhint"},c.cl={enjoy_hint:"enjoyhint",hide:"enjoyhint_hide",disable_events_element:"enjoyhint_disable_events",btn:"enjoyhint_btn",skip_btn:"enjoyhint_skip_btn",close_btn:"enjoyhint_close_btn",next_btn:"enjoyhint_next_btn",previous_btn:"enjoyhint_prev_btn",main_canvas:"enjoyhint_canvas",main_svg:"enjoyhint_svg",svg_wrapper:"enjoyhint_svg_wrapper",svg_transparent:"enjoyhint_svg_transparent",kinetic_container:"kinetic_container"},c.canvas_size={w:1.4*a(window).width(),h:1.4*a(window).height()},c.enjoyhint=a("
",{class:c.cl.enjoy_hint+" "+c.cl.svg_transparent}).appendTo(s),c.enjoyhint_svg_wrapper=a("
",{class:c.cl.svg_wrapper+" "+c.cl.svg_transparent}).appendTo(c.enjoyhint),c.$stage_container=a('
').appendTo(c.enjoyhint),c.$canvas=a('').appendTo(c.enjoyhint),c.$svg=a('').appendTo(c.enjoyhint_svg_wrapper);var t=a(q("defs")),u=a(q("marker",{id:"arrowMarker",viewBox:"0 0 36 21",refX:"21",refY:"10",markerUnits:"strokeWidth",orient:"auto",markerWidth:"16",markerHeight:"12"})),v=a(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:2",d:"M0,0 c30,11 30,9 0,20",id:"poliline"}));t.append(u.append(v)).appendTo(c.$svg),c.kinetic_stage=new b.Stage({container:c.cl.kinetic_container,width:c.canvas_size.w,height:c.canvas_size.h,scaleX:1}),c.layer=new b.Layer,c.rect=new b.Rect({fill:p.fill,width:c.canvas_size.w,height:c.canvas_size.h});var w=a("
",{class:c.cl.disable_events_element}).appendTo(c.enjoyhint),x=w.clone().appendTo(c.enjoyhint),y=w.clone().appendTo(c.enjoyhint),z=w.clone().appendTo(c.enjoyhint),A=function(a){a.stopImmediatePropagation()};a("button").focusout(A),w.click(A),x.click(A),y.click(A),z.click(A),c.$skip_btn=a("
",{class:c.cl.skip_btn}).appendTo(c.enjoyhint).html("Skip").click(function(a){c.hide(),c.options.onSkipClick()}),c.$next_btn=a("
",{class:c.cl.next_btn}).appendTo(c.enjoyhint).html("Next").click(function(a){c.options.onNextClick()}),c.$close_btn=a("
",{class:c.cl.close_btn}).appendTo(c.enjoyhint).html("").click(function(a){c.hide(),c.options.onSkipClick()}),c.$prev_btn=a("
",{class:c.cl.previous_btn}).appendTo(c.enjoyhint).html("Previous").click(function(a){c.options.onPrevClick()}),c.$canvas.mousedown(function(b){a("canvas").css({left:"4000px"});var c=document.elementFromPoint(b.clientX,b.clientY);return a("canvas").css({left:"0px"}),a(c).click(),!1});var B=0,C=130;c.shape=new b.Shape({radius:B,center_x:-C,center_y:-C,width:0,height:0,sceneFunc:function(a){var b=this.getContext("2d")._context,c=(this.pos,b.globalCompositeOperation);b.globalCompositeOperation="destination-out",b.beginPath();var d=this.attrs.center_x-Math.round(this.attrs.width/2),e=this.attrs.center_y-Math.round(this.attrs.height/2);b.roundRect(d,e,this.attrs.width,this.attrs.height,this.attrs.radius),b.fill(),b.globalCompositeOperation=c}}),c.shape.radius=B,c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.add(c.layer);var D;a(window).on("resize",function(){function d(){var b=a(c.stepData.enjoyHintElementSelector).get(0).getBoundingClientRect();c.stepData.center_x=b.left+b.width/2,c.stepData.center_y=b.top+b.height/2,c.stepData.width=b.width+11,c.stepData.height=b.height+11,c.renderLabelWithShape(c.stepData,c.customBtnProps),a(".enjoyhint_next_btn").css("visibility","visible"),a(".enjoyhint_prev_btn").css("visibility","visible"),a(".enjoyhint_skip_btn").css("visibility","visible")}if(clearTimeout(D),a(".enjoyhint_next_btn").css("visibility","hidden"),a(".enjoyhint_prev_btn").css("visibility","hidden"),a(".enjoyhint_skip_btn").css("visibility","hidden"),a(".enjoy_hint_label").remove(),a("#enjoyhint_arrpw_line").remove(),!a(c.stepData.enjoyHintElementSelector).is(":visible"))return c.stopFunction(),void a(window).off("resize");var e=a(c.stepData.enjoyHintElementSelector)[0].getBoundingClientRect();c.shape.attrs.center_x=Math.round(e.left+e.width/2),c.shape.attrs.center_y=Math.round(e.top+e.height/2),c.shape.attrs.width=e.width+11,c.shape.attrs.height=e.height+11,D=setTimeout(function(){e.top<0||e.bottom>(window.innerHeight||document.documentElement.clientHeight)?a(document.body).scrollTo(c.stepData.enjoyHintElementSelector,150,{offset:-200,onAfter:d}):d()},150);var f=window.innerWidth,g=window.innerHeight,h=f/n,i=g/o;c.kinetic_stage.setAttr("width",n*h),c.kinetic_stage.setAttr("height",o*i),c.rect=new b.Rect({fill:p.fill,width:window.innerWidth,height:window.innerHeight}),c.layer.removeChildren(),c.layer.add(c.rect),c.layer.add(c.shape),c.kinetic_stage.draw()});c.enjoyhint;return c.show=function(){c.enjoyhint.removeClass(c.cl.hide)},c.hide=function(){c.enjoyhint.addClass(c.cl.hide),new b.Tween({node:c.shape,duration:.002,center_x:-C,center_y:-C}).play()},c.hide(),c.hideNextBtn=function(){c.$next_btn.addClass(c.cl.hide),c.nextBtn="hide"},c.hidePrevBtn=function(){c.$prev_btn.addClass(c.cl.hide),c.prevBtn="hide"},c.showPrevBtn=function(){c.$prev_btn.removeClass(c.cl.hide),c.prevBtn="show"},c.showNextBtn=function(){c.$next_btn.removeClass(c.cl.hide),c.nextBtn="show"},c.hideSkipBtn=function(){c.$skip_btn.addClass(c.cl.hide)},c.showSkipBtn=function(){c.$skip_btn.removeClass(c.cl.hide)},c.renderCircle=function(a){var d=a.r||0,e=a.x||0,f=a.y||0;new b.Tween({node:c.shape,duration:.2,center_x:e,center_y:f,width:2*d,height:2*d,radius:d}).play();var g=e-d,h=e+d,i=f-d,j=f+d,k=20;return{x:e,y:f,left:g,right:h,top:i,bottom:j,conn:{left:{x:g-k,y:f},right:{x:h+k,y:f},top:{x:e,y:i-k},bottom:{x:e,y:j+k}}}},c.renderRect=function(a,d){var e=a.r||0,f=a.x||0,g=a.y||0,h=a.w||0,i=a.h||0,j=20;new b.Tween({node:c.shape,duration:d,center_x:f,center_y:g,width:h,height:i,radius:e}).play();var k=Math.round(h/2),l=Math.round(i/2),m=f-k,n=f+k,o=g-l,p=g+l;return{x:f,y:g,left:m,right:n,top:o,bottom:p,conn:{left:{x:m-j,y:g},right:{x:n+j,y:g},top:{x:f,y:o-j},bottom:{x:f,y:p+j}}}},c.renderLabel=function(b){var d=b.x||0;c.originalElementX=d;var e=b.y||0,f=(b.text,c.getLabelElement({x:d,y:e,text:b.text})),g=f.width(),h=f.height(),i=f.offset().left,j=f.offset().left+g,k=f.offset().top-a(document).scrollTop(),l=f.offset().top-a(document).scrollTop()+h,m=10,n={x:i-m,y:k+Math.round(h/2)},o={x:j+m,y:k+Math.round(h/2)},p={x:i+Math.round(g/2),y:k-m},q={x:i+Math.round(g/2),y:l+m};return f.detach(),setTimeout(function(){a("#enjoyhint_label").remove(),f.appendTo(c.enjoyhint)},c.options.animation_time/2),{label:f,left:i,right:j,top:k,bottom:l,conn:{left:n,right:o,top:p,bottom:q}}},c.setMarkerColor=function(b){function c(a){const b=(new Option).style;return b.color=a,""!==b.color}if(c(b))return[a("#poliline"),a("#enjoyhint_arrpw_line")].forEach(function(a){a.css("stroke",b)});a("#poliline").css("stroke","rgb(255,255,255)"),console.log("Error: invalid color name property - "+b)},c.renderArrow=function(b){var d=b.x_from||0,e=b.y_from||0,f=b.x_to||0,g=b.y_to||0,h=b.by_top_side,i=0,j=0;"hor"===h?(i=f,j=e):(i=d,j=g),c.enjoyhint.addClass(c.cl.svg_transparent),setTimeout(function(){a("#enjoyhint_arrpw_line").remove();var b="M"+d+","+e+" Q"+i+","+j+" "+f+","+g;c.$svg.append(q("path",{style:"fill:none; stroke:rgb(255,255,255); stroke-width:3","marker-end":"url(#arrowMarker)",d:b,id:"enjoyhint_arrpw_line"})),c.stepData.arrowColor?c.setMarkerColor(c.stepData.arrowColor):a("#poliline").css("stroke","rgb(255, 255, 255)"),c.enjoyhint.removeClass(c.cl.svg_transparent)},c.options.animation_time/2)},c.getLabelElement=function(b){return a("
",{class:"enjoy_hint_label",id:"enjoyhint_label"}).css({top:b.y+"px",left:b.x+"px"}).html(b.text).appendTo(c.enjoyhint)},c.disableEventsNearRect=function(a,b){var c=a.top,d=a.left,e=a.right,f=a.bottom;!0===b&&(c=f,e=d),w.css({top:"0",left:"0"}).height(c),x.css({top:f+"px",left:"0"}),y.css({top:"0",left:"0px"}).width(d),z.css({top:"0",left:e+"px"})},function(a){a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}}(a),c.renderLabelWithShape=function(b,d){function e(b){return"MD-DIALOG"===b.tagName?b:void 0===b.tagName?null:e(a(b).parent()[0])}c.stepData=b,c.customBtnProps=d;var f=e(a(c.stepData.enjoyHintElementSelector)[0]);null!=f&&a(f).on("dialogClosing",function(){c.stopFunction()}),c.resetComponentStuff();var g=b.shape||"rect",h={},i=0,j=0,k={top:b.top||0,bottom:b.bottom||0,left:b.left||0,right:b.right||0};switch(g){case"circle":i=j=b.radius;var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right},m=l.right-l.left,n=l.bottom-l.top;b.radius=Math.round(Math.min(m,n)/2),i=j=Math.round(b.radius/2);var o=Math.round(m/2),p=Math.round(n/2);b.center_x=l.left+o,b.center_y=l.top+p,h=c.renderCircle({x:b.center_x,y:b.center_y,r:b.radius});break;case"rect":i=Math.round(b.width/2),j=Math.round(b.height/2);var l={top:b.center_y-j+k.top,bottom:b.center_y+j-k.bottom,left:b.center_x-i+k.left,right:b.center_x+i-k.right};b.width=l.right-l.left,b.height=l.bottom-l.top,i=Math.round(b.width/2),j=Math.round(b.height/2),b.center_x=l.left+i,b.center_y=l.top+j,h=c.renderRect({x:b.center_x,y:b.center_y,w:b.width,h:b.height,r:b.radius},.2)}var q={w:c.enjoyhint.width(),h:c.enjoyhint.height()},r=c.getLabelElement({x:0,y:0,text:b.text}),s=r.outerWidth(),t=r.outerHeight();r.remove();for(var u=b.center_y-j,v=q.h-(b.center_y+j),w=b.center_x-i,x=q.w-(b.center_x+i),y=window.innerHeight<670?130:150,z=window.innerHeight<670?0:40,A=y+t+z,B=j+y,C=[{name:"right_center",common_area:x*window.innerHeight,width:x,height:window.innerHeight},{name:"right_top",common_area:x*u,width:x,height:u},{name:"right_bottom",common_area:x*v,width:x,height:v},{name:"left_center",common_area:w*window.innerHeight,width:w,height:window.innerHeight},{name:"left_top",common_area:w*u,width:w,height:u},{name:"left_bottom",common_area:w*v,width:w,height:v},{name:"center_top",common_area:window.innerWidth*u,width:window.innerWidth,height:u},{name:"center_bottom",common_area:window.innerWidth*v,width:window.innerWidth,height:v}],D=s,E=window.innerHeight<=670?A:A+20,F=C.sort(function(a,b){return a.common_area-b.common_area}),G="oversized",H=0;HD&&J.height>E&&(G=I)}var K,L,M,N,O,P,Q="circle"===b.shape?2*b.radius:b.width?b.width:2*b.radius,R="circle"===b.shape?2*b.radius:b.height?b.height:2*b.radius,S=b.center_x+Q/2+80,T=b.center_x-s-Q/2-80,U=window.innerWidth/2-s/2,V=b.center_y-B-t,W=b.center_y+B,X=window.innerHeight/2-E/2+20,Y="hor";switch(G){case"center_top":L=V,K=U,M=b.center_x,N=b.center_y-R/2-20;break;case"center_bottom":L=W,K=U,M=b.center_x,N=b.center_y+R/2+20;break;case"left_center":L=X,K=T,M=b.center_x-Q/2-20,N=b.center_y,Y="ver";break;case"left_top":L=V,K=T,M=b.center_x-Q/2,N=b.center_y-20;break;case"left_bottom":L=W,K=T,M=b.center_x-Q/2,N=b.center_y+20,Y="ver";break;case"right_center":L=X,K=S,M=b.center_x+Q/2+20,N=b.center_y,Y="ver";break;case"right_top":L=V,K=S,M=b.center_x+Q/2,N=b.center_y-20;break;case"right_bottom":L=W,K=S,M=b.center_x+Q/2,N=b.center_y+20,Y="ver";break;case"oversized":setTimeout(function(){a("#enjoyhint_arrpw_line").remove(),a(".enjoy_hint_label").css({"border-radius":"20px","-webkit-border-radius":"20px","-moz-border-radius":"20px","background-color":"#272A26","-webkit-transition":"background-color ease-out 0.5s","-moz-transition":"background-color ease-out 0.5s","-o-transition":"background-color ease-out 0.5s",transition:"background-color ease-out 0.5s"})},450),L=X,K=U}O=K+s/2,P=b.center_y>L+t/2?L+t:L,b.center_y<0?N=20:b.center_y>window.innerHeight+20&&(N=window.innerHeight-20),b.center_y>=L&&b.center_y<=L+t&&(O=b.center_x>K?K+s:K,P=b.center_y),c.renderLabel({x:K,y:L,text:b.text}),setTimeout(function(){var a=c.$next_btn.width()+c.$skip_btn.width()+c.$prev_btn.width()+30,b=K-100,e=L+t+40;a+K>M&&(b=M>=O?M+20:K+s/2),(a+b>window.innerWidth||b<0)&&(b=10,e=P Date: Mon, 11 Jan 2021 18:36:51 +0100 Subject: [PATCH 15/17] Bump version to 4.1.0 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 1fdf8b7..5027417 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "enjoyhint.js", "enjoyhint.css" ], - "version": "4.0.1", + "version": "4.1.0", "homepage": "https://github.com/xbsoftware/enjoyhint", "authors": [ "XB Software" diff --git a/package.json b/package.json index 7b4f6de..3d1f15c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "enjoyhint", - "version": "4.0.1", + "version": "4.1.0", "description": "Web-tool that provides the simplest way to create interactive tutorials and hints.", "main": "enjoyhint.js", "scripts": { From 57ebabef8624c7da337e497f974f5f4bdec99aee Mon Sep 17 00:00:00 2001 From: mikocot Date: Mon, 11 Jan 2021 18:44:51 +0100 Subject: [PATCH 16/17] Update README.md --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e7b7d4..32fa7d9 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Comparing to the original library this version was modified to support more adva ##### Added features * Pause tour until specified element becomes visible or event is triggered * Prevent user interaction within highlighted element +* Ability to specify which container is being scrolled ##### Fixed Issues * Next button not showing with 'click' and 'custom' events @@ -177,7 +178,18 @@ var enjoyhint_script_steps = [ #### Release notes -##### v.4 +##### v.4.1.0 +Improvements: +* Disable user interaction within highlighted area (`preventEvents` step property) +* Pause and hide overlay until element becomes visible or event is triggered (`paudedUntil1 step property) +* Specify which container should be scrolled (`elementToScroll` option) + +Bug Fixes: +* Fixed Next button not showing +* Fixed skippind steps when event is duplicated +* Fixed OnSkip method not called when skipping steps programmatically + +##### v.4.x * Fixed label position bugs * Fixed arrow position bugs From 56f0b087af073c954ef88c1f49d3f4a6ec04e12a Mon Sep 17 00:00:00 2001 From: mikocot Date: Mon, 11 Jan 2021 18:46:29 +0100 Subject: [PATCH 17/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32fa7d9..0575c30 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ var enjoyhint_script_steps = [ ##### v.4.1.0 Improvements: * Disable user interaction within highlighted area (`preventEvents` step property) -* Pause and hide overlay until element becomes visible or event is triggered (`paudedUntil1 step property) +* Pause and hide overlay until element becomes visible or event is triggered (`pausedUntil` step property) * Specify which container should be scrolled (`elementToScroll` option) Bug Fixes: