1(function( $ ){ 2 3 $.fn.responsiveText = function( options ) { 4 5 // Setup options 6 var settings = $.extend({ 7 'minFontSize' : Number.NEGATIVE_INFINITY, 8 'maxFontSize' : Number.POSITIVE_INFINITY 9 }, options); 10 11 return this.each(function(){ 12 13 // Store the object 14 var $this = $(this), 15 text = $this.get(0); 16 17 if (!text) return; 18 19 $this.data('original-font-size', parseFloat( 20 window.getComputedStyle(text).fontSize 21 ), 10); 22 23 // Resizer() resizes items based on the object width divided by the compressor * 10 24 var resizer = function () { 25 var ratio = null, 26 originalWidth = window.screen.availWidth, 27 currentWidth = window.innerWidth, 28 size = $this.data('original-font-size'); 29 30 if (originalWidth == currentWidth || !size) return; 31 32 if (currentWidth != originalWidth) 33 ratio = originalWidth / currentWidth; 34 35 if (currentWidth > originalWidth) 36 size *= ratio; 37 else 38 size /= ratio; 39 40 size = Math.max( 41 Math.min( 42 size, 43 settings.maxFontSize 44 ), 45 settings.minFontSize 46 ); 47 48 $this.css('font-size', size + 'px'); 49 }; 50 51 resizer(); 52 53 // Call on resize. Opera debounces their resize by default. 54 $(window).on('resize.responsiveText orientationchange.responsiveText', resizer); 55 56 }); 57 58 }; 59 60})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.