forked from tkahn/jquery-responsive-headlines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery-responsive-headlines.min.js
1 lines (1 loc) · 1.39 KB
/
jquery-responsive-headlines.min.js
1
!function(a,b){function g(b,c){this.element=b,this.options=a.extend({},f,c),this._defaults=f,this._name=e,this.init()}var e="responsiveHeadlines",f={container:"parent",maxFontSize:9999,minFontSize:1,useThrottleDebounce:!0,throttleDebounceParams:{method:"debounce",delay:250,no_trailing:!1,at_begin:!1}};g.prototype={init:function(){var c=this,d=a(this.element),e=this.options;"inline"!==d.css("display")&&d.css("display","inline"),"nowrap"!==d.css("white-space")&&d.css("white-space","nowrap"),c.resizeText(),e.useThrottleDebounce?"trottle"===e.throttleDebounceParams.method?a(b).on("resize",a.trottle(e.throttleDebounceParams.delay,e.throttleDebounceParams.no_trailing,function(){c.resizeText()})):a(b).on("resize",a.debounce(e.throttleDebounceParams.delay,e.throttleDebounceParams.at_begin,function(){c.resizeText()})):a(b).on("resize",function(){c.resizeText()})},resizeText:function(){var d,b=a(this.element),c=this.options;d="parent"===c.container?b.parent():a("."+c.container);var e=d.width(),f=b.outerWidth(),g=parseInt(b.css("font-size"),10),h=g;if(e>f){for(;b.outerWidth()<d.width()&&c.maxFontSize>h;)h++,b.css("font-size",h);b.outerWidth()>d.width()&&c.minFontSize<h&&(h--,b.css("font-size",h))}else for(;b.outerWidth()>d.width()&&c.minFontSize<h;)h--,b.css("font-size",h)}},a.fn[e]=function(b){return this.each(function(){a.data(this,"plugin_"+e)||a.data(this,"plugin_"+e,new g(this,b))})}}(jQuery,window,document);