From e99d02c75b95523f7b67fbc9fcde42d83808ced1 Mon Sep 17 00:00:00 2001 From: Rich Gomez <0xkione@gmail.com> Date: Tue, 24 Nov 2015 12:18:19 -0800 Subject: [PATCH 1/2] Changed onStep() function to trigger before page travsersal --- bootstro.js | 4 ++-- bootstro.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bootstro.js b/bootstro.js index 80a995e..2081722 100644 --- a/bootstro.js +++ b/bootstro.js @@ -289,9 +289,9 @@ $(document).ready(function(){ } else { - bootstro.go_to(activeIndex + 1); if (typeof settings.onStep == 'function') settings.onStep.call(this, {idx : activeIndex, direction : 'next'});// + bootstro.go_to(activeIndex + 1); } }; @@ -306,9 +306,9 @@ $(document).ready(function(){ } else { - bootstro.go_to(activeIndex -1); if (typeof settings.onStep == 'function') settings.onStep.call(this, {idx : activeIndex, direction : 'prev'});// + bootstro.go_to(activeIndex -1); } }; diff --git a/bootstro.min.js b/bootstro.min.js index c6861c0..ad1d077 100644 --- a/bootstro.min.js +++ b/bootstro.min.js @@ -1 +1 @@ -$(document).ready(function(){(function(e,t,n){function f(e){var n=t(window).scrollTop();var r=n+t(window).height();var i=e.offset().top;var s=i+e.height();return s>=n&&i<=r&&s<=r&&i>=n}function l(e,t){var n=get_element(t);var r,s,o;e=e+"
";if(n.attr("data-bootstro-nextButton")){r=n.attr("data-bootstro-nextButton")}else if(n.attr("data-bootstro-nextButtonText")){r='"}else{if(typeof a.nextButton!="undefined")r=a.nextButton;else r='"}if(n.attr("data-bootstro-prevButton")){s=n.attr("data-bootstro-prevButton")}else if(n.attr("data-bootstro-prevButtonText")){s='"}else{if(typeof a.prevButton!="undefined")s=a.prevButton;else s='"}if(n.attr("data-bootstro-finishButton")){o=n.attr("data-bootstro-finishButton")}else if(n.attr("data-bootstro-finishButtonText")){o='"}else{if(typeof a.finishButton!="undefined")o=a.finishButton;else o='"}if(i!=1){if(t==0)e=e+r;else if(t==i-1)e=e+s;else e=e+r+s}e=e+"
";e=e+'
'+o+"
";return e}var r;var i;var s=[];var o=null;var u={nextButtonText:"Next »",prevButtonText:"« Prev",finishButtonText:' Ok I got it, get back to the site',stopOnBackdropClick:true,stopOnEsc:true,margin:100};var a;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={};var n=get_element(e);var r="";if(i>1){r=""+(e+1)+"/"+i+""}t.title=n.attr("data-bootstro-title")||"";if(t.title!=""&&r!="")t.title=r+" - "+t.title;else if(t.title=="")t.title=r;t.content=n.attr("data-bootstro-content")||"";t.content=l(t.content,e);t.placement=n.attr("data-bootstro-placement")||"top";var s="";if(n.attr("data-bootstro-width")){t.width=n.attr("data-bootstro-width");s=s+"width:"+n.attr("data-bootstro-width")+";"}if(n.attr("data-bootstro-height")){t.height=n.attr("data-bootstro-height");s=s+"height:"+n.attr("data-bootstro-height")+";"}t.trigger="manual";t.html=n.attr("data-bootstro-html")||"top";t.template='

'+"
";return t};e.destroy_popover=function(e){var e=e||0;if(e!="all"){var t=get_element(e);t.popover("destroy").removeClass("bootstro-highlight")}};e.stop=function(){e.destroy_popover(o);e.unbind();t("div.bootstro-backdrop").remove();if(typeof a.onExit=="function")a.onExit.call(this,{idx:o})};e.go_to=function(n){e.destroy_popover(o);if(i!=0){var r=get_popup(n);var s=get_element(n);s.popover(r).popover("show");var u=t(window).scrollTop();var l=Math.min(t(".popover.in").offset().top,s.offset().top);var c=l-u;if(c0&&t("div.bootstro-backdrop").length===0){t('
').appendTo("body");e.bind();e.go_to(0)}};e.start=function(n,r){a=t.extend(true,{},u);t.extend(a,r||{});if(typeof a.url!="undefined"){t.ajax({url:a.url,success:function(r){if(r.success){var i=r.result;var s=[];t.each(i,function(e,n){t.each(n,function(e,r){t(n.selector).attr("data-bootstro-"+e,r)});if(t(n.selector).is(":visible"))s.push(n.selector)});n=s.join(",");e._start(n)}}})}else{e._start(n)}};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")}})(window.bootstro=window.bootstro||{},jQuery)}) +$(document).ready(function(){!function(a,b,c){function d(a){var c=b(window).scrollTop(),d=c+b(window).height(),e=a.offset().top,f=e+a.height();return f>=c&&d>=e&&d>=f&&e>=c}function e(a,b){var c,d,e,f,i=get_element(b);return f=2==j?"btn btn-primary btn-mini":"btn btn-primary btn-xs",a+="
",c=i.attr("data-bootstro-nextButton")?i.attr("data-bootstro-nextButton"):i.attr("data-bootstro-nextButtonText")?'":"undefined"!=typeof h.nextButton?h.nextButton:'",d=i.attr("data-bootstro-prevButton")?i.attr("data-bootstro-prevButton"):i.attr("data-bootstro-prevButtonText")?'":"undefined"!=typeof h.prevButton?h.prevButton:'",e=i.attr("data-bootstro-finishButton")?i.attr("data-bootstro-finishButton"):i.attr("data-bootstro-finishButtonText")?'":"undefined"!=typeof h.finishButton?h.finishButton:'",1!=g&&(0==b?a+=c:b==g-1?a+=d:a=a+c+d),a+="
",a=a+'
'+e+"
"}var f,g,h,i=null,j=3,k={nextButtonText:"Next »",prevButtonText:"« Prev",finishButtonText:' Ok I got it, get back to the site',stopOnBackdropClick:!0,stopOnEsc:!0,margin:100};process_items=function(a){var c=[];return b.each(a,function(a,d){b.each(d,function(a,c){b(d.selector).attr("data-bootstro-"+a,c)}),b(d.selector).is(":visible")&&c.push(d.selector)}),c.join(",")},get_element=function(a){return f.filter("[data-bootstro-step="+a+"]").size()>0?f.filter("[data-bootstro-step="+a+"]"):f.eq(a)},get_popup=function(a){var b={},c=get_element(a),d="";g>1&&(d=""+(a+1)+"/"+g+""),b.title=c.attr("data-bootstro-title")||"",""!=b.title&&""!=d?b.title=d+" - "+b.title:""==b.title&&(b.title=d),b.content=c.attr("data-bootstro-content")||"",b.content=e(b.content,a),b.placement=c.attr("data-bootstro-placement")||"top";var f="";return c.attr("data-bootstro-width")&&(b.width=c.attr("data-bootstro-width"),f=f+"width:"+c.attr("data-bootstro-width")+";"),c.attr("data-bootstro-height")&&(b.height=c.attr("data-bootstro-height"),f=f+"height:"+c.attr("data-bootstro-height")+";"),b.trigger="manual",b.html=c.attr("data-bootstro-html")||"top",c.attr("data-bootstro-container")&&(b.container=c.attr("data-bootstro-container")),b.template='

',b},a.destroy_popover=function(a){var a=a||0;if("all"!=a){var b=get_element(a);b.popover("destroy").removeClass("bootstro-highlight")}},a.stop=function(){a.destroy_popover(i),a.unbind(),b("div.bootstro-backdrop").remove(),"function"==typeof h.onExit&&h.onExit.call(this,{idx:i})},a.go_to=function(c){if(a.destroy_popover(i),0!=g){var e=get_popup(c),f=get_element(c);f.popover(e).popover("show");var j=b(window).scrollTop(),k=Math.min(b(".popover.in").offset().top,f.offset().top),l=k-j;l0&&0===b("div.bootstro-backdrop").length&&(b('
').appendTo("body"),a.bind(),a.go_to(0))},a.start=function(c,d){h=b.extend(!0,{},k),b.extend(h,d||{}),"undefined"!=typeof h.url?b.ajax({url:h.url,success:function(b){if(b.success){var d=b.result;c=process_items(d),a._start(c)}}}):"undefined"!=typeof h.items?a._start(process_items(h.items)):a._start(c)},a.set_bootstrap_version=function(a){j=a},a.bind=function(){a.unbind(),b("html").on("click.bootstro",".bootstro-next-btn",function(b){return a.next(),b.preventDefault(),!1}),b("html").on("click.bootstro",".bootstro-prev-btn",function(b){return a.prev(),b.preventDefault(),!1}),b("html").on("click.bootstro",".bootstro-finish-btn",function(b){b.preventDefault(),a.stop()}),h.stopOnBackdropClick&&b("html").on("click.bootstro","div.bootstro-backdrop",function(c){b(c.target).hasClass("bootstro-backdrop")&&a.stop()}),b(document).on("keydown.bootstro",function(b){var c=b.keyCode?b.keyCode:b.which;39==c||40==c?a.next():37==c||38==c?a.prev():27==c&&h.stopOnEsc&&a.stop()})},a.unbind=function(){b("html").unbind("click.bootstro"),b(document).unbind("keydown.bootstro")}}(window.bootstro=window.bootstro||{},jQuery)}); \ No newline at end of file From 82d1fce0448a653efe8f70ee9afc14875f790d89 Mon Sep 17 00:00:00 2001 From: Rich Gomez <0xkione@gmail.com> Date: Wed, 25 Nov 2015 09:32:56 -0800 Subject: [PATCH 2/2] Added configurable option to allow invisible elements when using the ajax feature --- bootstro.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bootstro.js b/bootstro.js index 2081722..5da077e 100644 --- a/bootstro.js +++ b/bootstro.js @@ -28,7 +28,8 @@ $(document).ready(function(){ finishButtonText : ' Ok I got it, get back to the site', //finishButton : '', stopOnBackdropClick : true, - stopOnEsc : true, + stopOnEsc: true, + allowAjaxInvisElements: false, //onComplete : function(params){} //params = {idx : activeIndex} //onExit : function(params){} //params = {idx : activeIndex} @@ -136,12 +137,13 @@ $(document).ready(function(){ { var selectorArr = []; $.each(popover, function(t,e){ - //only deal with the visible element + //only deal with the visible element, unless flag is set //build the selector $.each(e, function(j, attr){ $(e.selector).attr('data-bootstro-' + j, attr); }); - if ($(e.selector).is(":visible")) + + if (settings.allowAjaxInvisElements || $(e.selector).is(":visible")) selectorArr.push(e.selector); }); return selectorArr.join(",");