jQuery(document).ready(function($) { "use strict"; const $floatingButton = $('#floatingButton'); const $floatingButtonLink = $floatingButton.find('a'); const $floatingButtonClose = $('#floatingButtonClose'); let floatingButtonDisabled = false; $floatingButtonClose.add( $floatingButtonLink ).on( 'click', function() { floatingButtonDisabled = !floatingButtonDisabled; $floatingButton.addClass( 'float-hidden' ); }); $(window).scroll( function() { if ( !floatingButtonDisabled ) { if ( $(this).scrollTop() > 200 ) { $floatingButton.removeClass('float-hidden'); } else { $floatingButton.addClass('float-hidden'); } } }); /** * A simple plugin for word count because * all the other options don't count accurately */ $.fn.winkWordCount = function( options ) { var settings = $.extend({ goal : 500, type : 'words', // words|characters target : '.wwc-result', colorError : 'red', colorOk : 'green', prepend : false, append : false }, options ); return this.each( function() { var $this = $( this ); $this.on( 'input paste', function() { var words = $this.val() || '', theCount = 0, // words or characters count $counter = $( settings.target ), textColor, prepend, append; if ( 'words' === settings.type ) { words = words.match(/\S+/g); theCount = words !== null ? words.length : 0; } else { theCount = words.length; } textColor = theCount > settings.goal ? settings.colorError : settings.colorOk; prepend = settings.prepend ? settings.prepend : ''; append = settings.append ? settings.append : ''; if ( $counter.length ) { $counter.css({ color : textColor }).html( prepend + theCount + ' / ' + settings.goal + append ); } }); // Run on page load too $this.trigger( 'paste' ); }); }; }); // jQuery end