[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/text_resize/ -> text_resize.js (source)

   1  // $Id $
   2  
   3  if (Drupal.jsEnabled) {
   4    $(document).ready(function() {
   5      // Which div or page element are we resizing?
   6      if (text_resize_scope) { // Admin-specified scope takes precedence.
   7        if ($('#'+text_resize_scope).length > 0) {
   8          var element_to_resize = $('#'+text_resize_scope); // ID specified by admin
   9        }
  10        else if ($('.'+text_resize_scope).length > 0) {
  11          var element_to_resize = $('.'+text_resize_scope); // CLASS specified by admin
  12        }
  13        else {
  14          var element_to_resize = $(text_resize_scope); // It's just a tag specified by admin
  15        }
  16          }
  17          else { // Look for some default scopes that might exist.
  18        if ($('DIV.left-corner').length > 0) {
  19          var element_to_resize = $('DIV.left-corner'); // Main body div for Garland
  20        }
  21        else if ($('#content-inner').length > 0) {
  22          var element_to_resize = $('#content-inner'); // Main body div for Zen-based themes
  23        }
  24        else if ($('#squeeze > #content').length > 0) {
  25          var element_to_resize = $('#squeeze > #content'); // Main body div for Zen Classic
  26        }
  27          }
  28      // Set the initial font size if necessary
  29      if ($.cookie('text_resize') != null) {
  30        element_to_resize.css('font-size', parseFloat($.cookie('text_resize')) + 'px');
  31        //alert( "Should be size: " + $.cookie('text_resize'));
  32      }
  33      else {
  34        //alert('Couldn\'t find text_resize cookie.');
  35      }
  36      if (text_resize_line_height_allow) {
  37        //alert('line height adjustment allowed! The current line-height is '+parseFloat(element_to_resize.css('line-height'), 10));
  38              // Set the initial line height if necessary
  39        if ($.cookie('text_resize_line_height') != null) {
  40          element_to_resize.css('line-height', parseFloat($.cookie('text_resize_line_height')) + 'px');
  41        }
  42          }
  43      // Changer links will change the text size when clicked
  44      $('a.changer').click(function() {
  45        // Set the current font size of the specified section as a variable
  46        var currentFontSize = parseFloat(element_to_resize.css('font-size'), 10);
  47              //alert('currentFontSize = '+currentFontSize);
  48              // Set the current line-height
  49              var current_line_height = parseFloat(element_to_resize.css('line-height'), 10);
  50              //alert('current_line_height = '+current_line_height);
  51        // javascript lets us choose which link was clicked, by ID
  52        if (this.id == 'text_resize_increase') {
  53          var new_font_size = currentFontSize * 1.2;
  54          if (text_resize_line_height_allow) { var new_line_height = current_line_height * 1.2; }
  55          // Allow resizing as long as font size doesn't go above text_resize_maximum.
  56          if (new_font_size <= text_resize_maximum) {
  57            $.cookie('text_resize', new_font_size, { path: '/' });
  58            if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', new_line_height, { path: '/' }); }
  59            var allow_change = true;
  60          }
  61          else {
  62                      $.cookie('text_resize', text_resize_maximum, { path: '/' });
  63            if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', text_resize_line_height_max, { path: '/' }); }
  64            var reset_size_max = true;
  65                  }
  66        }
  67        else if (this.id == 'text_resize_decrease') {
  68          var new_font_size = currentFontSize * 0.8;
  69          if (text_resize_line_height_allow) { var new_line_height = current_line_height * 0.8; }
  70          if (new_font_size >= text_resize_minimum) {
  71            // Allow resizing as long as font size doesn't go below text_resize_minimum.
  72            $.cookie('text_resize', new_font_size, { path: '/' });
  73            if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', new_line_height, { path: '/' }); }
  74            var allow_change = true;
  75          }
  76          else {
  77            // If it goes below text_resize_minimum, just leave it at text_resize_minimum.
  78            $.cookie('text_resize', text_resize_minimum, { path: '/' });
  79                      if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', text_resize_line_height_min, { path: '/' }); }
  80            var reset_size_min = true;
  81          }
  82        }
  83        else if (this.id == 'text_resize_reset') {
  84          $.cookie('text_resize', text_resize_minimum, { path: '/' });
  85                  if (text_resize_line_height_allow) { $.cookie('text_resize_line_height', text_resize_line_height_min, { path: '/' }); }
  86          var reset_size_min = true;
  87        }
  88        // jQuery lets us set the font size value of the main text div
  89        if (allow_change == true) {
  90          element_to_resize.css('font-size', new_font_size + 'px'); // Add 'px' onto the end, otherwise ems are used as units by default
  91                  if (text_resize_line_height_allow) { element_to_resize.css('line-height', new_line_height + 'px'); }
  92          return false;
  93        }
  94        else if (reset_size_min == true) {
  95          element_to_resize.css('font-size', text_resize_minimum + 'px');
  96                  if (text_resize_line_height_allow) { element_to_resize.css('line-height', text_resize_line_height_min + 'px'); }
  97          return false;
  98        }
  99        else if (reset_size_max == true) {
 100          element_to_resize.css('font-size', text_resize_maximum + 'px');
 101                  if (text_resize_line_height_allow) { element_to_resize.css('line-height', text_resize_line_height_max + 'px'); }
 102          return false;
 103        }
 104      });
 105    });
 106  }
 107  // My random jquery
 108  if (Drupal.jsEnabled) {
 109    $(document).ready(function() {
 110                        if (jQuery().equalHeights) {
 111                          $("div.sidebar-first-inner div.sidebar-last-inner").equalHeights();
 112                        }
 113                      });
 114  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7