Skip to content

Commit aedfc3e

Browse files
westonruterclaudesiliconforks
committed
Use the function form of 'use strict' in thickbox.js
Move the strict-mode directive from file scope into each of the 10 outermost functions. A file-level 'use strict' would, if thickbox.js were the first script in a concatenated bundle, force every other script in that bundle into strict mode, potentially breaking scripts that rely on sloppy-mode semantics. The function form scopes strict mode to thickbox's own functions only. The now-unnecessary JSHint W097 suppression ("Use the function form of 'use strict'") is removed since the function form no longer triggers it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: siliconforks <siliconforks@git.wordpress.org>
1 parent 09b6010 commit aedfc3e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎src/js/_enqueues/vendor/thickbox/thickbox.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
/*
32
* Thickbox 3.1 - One Box To Rule Them All.
43
* By Cody Lindley (http://www.codylindley.com)
@@ -11,7 +10,6 @@
1110
/* jshint -W038 */
1211
/* jshint -W040 */
1312
/* jshint -W069 */
14-
/* jshint -W097 */
1513
/* jshint -W098 */
1614
/* jshint -W109 */
1715
/* jshint -W116 */
@@ -27,6 +25,7 @@ var imgLoader, TB_PrevCaption, TB_PrevURL, TB_PrevHTML, TB_NextCaption, TB_NextU
2725

2826
//on page load call tb_init
2927
jQuery(document).ready(function(){
28+
'use strict';
3029
tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
3130
imgLoader = new Image();// preload image
3231
imgLoader.src = tb_pathToImage;
@@ -37,6 +36,7 @@ jQuery(document).ready(function(){
3736
* Remove the loading indicator when content in an iframe has loaded.
3837
*/
3938
function tb_init(domChunk){
39+
'use strict';
4040
jQuery( 'body' )
4141
.on( 'click', domChunk, tb_click )
4242
.on( 'thickbox:iframe:loaded', function() {
@@ -45,6 +45,7 @@ function tb_init(domChunk){
4545
}
4646

4747
function tb_click(){
48+
'use strict';
4849
var t = this.title || this.name || null;
4950
var a = this.href || this.alt;
5051
var g = this.rel || false;
@@ -54,6 +55,7 @@ function tb_click(){
5455
}
5556

5657
function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
58+
'use strict';
5759

5860
var $closeBtn;
5961

@@ -302,11 +304,13 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic
302304

303305
//helper functions below
304306
function tb_showIframe(){
307+
'use strict';
305308
jQuery("#TB_load").remove();
306309
jQuery("#TB_window").css({'visibility':'visible'}).trigger( 'thickbox:iframe:loaded' );
307310
}
308311

309312
function tb_remove() {
313+
'use strict';
310314
jQuery("#TB_imageOff").off("click");
311315
jQuery("#TB_closeWindowButton").off("click");
312316
jQuery( '#TB_window' ).fadeOut( 'fast', function() {
@@ -324,6 +328,7 @@ function tb_remove() {
324328
}
325329

326330
function tb_position() {
331+
'use strict';
327332
var isIE6 = typeof document.body.style.maxHeight === "undefined";
328333
jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
329334
if ( ! isIE6 ) { // take away IE6
@@ -332,6 +337,7 @@ jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px',
332337
}
333338

334339
function tb_parseQuery ( query ) {
340+
'use strict';
335341
var Params = {};
336342
if ( ! query ) {return Params;}// return empty object
337343
var Pairs = query.split(/[;&]/);
@@ -347,13 +353,15 @@ function tb_parseQuery ( query ) {
347353
}
348354

349355
function tb_getPageSize(){
356+
'use strict';
350357
var de = document.documentElement;
351358
var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
352359
var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
353360
return [w,h];
354361
}
355362

356363
function tb_detectMacXFF() {
364+
'use strict';
357365
var userAgent = navigator.userAgent.toLowerCase();
358366
if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
359367
return true;

0 commit comments

Comments
 (0)