1/** 2 * Do not remove or edit this. 3 * Modified by Templates-Master, 4 * to provide support of multiple navigation levels 5 * of one accordion instance. 6 * 7 * www.templates-master.com 8 */ 9// accordion.js v2.0 10// 11// Copyright (c) 2007 stickmanlabs 12// Author: Kevin P Miller | http://www.stickmanlabs.com 13// 14// Accordion is freely distributable under the terms of an MIT-style license. 15// 16 17var accordion = Class.create(); 18accordion.prototype = { 19 currentAccordion: null, 20 duration: null, 21 effects: [], 22 animating: false, 23 24 initialize: function(container, options) 25 { 26 this.options = Object.extend({ 27 resizeSpeed: 8, 28 classNames: { 29 toggle: 'accordion-toggle', 30 toggleActive: 'accordion-toggle-active' 31 }, 32 defaultSize: { 33 height: null, 34 width: null 35 }, 36 direction: 'vertical', 37 onEvent: 'click' 38 }, options || {}); 39 40 this.duration = ((11-this.options.resizeSpeed)*0.15); 41 42 var accordions = $$('#'+container+' .'+this.options.classNames.toggle); 43 accordions.each(function(accordion) { 44 Event.observe(accordion, this.options.onEvent, this.activate.bind(this, accordion), false); 45 if (this.options.onEvent == 'click') { 46 accordion.onclick = function() {return false;}; 47 } 48 49 if (this.options.direction == 'horizontal') {
50 var accordion_options = $H({width: '0px'/*, display: 'none'*/}); 51 } else { 52 var accordion_options = $H({height: '0px'/*, display: 'none'*/}); 53 } 54 55 this.currentAccordion = $(accordion.next(0)).setStyle(accordion_options.toJSON()); 56 }.bind(this)); 57 58 this.showActive(container); //ie6 fix 59 }, 60 61 showActive: function(container) 62 { 63 $$('#' + container + ' li.active > ul').each(function(el) { 64 el.setStyle({ height: 'auto' }); 65 }) 66 }, 67 68 activate: function(accordion) 69 { 70 if (this.animating) { 71 return false; 72 } 73 74 this.effects = []; 75 76 if (this.options.direction == 'horizontal') { 77 this.scaleX = true; 78 this.scaleY = false; 79 } else { 80 this.scaleX = false; 81 this.scaleY = true; 82 } 83 84 this.currentAccordion = $(accordion.next(0)); 85 86 if (accordion.hasClassName(this.options.classNames.toggleActive)) { 87 this.deactivate(); 88 } else { 89 this._handleAccordion(); 90 } 91 }, 92 93 deactivate: function() 94 { 95 this.currentAccordion.previous(0).removeClassName(this.options.classNames.toggleActive); 96 97 new Effect.Scale(this.currentAccordion, 0, { 98 duration: this.duration, 99 scaleContent: false, 100 scaleX: this.scaleX, 101 scaleY: this.scaleY, 102 transition: Effect.Transitions.sinoidal, 103 queue: { 104 position: 'end', 105 scope: 'accordionAnimation' 106 }, 107 scaleMode: { 108 originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight, 109 originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth 110 }, 111 afterFinish: function() { 112 this.animating = false; 113 }.bind(this) 114 }); 115 }, 116 117 _handleAccordion: function() 118 { 119 this.effects.push( 120 new Effect.Scale(this.currentAccordion, 100, { 121 sync: true, 122 scaleFrom: 0, 123 scaleContent: false, 124 scaleX: this.scaleX, 125 scaleY: this.scaleY, 126 transition: Effect.Transitions.sinoidal, 127 scaleMode: { 128 originalHeight: this.options.defaultSize.height ? this.options.defaultSize.height : this.currentAccordion.scrollHeight, 129 originalWidth: this.options.defaultSize.width ? this.options.defaultSize.width : this.currentAccordion.scrollWidth 130 } 131 }) 132 ); 133 134 var opened = this._getOpened(); 135 if (opened) { 136 opened.previous(0).removeClassName(this.options.classNames.toggleActive); 137 this.effects.push( 138 new Effect.Scale(opened, 0, { 139 sync: true, 140 scaleContent: false, 141 scaleX: this.scaleX, 142 scaleY: this.scaleY, 143 transition: Effect.Transitions.sinoidal 144 }) 145 ); 146 } 147 148 this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive); 149 new Effect.Parallel(this.effects, { 150 duration: this.duration, 151 queue: { 152 position: 'end', 153 scope: 'accordionAnimation' 154 }, 155 beforeStart: function() { 156 this.animating = true; 157 }.bind(this), 158 afterFinish: function() { 159 this.currentAccordion.setStyle({ height: 'auto' }); 160 this.animating = false; 161 }.bind(this) 162 }); 163 }, 164 165 _getOpened: function() 166 { 167 var siblings = this.currentAccordion.up('li').siblings(); 168 var opened = false; 169 siblings.each(function(el) { 170 if (opened) { 171 return; 172 } 173 el.childElements().each(function(innerEl) { 174 if (innerEl.hasClassName(this.options.classNames.toggleActive)) { 175 opened = innerEl.next(0); 176 return; 177 } 178 }.bind(this)); 179 }.bind(this)); 180 return opened; 181 } 182}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.