-
Notifications
You must be signed in to change notification settings - Fork 0
/
ionic.tour.min.js
1 lines (1 loc) · 6.17 KB
/
ionic.tour.min.js
1
!function(t){angular.module("ionic.tour",[]).factory("$ionicTour",["$rootScope","$compile","$timeout","$window","$q","$ionicTemplateLoader","$ionicBody","$ionicPosition","$ionicScrollDelegate",function(o,e,n,r,i,s,u,a,l){var f=[],p=function(t,o){return o>=t?function(e){return t+(o-t)*e}:function(e){return t-(t-o)*e}},c=function(t,o){return Math.abs(t-o)/.5},_=function(t,o){var e;return e="function"==typeof t.currentStyle?t.currentStyle[o]:"function"==typeof window.getComputedStyle?t.ownerDocument.defaultView.getComputedStyle(t,null)[o]:t.style[o],""===e?void 0:e},d=t.views.View.inherit({initialize:function(o){o=t.extend({},o),t.extend(this,o)},start:function(o){var e=this;o=o||{autoplay:!0},l.freezeScroll(!0),u.append(e._$tourtipEl),e._windowOffset={height:r.innerHeight,width:r.innerWidth},e._tourtipOffset=a.offset(e._$tourtipEl),e._arrowStyles={color:_(e._arrowEl,"borderBottomColor"),top:_(e._arrowEl,"top")},e.sort(),n(function(){e._$tourtipEl.addClass("slide-in-up ng-enter active")}),t.on("resize",e.resize.bind(e),window),o.autoplay&&e.next()},resize:function(){var o=this;n(function(){o._windowOffset={height:r.innerHeight,width:r.innerWidth};for(var e=0;e<o._steps.length;e++){var n=a.offset(o._steps[e]);t.extend(o._steps[e],{offset:n})}o._tourtipOffset=a.offset(o._$tourtipEl),o.goToStep(o._index)},500)},finish:function(t){var o=this,e=o._index,n=o._steps[e],r=o._tourtipEl;t=t||{destroy:!0},l.freezeScroll(!1),o._orientation="next",n.onLeave(n[0],r),o._index=-1,o.scope.$parent&&o.scope.$parent.$broadcast("tourFinished"),t.destroy&&o.scope.$destroy(),r.remove()},goToStep:function(t,o){var e=this,n=e._steps[t],r=e._tourtipEl;o=o||n.onLeave,e._isRunning||(e._isRunning=!0,e._isFirst=0===t,e._isLast=t===e._steps.length-1,o(),n.onEnter(n,r),e.animateStep(t).then(function(){e._isRunning=!1}))},reset:function(){var t=this,o=t._index,e=t._steps[o],n=t._tourtipEl;t._orientation="next",o=0,t.goToStep(o,function(){e.onLeave(e[0],n)})},step:function(t){var o=this,e=o._index,n=o._steps[e],r=o._tourtipEl;return e=--t,0>e?void o.scope.$parent.$broadcast("tourAtStart"):e>=o._steps.length?void o.scope.$parent.$broadcast("tourAtEnd"):(o._orientation="step",void o.goToStep(e,function(){n.onLeave(n[0],r)}))},next:function(){var t=this,o=t._index,e=t._steps[o],n=t._tourtipEl;return t._orientation="next",o++,o>=t._steps.length?void t.scope.$parent.$broadcast("tourAtEnd"):void t.goToStep(o,function(){o-1>-1&&t._steps[o-1].onLeave(e[0],n)})},previous:function(){var t=this,o=t._index,e=t._steps[o],n=t._tourtipEl;return t._orientation="previous",o--,0>o?void t.scope.$parent.$broadcast("tourAtStart"):void t.goToStep(o,function(){o+1<t._steps.length&&e.onLeave(e[0],n)})},animateStep:function(t){var o=this;o._index=t;var e=o._index,n=o._steps[e],r=o._tourtipEl,s=o._tourtipOffset,u=o._windowOffset,a=o._arrowEl,f=(o._arrowStyles,l.getScrollView()),_=n.offset.top+n.offset.height+20,d=n.offset.left+n.offset.width/2-(u.width-s.width)/2,h=0,w=10;"undefined"!=typeof n.scrollDiff&&l.scrollBy(0,-n.scrollDiff,!0),_>u.height&&(h=Math.min(_-u.height,f.__maxScrollTop),l.scrollBy(0,h,!0),o._steps[e-1].scrollDiff=h,o._steps[e+1].scrollDiff=h),_+s.height+w>u.height+w?(_=n.offset.top-s.height-h-20,o.styleArrow("bottom")):o.styleArrow("top");var v=p(s.top,_),y=p(s.left,d),S=c(s.top,_);s.top=_,s.left=d;var $=i.defer();collide.animation({duration:S,percent:0,reverse:!1}).easing({type:"spring",frequency:5,friction:250,initialForce:!1}).on("start",function(){n.onStart(n[0],r)}).on("step",function(t){n.onTransition(t,n[0],r),r.style.transform=r.style.webkitTransform="translate3d(0,"+v(t)+"px,0)",a.style.transform=o._arrowEl.style.webkitTransform="translate3d("+y(t)+"px,0,0)"}).on("complete",function(){n.onEnd(n[0],r),$.resolve()}).start();return $.promise},styleArrow:function(t){var o=this;t=t||"top";var e=o._arrowEl,n=o._arrowStyles;"top"===t?(e.style.top=n.top,e.style.borderTopColor="transparent",e.style.borderBottomColor=n.color,o._arrowStyle="top"):"bottom"===t?(e.style.top="100%",e.style.borderTopColor=n.color,e.style.borderBottomColor="transparent",o._arrowStyle="bottom"):"none"===t&&(e.style.display="none",o._arrowStyle="none")},sort:function(){var t=this,o=t._steps;o.sort(function(t,o){return t.step-o.step})},removeStep:function(t){var o=this;t--;var e=o._steps[t],n=o._tourtipEl;if(t===o._index){var r=0!==t?t-1:t+1;o.goToStep(r,function(){o._steps[t].onLeave(e[0],n)})}o._steps.splice(t,1)},isRunning:function(){return!!this._isRunning},isShown:function(){return!!this._isShown},_arrowEl:null,_$arrowEl:null,_arrowStyles:{},_el:null,_$el:null,_index:-1,_isFirst:!1,_isLast:!1,_isRunning:!1,_isShown:!1,_orientation:"next",_steps:[],_scrollDiff:0,_tourtipEl:null,_$tourtipEl:null,_tourtipOffset:{},_windowOffset:{}}),h=function(n,r){var s=r.scope&&r.scope.$new()||o.$new(!0);r.viewType="tour",t.extend(s,{$hasHeader:!1,$hasSubheader:!1,$hasFooter:!1,$hasSubfooter:!1,$hasTabs:!1,$hasTabsTop:!1});var u=e('<div class="ion-tourtip">'+n+"</div>")(s);r._steps=f,r._$el=u,r._el=u[0],r._tourtipEl=r._el.querySelector("tourtip"),r._$tourtipEl=angular.element(r._tourtipEl),r._tourtipOffset={top:0,left:0},r._arrowEl=r._tourtipEl.querySelector("tourtip-arrow"),r._$arrowEl=angular.element(r._arrowEl),r.tour=a;var a=new d(r);return a.scope=s,r.scope||(s[r.tour]=a),i.when(a)};return{fromTemplateUrl:function(t,o){if(!t)throw"A template was not defined.";if(!o)throw"Options are not defined.";return s.load(t).then(function(t){var e=h(t,o);return e})},registerStep:function(o){n(function(){var e=a.offset(o);t.extend(o,{offset:e,scrollDiff:0}),f.push(o)})}}}]).directive("tourStep",["$timeout","$ionicTour",function(o,e){return{restrict:"A",scope:{tourOnStart:"=",tourOnEnd:"=",tourOnTransition:"=",tourOnEnter:"=",tourOnLeave:"="},link:function(n,r,i){t.extend(r,{step:i.tourStep,onStart:function(t,e){"function"==typeof n.tourOnStart&&o(function(){n.tourOnStart(t,e)})},onEnd:function(t,e){"function"==typeof n.tourOnEnd&&o(function(){n.tourOnEnd(t,e)})},onTransition:function(t,e,r){"function"==typeof n.tourOnTransition&&o(function(){n.tourOnTransition(t,e,r)})},onEnter:function(t,e){"function"==typeof n.tourOnEnter&&o(function(){n.tourOnEnter(t,e)})},onLeave:function(t,e){"function"==typeof n.tourOnLeave&&o(function(){n.tourOnLeave(t,e)})}}),e.registerStep(r)}}}])}(window.ionic);