PageSourceSearch

https://journal.fledu.uz/wp-content/themes/fraction-theme/js/ot_gallery.js?ver=1.0

js fledu.uz collected 2026-09-24 19:52:06 UTC 10,533 bytes, 344 lines download raw bytes

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

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.