PageSourceSearch

https://www.zagrayforum.com/ext/vse/lightbox/styles/all/template/js/resizer.js?assets_version=89

js zagrayforum.com collected 2026-10-10 01:18:02 UTC 4,080 bytes, 144 lines download raw bytes

1/*global vseLightbox, mChat*/
2(function($) { // Avoid conflicts with other libraries
3
4	'use strict';
5
6	$.fn.extend({
7		borderHover: function() {
8			return this.each(function() {
9				$(this).css({
10					border: 'solid 3px transparent',
11					borderRadius: '6px',
12					transition: 'border-color 0.1s ease-out',
13					cursor: 'pointer'
14				}).on('mouseenter', function() {
15					$(this).css('border-color', '#4ae');
16				}).on('mouseleave',  function() {
17					$(this).css('border-color', 'transparent');
18				});
19			});
20		}
21	});
22
23	function resizeWideImages() {
24		return (vseLightbox.resizeWidth > 0);
25	}
26
27	function resizeTallImages() {
28		return (vseLightbox.resizeHeight > 0);
29	}
30
31	function isMobile() {
32		var mobileWidth = 900; // disable on screens < 900px
33		return $(window).width() <= mobileWidth && phpbb.isTouch;
34	}
35
36	function isOversized(img) {
37		return (resizeWideImages() && img.width >= vseLightbox.resizeWidth) || (resizeTallImages() && img.height >= vseLightbox.resizeHeight);
38	}
39
40	function lightboxResizer(elements) {
41		if (isMobile() || (!resizeWideImages() && !resizeTallImages() && !vseLightbox.lightboxAll)) {
42			return;
43		}
44		var $targetImage = elements.find('.postimage'),
45			galleryName = 'post-gallery';
46		if (!vseLightbox.lightboxSig) {
47			$targetImage = $targetImage.not(function() {
48				return $(this).closest('.signature').length > 0;
49			});
50		}
51		// enclosing the following in a setTimeout seems to solve issues with
52		// images not being ready and causing $(this).width() to return 0.
53		setTimeout(function() {
54			$targetImage.one('load', function() {
55				if ($(this).closest('.postlink').length > 0) {
56					return;
57				}
58				var img = {
59					index: '',
60					width: $(this).outerWidth(),
61					height: $(this).outerHeight()
62				};
63				switch (vseLightbox.lightboxGal)
64				{
65					case 0:
66						img.index = $targetImage.index(this);
67					break;
68					case 2:
69						img.index = $(this).closest('.post').attr('id') || '';
70					break;
71				}
72				// attached images
73				if ($(this).parent('a').length > 0) {
74					if (vseLightbox.lightboxAll || isOversized(img)) {
75						$(this).parent('a').attr({
76							'data-lightbox': galleryName + img.index,
77							'data-title': (vseLightbox.imageTitles) ? $(this).attr('alt') : ''
78						}).end().borderHover();
79					}
80				}
81				// regular images
82				else if (vseLightbox.lightboxAll || isOversized(img)) {
83					$(this).wrap(function() {
84						var url = $(this).attr('src');
85						return $('<a/>').attr({
86							href: url,
87							'data-lightbox': (vseLightbox.lightboxSig && $(this).closest('.signature').length > 0) ? $targetImage.index(this) : galleryName + img.index,
88							'data-title': (vseLightbox.imageTitles) ? ((url.indexOf(vseLightbox.downloadFile) !== -1) ? $(this).attr('alt') : url.split('/').pop()) : ''
89						});
90					}).borderHover();
91				}
92			}).each(function() {
93				if (this.complete) {
94					$(this).trigger('load');
95				}
96			});
97		}, 0);
98	}
99
100	$(function() {
101		lightboxResizer($(document));
102	});
103
104	// Compatibility with QuickReply Reloaded extension
105	$('#qr_posts').on('qr_loaded', function(e, elements) {
106		lightboxResizer(elements);
107	});
108	$('#qr_postform').on('ajax_submit_preview', function() {
109		lightboxResizer($('#preview'));
110	});
111
112	// Compatibility with SimpleSpoiler extension
113	$('.spoiler-header').on('click', function(e) {
114		var spoiler = e.target.closest('.spoiler');
115		if (!spoiler.hasAttribute('open')) {
116			lightboxResizer($(spoiler).find('.spoiler-body'));
117		}
118	});
119
120	// Compatibility with ABBC3 spoil BBCode
121	$('.spoilbtn').on('click', function(e) {
122		var spoilcontent = $(e.target.closest('.spoilwrapper')).find('.spoilcontent');
123		if (spoilcontent.css('display') === 'none') {
124			lightboxResizer(spoilcontent);
125		}
126	});
127
128	// Compatibility with mChat extension
129	if (typeof mChat === 'object') {
130		$(mChat).on({
131			mchat_add_message_before: function(e, data) {
132				setTimeout(function() {
133					lightboxResizer(data.message);
134				}, 0);
135			},
136			mchat_edit_message_before: function(e, data) {
137				setTimeout(function() {
138					lightboxResizer(data.newMessage);
139				}, 0);
140			}
141		});
142	}
143
144})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.