diff --git a/Gruntfile.js b/Gruntfile.js index ab56358b8f60d..ef6db01d75251 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1025,7 +1025,8 @@ module.exports = function(grunt) { src: [ 'js/_enqueues/**/*.js', // Third party scripts. - '!js/_enqueues/vendor/**/*.js' + '!js/_enqueues/vendor/**/*.js', + 'js/_enqueues/vendor/thickbox/thickbox.js', ], // Remove once other JSHint errors are resolved. options: { diff --git a/src/js/_enqueues/vendor/thickbox/thickbox.js b/src/js/_enqueues/vendor/thickbox/thickbox.js index 2c7b7f95260fa..dfe095bf6d186 100644 --- a/src/js/_enqueues/vendor/thickbox/thickbox.js +++ b/src/js/_enqueues/vendor/thickbox/thickbox.js @@ -3,16 +3,29 @@ * By Cody Lindley (http://www.codylindley.com) * Copyright (c) 2007 cody lindley * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php -*/ + */ + +/* global thickboxL10n, unescape */ +/* jshint -W018 */ +/* jshint -W038 */ +/* jshint -W040 */ +/* jshint -W069 */ +/* jshint -W098 */ +/* jshint -W109 */ +/* jshint -W116 */ if ( typeof tb_pathToImage != 'string' ) { var tb_pathToImage = thickboxL10n.loadingAnimation; } +var imgLoader, TB_PrevCaption, TB_PrevURL, TB_PrevHTML, TB_NextCaption, TB_NextURL, + TB_NextHTML, TB_imageCount, TB_FoundURL, TB_TempArray, TB_Counter, TB_WIDTH, TB_HEIGHT; + /*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ //on page load call tb_init jQuery(document).ready(function(){ + 'use strict'; tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox imgLoader = new Image();// preload image imgLoader.src = tb_pathToImage; @@ -23,6 +36,7 @@ jQuery(document).ready(function(){ * Remove the loading indicator when content in an iframe has loaded. */ function tb_init(domChunk){ + 'use strict'; jQuery( 'body' ) .on( 'click', domChunk, tb_click ) .on( 'thickbox:iframe:loaded', function() { @@ -31,6 +45,7 @@ function tb_init(domChunk){ } function tb_click(){ + 'use strict'; var t = this.title || this.name || null; var a = this.href || this.alt; var g = this.rel || false; @@ -40,6 +55,7 @@ function tb_click(){ } function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link + 'use strict'; var $closeBtn; @@ -87,6 +103,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic urlType == '.webp' || urlType == '.avif' ){//code to show images + var imgPreloader = new Image(); TB_PrevCaption = ""; TB_PrevURL = ""; @@ -117,7 +134,6 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } } - imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; @@ -150,24 +166,26 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic jQuery("#TB_closeWindowButton").on( 'click', tb_remove ); + // Declared in the function scope (not the blocks below) so the keydown handler can reach them under strict mode. + var goPrev = function(){ + if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);} + jQuery("#TB_window").remove(); + jQuery("body").append("
"); + tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); + return false; + }; + var goNext = function(){ + jQuery("#TB_window").remove(); + jQuery("body").append(""); + tb_show(TB_NextCaption, TB_NextURL, imageGroup); + return false; + }; + if (!(TB_PrevHTML === "")) { - function goPrev(){ - if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);} - jQuery("#TB_window").remove(); - jQuery("body").append(""); - tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); - return false; - } jQuery("#TB_prev").on( 'click', goPrev ); } if (!(TB_NextHTML === "")) { - function goNext(){ - jQuery("#TB_window").remove(); - jQuery("body").append(""); - tb_show(TB_NextCaption, TB_NextURL, imageGroup); - return false; - } jQuery("#TB_next").on( 'click', goNext ); } @@ -201,6 +219,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic var queryString = url.replace(/^[^\?]+\??/,''); var params = tb_parseQuery( queryString ); + var ajaxContentW, ajaxContentH; TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL @@ -208,7 +227,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window - urlNoQuery = url.split('TB_'); + var urlNoQuery = url.split('TB_'); jQuery("#TB_iframeContent").remove(); if(params['modal'] != "true"){//iframe no modal jQuery("#TB_window").append("