Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1013440 // jquery.fittext.js

Document

1  
/*global jQuery */
2  
/*!
3  
* FitText.js 1.2
4  
*
5  
* Copyright 2011, Dave Rupert http://daverupert.com
6  
* Released under the WTFPL license
7  
* http://sam.zoy.org/wtfpl/
8  
*
9  
* Date: Thu May 05 14:23:00 2011 -0600
10  
*/
11  
12  
(function( $ ){
13  
14  
  $.fn.fitText = function( kompressor, options ) {
15  
16  
    // Setup options
17  
    var compressor = kompressor || 1,
18  
        settings = $.extend({
19  
          'minFontSize' : Number.NEGATIVE_INFINITY,
20  
          'maxFontSize' : Number.POSITIVE_INFINITY
21  
        }, options);
22  
23  
    return this.each(function(){
24  
25  
      // Store the object
26  
      var $this = $(this);
27  
28  
      // Resizer() resizes items based on the object width divided by the compressor * 10
29  
      var resizer = function () {
30  
        $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
31  
      };
32  
33  
      // Call once to set.
34  
      resizer();
35  
36  
      // Call on resize. Opera debounces their resize by default.
37  
      $(window).on('resize.fittext orientationchange.fittext', resizer);
38  
39  
    });
40  
41  
  };
42  
43  
})( jQuery );

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013440
Snippet name: jquery.fittext.js
Eternal ID of this version: #1013440/1
Text MD5: 4fa4ddbf9edf638d8627badb104732c1
Author: stefan
Category: html
Type: Document
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-07 00:28:40
Source code size: 1117 bytes / 43 lines
Pitched / IR pitched: No / No
Views / Downloads: 336 / 316
Referenced in: [show references]