PageSourceSearch

https://diocesisvitoria.org/wp-content/plugins/wpdevart_chart_premium/front/js/panzoom/panzoom.js?ver=10.0

js diocesisvitoria.org collected 2026-10-02 06:54:34 UTC 20,067 bytes, 672 lines download raw bytes

1(function(){	
2	var __assign = (this && this.__assign) || function () {
3		__assign = Object.assign || function(t) {
4			for (var s, i = 1, n = arguments.length; i < n; i++) {
5				s = arguments[i];
6				for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7					t[p] = s[p];
8			}
9			return t;
10		};
11		return __assign.apply(this, arguments);
12	};
13	
14	if (typeof window !== 'undefined') {
15	  if (window.NodeList && !NodeList.prototype.forEach) {
16		NodeList.prototype.forEach = Array.prototype.forEach
17	  }
18	  if (typeof window.CustomEvent !== 'function') {
19		window.CustomEvent = function CustomEvent(event, params) {
20		  params = params || { bubbles: false, cancelable: false, detail: null }
21		  var evt = document.createEvent('CustomEvent')
22		  evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
23		  return evt
24		}
25	  }
26	}
27	
28	function findEventIndex(pointers, event) {
29		var i = pointers.length;
30		while (i--) {
31			if (pointers[i].pointerId === event.pointerId) {
32				return i;
33			}
34		}
35		return -1;
36	}
37	
38	function addPointer(pointers, event) {
39		var i;
40		if (event.touches) {
41			i = 0;
42			for (var _i = 0, _a = event.touches; _i < _a.length; _i++) {
43				var touch = _a[_i];
44				touch.pointerId = i++;
45				addPointer(pointers, touch);
46			}
47			return;
48		}
49		i = findEventIndex(pointers, event);
50		if (i > -1) {
51			pointers.splice(i, 1);
52		}
53		pointers.push(event);
54	}
55	
56	function removePointer(pointers, event) {
57		if (event.touches) {
58			while (pointers.length) {
59				pointers.pop();
60			}
61			return;
62		}
63		var i = findEventIndex(pointers, event);
64		if (i > -1) {
65			pointers.splice(i, 1);
66		}
67	}
68	
69	function getMiddle(pointers) {
70		pointers = pointers.slice(0);
71		var event1 = pointers.pop();
72		var event2;
73		while ((event2 = pointers.pop())) {
74			event1 = {
75				clientX: (event2.clientX - event1.clientX) / 2 + event1.clientX,
76				clientY: (event2.clientY - event1.clientY) / 2 + event1.clientY
77			};
78		}
79		return event1;
80	}
81	
82	function getDistance(pointers) {
83		if (pointers.length < 2) {
84			return 0;
85		}
86		var event1 = pointers[0];
87		var event2 = pointers[1];
88		return Math.sqrt(Math.pow(Math.abs(event2.clientX - event1.clientX), 2) +
89			Math.pow(Math.abs(event2.clientY - event1.clientY), 2));
90	}
91	
92	if (typeof window !== 'undefined') {
93		if(typeof events === 'undefined'){
94			var events = {}
95		}
96		if (typeof window.PointerEvent === 'function') {
97			events = {
98				down: 'pointerdown',
99				move: 'pointermove',
100				up: 'pointerup pointerleave pointercancel'
101			};
102		}
103		else if (typeof window.TouchEvent === 'function') {
104			events = {
105				down: 'touchstart',
106				move: 'touchmove',
107				up: 'touchend touchcancel'
108			};
109		}
110	}
111	
112	function onPointer(event, elem, handler, eventOpts) {
113		events[event].split(' ').forEach(function (name) {
114			;
115			elem.addEventListener(name, handler, eventOpts);
116		});
117	}
118	
119	function destroyPointer(event, elem, handler) {
120		events[event].split(' ').forEach(function (name) {
121			;
122			elem.removeEventListener(name, handler);
123		});
124	}
125	
126	var isIE = typeof document !== 'undefined' && !!document.documentMode;
127	var divStyle;
128	
129	function createStyle() {
130		if (divStyle) {
131			return divStyle;
132		}
133		return (divStyle = document.createElement('div').style);
134	}
135	
136	var prefixes = ['webkit', 'moz', 'ms'];
137	var prefixCache = {};
138	
139	function getPrefixedName(name) {
140		if (prefixCache[name]) {
141			return prefixCache[name];
142		}
143		var divStyle = createStyle();
144		if (name in divStyle) {
145			return (prefixCache[name] = name);
146		}
147		var capName = name[0].toUpperCase() + name.slice(1);
148		var i = prefixes.length;
149		while (i--) {
150			var prefixedName = "" + prefixes[i] + capName;
151			if (prefixedName in divStyle) {
152				return (prefixCache[name] = prefixedName);
153			}
154		}
155	}
156	
157	function getCSSNum(name, style) {
158		return parseFloat(style[getPrefixedName(name)]) || 0;
159	}
160	
161	function getBoxStyle(elem, name, style) {
162		if (style === void 0) { style = window.getComputedStyle(elem); }
163		// Support: FF 68+
164		// Firefox requires specificity for border
165		var suffix = name === 'border' ? 'Width' : '';
166		return {
167			left: getCSSNum(name + "Left" + suffix, style),
168			right: getCSSNum(name + "Right" + suffix, style),
169			top: getCSSNum(name + "Top" + suffix, style),
170			bottom: getCSSNum(name + "Bottom" + suffix, style)
171		};
172	}
173	
174	function setStyle(elem, name, value) {
175		// eslint-disable-next-line @typescript-eslint/no-explicit-any
176		elem.style[getPrefixedName(name)] = value;
177	}
178	
179	function setTransition(elem, options) {
180		var transform = getPrefixedName('transform');
181		setStyle(elem, 'transition', transform + " " + options.duration + "ms " + options.easing);
182	}
183	
184	function setTransform(elem, _a, _options) {
185		var x = _a.x, y = _a.y, scale = _a.scale, isSVG = _a.isSVG;
186		setStyle(elem, 'transform', "scale(" + scale + ") translate(" + x + "px, " + y + "px)");
187		if (isSVG && isIE) {
188			var matrixValue = window.getComputedStyle(elem).getPropertyValue('transform');
189			elem.setAttribute('transform', matrixValue);
190		}
191	}
192	
193	function getDimensions(elem) {
194		var parent = elem.parentNode;
195		var style = window.getComputedStyle(elem);
196		var parentStyle = window.getComputedStyle(parent);
197		var rectElem = elem.getBoundingClientRect();
198		var rectParent = parent.getBoundingClientRect();
199		return {
200			elem: {
201				style: style,
202				width: rectElem.width,
203				height: rectElem.height,
204				top: rectElem.top,
205				bottom: rectElem.bottom,
206				left: rectElem.left,
207				right: rectElem.right,
208				margin: getBoxStyle(elem, 'margin', style),
209				border: getBoxStyle(elem, 'border', style)
210			},
211			parent: {
212				style: parentStyle,
213				width: rectParent.width,
214				height: rectParent.height,
215				top: rectParent.top,
216				bottom: rectParent.bottom,
217				left: rectParent.left,
218				right: rectParent.right,
219				padding: getBoxStyle(parent, 'padding', parentStyle),
220				border: getBoxStyle(parent, 'border', parentStyle)
221			}
222		};
223	}
224	
225	function isAttached(elem) {
226		var doc = elem.ownerDocument;
227		var parent = elem.parentNode;
228		return (doc &&
229			parent &&
230			doc.nodeType === 9 &&
231			parent.nodeType === 1 &&
232			doc.documentElement.contains(parent));
233	}
234	
235	function getClass(elem) {
236		return (elem.getAttribute('class') || '').trim();
237	}
238	
239	function hasClass(elem, className) {
240		return elem.nodeType === 1 && (" " + getClass(elem) + " ").indexOf(" " + className + " ") > -1;
241	}
242	
243	function isExcluded(elem, options) {
244		for (var cur = elem; cur != null; cur = cur.parentNode) {
245			if (hasClass(cur, options.excludeClass) || options.exclude.indexOf(cur) > -1) {
246				return true;
247			}
248		}
249		return false;
250	}
251	
252	var rsvg = /^http:[\w\.\/]+svg$/;
253	
254	function isSVGElement(elem) {
255		return rsvg.test(elem.namespaceURI) && elem.nodeName.toLowerCase() !== 'svg';
256	}
257	
258	function shallowClone(obj) {
259		var clone = {};
260		for (var key in obj) {
261			if (obj.hasOwnProperty(key)) {
262				clone[key] = obj[key];
263			}
264		}
265		return clone;
266	}
267
268	var defaultOptions = {
269		animate: false,
270		canvas: false,
271		cursor: 'move',
272		disablePan: false,
273		disableZoom: false,
274		disableXAxis: false,
275		disableYAxis: false,
276		duration: 200,
277		easing: 'ease-in-out',
278		exclude: [],
279		excludeClass: 'panzoom-exclude',
280		handleStartEvent: function (e) {
281			e.preventDefault();
282			e.stopPropagation();
283		},
284		maxScale: 4,
285		minScale: 0.125,
286		overflow: 'hidden',
287		panOnlyWhenZoomed: false,
288		relative: false,
289		setTransform: setTransform,
290		startX: 0,
291		startY: 0,
292		startScale: 1,
293		step: 0.3,
294		touchAction: 'none'
295	};
296	
297	function Panzoom(elem, options) {
298		if (!elem) {
299			throw new Error('Panzoom requires an element as an argument');
300		}
301		if (elem.nodeType !== 1) {
302			throw new Error('Panzoom requires an element with a nodeType of 1');
303		}
304		if (!isAttached(elem)) {
305			throw new Error('Panzoom should be called on elements that have been attached to the DOM');
306		}
307		options = __assign(__assign({}, defaultOptions), options);
308		var isSVG = isSVGElement(elem);
309		var parent = elem.parentNode;
310		parent.style.overflow = options.overflow;
311		parent.style.userSelect = 'none';
312		parent.style.touchAction = options.touchAction;
313		(options.canvas ? parent : elem).style.cursor = options.cursor;
314		elem.style.userSelect = 'none';
315		elem.style.touchAction = options.touchAction;
316		setStyle(elem, 'transformOrigin', typeof options.origin === 'string' ? options.origin : isSVG ? '0 0' : '50% 50%');
317		function resetStyle() {
318			parent.style.overflow = '';
319			parent.style.userSelect = '';
320			parent.style.touchAction = '';
321			parent.style.cursor = '';
322			elem.style.cursor = '';
323			elem.style.userSelect = '';
324			elem.style.touchAction = '';
325			setStyle(elem, 'transformOrigin', '');
326		}
327		
328		function setOptions(opts) {
329			if (opts === void 0) { opts = {}; }
330			for (var key in opts) {
331				if (opts.hasOwnProperty(key)) {
332					options[key] = opts[key];
333				}
334			}
335			if (opts.hasOwnProperty('cursor') || opts.hasOwnProperty('canvas')) {
336				parent.style.cursor = elem.style.cursor = '';
337				(options.canvas ? parent : elem).style.cursor = options.cursor;
338			}
339			if (opts.hasOwnProperty('overflow')) {
340				parent.style.overflow = opts.overflow;
341			}
342			if (opts.hasOwnProperty('touchAction')) {
343				parent.style.touchAction = opts.touchAction;
344				elem.style.touchAction = opts.touchAction;
345			}
346			if (opts.hasOwnProperty('minScale') ||
347				opts.hasOwnProperty('maxScale') ||
348				opts.hasOwnProperty('contain')) {
349				setMinMax();
350			}
351		}
352		
353		var x = 0;
354		var y = 0;
355		var scale = 1;
356		var isPanning = false;
357		zoom(options.startScale, { animate: false });
358		setTimeout(function () {
359			setMinMax();
360			pan(options.startX, options.startY, { animate: false });
361		});
362		
363		function trigger(eventName, detail, opts) {
364			if (opts.silent) {
365				return;
366			}
367			var event = new CustomEvent(eventName, { detail: detail });
368			elem.dispatchEvent(event);
369		}
370		
371		function setTransformWithEvent(eventName, opts, originalEvent) {
372			var value = { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: originalEvent };
373			requestAnimationFrame(function () {
374				if (typeof opts.animate === 'boolean') {
375					if (opts.animate) {
376						setTransition(elem, opts);
377					}
378					else {
379						setStyle(elem, 'transition', 'none');
380					}
381				}
382				opts.setTransform(elem, value, opts);
383			});
384			trigger(eventName, value, opts);
385			trigger('panzoomchange', value, opts);
386			return value;
387		}
388		
389		function setMinMax() {
390			if (options.contain) {
391				var dims = getDimensions(elem);
392				var parentWidth = dims.parent.width - dims.parent.border.left - dims.parent.border.right;
393				var parentHeight = dims.parent.height - dims.parent.border.top - dims.parent.border.bottom;
394				var elemWidth = dims.elem.width / scale;
395				var elemHeight = dims.elem.height / scale;
396				var elemScaledWidth = parentWidth / elemWidth;
397				var elemScaledHeight = parentHeight / elemHeight;
398				if (options.contain === 'inside') {
399					options.maxScale = Math.min(elemScaledWidth, elemScaledHeight);
400				}
401				else if (options.contain === 'outside') {
402					options.minScale = Math.max(elemScaledWidth, elemScaledHeight);
403				}
404			}
405		}
406		
407		function constrainXY(toX, toY, toScale, panOptions) {
408			var opts = __assign(__assign({}, options), panOptions);
409			var result = { x: x, y: y, opts: opts };
410			if (!opts.force && (opts.disablePan || (opts.panOnlyWhenZoomed && scale === opts.startScale))) {
411				return result;
412			}
413			toX = parseFloat(toX);
414			toY = parseFloat(toY);
415			if (!opts.disableXAxis) {
416				result.x = (opts.relative ? x : 0) + toX;
417			}
418			if (!opts.disableYAxis) {
419				result.y = (opts.relative ? y : 0) + toY;
420			}
421			if (opts.contain === 'inside') {
422				var dims = getDimensions(elem);
423				result.x = Math.max(-dims.elem.margin.left - dims.parent.padding.left, Math.min(dims.parent.width -
424					dims.elem.width / toScale -
425					dims.parent.padding.left -
426					dims.elem.margin.left -
427					dims.parent.border.left -
428					dims.parent.border.right, result.x));
429				result.y = Math.max(-dims.elem.margin.top - dims.parent.padding.top, Math.min(dims.parent.height -
430					dims.elem.height / toScale -
431					dims.parent.padding.top -
432					dims.elem.margin.top -
433					dims.parent.border.top -
434					dims.parent.border.bottom, result.y));
435			}
436			else if (opts.contain === 'outside') {
437				var dims = getDimensions(elem);
438				var realWidth = dims.elem.width / scale;
439				var realHeight = dims.elem.height / scale;
440				var scaledWidth = realWidth * toScale;
441				var scaledHeight = realHeight * toScale;
442				var diffHorizontal = (scaledWidth - realWidth) / 2;
443				var diffVertical = (scaledHeight - realHeight) / 2;
444				var minX = (-(scaledWidth - dims.parent.width) -
445					dims.parent.padding.left -
446					dims.parent.border.left -
447					dims.parent.border.right +
448					diffHorizontal) /
449					toScale;
450				var maxX = (diffHorizontal - dims.parent.padding.left) / toScale;
451				result.x = Math.max(Math.min(result.x, maxX), minX);
452				var minY = (-(scaledHeight - dims.parent.height) -
453					dims.parent.padding.top -
454					dims.parent.border.top -
455					dims.parent.border.bottom +
456					diffVertical) /
457					toScale;
458				var maxY = (diffVertical - dims.parent.padding.top) / toScale;
459				result.y = Math.max(Math.min(result.y, maxY), minY);
460			}
461			return result;
462		}
463		
464		function constrainScale(toScale, zoomOptions) {
465			var opts = __assign(__assign({}, options), zoomOptions);
466			var result = { scale: scale, opts: opts };
467			if (!opts.force && opts.disableZoom) {
468				return result;
469			}
470			result.scale = Math.min(Math.max(toScale, opts.minScale), opts.maxScale);
471			return result;
472		}
473		
474		function pan(toX, toY, panOptions, originalEvent) {
475			var result = constrainXY(toX, toY, scale, panOptions);
476			var opts = result.opts;
477			x = result.x;
478			y = result.y;
479			return setTransformWithEvent('panzoompan', opts, originalEvent);
480		}
481		
482		function zoom(toScale, zoomOptions, originalEvent) {
483			var result = constrainScale(toScale, zoomOptions);
484			var opts = result.opts;
485			if (!opts.force && opts.disableZoom) {
486				return;
487			}
488			toScale = result.scale;
489			var toX = x;
490			var toY = y;
491			if (opts.focal) {
492				var focal = opts.focal;
493				toX = (focal.x / toScale - focal.x / scale + x * toScale) / toScale;
494				toY = (focal.y / toScale - focal.y / scale + y * toScale) / toScale;
495			}
496			var panResult = constrainXY(toX, toY, toScale, { relative: false, force: true });
497			x = panResult.x;
498			y = panResult.y;
499			scale = toScale;
500			return setTransformWithEvent('panzoomzoom', opts, originalEvent);
501		}
502		
503		function zoomInOut(isIn, zoomOptions) {
504			var opts = __assign(__assign(__assign({}, options), { animate: true }), zoomOptions);
505			return zoom(scale * Math.exp((isIn ? 1 : -1) * opts.step), opts);
506		}
507		
508		function zoomIn(zoomOptions) {
509			return zoomInOut(true, zoomOptions);
510		}
511		
512		function zoomOut(zoomOptions) {
513			return zoomInOut(false, zoomOptions);
514		}
515		
516		function zoomToPoint(toScale, point, zoomOptions, originalEvent) {
517			var dims = getDimensions(elem);
518			var effectiveArea = {
519				width: dims.parent.width -
520					dims.parent.padding.left -
521					dims.parent.padding.right -
522					dims.parent.border.left -
523					dims.parent.border.right,
524				height: dims.parent.height -
525					dims.parent.padding.top -
526					dims.parent.padding.bottom -
527					dims.parent.border.top -
528					dims.parent.border.bottom
529			};
530			var clientX = point.clientX -
531				dims.parent.left -
532				dims.parent.padding.left -
533				dims.parent.border.left -
534				dims.elem.margin.left;
535			var clientY = point.clientY -
536				dims.parent.top -
537				dims.parent.padding.top -
538				dims.parent.border.top -
539				dims.elem.margin.top;
540			if (!isSVG) {
541				clientX -= dims.elem.width / scale / 2;
542				clientY -= dims.elem.height / scale / 2;
543			}
544			var focal = {
545				x: (clientX / effectiveArea.width) * (effectiveArea.width * toScale),
546				y: (clientY / effectiveArea.height) * (effectiveArea.height * toScale)
547			};
548			return zoom(toScale, __assign(__assign({ animate: false }, zoomOptions), { focal: focal }), originalEvent);
549		}
550		
551		function zoomWithWheel(event, zoomOptions) {
552			event.preventDefault();
553			var opts = __assign(__assign({}, options), zoomOptions);
554			var delta = event.deltaY === 0 && event.deltaX ? event.deltaX : event.deltaY;
555			var wheel = delta < 0 ? 1 : -1;
556			var toScale = constrainScale(scale * Math.exp((wheel * opts.step) / 3), opts).scale;
557			return zoomToPoint(toScale, event, opts);
558		}
559		
560		function reset(resetOptions) {
561			var opts = __assign(__assign(__assign({}, options), { animate: true, force: true }), resetOptions);
562			scale = constrainScale(opts.startScale, opts).scale;
563			var panResult = constrainXY(opts.startX, opts.startY, scale, opts);
564			x = panResult.x;
565			y = panResult.y;
566			return setTransformWithEvent('panzoomreset', opts);
567		}
568		
569		var origX;
570		var origY;
571		var startClientX;
572		var startClientY;
573		var startScale;
574		var startDistance;
575		var pointers = [];
576		function handleDown(event) {
577			if (isExcluded(event.target, options)) {
578				return;
579			}
580			addPointer(pointers, event);
581			isPanning = true;
582			options.handleStartEvent(event);
583			origX = x;
584			origY = y;
585			trigger('panzoomstart', { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: event }, options);
586			var point = getMiddle(pointers);
587			startClientX = point.clientX;
588			startClientY = point.clientY;
589			startScale = scale;
590			startDistance = getDistance(pointers);
591		}
592		
593		function move(event) {
594			if (!isPanning ||
595				origX === undefined ||
596				origY === undefined ||
597				startClientX === undefined ||
598				startClientY === undefined) {
599				return;
600			}
601			addPointer(pointers, event);
602			var current = getMiddle(pointers);
603			if (pointers.length > 1) {
604				var diff = getDistance(pointers) - startDistance;
605				var toScale = constrainScale((diff * options.step) / 80 + startScale).scale;
606				zoomToPoint(toScale, current);
607			}
608			pan(origX + (current.clientX - startClientX) / scale, origY + (current.clientY - startClientY) / scale, {
609				animate: false
610			}, event);
611		}
612		
613		function handleUp(event) {
614			if (pointers.length === 1) {
615				trigger('panzoomend', { x: x, y: y, scale: scale, isSVG: isSVG, originalEvent: event }, options);
616			}
617			removePointer(pointers, event);
618			if (!isPanning) {
619				return;
620			}
621			isPanning = false;
622			origX = origY = startClientX = startClientY = undefined;
623		}
624		
625		var bound = false;
626		function bind() {
627			if (bound) {
628				return;
629			}
630			bound = true;
631			onPointer('down', options.canvas ? parent : elem, handleDown);
632			onPointer('move', document, move, { passive: true });
633			onPointer('up', document, handleUp, { passive: true });
634		}
635		
636		function destroy() {
637			bound = false;
638			destroyPointer('down', options.canvas ? parent : elem, handleDown);
639			destroyPointer('move', document, move);
640			destroyPointer('up', document, handleUp);
641		}
642		
643		if (!options.noBind) {
644			bind();
645		}
646		
647		return {
648			bind: bind,
649			destroy: destroy,
650			eventNames: {
651				down: 'mousedown',
652				move: 'mousemove',
653				up: 'mouseup mouseleave'
654			},
655			getPan: function () { return ({ x: x, y: y }); },
656			getScale: function () { return scale; },
657			getOptions: function () { return shallowClone(options); },
658			pan: pan,
659			reset: reset,
660			resetStyle: resetStyle,
661			setOptions: setOptions,
662			setStyle: function (name, value) { return setStyle(elem, name, value); },
663			zoom: zoom,
664			zoomIn: zoomIn,
665			zoomOut: zoomOut,
666			zoomToPoint: zoomToPoint,
667			zoomWithWheel: zoomWithWheel
668		};
669	}
670	Panzoom.defaultOptions = defaultOptions;
671	window.panZoom = Panzoom
672})()

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.