[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/elements/js/ -> tip_followscroll.js (source)

   1  /*
   2  tip_followscroll.js    v. 1.11
   3  
   4  The latest version is available at
   5  http://www.walterzorn.com
   6  or http://www.devira.com
   7  or http://www.walterzorn.de
   8  
   9  Initial author: Walter Zorn
  10  Last modified: 3.6.2008
  11  
  12  Extension for the tooltip library wz_tooltip.js.
  13  Lets a "sticky" tooltip keep its position inside the clientarea if the window
  14  is scrolled.
  15  */
  16  
  17  // Make sure that the core file wz_tooltip.js is included first
  18  if(typeof config == "undefined")
  19      alert("Error:\nThe core tooltip script file 'wz_tooltip.js' must be included first, before the plugin files!");
  20  
  21  // Here we define new global configuration variable(s) (as members of the
  22  // predefined "config." class).
  23  // From each of these config variables, wz_tooltip.js will automatically derive
  24  // a command which can be passed to Tip() or TagToTip() in order to customize
  25  // tooltips individually. These command names are just the config variable
  26  // name(s) translated to uppercase,
  27  // e.g. from config. FollowScroll a command FOLLOWSCROLL will automatically be
  28  // created.
  29  
  30  //===================    GLOBAL TOOPTIP CONFIGURATION    ======================//
  31  config. FollowScroll = false        // true or false - set to true if you want this to be the default behaviour
  32  //=======    END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW    ==============//
  33  
  34  
  35  // Create a new tt_Extension object (make sure that the name of that object,
  36  // here fscrl, is unique amongst the extensions available for
  37  // wz_tooltips.js):
  38  var fscrl = new tt_Extension();
  39  
  40  // Implement extension eventhandlers on which our extension should react
  41  fscrl.OnShow = function()
  42  {
  43      if(tt_aV[FOLLOWSCROLL])
  44      {
  45          // Permit FOLLOWSCROLL only if the tooltip is sticky
  46          if(tt_aV[STICKY])
  47          {
  48              var x = tt_x - tt_GetScrollX(), y = tt_y - tt_GetScrollY();
  49  
  50              if(tt_ie)
  51              {
  52                  fscrl.MoveOnScrl.offX = x;
  53                  fscrl.MoveOnScrl.offY = y;
  54                  fscrl.AddRemEvtFncs(tt_AddEvtFnc);
  55              }
  56              else
  57              {
  58                  tt_SetTipPos(x, y);
  59                  tt_aElt[0].style.position = "fixed";
  60              }
  61              return true;
  62          }
  63          tt_aV[FOLLOWSCROLL] = false;
  64      }
  65      return false;
  66  };
  67  fscrl.OnHide = function()
  68  {
  69      if(tt_aV[FOLLOWSCROLL])
  70      {
  71          if(tt_ie)
  72              fscrl.AddRemEvtFncs(tt_RemEvtFnc);
  73          else
  74              tt_aElt[0].style.position = "absolute";
  75      }
  76  };
  77  // Helper functions (encapsulate in the class to avoid conflicts with other
  78  // extensions)
  79  fscrl.MoveOnScrl = function()
  80  {
  81      tt_SetTipPos(fscrl.MoveOnScrl.offX + tt_GetScrollX(), fscrl.MoveOnScrl.offY + tt_GetScrollY());
  82  };
  83  fscrl.AddRemEvtFncs = function(PAddRem)
  84  {
  85      PAddRem(window, "resize", fscrl.MoveOnScrl);
  86      PAddRem(window, "scroll", fscrl.MoveOnScrl);
  87  };
  88  


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1