|
33 | 33 | Bellows.__super__.call(this, element, options, Bellows.DEFAULTS); |
34 | 34 | } |
35 | 35 |
|
36 | | - Bellows.VERSION = '5.1.1'; |
| 36 | + Bellows.VERSION = '5.1.2'; |
37 | 37 |
|
38 | 38 | Bellows.DEFAULTS = { |
39 | 39 | singleItemOpen: false, |
|
67 | 67 | /** |
68 | 68 | * Ghetto Event Delegation™ |
69 | 69 |
|
70 | | - Zepto doesn't support descendant selectors in event delegation, |
71 | | - so we compare against the closest bellows to ensure we are invoking |
72 | | - the event from a direct child, not a bellows child from a nested bellows. |
| 70 | + Zepto doesn't support descendant selectors in event delegation, |
| 71 | + so we compare against the closest bellows to ensure we are invoking |
| 72 | + the event from a direct child, not a bellows child from a nested bellows. |
73 | 73 | */ |
74 | 74 | this.$bellows |
75 | 75 | .on(events.CLICK, function(e) { |
|
118 | 118 | return item; |
119 | 119 | }, |
120 | 120 |
|
| 121 | + _isOpen: function($item) { |
| 122 | + return $item.hasClass(cssClasses.OPENED); |
| 123 | + }, |
| 124 | + |
| 125 | + _isDisabled: function($item) { |
| 126 | + return $item.hasClass(cssClasses.DISABLED); |
| 127 | + }, |
| 128 | + |
121 | 129 | _wrapContent: function($items) { |
122 | 130 | $items |
123 | 131 | .find(selectors.ITEM_CONTENT) |
|
138 | 146 | open: function($item) { |
139 | 147 | $item = this._item($item); |
140 | 148 |
|
141 | | - if ($item.hasClass(cssClasses.OPENED) || $item.hasClass(cssClasses.DISABLED)) { |
| 149 | + if (this._isOpen($item) || this._isDisabled($item)) { |
142 | 150 | return; |
143 | 151 | } |
144 | 152 |
|
|
149 | 157 | this.closeAll(); |
150 | 158 | } |
151 | 159 |
|
152 | | - this._trigger('open', { item: $item }); |
| 160 | + this._trigger('open', {item: $item}); |
153 | 161 |
|
154 | 162 | Velocity |
155 | 163 | .animate($contentWrapper, 'slideDown', { |
|
168 | 176 |
|
169 | 177 | plugin._setHeight(); |
170 | 178 |
|
171 | | - plugin._trigger('opened', { item: $item }); |
| 179 | + plugin._trigger('opened', {item: $item}); |
172 | 180 | } |
173 | 181 | }); |
174 | 182 | }, |
175 | 183 |
|
176 | 184 | close: function($item) { |
177 | 185 | $item = this._item($item); |
178 | 186 |
|
179 | | - if (!$item.hasClass(cssClasses.OPENED)) { |
| 187 | + if (!this._isOpen($item) || this._isDisabled($item)) { |
180 | 188 | return; |
181 | 189 | } |
182 | 190 |
|
183 | 191 | var plugin = this; |
184 | 192 | var $contentWrapper = $item.find(selectors.ITEM_CONTENT_WRAPPER); |
185 | 193 |
|
186 | | - this._trigger('close', { item: $item }); |
| 194 | + this._trigger('close', {item: $item}); |
187 | 195 |
|
188 | 196 | Velocity |
189 | 197 | .animate($contentWrapper, 'slideUp', { |
|
203 | 211 |
|
204 | 212 | plugin._setHeight(); |
205 | 213 |
|
206 | | - plugin._trigger('closed', { item: $item }); |
| 214 | + plugin._trigger('closed', {item: $item}); |
207 | 215 | } |
208 | 216 | }); |
209 | 217 | }, |
|
0 commit comments