PageSourceSearch

https://mezoameryka.pl/modules/mod_jquery_reel/js/jquery.panorama360.js

js mezoameryka.pl collected 2026-10-03 18:56:04 UTC 9,748 bytes, 284 lines download raw bytes

1/*
2 * panorama360 - jQuery plugin made by Liviu Holhos
3 * Copyright (c) 2011 Minimalistic Studio (http://minimalisticstudio.com/)
4 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
5 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
6 */
7(function($) {
8	$.fn.panorama360 = function(options){
9		this.each(function(){
10			var settings = {
11				start_position: 0, // initial start position for the view
12				image_width: 0,
13				image_height: 0,
14				mouse_wheel_multiplier: 20,
15				bind_resize: true, // determine if window resize affects panorama viewport
16				is360: true, // glue left and right and make it scrollable
17				auto_scroll: false
18			};
19			if(options) $.extend(settings, options);
20			var viewport = $(this);
21			var panoramaContainer = viewport.children('.panorama-container');
22			var viewportImage = panoramaContainer.children('img:first-child');
23			if(settings.image_width<=0 && settings.image_height<=0){
24				settings.image_width = parseInt(viewportImage.data("width"));
25				settings.image_height = parseInt(viewportImage.data("height"));
26				if (!(settings.image_width) || !(settings.image_height)) return;
27			}
28			var image_ratio = settings.image_height/settings.image_width;
29			var elem_height = parseInt(viewport.height());
30			var elem_width = parseInt(elem_height/image_ratio);
31			var image_map = viewportImage.attr('usemap');
32			var circle_map = viewportImage.attr('circlemap');
33			var image_areas;
34			var isDragged = false;
35			var mouseXprev = 0;
36			var scrollDelta = 0;
37			
38			if (settings.is360) viewportImage.height(elem_height).removeAttr("usemap").css("left",0).clone().css("left",elem_width+"px").insertAfter(viewportImage);
39
40			panoramaContainer.css({
41				'margin-left': '-'+settings.start_position+'px',
42				'width': (elem_width*2)+'px',
43				'height': (elem_height)+'px'
44			});
45
46			setInterval( function() {
47				if (isDragged) return false;
48				scrollDelta = scrollDelta * 0.98; // artd 0.98
49				if (Math.abs(scrollDelta)<=2) scrollDelta = 0;
50				scrollView(panoramaContainer, elem_width, scrollDelta, settings);
51			}, 1);
52			viewport.unbind('mousedown mouseup mousemove mouseout mousewheel contextmenu touchmove touchend');
53			viewport.mousedown(function(e){
54				if (isDragged) return false;
55				$(this).addClass("grab");
56				isDragged = true;
57				mouseXprev = e.clientX;
58				scrollOffset = 0;
59				return false;
60			}).mouseup(function(){
61				$(this).removeClass("grab");
62				isDragged = false;
63				scrollDelta = scrollDelta * 0.45;
64				return false;
65			}).mousemove(function(e){
66				if (!isDragged) return false;
67				scrollDelta = parseInt((e.clientX - mouseXprev));
68				mouseXprev = e.clientX;
69				scrollView(panoramaContainer, elem_width, scrollDelta,settings);
70				return false;
71			}).mouseout(function(e){
72				isDragged = false;
73			}).bind("mousewheel",function(e,distance){
74				var delta=Math.ceil(Math.sqrt(Math.abs(distance)));
75				delta=distance<0 ? -delta : delta;
76				scrollDelta = scrollDelta + delta * 5;
77				scrollView(panoramaContainer,elem_width,delta*settings.mouse_wheel_multiplier,settings);
78				return false;
79			}).bind('contextmenu',stopEvent).bind('touchstart', function(e){
80				if (isDragged) return false;
81				isDragged = true;
82				mouseXprev = e.originalEvent.touches[0].pageX;
83				scrollOffset = 0;
84			}).bind('touchmove', function(e){
85				e.preventDefault();
86				if (!isDragged) return false;
87				var touch_x = e.originalEvent.touches[0].pageX;
88				scrollDelta = parseInt((touch_x - mouseXprev));
89				mouseXprev = touch_x;
90				scrollView(panoramaContainer, elem_width, scrollDelta,settings);
91			}).bind('touchend', function(e){
92				isDragged = false;
93				scrollDelta = scrollDelta * 0.45;
94			});
95
96			if (image_map) {
97				// new_area = $("a").addClass("area"); // artd auskommentiert, keine ahnung was das macht.
98				$('.info').removeClass("area"); // artd add: bei caption keine area class
99				$('map[name='+image_map+']').children('area').each(function(){
100					
101					switch ($(this).attr("shape").toLowerCase()){
102						case 'rect':
103							var area_coord = $(this).attr("coords").split(",");
104							var new_area = $(document.createElement('a')).addClass("area").attr("href",$(this).attr("href"));
105							new_area.addClass($(this).attr("class"));
106							
107							$(new_area).attr("teaser", $(this).attr("teaser"));
108							$(new_area).attr("description",$(this).attr("description"));
109							$(new_area).attr("target", $(this).attr("target")); // artd setting target to value from xml
110							$(new_area).html($(this).attr("teaser"));  // artd add teaser into a element
111							
112							panoramaContainer.append(new_area.data("stitch",1).data("coords",area_coord));
113							panoramaContainer.append(new_area.clone().data("stitch",2).data("coords",area_coord));
114							break;
115					}
116				});
117				$('map[name='+image_map+']').remove();
118				image_areas = panoramaContainer.children(".area");
119
120				image_areas.mouseup(stopEvent).mousemove(stopEvent).mousedown(stopEvent);
121				repositionHotspots(image_areas,settings.image_height,elem_height,elem_width);
122				
123			}
124			
125			// artd own circle a map
126			if (circle_map) {
127				var allCircles = $(panoramaContainer).children('.circle');
128				
129				$(allCircles).each(function(){
130					var new_circle = $(this);
131					var coords = $(new_circle).attr('coords').split(",");
132					
133					new_circle.data("stitch",1).data("coords",coords);
134					new_circle_clone = new_circle.clone().data("stitch",2).data("coords",coords);
135					
136					panoramaContainer.append(new_circle);
137					panoramaContainer.append(new_circle_clone);
138				});
139				
140				var circles = panoramaContainer.children('.circle');
141				
142				repositionCircles(circles,settings.image_height,elem_height,elem_width);
143			} // artd
144
145			if (settings.bind_resize){
146				$(window).resize(function(){
147					elem_height = parseInt(viewport.height());
148					elem_width = parseInt(elem_height/image_ratio);
149					panoramaContainer.css({
150						'width': (elem_width*2)+'px',
151						'height': (elem_height)+'px'
152					});
153					viewportImage.css("left",0).next().css("left",elem_width+"px");
154					if (image_map) repositionHotspots(image_areas,settings.image_height,elem_height,elem_width);
155				});
156			}
157
158			if (settings.loaded && $.isFunction(loaded)) {
159				settings.loaded();
160			}
161
162			if (settings.callback && $.isFunction(settings.callback)) {
163				var img = 0;
164				$('.panorama-container img').load(function(e){
165					img += 1;
166					if (img == 2) settings.callback();
167				});
168			}
169			
170			// artd right and left buttons, autoscroll
171			var rightButton = $(this).parent().parent().children('.rightButton');
172			
173			$(rightButton).mousedown(function(){
174			    int00 = setInterval(function() { repeatingfunctionRight() }, 5);
175			}).mouseup(function() {
176			    clearInterval(int00);
177			}).mouseleave(function(){ // wichtig: wenn geklickt und dabei maus rausgeht
178				if (typeof(int00)!=='undefined'){
179					clearInterval(int00);
180				}
181			});
182			
183			function repeatingfunctionRight() {
184				scrollView(panoramaContainer, elem_width, -3,settings);
185			}
186			
187			var leftButton = $(this).parent().parent().children('.leftButton');
188
189			$(leftButton).mousedown(function(){
190			    int01 = setInterval(function() { repeatingfunctionLeft() }, 5);
191			}).mouseup(function() {
192			    clearInterval(int01);
193			}).mouseleave(function(){
194				if (typeof(int01)!=='undefined'){
195					clearInterval(int01);
196				}
197			});
198			
199			function repeatingfunctionLeft() {
200				scrollView(panoramaContainer, elem_width, 3,settings);
201			}
202			
203			if (settings.auto_scroll){
204				
205				setInterval(function() { autoScroll() },40);
206				
207				function autoScroll(){
208					scrollView(panoramaContainer, elem_width, -1,settings);
209				}
210			}
211			// artd ende
212			
213		});
214		
215		// artd 
216		function repositionCircles(areas,image_height,elem_height,elem_width){
217
218			var percent = elem_height/image_height;
219			areas.each(function(){
220				area_coord = $(this).data("coords");
221				stitch = $(this).data("stitch");
222				switch (stitch){
223					case 1:
224						$(this).css({
225							'left':		(area_coord[0]*percent)+"px",
226							'top':		(area_coord[1]*percent)+"px",
227						});
228						break;
229					case 2:
230						$(this).css({
231							'left':		(elem_width+parseInt(area_coord[0])*percent)+"px",
232							'top':		(area_coord[1]*percent)+"px",
233						});
234						break;
235				}
236			});
237		} //artd
238
239		function stopEvent(e){
240			e.preventDefault();
241			return false;
242		}
243
244		function scrollView(panoramaContainer,elem_width,delta,settings){
245			var newMarginLeft = parseInt(panoramaContainer.css('marginLeft'))+delta;
246			if(settings.is360){
247				if (newMarginLeft > 0) newMarginLeft = -elem_width;
248				if (newMarginLeft < -elem_width) newMarginLeft = 0;
249			}
250			else{
251				var right = -(elem_width - panoramaContainer.parent().width());
252				if (newMarginLeft > 0) newMarginLeft = 0;
253				if (newMarginLeft < right) newMarginLeft = right;
254			}
255			panoramaContainer.css('marginLeft', newMarginLeft+'px');
256		}
257
258		function repositionHotspots(areas,image_height,elem_height,elem_width){
259			var percent = elem_height/image_height;
260			areas.each(function(){
261				area_coord = $(this).data("coords");
262				stitch = $(this).data("stitch");
263				switch (stitch){
264					case 1:
265						$(this).css({
266							'left':		(area_coord[0]*percent)+"px",
267							'top':		(area_coord[1]*percent)+"px",
268							'width':	((area_coord[2]-area_coord[0])*percent-7)+"px", // artd -7 war vorher nicht drin
269							'height':	((area_coord[3]-area_coord[1])*percent-7)+"px"
270						});
271						break;
272					case 2:
273						$(this).css({
274							'left':		(elem_width+parseInt(area_coord[0])*percent)+"px",
275							'top':		(area_coord[1]*percent)+"px",
276							'width':	((area_coord[2]-area_coord[0])*percent-7)+"px",
277							'height':	((area_coord[3]-area_coord[1])*percent-7)+"px"
278						});
279						break;
280				}
281			});
282		}
283	}
284})(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.