You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ERP/TradeManageNew/js2/jquery.pagewalkthrough.min.js

1 line
14 KiB
JavaScript

2 months ago
(function($,window,document,undefined){"use strict";var _globalWalkthrough={},_elements=[],_activeWalkthrough,_activeId,_hasDefault=true,_counter=0,_isCookieLoad,_firstTimeLoad=true,_onLoad=true,_index=0,_isWalkthroughActive=false,$jpwOverlay=$('<div id="jpwOverlay"></div>'),$jpWalkthrough=$('<div id="jpWalkthrough"></div>'),$jpwTooltip=$('<div id="jpwTooltip"></div>');var methods={isActive:function(){return!!_isWalkthroughActive},index:function(value){if(typeof value!=="undefined"){_index=value}return _index},init:function(options){options=$.extend(true,{},$.fn.pagewalkthrough.defaults,options);var that=this;if(!options.name){throw new Error("Must provide a unique name for a tour")}this.first().data("jpw",options);options._element=this;return this.each(function(i){options=options||{};options.elementID=options.name;_globalWalkthrough[options.name]=options;_elements.push(options.name);if(options.onLoad){_counter++}if(_counter===1&&_onLoad){_activeId=options.name;_activeWalkthrough=_globalWalkthrough[_activeId];_onLoad=false}if(i+1===that.length&&_counter===0){_activeId=options.name;_activeWalkthrough=_globalWalkthrough[_elements[0]];_hasDefault=false}})},renderOverlay:function(){if(_counter>1){debug("Warning: Only 1st walkthrough will be shown onLoad as default")}_isCookieLoad=getCookie("_walkthrough-"+_activeId);if(typeof _isCookieLoad==="undefined"){_isWalkthroughActive=true;if(!onEnter())return;showStep();showButton("jpwClose","body");setTimeout(function(){if(isFirstStep()&&_firstTimeLoad){if(!onAfterShow())return}},100)}else{onCookieLoad(_globalWalkthrough)}},restart:function(e){if(isFirstStep())return;_index=0;if(!onRestart(e))return;if(!onEnter(e))return;showStep()},close:function(){var options=_activeWalkthrough;onLeave();if(typeof options.onClose==="function"){options.onClose.call(this)}_index=0;_firstTimeLoad=true;_isWalkthroughActive=false;setCookie("_walkthrough-"+_activeId,0,365);_isCookieLoad=getCookie("_walkthrough-"+_activeId);$jpwOverlay.fadeOut("slow",function(){$(this).remove()});$jpWalkthrough.fadeOut("slow",function(){$(this).html("").remove()});$("#jpwClose").fadeOut("slow",function(){$(this).remove()})},show:function(name,e){e=name==null?name:e;name=name||this.first().data("jpw").name;_activeWalkthrough=_globalWalkthrough[this.first().data("jpw").name];if(name===_activeId&&_isWalkthroughActive||!onEnter(e))return;_isWalkthroughActive=true;_firstTimeLoad=true;if(!onBeforeShow())return;showStep();showButton("jpwClose","body");if(isFirstStep()&&_firstTimeLoad){if(!onAfterShow())return}},next:function(e){_firstTimeLoad=false;if(isLastStep())return;if(!onLeave(e))return;_index=parseInt(_index,10)+1;if(!onEnter(e)){methods.next()}showStep("next")},prev:function(e){if(isFirstStep())return;if(!onLeave(e))return;_index=parseInt(_index,10)-1;if(!onEnter(e)){methods.prev()}showStep("prev")},getOptions:function(activeWalkthrough){var _wtObj;if(activeWalkthrough){_wtObj={};_wtObj=_activeWalkthrough}else{_wtObj=[];for(var wt in _globalWalkthrough){_wtObj.push(_globalWalkthrough[wt])}}return _wtObj},refresh:function(){showStep("next")}};function showStep(skipDirection){var options=_activeWalkthrough,step=options.steps[_index],targetElement=options._element.find(step.wrapper),scrollTarget=getScrollParent(targetElement),maxScroll,scrollTo;if(step.popup.type!=="modal"&&!targetElement.length){if(step.popup.fallback==="skip"||typeof step.popup.fallback==="undefined"){methods[skipDirection]();return}step.popup.type=step.popup.fallback}maxScroll=scrollTarget[0].scrollHeight-scrollTarget.outerHeight();scrollTo=step.popup.type==="modal"?0:Math.floor(targetElement.offset().top-$(window).height()/2+scrollTarget.scrollTop());if(scrollTarget.scrollTop()!==scrollTo&&(scrollTarget.scrollTop()===maxScroll&&scrollTo<maxScroll||scrollTo<=0&&scrollTarget.scrollTop()>0||scrollTo>0)){$jpWalkthrough.addClass("jpw-scrolling");$jpwTooltip.fadeOut("fast");scrollTarget.animate({scrollTop:scrollTo},options.steps[_index].scrollSpeed,buildWalkthrough)}else{buildWalkthrough()}}function buildWalkthrough(){$jpWalkthrough.removeClass("jpw-scrolli