includes/clientside/static/misc.js
changeset 513 c15fbf197a54
parent 504 bc8e0e9ee01d
child 520 4c16e87cfeae
equal deleted inserted replaced
512:13532b0a223f 513:c15fbf197a54
   587 var expander_onload = function()
   587 var expander_onload = function()
   588 {
   588 {
   589   var sets = document.getElementsByTagName('fieldset');
   589   var sets = document.getElementsByTagName('fieldset');
   590   if ( sets.length < 1 )
   590   if ( sets.length < 1 )
   591     return false;
   591     return false;
   592   for ( var i = 0; i < sets.length; i++ )
   592   var init_us = [];
   593   {
   593   for ( var index = 0; index < sets.length; index++ )
   594     var mode = sets[i].getAttribute('enano:expand');
   594   {
       
   595     var mode = sets[index].getAttribute('enano:expand');
   595     if ( mode == 'closed' || mode == 'open' )
   596     if ( mode == 'closed' || mode == 'open' )
   596     {
   597     {
   597       expander_init_element(sets[i]);
   598       init_us.push(sets[index]);
   598     }
   599     }
       
   600   }
       
   601   for ( var k = 0; k < init_us.length; k++ )
       
   602   {
       
   603     expander_init_element(init_us[k]);
   599   }
   604   }
   600 }
   605 }
   601 
   606 
   602 function expander_init_element(el)
   607 function expander_init_element(el)
   603 {
   608 {
   622     {
   627     {
   623       expander_handle_click(this);
   628       expander_handle_click(this);
   624     }
   629     }
   625     catch(e)
   630     catch(e)
   626     {
   631     {
       
   632       console.debug('Exception caught: ', e);
   627     }
   633     }
   628     return false;
   634     return false;
   629   }
   635   }
   630   
   636   
   631   if ( el.getAttribute('enano:expand') == 'closed' )
   637   if ( el.getAttribute('enano:expand') == 'closed' )
   660       var a = child.getElementsByTagName('a')[0];
   666       var a = child.getElementsByTagName('a')[0];
   661       $(a).rmClass('expander-open');
   667       $(a).rmClass('expander-open');
   662       $(a).addClass('expander-closed');
   668       $(a).addClass('expander-closed');
   663       continue;
   669       continue;
   664     }
   670     }
   665     child.expander_meta_old_state = child.style.display;
   671     if ( child.style )
   666     child.style.display = 'none';
   672     {
       
   673       child.expander_meta_old_state = child.style.display;
       
   674       child.style.display = 'none';
       
   675     }
   667   }
   676   }
   668   el.expander_meta_padbak = el.style.padding;
   677   el.expander_meta_padbak = el.style.padding;
   669   el.setAttribute('enano:expand', 'closed');
   678   el.setAttribute('enano:expand', 'closed');
   670 }
   679 }
   671 
   680 
   680       var a = child.getElementsByTagName('a')[0];
   689       var a = child.getElementsByTagName('a')[0];
   681       $(a).rmClass('expander-closed');
   690       $(a).rmClass('expander-closed');
   682       $(a).addClass('expander-open');
   691       $(a).addClass('expander-open');
   683       continue;
   692       continue;
   684     }
   693     }
   685     if ( child.expander_meta_old_state )
   694     if ( child.expander_meta_old_state && child.style )
   686     {
   695     {
   687       child.style.display = child.expander_meta_old_state;
   696       child.style.display = child.expander_meta_old_state;
   688       child.expander_meta_old_state = null;
   697       child.expander_meta_old_state = null;
   689     }
   698     }
   690     else
   699     else
   691     {
   700     {
   692       child.style.display = null;
   701       if ( child.style )
       
   702       {
       
   703         child.style.display = null;
       
   704       }
   693     }
   705     }
   694   }
   706   }
   695   if ( el.expander_meta_padbak )
   707   if ( el.expander_meta_padbak )
   696   {
   708   {
   697     el.style.padding = el.expander_meta_padbak;
   709     el.style.padding = el.expander_meta_padbak;