PageSourceSearch

https://vrach-aspirant.ru/js/XtLightbox/Adaptor/Image.js

js vrach-aspirant.ru collected 2026-10-02 18:10:40 UTC 1,888 bytes, 81 lines download raw bytes

1/*
2---
3name: XtLightbox.Adaptor.Image
4
5description: extendable lightbox Image Adaptor class
6
7license: MIT-style
8
9authors:
10- Anton Suprun <[email protected]>
11
12requires: [XtLightbox.Adaptor]
13
14provides: [XtLightbox.Adaptor.Image]
15
16...
17*/
18
19XtLightbox.Adaptor.Image = new Class({
20
21	Extends: XtLightbox.Adaptor,
22
23	$name: 'Image',
24
25	options: {
26		extensions: ['jpg', 'png', 'gif'],
27		lightboxCompat: true
28	},
29
30	initialize: function(options){
31		this.parent(options);
32		var e = this.options.extensions || [];
33		if (e.contains('jpg') && !e.contains('jpeg')) e.push('jpeg');
34	},
35
36	check: function(element){
37		return this.options.lightboxCompat ? this.parent(element) : element.href.test('\\.(?:' + this.options.extensions.join('|') + ')$', 'i');
38	},
39
40	getContent: function(element){
41		if (!XtLightbox.Adaptor.cached(element)) throw new Error('Element content must be loaded first');
42		return XtLightbox.Adaptor.load(element);
43	},
44
45	getSize: function(element){
46		if (!XtLightbox.Adaptor.cached(element)) throw new Error('Element content must be loaded first');
47		var img = XtLightbox.Adaptor.load(element);
48		return {
49			x: img.naturalWidth,
50			y: img.naturalHeight
51		};
52	},
53
54	setSize: function(element, size){
55		if (!XtLightbox.Adaptor.cached(element)) throw new Error('Element content must be loaded first');
56		var img = XtLightbox.Adaptor.load(element);
57		img.set({
58			width: size.x,
59			height: size.y
60		});
61		return this;
62	},
63
64	load: function(element, callback){
65		callback = callback || function(){};
66		if (XtLightbox.Adaptor.cached(element)){
67			callback(element);
68			return this;
69		}
70		new Element('img').addEvent('load', function(){
71			if (!this.naturalWidth) this.naturalWidth = this.width;
72			if (!this.naturalHeight) this.naturalHeight = this.height;
73			XtLightbox.Adaptor.cache(element, this);
74			callback(element);
75		}).set({
76			src: element.href,
77			alt: ''
78		});
79		return this;
80	}
81});

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.