Projet

Général

Profil

Paste
Télécharger (2,13 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / mayo / js / mayo-fontsize.js @ d7f58da2

1
/**
2
 * @file
3
 * Adds javascript functions for font resizing.
4
 */
5
jQuery(document).ready(function() {
6
  var originalFontSize = jQuery('body').css('font-size');
7

    
8
  // Reset font size
9
  jQuery(".resetFont").click(function() {
10
    mayoColumnsResetHeight();
11
    jQuery('body').css('font-size', originalFontSize);
12
    mayoColumnsAdjustHeight();
13
    return false;
14
  });
15

    
16
  // Increase font size
17
  jQuery(".increaseFont").click(function() {
18
    var currentFontSize = jQuery('body').css('font-size');
19
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
20
    var newFontSizeNum = currentFontSizeNum + 1;
21
    if (20 >= newFontSizeNum) { /* max 20px */
22
      var newFontSize = newFontSizeNum + 'px';
23
      mayoColumnsResetHeight();
24
      jQuery('body').css('font-size', newFontSize);
25
      mayoColumnsAdjustHeight();
26
    }
27
    return false;
28
  });
29

    
30
  // Decrease font size
31
  jQuery(".decreaseFont").click(function() {
32
    var currentFontSize = jQuery('body').css('font-size');
33
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
34
    var newFontSizeNum = currentFontSizeNum - 1;
35
    if (10 <= newFontSizeNum) { /* min 10px */
36
      var newFontSize = newFontSizeNum + 'px';
37
      mayoColumnsResetHeight();
38
      jQuery('body').css('font-size', newFontSize);
39
      mayoColumnsAdjustHeight();
40
    }
41
    return false;
42
  });
43
});
44

    
45
function mayoColumnsResetHeight() {
46
  // reset height of column blocks to 'auto' before chaning font size
47
  // so that the column blocks can change the size based on the new
48
  // font size
49
  if (mayoFunctionExists('mayoEqualHeight')) {
50
    jQuery("#top-columns .column-block").height('auto');
51
    jQuery("#bottom-columns .column-block").height('auto');
52
  }
53
}
54
function mayoColumnsAdjustHeight() {
55
  // equalize the height of the column blocks to the tallest height
56
  if (mayoFunctionExists('mayoEqualHeight')) {
57
    mayoEqualHeight(jQuery("#top-columns .column-block"));
58
    mayoEqualHeight(jQuery("#bottom-columns .column-block"));
59
  }
60
}
61
function mayoFunctionExists(function_name) {
62
  if (typeof function_name == 'string') {
63
    return (typeof this.window[function_name] == 'function');
64
  }
65
  else {
66
    return (function_name instanceof Function);
67
  }
68
}