Sha256: caaf11a59141da0b36c413eb60057e090bba777508c5a836028e14992b1e20fc
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
var Expander; Expander = (function() { Expander.selector = '.expander'; Expander.toggleSelector = '.expander-toggle'; Expander.contentSelector = '.expander-content'; Expander.enhancedClass = 'js-expander'; Expander.expandedClass = 'expanded'; Expander.enhance = function() { var thisClass; thisClass = this; return $(this.selector).each(function() { return new thisClass(this).enhance(); }); }; function Expander(element) { this._element = $(element); this._toggleElement = this._element.find(this.constructor.toggleSelector); this._contentElement = this._element.find(this.constructor.contentSelector); } Expander.prototype.enhance = function() { this._element.addClass(this.constructor.enhancedClass); this._buildUI(); return this._bindEvents(); }; Expander.prototype._buildUI = function() { return this._contentElement.hide(); }; Expander.prototype._bindEvents = function() { return this._toggleElement.click((function(_this) { return function() { return _this._toggleContent(); }; })(this)); }; Expander.prototype._toggleContent = function() { this._contentElement.toggle(); return this._element.toggleClass(this.constructor.expandedClass); }; return Expander; })(); $(function() { return Expander.enhance(); });
Version data entries
8 entries across 8 versions & 1 rubygems