-
Notifications
You must be signed in to change notification settings - Fork 3
/
jquery.textpager.min.js
1 lines (1 loc) · 4.76 KB
/
jquery.textpager.min.js
1
!function(b,a,c,d){b.fn.textpager=function(p){var m=$("<div>").insertBefore($(this));$(this).css("overflow","hidden").appendTo($(m));var k={controlArrows:(typeof(p)!=="undefined"&&p!==null&&typeof(p.controlArrows)!=="undefined"&&p.controlArrows!==null)?p.controlArrows:"",controlArrowsEnabel:(typeof(p)!=="undefined"&&p!==null&&typeof(p.controlArrowsEnabel)!=="undefined"&&p.controlArrowsEnabel!==null)?p.controlArrowsEnabel:true,controlPages:(typeof(p)!=="undefined"&&p!==null&&typeof(p.controlPages)!=="undefined"&&p.controlPages!==null)?p.controlPages:"",controlPagesEnabel:(typeof(p)!=="undefined"&&p!==null&&typeof(p.controlPagesEnabel)!=="undefined"&&p.controlPagesEnabel!==null)?p.controlPagesEnabel:true,controlPagesContent:(typeof(p)!=="undefined"&&p!==null&&typeof(p.controlPagesContent)!=="undefined"&&p.controlPagesContent!==null)?p.controlPagesContent:"div"};var j=$(this).prop("scrollHeight"),q=$(this).height(),e=$(this).width();parseContent=function(y,A,u){var w=$(y).html(),v=$.parseHTML(w),s=1;childrenChecker=function(B){$.each(B,function(F,G){var E=G.attributes,I=G.nodeName.toLowerCase();if(I=="div"){r++;z[r-1]=E;var D=$("<div>");if(E){$.each(E,function(K,J){D.attr(J.name,J.value)})}D.appendTo(t);t=D;childrenChecker(G.childNodes);var D=t.parent();t=D;r--;return}var H=$(G).clone();t.append(H);if(t.height()>A){H.detach();if(r>0){for(var C=0;C<r;C++){var D=t.parent();t=D}}t.addClass("tp-page-one").css("height",A+"px").css("width",e+"px");s++;t=$("<div>").appendTo($(y));if(r>0){for(var C=0;C<r;C++){var D=$("<div>");if(z[C]){$.each(z[C],function(K,J){D.attr(J.name,J.value)})}D.appendTo(t);t=D}}t.append(H)}})};$(y).html("");var x=1,r=0,z=[],t=$("<div>").appendTo($(y));childrenChecker(v);t.addClass("tp-page-one").css("height",A+"px").css("width",e+"px");return s};if(q<j){var o=this;var i=1,n=0,g=parseContent(o,q,j);if(k.controlArrows===""){$("<div>").addClass("tp-control-arrows").appendTo($(m));k.controlArrows=$(m).find(".tp-control-arrows");$("<a>").addClass("tp-control-arrow-left").addClass("unactive").html("<span><</span>").appendTo($(k.controlArrows));$("<a>").addClass("tp-control-arrow-right").html("<span>></span>").appendTo($(k.controlArrows))}if(k.controlPages===""){$("<div>").addClass("tp-control-pages").appendTo($(m));k.controlPages=$(m).find(".tp-control-pages")}var f="";for(var h=0;h<g;h++){f+=$("<"+k.controlPagesContent+">").attr("data-page",""+(h+1)).html("<span>"+(h+1)+"</span>").addClass("tp-page").addClass(!h?"active":"").prop("outerHTML")}$(k.controlPages).html(f);$(this).css("height",q+"px").css("padding",0);var l=$(this).html();$(this).html("");$("<div>").addClass("tp-horizontalbox").css("height",q+"px").css("width",e+"px").appendTo($(this));$("<div>").addClass("tp-vertivalbox").html(l).css("width",e+"px").appendTo($(this).find(".tp-horizontalbox"));$(k.controlArrows).find(".tp-control-arrow-left").unbind("click").click(function(){var s=i-1;if(s<1){return}if(s==1){$(this).addClass("unactive")}$(k.controlArrows).find(".tp-control-arrow-right").removeClass("unactive");var r=(s-i)*q;n-=r;i=s;$(k.controlPages).find(k.controlPagesContent+".tp-page").removeClass("active");$(k.controlPages).find(k.controlPagesContent+'[data-page="'+s+'"]').addClass("active");o.animateStep(o,e,n,false)});$(k.controlArrows).find(".tp-control-arrow-right").unbind("click").click(function(){var s=i+1;if(s>g){return}if(s==g){$(this).addClass("unactive")}$(k.controlArrows).find(".tp-control-arrow-left").removeClass("unactive");var r=(s-i)*q;n-=r;i=s;$(k.controlPages).find(k.controlPagesContent+".tp-page").removeClass("active");$(k.controlPages).find(k.controlPagesContent+'[data-page="'+s+'"]').addClass("active");o.animateStep(o,e,n,true)});$(k.controlPages).find(k.controlPagesContent+".tp-page").unbind("click").click(function(){var t=$(this).data("page");if(t===i){return}var s=true;if(t<i){s=false}if(t==1){$(k.controlArrows).find(".tp-control-arrow-left").addClass("unactive");$(k.controlArrows).find(".tp-control-arrow-right").removeClass("unactive")}else{if(t==g){$(k.controlArrows).find(".tp-control-arrow-right").addClass("unactive");$(k.controlArrows).find(".tp-control-arrow-left").removeClass("unactive")}else{$(k.controlArrows).find(".tp-control-arrow-right").removeClass("unactive");$(k.controlArrows).find(".tp-control-arrow-left").removeClass("unactive")}}var r=(t-i)*q;n-=r;i=t;$(k.controlPages).find(k.controlPagesContent+".tp-page").removeClass("active");$(this).addClass("active");o.animateStep(o,e,n,s)})}this.animateStep=function(t,r,u,s){$(t).find(".tp-horizontalbox").animate({marginLeft:(s?"-="+r:"+="+r)},400,function(){$(this).css({marginLeft:(s?"+="+(r*2):"-="+(r*2))}).find(".tp-vertivalbox").css({marginTop:u});$(this).animate({marginLeft:(s?"-="+r:"+="+r)},400).find(".tp-vertivalbox").animate({opacity:1},400)}).find(".tp-vertivalbox").animate({opacity:0},400)}}}(jQuery,window,document);