Side Accordion using Moo.Fx

. 6/2/10
  • Agregar a Technorati
  • Agregar a Del.icio.us
  • Agregar a DiggIt!
  • Agregar a Yahoo!
  • Agregar a Google
  • Agregar a Meneame
  • Agregar a Furl
  • Agregar a Reddit
  • Agregar a Magnolia
  • Agregar a Blinklist
  • Agregar a Blogmarks

Side Accordion using moo.fx


HTML


<div id="wrapper">
 
 <div id="left">
  <div class="tab">
  <h3 title="first"><a href="javascript:;">first</a></h3>
  </div>
  <div class="tab">
  <h3 title="second"><a href="javascript:;">second</a></h3>
  </div>
  <div class="tab">
  <h3 title="third"><a href="javascript:;">third</a></h3>
  </div>
  <br />
 </div>
 
 <div id="right">
 <div id="content">
 <div class="stretcher">
  <h3>The standard Lorem Ipsum passage</h3>
 <p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
 </div>
 
 <div class="stretcher">
 <h3>1914 translation by H. Rackham</h3>
 <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.</p>
 </div>
 
 <div class="stretcher">
 <h3>written by Cicero in 45 BC</h3>
 <p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.</p>
 </div>
 </div>
 </div>
</div>



CSS

.tab h3{ color: #333; padding: 3px; margin: 0 1px 1px 0; text-align: center; background: #A9D74E; text-transform:uppercase; color:#FFFFFF; }

h3{ margin: 0; padding: 10px; color:#FFFFFF; font-weight:normal; } 

p{ margin: 0; padding: 10px; line-height: 1.5em; }

#wrapper{ width: 600px; } 

#left{ float: left; width: 150px; }

#right{ float: right; width: 450px; }

.tab{ color: #333; padding: 3px; margin: 0 1px 1px 0; text-align: center; background:#A9D74E;  }

.stretcher{ background: #6FB9E9; }




Moo.fx JavaScript


function init(){
  
  var stretchers = document.getElementsByClassName('stretcher'); //div that stretches
  var toggles = document.getElementsByClassName('tab'); //h3s where I click on

  //accordion effect
  var myAccordion = new fx.Accordion(
   toggles, stretchers, {opacity: true, height: true, duration: 400}
  );

  //hash functions
  var found = false;
  toggles.each(function(h3, i){
   var div = Element.find(h3, 'nextSibling'); //element.find is located in prototype.lite
   if (window.location.href.indexOf(h3.title) > 0) {
    myAccordion.showThisHideOpen(div);
    found = true;
   }
  });
  if (!found) myAccordion.showThisHideOpen(stretchers[0]);
 }


JavaScript


Element.cleanWhitespace('content');
  init();


prototype.lite.js


Click to Download


moo.fx.js


Click to Download


moo.fx.pack.js


Click to Download




Example


Click to DEMO

0 comments: