forked from clu3/bootstro.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstro.min.js
1 lines (1 loc) · 3.75 KB
/
bootstro.min.js
1
$(document).ready(function(){(function(e,t,n){function h(e,t){i=r.size();e=e+"<div class='bootstro-nav-wrapper'>";if(i!=1){if(t==0)e=e+a.nextButton;else if(t==i-1)e=e+a.prevButton;else e=e+a.nextButton+a.prevButton}e=e+"</div>";e=e+'<div class="bootstro-finish-btn-wrapper">'+a.finishButton+"</div>";return e}var r;var i;var s=[];var o=null;var u={nextButton:'<button class="btn btn-primary btn-mini bootstro-next-btn">Next »</button>',prevButton:'<button class="btn btn-primary btn-mini bootstro-prev-btn">« Prev</button>',finishButton:'<button class="btn btn-mini btn-success bootstro-finish-btn"><i class="icon-ok"></i> Ok I got it, get back to the site</button>',stopOnBackdropClick:true,stopOnEsc:true};var a;var f;var l;var c;get_element=function(e){if(r.filter("[data-bootstro-step="+e+"]").size()>0)return r.filter("[data-bootstro-step="+e+"]");else{return r.eq(e)}};get_popup=function(e){var t={};$el=get_element(e);var n="";if(i>1){n="<span class='label label-success'>"+(e+1)+"/"+i+"</span>"}t.title=$el.attr("data-bootstro-title")||"";if(t.title!=""&&n!="")t.title=n+" - "+t.title;else if(t.title=="")t.title=n;t.content=$el.attr("data-bootstro-content")||"";t.content=h(t.content,e);t.placement=$el.attr("data-bootstro-placement")||"top";var r="";if($el.attr("data-bootstro-width")){t.width=$el.attr("data-bootstro-width");r=r+"width:"+$el.attr("data-bootstro-width")+";"}if($el.attr("data-bootstro-height")){t.height=$el.attr("data-bootstro-height");r=r+"height:"+$el.attr("data-bootstro-height")+";"}t.trigger="manual";t.html=$el.attr("data-bootstro-html")||"top";t.template='<div class="popover" style="'+r+'"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div>'+"</div>";return t};e.destroy_popover=function(e){e=e||0;if(e!="all"){$el=get_element(e);$el.popover("destroy").removeClass("bootstro-highlight")}};e.stop=function(){if(this.onExitFunc!=n){this.onExitFunc.call(this,{idx:o})}e.destroy_popover(o);e.unbind();t("div.bootstro-backdrop").remove()};e.go_to=function(r){if(this.onStepFunc!=n){this.onStepFunc.call(this,{idx:r})}e.destroy_popover(o);if(i!=0){p=get_popup(r);$el=get_element(r);$el.popover(p).popover("show");min=Math.min(t(".popover.in").offset().top,$el.offset().top);t("html,body").animate({scrollTop:min-20},"slow");$el.addClass("bootstro-highlight");o=r}};e.next=function(){if(o+1==i){if(this.onCompleteFunc!=n){this.onCompleteFunc.call(this,{idx:o})}}else e.go_to(o+1)};e.prev=function(){if(o==0){alert("At start of intros")}else e.go_to(o-1)};e.start=function(n,s){a=t.extend(true,{},u);t.extend(a,s||{});n=n||".bootstro";r=t(n);i=r.size();t('<div class="bootstro-backdrop"></div>').appendTo("body");e.bind();e.go_to(0)};e.bind=function(){e.unbind();t("html").on("click.bootstro",".bootstro-next-btn",function(t){e.next();t.preventDefault();return false});t("html").on("click.bootstro",".bootstro-prev-btn",function(t){e.prev();t.preventDefault();return false});t("html").on("click.bootstro",".bootstro-finish-btn",function(t){e.stop()});if(a.stopOnBackdropClick){t("html").on("click.bootstro","div.bootstro-backdrop",function(n){if(t(n.target).hasClass("bootstro-backdrop"))e.stop()})}t(document).on("keydown.bootstro",function(t){var n=t.keyCode?t.keyCode:t.which;if(n==39||n==40)e.next();else if(n==37||n==38)e.prev();else if(n==27&&a.stopOnEsc)e.stop()})};e.unbind=function(){t("html").unbind("click.bootstro");t(document).unbind("keydown.bootstro")};e.on_complete=function(e){if(Object.prototype.toString.call(e)=="[object Function]"){this.onCompleteFunc=e}};e.on_exit=function(e){if(Object.prototype.toString.call(e)=="[object Function]"){this.onExitFunc=e}};e.on_step=function(e){if(Object.prototype.toString.call(e)=="[object Function]"){this.onStepFunc=e}}})(window.bootstro=window.bootstro||{},jQuery)})