From d8c9c08cda766252848ae5752afe952f310017e3 Mon Sep 17 00:00:00 2001 From: Alex Muraro Date: Thu, 11 Jun 2015 12:35:20 +0200 Subject: [PATCH 1/2] Update bjqs-1.3.js Added a simpler method to center prev and next links --- js/bjqs-1.3.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/bjqs-1.3.js b/js/bjqs-1.3.js index f06e7b2..dd4697b 100755 --- a/js/bjqs-1.3.js +++ b/js/bjqs-1.3.js @@ -451,13 +451,12 @@ $c_wrapper.addClass('v-centered'); - // calculate offset % for vertical positioning + // vertically center prev and next var offset_px = ($wrapper.height() - $c_fwd.children('a').outerHeight()) / 2, - ratio = (offset_px / settings.height) * 100, - offset = ratio + '%'; + link_height = $c_fwd.children('a').outerHeight(); - $c_fwd.find('a').css('top', offset); - $c_prev.find('a').css('top', offset); + $c_fwd.find('a').css({'top' : '50%', 'margin-top' : link_height / -2 }); + $c_prev.find('a').css({'top' : '50%', 'margin-top' : link_height / -2 }); } From 82bc5f483e659f8a11f41c8b4af50bd3e1c1b018 Mon Sep 17 00:00:00 2001 From: Alex Muraro Date: Thu, 11 Jun 2015 12:37:53 +0200 Subject: [PATCH 2/2] Update bjqs-1.3.min.js --- js/bjqs-1.3.min.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/js/bjqs-1.3.min.js b/js/bjqs-1.3.min.js index 80d7618..83d2508 100644 --- a/js/bjqs-1.3.min.js +++ b/js/bjqs-1.3.min.js @@ -1,14 +1,16 @@ /* - * Basic jQuery Slider plug-in v.1.3 - * - * http://www.basic-slider.com - * - * Authored by John Cobb - * http://www.johncobb.name - * @john0514 - * - * Copyright 2011, John Cobb - * License: GNU General Public License, version 3 (GPL-3.0) - * http://www.opensource.org/licenses/gpl-3.0.html - * - */(function(e){"use strict";e.fn.bjqs=function(t){var n={width:700,height:300,animtype:"fade",animduration:450,animspeed:4e3,automatic:!0,showcontrols:!0,centercontrols:!0,nexttext:"Next",prevtext:"Prev",showmarkers:!0,centermarkers:!0,keyboardnav:!0,hoverpause:!0,usecaptions:!0,randomstart:!1,responsive:!1},r=e.extend({},n,t),i=this,s=i.find("ul.bjqs"),o=s.children("li"),u=null,a=null,f=null,l=null,c=null,h=null,p=null,d=null,v={slidecount:o.length,animating:!1,paused:!1,currentslide:1,nextslide:0,currentindex:0,nextindex:0,interval:null},m={width:null,height:null,ratio:null},g={fwd:"forward",prev:"previous"},y=function(){o.addClass("bjqs-slide");r.responsive?b():E();if(v.slidecount>1){r.randomstart&&L();r.showcontrols&&x();r.showmarkers&&T();r.keyboardnav&&N();r.hoverpause&&r.automatic&&C();r.animtype==="slide"&&S()}r.usecaptions&&k();if(r.animtype==="slide"&&!r.randomstart){v.currentindex=1;v.currentslide=2}s.show();o.eq(v.currentindex).show();r.automatic&&(v.interval=setInterval(function(){O(g.fwd,!1)},r.animspeed))},b=function(){m.width=i.outerWidth();m.ratio=m.width/r.width,m.height=r.height*m.ratio;if(r.animtype==="fade"){o.css({height:r.height,width:"100%"});o.children("img").css({height:r.height,width:"100%"});s.css({height:r.height,width:"100%"});i.css({height:r.height,"max-width":r.width,position:"relative"});if(m.width');if(r.responsive&&m.width');a=e('
  • '+r.nexttext+"
  • ");f=e('
  • '+r.prevtext+"
  • ");u.on("click","a",function(t){t.preventDefault();var n=e(this).attr("data-direction");if(!v.animating){n===g.fwd&&O(g.fwd,!1);n===g.prev&&O(g.prev,!1)}});f.appendTo(u);a.appendTo(u);u.appendTo(i);if(r.centercontrols){u.addClass("v-centered");var t=(i.height()-a.children("a").outerHeight())/2,n=t/r.height*100,s=n+"%";a.find("a").css("top",s);f.find("a").css("top",s)}},T=function(){l=e('
      ');e.each(o,function(t,n){var i=t+1,s=t+1;r.animtype==="slide"&&(s=t+2);var o=e('
    1. '+i+"
    2. ");i===v.currentslide&&o.addClass("active-marker");o.on("click","a",function(e){e.preventDefault();!v.animating&&v.currentslide!==s&&O(!1,s)});o.appendTo(l)});l.appendTo(i);c=l.find("li");if(r.centermarkers){l.addClass("h-centered");var t=(r.width-l.width())/2;l.css("left",t)}},N=function(){e(document).keyup(function(e){if(!v.paused){clearInterval(v.interval);v.paused=!0}if(!v.animating)if(e.keyCode===39){e.preventDefault();O(g.fwd,!1)}else if(e.keyCode===37){e.preventDefault();O(g.prev,!1)}if(v.paused&&r.automatic){v.interval=setInterval(function(){O(g.fwd)},r.animspeed);v.paused=!1}})},C=function(){i.hover(function(){if(!v.paused){clearInterval(v.interval);v.paused=!0}},function(){if(v.paused){v.interval=setInterval(function(){O(g.fwd,!1)},r.animspeed);v.paused=!1}})},k=function(){e.each(o,function(t,n){var r=e(n).children("img:first-child").attr("title");r||(r=e(n).children("a").find("img:first-child").attr("title"));if(r){r=e('

      '+r+"

      ");r.appendTo(e(n))}})},L=function(){var e=Math.floor(Math.random()*v.slidecount)+1;v.currentslide=e;v.currentindex=e-1},A=function(e){if(e===g.fwd)if(o.eq(v.currentindex).next().length){v.nextindex=v.currentindex+1;v.nextslide=v.currentslide+1}else{v.nextindex=0;v.nextslide=1}else if(o.eq(v.currentindex).prev().length){v.nextindex=v.currentindex-1;v.nextslide=v.currentslide-1}else{v.nextindex=v.slidecount-1;v.nextslide=v.slidecount}},O=function(e,t){if(!v.animating){v.animating=!0;if(t){v.nextslide=t;v.nextindex=t-1}else A(e);if(r.animtype==="fade"){if(r.showmarkers){c.removeClass("active-marker");c.eq(v.nextindex).addClass("active-marker")}o.eq(v.currentindex).fadeOut(r.animduration);o.eq(v.nextindex).fadeIn(r.animduration,function(){v.animating=!1;v.currentslide=v.nextslide;v.currentindex=v.nextindex})}if(r.animtype==="slide"){if(r.showmarkers){var n=v.nextindex-1;n===v.slidecount-2?n=0:n===-1&&(n=v.slidecount-3);c.removeClass("active-marker");c.eq(n).addClass("active-marker")}r.responsive&&m.width1?(n.randomstart&&D(),n.showcontrols&&T(),n.showmarkers&&b(),n.keyboardnav&&j(),n.hoverpause&&n.automatic&&C(),"slide"===n.animtype&&y()):n.automatic=!1,n.usecaptions&&I(),"slide"!==n.animtype||n.randomstart||(p.currentindex=1,p.currentslide=2),d.show(),s.eq(p.currentindex).show(),n.automatic&&(p.interval=setInterval(function(){z(m.fwd,!1)},n.animspeed))},x=function(){f.width=h.outerWidth(),f.ratio=f.width/n.width,f.height=n.height*f.ratio,"fade"===n.animtype&&(s.css({height:n.height,width:"100%"}),s.children("img").css({height:n.height,width:"100%"}),d.css({height:n.height,width:"100%"}),h.css({height:n.height,"max-width":n.width,position:"relative"}),f.width'),n.responsive&&f.width'),a=e('
    3. '+n.nexttext+"
    4. "),c=e('
    5. '+n.prevtext+"
    6. "),r.on("click","a",function(t){t.preventDefault();var i=e(this).attr("data-direction");p.animating||(i===m.fwd&&z(m.fwd,!1),i===m.prev&&z(m.prev,!1))}),c.appendTo(r),a.appendTo(r),r.appendTo(h),n.centercontrols){r.addClass("v-centered");var t=((h.height()-a.children("a").outerHeight())/2,a.children("a").outerHeight());a.find("a").css({top:"50%","margin-top":t/-2}),c.find("a").css({top:"50%","margin-top":t/-2})}},b=function(){if(l=e('
        '),e.each(s,function(t){var i=t+1,h=t+1;"slide"===n.animtype&&(h=t+2);var d=e('
      1. '+i+"
      2. ");i===p.currentslide&&d.addClass("active-marker"),d.on("click","a",function(e){e.preventDefault(),p.animating||p.currentslide===h||z(!1,h)}),d.appendTo(l)}),l.appendTo(h),o=l.find("li"),n.centermarkers){l.addClass("h-centered");var t=(n.width-l.width())/2;l.css("left",t)}},j=function(){e(document).keyup(function(e){p.paused||(clearInterval(p.interval),p.paused=!0),p.animating||(39===e.keyCode?(e.preventDefault(),z(m.fwd,!1)):37===e.keyCode&&(e.preventDefault(),z(m.prev,!1))),p.paused&&n.automatic&&(p.interval=setInterval(function(){z(m.fwd)},n.animspeed),p.paused=!1)})},C=function(){h.hover(function(){p.paused||(clearInterval(p.interval),p.paused=!0)},function(){p.paused&&(p.interval=setInterval(function(){z(m.fwd,!1)},n.animspeed),p.paused=!1)})},I=function(){e.each(s,function(t,i){var n=e(i).children("img:first-child").attr("title");n||(n=e(i).children("a").find("img:first-child").attr("title")),n&&(n=e('

        '+n+"

        "),n.appendTo(e(i)))})},D=function(){var e=Math.floor(Math.random()*p.slidecount)+1;p.currentslide=e,p.currentindex=e-1},W=function(e){e===m.fwd?s.eq(p.currentindex).next().length?(p.nextindex=p.currentindex+1,p.nextslide=p.currentslide+1):(p.nextindex=0,p.nextslide=1):s.eq(p.currentindex).prev().length?(p.nextindex=p.currentindex-1,p.nextslide=p.currentslide-1):(p.nextindex=p.slidecount-1,p.nextslide=p.slidecount)},z=function(e,t){if(!p.animating&&(p.animating=!0,t?(p.nextslide=t,p.nextindex=t-1):W(e),"fade"===n.animtype&&(n.showmarkers&&(o.removeClass("active-marker"),o.eq(p.nextindex).addClass("active-marker")),s.eq(p.currentindex).fadeOut(n.animduration),s.eq(p.nextindex).fadeIn(n.animduration,function(){p.animating=!1,p.currentslide=p.nextslide,p.currentindex=p.nextindex})),"slide"===n.animtype)){if(n.showmarkers){var i=p.nextindex-1;i===p.slidecount-2?i=0:-1===i&&(i=p.slidecount-3),o.removeClass("active-marker"),o.eq(i).addClass("active-marker")}p.slidewidth=n.responsive&&f.width