|
a |
|
b/compass-app/platforms/android/assets/www/js/libs/flowtype.js |
|
|
1 |
/*
|
|
|
2 |
* If you create a derivative, please leave this text intact:
|
|
|
3 |
*
|
|
|
4 |
* FlowType.JS 1.0
|
|
|
5 |
* Copyright (c) 2013, Simple Focus http://simplefocus.com/
|
|
|
6 |
*
|
|
|
7 |
* FlowType.JS by Simple Focus (http://simplefocus.com/)
|
|
|
8 |
* is licensed under the MIT License. Read a copy of the
|
|
|
9 |
* license in the LICENSE.txt file or at
|
|
|
10 |
* http://choosealicense.com/licenses/mit
|
|
|
11 |
*
|
|
|
12 |
* Thanks to Giovanni Difeterici (http://www.gdifeterici.com/)
|
|
|
13 |
*/
|
|
|
14 |
|
|
|
15 |
(function($) {
|
|
|
16 |
$.fn.flowtype = function(options) {
|
|
|
17 |
|
|
|
18 |
// Establish default settings/variables
|
|
|
19 |
// ====================================
|
|
|
20 |
var settings = $.extend({
|
|
|
21 |
maximum : 9999,
|
|
|
22 |
minimum : 1,
|
|
|
23 |
maxFont : 9999,
|
|
|
24 |
minFont : 1,
|
|
|
25 |
fontRatio : 35,
|
|
|
26 |
lineRatio : 1.45
|
|
|
27 |
}, options),
|
|
|
28 |
|
|
|
29 |
// Do the magic math
|
|
|
30 |
// =================
|
|
|
31 |
changes = function(el) {
|
|
|
32 |
var $el = $(el),
|
|
|
33 |
elw = $el.width(),
|
|
|
34 |
width = elw > settings.maximum ? settings.maximum : elw < settings.minimum ? settings.minimum : elw,
|
|
|
35 |
fontBase = width / settings.fontRatio,
|
|
|
36 |
fontSize = fontBase > settings.maxFont ? settings.maxFont : fontBase < settings.minFont ? settings.minFont : fontBase;
|
|
|
37 |
|
|
|
38 |
$el.css({
|
|
|
39 |
'font-size' : fontSize + 'px',
|
|
|
40 |
'line-height' : fontSize * settings.lineRatio + 'px'
|
|
|
41 |
});
|
|
|
42 |
};
|
|
|
43 |
|
|
|
44 |
// Make the magic visible
|
|
|
45 |
// ======================
|
|
|
46 |
return this.each(function() {
|
|
|
47 |
|
|
|
48 |
// Context for resize callback
|
|
|
49 |
var that = this;
|
|
|
50 |
|
|
|
51 |
// Set changes on load
|
|
|
52 |
changes(this);
|
|
|
53 |
|
|
|
54 |
// Make changes upon resize
|
|
|
55 |
$(window).resize(function(){changes(that);});
|
|
|
56 |
});
|
|
|
57 |
};
|
|
|
58 |
}(jQuery));
|