PageSourceSearch

https://www.archisevilla.org/wp-content/themes/archisevilla/js/ot_gallery.js?ver=1.0

js archisevilla.org collected 2026-10-02 10:07:42 UTC 14,868 bytes, 396 lines download raw bytes

1/* -------------------------------------------------------------------------*
2 * 									GALLERY	
3 * -------------------------------------------------------------------------*/
4	
5
6 			jQuery(document).ready(function($){	
7				var adminUrl = ot.adminUrl;
8				var gallery_id = ot.gallery_id;
9				var type = window.location.hash.replace(/[^a-z]/g, '');
10				if(type=="gallery") { 
11					OT_gallery_click(adminUrl, gallery_id);
12				} else {
13					OT_gallery_live_click(adminUrl, gallery_id);
14				}
15				//jQuery(".gallery-image").css("max-height", jQuery(window).height()-300+"px");
16			});
17			
18			function OT_gallery_click(adminUrl, gallery_id) {
19
20
21				ot_swipe(100);
22				var opened_image = jQuery('.gallery-image').attr("data-id");
23				var active_thumb = jQuery(".image-list ul li");
24				
25				
26				//if images loaded
27				jQuery(".gallery-image").each(function() {
28					if(jQuery(this).attr("src")=="") {
29						jQuery(this).load(function(){
30							jQuery(this).fadeIn('slow');
31							//gallery
32							jQuery(".waiter").removeClass("loading").addClass("loaded");
33							//portfolio
34							jQuery(".waiter-portfolio").removeClass("loading").addClass("loaded");
35						});
36					} else {
37						jQuery(this).fadeIn('slow');
38						//gallery
39						jQuery(".waiter").removeClass("loading").addClass("loaded");
40						//portfolio
41						jQuery(".waiter-portfolio").removeClass("loading").addClass("loaded");
42					}
43				});
44			
45				
46				jQuery.each(active_thumb, function() {
47
48					jQuery(this).removeClass("active");
49					if(jQuery(this).attr("data-nr") == opened_image) {
50						jQuery(this).addClass("active");
51					}
52
53				});
54				
55				
56				jQuery('.next, .prev, .next-image, .gal-thumbs').click(function() {	
57					otLoading(jQuery(this),adminUrl,false);
58				});
59
60
61				jQuery('.next').click(function() {
62					otNextImage(jQuery(this));
63				});	
64				
65				jQuery('.prev').click(function() {
66					otPrevImage(jQuery(this));
67				});
68
69				jQuery('#next-image').click(function() {
70					var total_img = jQuery(this).closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
71					var opened_image = jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id");
72					
73					if(parseInt(total_img) > opened_image) {
74						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(opened_image)+1);
75						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel"))+1);
76					}	
77					
78					if(parseInt(total_img) > parseInt(jQuery(this).attr("rel"))) {
79						jQuery(this).attr("rel", parseInt(jQuery(this).attr("rel"))+1);
80						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(jQuery(this).attr("rel"))); 
81						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel", parseInt(jQuery(this).attr("rel"))); 
82					}
83
84				});
85				
86				jQuery('.gal-thumbs').click(function() {
87					var next = jQuery(this).attr("rel");
88					var total_img = jQuery(this).closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
89					
90					if(jQuery(this).attr("rel")!=total_img) { 
91						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel", parseInt(next)+1); 
92						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(next)-1); 
93						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(next)+1); 
94						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
95					} else {
96						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel",total_img); 
97						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(total_img)-1); 
98						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", total_img); 
99						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
100
101					}
102					if(jQuery(this).attr("rel")==1) { 
103						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", 0); 
104						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
105					}
106
107				});
108				
109				
110				jQuery('.next, .prev, .next-image, .gal-thumbs').click(function() {	
111					otThumbs(jQuery(this));
112				});
113				
114		
115			}
116			
117			function OT_gallery_live_click(adminUrl, gallery_id) {
118
119				ot_swipe(100);
120				var opened_image = jQuery('.gallery-image').attr("data-id");
121				var active_thumb = jQuery(".image-list ul li");
122				
123				//if images loaded
124				jQuery(".gallery-image").each(function() {
125					if(jQuery(this).attr("src")=="") {
126						jQuery(this).load(function(){
127							jQuery(this).fadeIn('slow');
128							//gallery
129							jQuery(".waiter").removeClass("loading").addClass("loaded");
130							//portfolio
131							jQuery(".waiter-portfolio").removeClass("loading").addClass("loaded");
132						});
133					} else {
134						jQuery(this).fadeIn('slow');
135						//gallery
136						jQuery(".waiter").removeClass("loading").addClass("loaded");
137						//portfolio
138						jQuery(".waiter-portfolio").removeClass("loading").addClass("loaded");
139					}
140				});
141				
142				jQuery.each(active_thumb, function() {
143					jQuery(this).removeClass("active");
144					if(jQuery(this).attr("data-nr") == opened_image) {
145						jQuery(this).addClass("active");
146					}
147
148				});
149				
150				
151				jQuery('.next, .prev, .next-image, .gal-thumbs').on("click",function() {	
152					otLoading(jQuery(this),adminUrl,false);
153				});
154
155
156				jQuery('.next').on("click",function() {
157					otNextImage(jQuery(this));
158				});	
159				
160				jQuery('.prev').on("click",function() {
161					otPrevImage(jQuery(this));
162				});
163
164				jQuery('#next-image').on("click",function() {
165					var opened_image = jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id");
166					var total_img = jQuery(this).closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
167					if(parseInt(total_img) > opened_image) {
168						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(opened_image)+1);
169						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel"))+1);
170					}	
171					
172					if(parseInt(total_img) > parseInt(jQuery(this).attr("rel"))) {
173						jQuery(this).attr("rel", parseInt(jQuery(this).attr("rel"))+1);
174						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(jQuery(this).attr("rel"))); 
175						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel", parseInt(jQuery(this).attr("rel"))); 
176					}
177
178				});
179				
180				jQuery('.gal-thumbs').on("click",function() {
181					var next = jQuery(this).attr("rel");
182					var total_img = jQuery(this).closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
183					if(jQuery(this).attr("rel")!=total_img) { 
184						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel", parseInt(next)+1); 
185						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(next)-1); 
186						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(next)+1); 
187						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
188					} else {
189						jQuery(this).closest('.ot-slide-item').find(".next").attr("rel",total_img); 
190						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", parseInt(total_img)-1); 
191						jQuery(this).closest('.ot-slide-item').find(".next-image").attr("data-next", total_img); 
192						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
193
194					}
195					if(jQuery(this).attr("rel")==1) { 
196						jQuery(this).closest('.ot-slide-item').find(".prev").attr("rel", 0); 
197						jQuery(this).closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(next)); 
198					}
199
200				});
201				
202				
203				jQuery('.next, .prev, .next-image, .gal-thumbs').on("click",function() {	
204					otThumbs(jQuery(this));
205				});
206				
207		
208			}
209			
210			function otNextImage(clicked) {
211				OT_lightbox_slider(clicked,"right");
212				var opened_image = clicked.closest('.ot-slide-item').find(".gallery-image").attr("data-id");
213				var total_img = clicked.closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
214					
215				if(parseInt(total_img) > opened_image) {
216					clicked.closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(opened_image)+1);
217					clicked.closest('.ot-slide-item').find(".prev").attr("rel", parseInt(clicked.closest('.ot-slide-item').find(".prev").attr("rel"))+1);
218				}	
219					
220				if(parseInt(total_img) > parseInt(clicked.attr("rel"))) {
221					clicked.attr("rel", parseInt(clicked.attr("rel"))+1);
222					clicked.closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(clicked.attr("rel"))); 
223				}
224			}	
225			
226			function otPrevImage(clicked) {
227				OT_lightbox_slider(clicked,"left");
228				var opened_image = clicked.closest('.ot-slide-item').find(".gallery-image").attr("data-id");
229				
230				if(parseInt(opened_image) > 1 && parseInt(opened_image) != jQuery(".next").attr("rel")) {
231					clicked.closest('.ot-slide-item').find(".next").attr("rel", parseInt(clicked.closest('.ot-slide-item').find(".next").attr("rel"))-1);
232					clicked.closest('.ot-slide-item').find(".next-image").attr("data-next", parseInt(clicked.closest('.ot-slide-item').find(".next").attr("rel"))); 
233				}
234				if(parseInt(opened_image) > 1) {
235					clicked.attr("rel", parseInt(clicked.attr("rel"))-1);
236					clicked.closest('.ot-slide-item').find(".gallery-image").attr("data-id", parseInt(opened_image)-1);
237				}
238			}	
239			
240			function otLoading(clicked,adminUrl,swipe) {
241				var ID = clicked.closest('.ot-slide-item').attr("id");
242				var clicked = clicked;
243				var next = clicked.attr("rel");
244				var opened_image = clicked.closest('.ot-slide-item').find(".gallery-image").attr("data-id");
245				var total_img = clicked.closest('.ot-slide-item').find('.ot-last-image').attr("data-last");
246				var waiter = clicked.closest('.ot-slide-item').find('.waiter');
247				var waiterPorfolio = clicked.closest('.ot-slide-item').find('.waiter-portfolio');
248				var image = clicked.closest('.ot-slide-item').find('.gallery-image');
249					
250				if( (parseInt(opened_image) < parseInt(total_img) || next!=p
250arseInt(total_img)) && next!=0 && next!=opened_image) {
251					if(swipe==true) jQuery('.image-big-gallery').attr("src",ot.imageUrl+"blank.jpg");
252					waiter.removeClass("loaded");
253					waiter.addClass("loading");
254					waiterPorfolio.removeClass("loaded");
255					waiterPorfolio.addClass("loading");
256						
257					jQuery.ajax({
258						url:adminUrl,
259						type:"POST",
260						data:"action=load_next_image&gallery_id="+ID+"&next_image="+next,
261						success:function(results) {
262							image.attr("src", results);
263							//image.css("max-height", jQuery(window).height()-300+"px");
264							image.load(function(){
265								waiter.removeClass("loading");
266								waiter.addClass("loaded");
267								waiterPorfolio.removeClass("loading");
268								waiterPorfolio.addClass("loaded");
269							});
270						}
271					});
272					
273				}
274			}			
275			
276			function otThumbs(clicked) {
277				var opened_image = clicked.closest('.ot-slide-item').find('.gallery-image').attr("data-id");
278				var active_thumb = jQuery(".image-list ul li");
279	
280				jQuery.each(active_thumb, function() {
281					jQuery(this).removeClass("active");
282					if(jQuery(this).attr("data-nr") == opened_image) {
283						jQuery(this).addClass("active");
284					}
285
286				});
287			}
288			
289			//key navigation
290			jQuery(document).keydown(function(e){
291				var adminUrl = ot.adminUrl;
292				if (e.keyCode == 39) { 
293					otLoading(jQuery('.ot-slide-item .next'),adminUrl,false);
294					otNextImage(jQuery('.ot-slide-item .next'));
295					otThumbs(jQuery('.ot-slide-item .next'));
296				   return false;
297				}
298				if (e.keyCode == 37) { 
299					otLoading(jQuery('.ot-slide-item .prev'),adminUrl,false);
300					otPrevImage(jQuery('.ot-slide-item .prev'));
301					otThumbs(jQuery('.ot-slide-item .prev'));
302				   return false;
303				}
304			});
305			
306			// swipe navigation
307			function ot_swipe(xx) {
308
309				(function(jQuery, undefined) {
310					
311						var adminUrl = ot.adminUrl;
312						var wrap = jQuery('.waiter'),
313							slides = wrap.find('.image-big-gallery'),
314
315							width = wrap.width();
316
317						// Listen for swipe events on slides, and use a custom 'activate'
318						// or next slide, and to keep the index up-to-date. The class
319						slides
320
321						.on('swipeleft', function(e) {
322							otLoading(jQuery('.ot-slide-item .next'),adminUrl,true);
323							otNextImage(jQuery('.ot-slide-item .next'));
324							otThumbs(jQuery('.ot-slide-item .next'));
325						})
326
327						.on('swiperight', function(e) {
328							otLoading(jQuery('.ot-slide-item .prev'),adminUrl,true);
329							otPrevImage(jQuery('.ot-slide-item .prev'));
330							otThumbs(jQuery('.ot-slide-item .prev'));
331						})
332
333		
334
335						// The code below handles what happens before any swipe event is triggered.
336						// It makes the slides demo on this page work nicely, but really doesn't
337						// have much to do with demonstrating the swipe events themselves. For more
338						// on move events see:
339						//
340						// http://stephband.info/jquery.event.move
341
342						.on('movestart', function(e) {
343							// If the movestart heads off in a upwards or downwards
344							// direction, prevent it so that the browser scrolls normally.
345							if ((e.distX > e.distY && e.distX < -e.distY) ||
346								(e.distX < e.distY && e.distX > -e.distY)) {
347								e.preventDefault();
348								return;
349							}
350
351							// To allow the slide to keep step with the finger,
352							// temporarily disable transitions.
353							wrap.addClass('notransition');
354						})
355
356						.on('move', function(e) {
357							var left = xx * e.distX / width;
358
359							// Move slides with the finger
360							if (e.distX < 0) {
361								if (slides) {
362									slides.css("left", left + '%');
363									slides.css("left", (left+0)+'%');
364								}
365								else {
366									slides.css("left", left/4 + '%');
367								}
368							}
369							if (e.distX > 0) {
370								if (slides) {
371									slides.css("left", left + '%');
372									slides.css("left", (left-0)+'%');
373								}
374								else {
375									slides.css("left", left/5 + '%');
376								}
377							}
378						})
379
380						.on('moveend', function(e) {
381							wrap.removeClass('notransition');
382							
383							slides.css("left", '');
384							
385							if (slides) {
386								slides.css("left", '');
387							}
388							if (slides) {
389								slides.css("left", '');
390							}
391						});
392
393					
394				})(jQuery);	
395			
396			}

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.