[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/js/ -> navigation.js (source)

   1  // vim: expandtab sw=4 ts=4 sts=4:
   2  var today = new Date();
   3  var expires = new Date(today.getTime() + (56 * 86400000));
   4  var pma_navi_width;
   5  var pma_saveframesize_timeout = null;
   6  
   7  /**
   8   * opens/closes (hides/shows) tree elements
   9   *
  10   * @param   string  id          id of the element in the DOM
  11   * @param   boolean only_open   do not close/hide element
  12   */
  13  function toggle(id, only_open) {
  14      var el = document.getElementById('subel' + id);
  15      if (! el) {
  16          return false;
  17      }
  18  
  19      var img = document.getElementById('el' + id + 'Img');
  20  
  21      if (el.style.display == 'none' || only_open) {
  22          el.style.display = '';
  23          if (img) {
  24              img.src = image_minus;
  25              img.alt = '-';
  26          }
  27      } else {
  28          el.style.display = 'none';
  29          if (img) {
  30              img.src = image_plus;
  31              img.alt = '+';
  32          }
  33      }
  34      return true;
  35  }
  36  
  37  function PMA_callFunctionDelayed(myfunction, delay)
  38  {
  39      if (typeof pma_saveframesize_timeout == "number") {
  40           window.clearTimeout(pma_saveframesize_timeout);
  41          pma_saveframesize_timeout = null;
  42      }
  43  }
  44  
  45  /**
  46   * saves current navigation frame width in a cookie
  47   * usally called on resize of the navigation frame
  48   */
  49  function PMA_saveFrameSizeReal()
  50  {
  51      pma_navi_width = document.getElementById('body_leftFrame').offsetWidth
  52      //alert('from DOM: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
  53      if (pma_navi_width > 0) {
  54          PMA_setCookie('pma_navi_width', pma_navi_width, expires);
  55          //alert('framesize saved');
  56      }
  57  }
  58  
  59  /**
  60   * calls PMA_saveFrameSizeReal with delay
  61   */
  62  function PMA_saveFrameSize()
  63  {
  64      //alert(typeof(pma_saveframesize_timeout) + ' : ' + pma_saveframesize_timeout);
  65  
  66      if (typeof pma_saveframesize_timeout == "number") {
  67          window.clearTimeout(pma_saveframesize_timeout);
  68          pma_saveframesize_timeout = null;
  69      }
  70  
  71      pma_saveframesize_timeout = window.setTimeout(PMA_saveFrameSizeReal, 2000);
  72  }
  73  
  74  /**
  75   * sets navigation frame width to the value stored in the cookie
  76   * usally called on document load
  77   */
  78  function PMA_setFrameSize()
  79  {
  80      pma_navi_width = PMA_getCookie('pma_navi_width');
  81      //alert('from cookie: ' + typeof(pma_navi_width) + ' : ' + pma_navi_width);
  82      if (pma_navi_width != null) {
  83          if (parent.text_dir == 'ltr') {
  84              parent.document.getElementById('mainFrameset').cols = pma_navi_width + ',*';
  85          } else {
  86              parent.document.getElementById('mainFrameset').cols = '*,' + pma_navi_width;
  87          }
  88          //alert('framesize set');
  89      }
  90  }
  91  
  92  /**
  93   * retrieves a named value from cookie
  94   *
  95   * @param   string  name    name of the value to retrieve
  96   * @return  string  value   value for the given name from cookie
  97   */
  98  function PMA_getCookie(name) {
  99      var start = document.cookie.indexOf(name + "=");
 100      var len = start + name.length + 1;
 101      if ((!start) && (name != document.cookie.substring(0, name.length))) {
 102          return null;
 103      }
 104      if (start == -1) {
 105          return null;
 106      }
 107      var end = document.cookie.indexOf(";", len);
 108      if (end == -1) {
 109          end = document.cookie.length;
 110      }
 111      return unescape(document.cookie.substring(len,end));
 112  }
 113  
 114  /**
 115   * stores a named value into cookie
 116   *
 117   * @param   string  name    name of value
 118   * @param   string  value   value to be stored
 119   * @param   Date    expires expire time
 120   * @param   string  path
 121   * @param   string  domain
 122   * @param   boolean secure
 123   */
 124  function PMA_setCookie(name, value, expires, path, domain, secure) {
 125      document.cookie = name + "=" + escape(value) +
 126          ( (expires) ? ";expires=" + expires.toGMTString() : "") +
 127          ( (path)    ? ";path=" + path : "") +
 128          ( (domain)  ? ";domain=" + domain : "") +
 129          ( (secure)  ? ";secure" : "");
 130  }


Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics