From cc240e2d4ff320e8df08c30ba84c54d2e7de4e76 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 20 May 2016 22:32:51 +0100 Subject: [PATCH] Fix lint of creative JS --- theme/static/src/js/creative/creative.js | 68 +++++++++---------- .../static/src/js/creative/jquery.fittext.js | 53 ++++++++------- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/theme/static/src/js/creative/creative.js b/theme/static/src/js/creative/creative.js index 7d5f4a8..b9703f9 100644 --- a/theme/static/src/js/creative/creative.js +++ b/theme/static/src/js/creative/creative.js @@ -4,41 +4,41 @@ * For details, see http://www.apache.org/licenses/LICENSE-2.0. */ -(function($) { - "use strict"; // Start of use strict +// jQuery for page scrolling feature - requires jQuery Easing plugin +$('a.page-scroll').bind('click', function(event) { + const anchor = $(this); + $('html, body').stop().animate( + { + scrollTop: ($(anchor.attr('href')).offset().top - 50) + }, + 1250, + 'easeInOutExpo' + ); + event.preventDefault(); +}); - // jQuery for page scrolling feature - requires jQuery Easing plugin - $('a.page-scroll').bind('click', function(event) { - var $anchor = $(this); - $('html, body').stop().animate({ - scrollTop: ($($anchor.attr('href')).offset().top - 50) - }, 1250, 'easeInOutExpo'); - event.preventDefault(); - }); +// Highlight the top nav as scrolling occurs +$('body').scrollspy({ + target: '.navbar-fixed-top', + offset: 51 +}); - // Highlight the top nav as scrolling occurs - $('body').scrollspy({ - target: '.navbar-fixed-top', - offset: 51 - }) +// Closes the Responsive Menu on Menu Item Click +$('.navbar-collapse ul li a').click(function() { + $('.navbar-toggle:visible').click(); +}); - // Closes the Responsive Menu on Menu Item Click - $('.navbar-collapse ul li a').click(function() { - $('.navbar-toggle:visible').click(); - }); +// Fit Text Plugin for Main Header +$('h1').fitText( + 1.2, { + minFontSize: '35px', + maxFontSize: '65px' + } +); - // Fit Text Plugin for Main Header - $("h1").fitText( - 1.2, { - minFontSize: '35px', - maxFontSize: '65px' - } - ); - - // Offset for Main Navigation - $('#main-nav').affix({ - offset: { - top: 100 - } - }); -})(jQuery); // End of use strict +// Offset for Main Navigation +$('#main-nav').affix({ + offset: { + top: 100 + } +}); diff --git a/theme/static/src/js/creative/jquery.fittext.js b/theme/static/src/js/creative/jquery.fittext.js index 0b3ddef..dcb83f5 100644 --- a/theme/static/src/js/creative/jquery.fittext.js +++ b/theme/static/src/js/creative/jquery.fittext.js @@ -1,4 +1,3 @@ -/*global jQuery */ /*! * FitText.js 1.2 * @@ -9,35 +8,37 @@ * Date: Thu May 05 14:23:00 2011 -0600 */ -(function( $ ){ +$.fn.fitText = function( kompressor, options ) { + // Setup options + const compressor = kompressor || 1, + settings = $.extend({ + 'minFontSize' : Number.NEGATIVE_INFINITY, + 'maxFontSize' : Number.POSITIVE_INFINITY + }, options); - $.fn.fitText = function( kompressor, options ) { + return this.each(function() { - // Setup options - var compressor = kompressor || 1, - settings = $.extend({ - 'minFontSize' : Number.NEGATIVE_INFINITY, - 'maxFontSize' : Number.POSITIVE_INFINITY - }, options); + // Store the object + var $this = $(this); - return this.each(function(){ + // Resizer() resizes items based on the object width divided by the compressor * 10 + var resizer = function () { + $this.css('font-size', + Math.max( + Math.min( + $this.width() / (compressor * 10), + parseFloat(settings.maxFontSize) + ), + parseFloat(settings.minFontSize)) + ); + }; - // Store the object - var $this = $(this); + // Call once to set. + resizer(); - // Resizer() resizes items based on the object width divided by the compressor * 10 - var resizer = function () { - $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize))); - }; + // Call on resize. Opera debounces their resize by default. + $(window).on('resize.fittext orientationchange.fittext', resizer); - // Call once to set. - resizer(); + }); - // Call on resize. Opera debounces their resize by default. - $(window).on('resize.fittext orientationchange.fittext', resizer); - - }); - - }; - -})( jQuery ); +};