/** Creates an accordion out of a set of images. The accordion should contain the data-cols-img-width data attribute that defines the number of columns in the accordion as well as the width of the image upon expansion. @requires @author [Matt Przybylski](mailto:mprzybylski@sapient.com) @example
$('.module').accordion(); **/ ;(function($, window, document, undefined) { 'use strict'; /* ----------------------------------------------------------------------------- *\ Private Properties \* ----------------------------------------------------------------------------- */ var pluginName = 'accordion', defaults = { accordion: '.accordion' }; /* ----------------------------------------------------------------------------- *\ Constructor \* ----------------------------------------------------------------------------- */ /** @constructor **/ function Accordion(element, options) { this.settings = $.extend(true, {}, defaults, options); this.element = element; this.$el = $(element); this.$accordion = $(this.settings.accordion, this.$el); this._width = Number(this.$accordion.data('cols-img-width').split('-')[1]); this._init(); } /* ----------------------------------------------------------------------------- *\ Private Methods \* ----------------------------------------------------------------------------- */ /** @method _init @return {null} **/ Accordion.prototype._init = function() { var self = this; this.$accordion.kwicks({ max: this._width, spacing: 2, size: 950 }); $('li', this.$accordion).on('mouseenter', function(evt) { var $this = $(this), lid = $this.data('lid'), lpos = $this.data('lpos'); $('h3', self.$accordion).hide(); $this.find('h3').show(); //linkTrack(lpos, lid); }).on('mouseleave', function(evt) { $('h3', self.$accordion).show(); }); }; /* ----------------------------------------------------------------------------- *\ Plugin Initialization \* ----------------------------------------------------------------------------- */ $.fn[pluginName] = function(options) { return this.each(function() { if (!$.data(this, 'plugin_' + pluginName)) { $.data(this, 'plugin_' + pluginName, new Accordion(this, options)); } }); }; })(jQuery, window, document);