includes/clientside/static/sliders.js
author Dan
Fri, 19 Dec 2008 21:26:47 -0500
changeset 764 60a5e25a4c50
parent 755 9b4cd3ef42f3
child 779 609e35845ec3
permissions -rw-r--r--
Updated KNOWN_BUGS.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
// Sliding drawers on the sidebar
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
// our global vars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
// the delay between the slide in/out, and a little inertia
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     5
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
     6
/*
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
     7
pseudocode:
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
     8
  oninit():
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
     9
    i = 0
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    10
    for every div with class "slideblock", do
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    11
      if ( cookie['mdgSliderState_' || i] == 'closed' )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    12
        hide(div)
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    13
        
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    14
      div.trigger.addEvent onclick():
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    15
        if ( div.hidden )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    16
          div.show()
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    17
          cookie['mdgSliderState_' || i] = 'open'
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    18
        else
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    19
          div.hide()
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    20
          cookie['mdgSliderState_' || i] = 'closed
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    21
          
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    22
      i++
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    23
    
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    24
*/
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    25
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    26
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
var sliders_initted = false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
      
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 362
diff changeset
    29
var initSliders = function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
{
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    31
  if ( KILL_SWITCH || IE )
57
b354deeaa4c4 Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents: 1
diff changeset
    32
    return false;
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    33
  
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    34
  var divs = getElementsByClassName(document, "div", "slideblock");
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    35
  var divs2 = getElementsByClassName(document, "div", "slideblock2");
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    36
  for ( var i = 0; i < divs2.length; i++ )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    37
  {
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    38
    divs.push(divs2[i]);
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    39
  }
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    40
  delete divs2;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    41
  
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    42
  if ( divs.length < 1 )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    43
    return false;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    44
  
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    45
  for ( var i = 0; i < divs.length; i++ )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    46
  {
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    47
    var div = divs[i];
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    48
    // set a unique id for this slider
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    49
    div.metaid = i;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
    
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    51
    var cookiename = 'mdgSliderState_' + i;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    52
    if ( readCookie(cookiename) == 'closed' )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
    {
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    54
      div.style.display = 'none';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
    }
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    56
    
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    57
    var el = div.previousSibling;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    58
    if ( !el )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    59
      continue;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    60
    while ( el.tagName != 'DIV' )
755
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    61
    {
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    62
      el = el.previousSibling;
755
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    63
      if ( !el )
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    64
        break;
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    65
    }
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    66
    if ( !el )
9b4cd3ef42f3 Fixed sliders not working right with non-Oxygen themes
Dan
parents: 753
diff changeset
    67
      continue;
753
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    68
    var toggler = el.getElementsByTagName('a')[0];
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    69
    if ( !toggler )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    70
      continue;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    71
    toggler.onclick = function()
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    72
    {
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    73
      load_component('jquery');
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    74
      load_component('jquery-ui');
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    75
      
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    76
      var mydiv = this.parentNode.nextSibling;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    77
      while ( mydiv.tagName != 'DIV' )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    78
        mydiv = mydiv.nextSibling;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    79
      if ( mydiv.style.display == 'none' )
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    80
      {
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    81
        $(mydiv).show('blind');
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    82
        var cookiename = 'mdgSliderState_' + mydiv.metaid;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    83
        createCookie(cookiename, 'open', 365);
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    84
      }
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    85
      else
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    86
      {
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    87
        $(mydiv).hide('blind');
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    88
        var cookiename = 'mdgSliderState_' + mydiv.metaid;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    89
        createCookie(cookiename, 'closed', 365);
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    90
      }
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    91
      
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    92
      return false;
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    93
    }
33ae51d7c685 Removed Slide-In-Slide-Out-Ala-Digg, replaced with jQuery
Dan
parents: 740
diff changeset
    94
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 362
diff changeset
    97
addOnloadHook(initSliders);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 362
diff changeset
    98