| 84 | |
| 85 | // Section constructor |
| 86 | function Section($el, parent) { |
| 87 | |
| 88 | if(!parent.options.clickQuery) $el.wrapInner('<a href="#"/>'); |
| 89 | |
| 90 | $.extend(this, { |
| 91 | isOpen : false, |
| 92 | $summary : $el.attr("data-collapse-summary",""), |
| 93 | $details : $el.next(), |
| 94 | options: parent.options, |
| 95 | parent: parent |
| 96 | }); |
| 97 | parent.sections.push(this); |
| 98 | |
| 99 | // Check current state of section |
| 100 | var state = parent.states[this._index()]; |
| 101 | |
| 102 | if(state === 0) { |
| 103 | this.close(true) |
| 104 | } |
| 105 | else if(this.$summary.is(".open") || state === 1) { |
| 106 | this.open(true); |
| 107 | } else { |
| 108 | this.close(true) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | Section.prototype = { |
| 113 | toggle : function() { |