summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJed Foster <jed@jedfoster.com>2015-01-02 15:44:02 -0800
committerJed Foster <jed@jedfoster.com>2015-01-02 15:44:02 -0800
commit3dd97600a1b14468952ebe4c83461d469bc43fcc (patch)
tree015b4154e914425320c52ef59edb70e564fcee91
parent2df00602dac646566b63d73a42915c82232eb3de (diff)
downloadReadmore.js-3dd97600a1b14468952ebe4c83461d469bc43fcc.zip
Readmore.js-3dd97600a1b14468952ebe4c83461d469bc43fcc.tar.gz
Readmore.js-3dd97600a1b14468952ebe4c83461d469bc43fcc.tar.bz2
Break up some long lines and make JSHint happy
-rw-r--r--readmore.js40
1 files changed, 25 insertions, 15 deletions
diff --git a/readmore.js b/readmore.js
index 54797c9..3a26cd9 100644
--- a/readmore.js
+++ b/readmore.js
@@ -7,7 +7,9 @@
* Debounce function from http://davidwalsh.name/javascript-debounce-function
*/
-!(function($) {
+/* global jQuery */
+
+(function($) {
var readmore = 'readmore',
defaults = {
@@ -52,7 +54,7 @@
function uniqueId(prefix) {
var id = ++uniqueIdCounter;
- return String(prefix == null ? 'readmore-js-' : prefix) + id;
+ return String(prefix === null ? 'readmore-js-' : prefix) + id;
}
var setBoxHeights = function(element) {
@@ -102,7 +104,10 @@
var styles = ' ';
if (options.embedCSS) {
- styles += options.selector + ' + [data-readmore-js-toggle], ' + options.selector + '[data-readmore-js-section]{' + options.sectionCSS + '}'
+ styles += options.selector + ' + [data-readmore-js-toggle], ' +
+ options.selector + '[data-readmore-js-section]{' +
+ options.sectionCSS +
+ '}';
}
// Include the transition CSS even if embedCSS is false
@@ -129,7 +134,6 @@
}
}
-
function Readmore(element, options) {
var $this = this;
@@ -147,7 +151,7 @@
this._defaults = defaults;
this._name = readmore;
- window.addEventListener('load', function(event) {
+ window.addEventListener('load', function() {
$this.init();
});
}
@@ -175,7 +179,9 @@
current.attr({'data-readmore-js-section': '', 'aria-expanded': false, 'id': id});
- current.after($(useLink).on('click', function(event) { $this.toggle(this, current[0], event); }).attr({'data-readmore-js-toggle': '', 'aria-controls': id}));
+ current.after($(useLink)
+ .on('click', function(event) { $this.toggle(this, current[0], event); })
+ .attr({'data-readmore-js-toggle': '', 'aria-controls': id}));
if (! $this.options.startOpen) {
current.css({height: collapsedHeight});
@@ -183,7 +189,7 @@
}
});
- window.addEventListener('resize', function(event) {
+ window.addEventListener('resize', function() {
resizeBoxes();
});
},
@@ -203,7 +209,8 @@
var $this = this,
$element = $(element),
- newHeight = newLink = '',
+ newHeight = '',
+ newLink = '',
expanded = false,
collapsedHeight = $element.data('collapsedHeight');
@@ -225,22 +232,25 @@
$element.css({'height': newHeight});
// Fire afterToggle callback
- $element.on('transitionend', function(e) {
+ $element.on('transitionend', function() {
$this.options.afterToggle(trigger, element, expanded);
$(this).attr('aria-expanded', expanded).off('transitionend');
});
- $(trigger).replaceWith($($this.options[newLink]).on('click', function(event) { $this.toggle(this, element, event); }).attr({'data-readmore-js-toggle': '', 'aria-controls': $element.attr('id')}));
+ $(trigger).replaceWith($($this.options[newLink])
+ .on('click', function(event) { $this.toggle(this, element, event); })
+ .attr({'data-readmore-js-toggle': '', 'aria-controls': $element.attr('id')}));
},
destroy: function() {
- var $this = this;
-
$(this.element).each(function() {
var current = $(this);
- current.attr({'data-readmore-js-section': null, 'aria-expanded': null }).css({'max-height': '', 'height': ''}).next('[data-readmore-js-toggle]').remove();
+ current.attr({'data-readmore-js-section': null, 'aria-expanded': null })
+ .css({'max-height': '', 'height': ''})
+ .next('[data-readmore-js-toggle]')
+ .remove();
current.removeData();
});
@@ -258,10 +268,10 @@
return this.each(function() {
if ($.data(this, 'plugin_' + readmore)) {
var instance = $.data(this, 'plugin_' + readmore);
- instance['destroy'].apply(instance);
+ instance.destroy.apply(instance);
}
- options['selector'] = selector;
+ options.selector = selector;
$.data(this, 'plugin_' + readmore, new Readmore(this, options));
});