PageSourceSearch

https://fittvita.hu/!common_packages/jquery/plugins/tools/overlay/overlay.js?mod_time=1789019842

js fittvita.hu collected 2026-10-06 17:35:58 UTC 7,257 bytes, 318 lines download raw bytes

1/**
2 * @license 
3 * jQuery Tools @VERSION Overlay - Overlay base. Extend it.
4 * 
5 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6 * 
7 * http://flowplayer.org/tools/overlay/
8 *
9 * Since: March 2008
10 * Date: @DATE 
11 */
12(function($) { 
13
14	// static constructs
15	$.tools = $.tools || {version: '@VERSION'};
16	
17	$.tools.overlay = {
18		
19		addEffect: function(name, loadFn, closeFn) {
20			effects[name] = [loadFn, closeFn];	
21		},
22	
23		conf: {  
24			close: null,	
25			closeOnClick: true,
26			closeOnEsc: true,			
27			closeSpeed: 'fast',
28			effect: 'default',
29			
30			// since 1.2. fixed positioning not supported by IE6
31			fixed: !$.browser.msie || $.browser.version > 6, 
32			
33			left: 'center',		
34			load: false, // 1.2
35			mask: null,  
36			oneInstance: true,
37			speed: 'normal',
38			target: null, // target element to be overlayed. by default taken from [rel]
39			top: '10%'
40		}
41	};
42
43	
44	var instances = [], effects = {};
45		
46	// the default effect. nice and easy!
47	$.tools.overlay.addEffect('default', 
48		
49		/* 
50			onLoad/onClose functions must be called otherwise none of the 
51			user supplied callback methods won't be called
52		*/
53		function(pos, onLoad) {
54			
55			var conf = this.getConf(),
56				 w = $(window);				 
57				
58			if (!conf.fixed)  {
59				pos.top += w.scrollTop();
60				pos.left += w.scrollLeft();
61			} 
62				
63			pos.position = conf.fixed ? 'fixed' : 'absolute';
64
65			let this_overlay = this.getOverlay();
66            let display_value = 'block';
67
68            if ( parseInt(unas_base_design_code) >= 2500 ) {
69                display_value = 'flex';
70            }
71            this_overlay.css(pos).css("display",display_value).hide().fadeIn(conf.speed, onLoad);
72			
73		}, function(onClose) {
74			this.getOverlay().fadeOut(this.getConf().closeSpeed, onClose); 			
75		}		
76	);		
77
78	
79	function Overlay(trigger, conf) {		
80		
81		// private variables
82		var self = this,
83			 fire = trigger.add(self),
84			 w = $(window), 
85			 closers,            
86			 overlay,
87			 opened,
88			 maskConf = $.tools.expose && (conf.mask || conf.expose),
89			 uid = Math.random().toString().slice(10);		
90		
91			 
92		// mask configuration
93		if (maskConf) {			
94			if (typeof maskConf == 'string') { maskConf = {color: maskConf}; }
95			maskConf.closeOnClick = maskConf.closeOnEsc = false;
96		}			 
97		 
98		// get overlay and trigger
99		var jq = conf.target || trigger.attr("rel");
100		overlay = jq ? $(jq) : null || trigger;	
101		
102		// overlay not found. cannot continue
103		if (!overlay.length) { throw "Could not find Overlay: " + jq; }
104		
105		// trigger's click event
106		if (trigger && trigger.index(overlay) == -1) {
107			trigger.click(function(e) {				
108				self.load(e);
109				return e.preventDefault();
110			});
111		}   			
112		
113		// API methods  
114		$.extend(self, {
115
116			load: function(e) {
117				
118				// can be opened only once
119				if (self.isOpened()) { return self; }
120				
121				// find the effect
122		 		var eff = effects[conf.effect];
123		 		if (!eff) { throw "Overlay: cannot find effect : \"" + conf.effect + "\""; }
124				
125				// close other instances?
126				if (conf.oneInstance) {
127					$.each(instances, function() {
128						this.close(e);
129					});
130				}
131				
132				// onBeforeLoad
133				e = e || $.Event();
134				e.type = "onBeforeLoad";
135				fire.trigger(e);				
136				if (e.isDefaultPrevented()) { return self; }				
137
138				// opened
139				opened = true;
140
141				// possible mask effect
142				if (maskConf) {
143					//UNAS start - ha már felugrott egy maskos ablak, akkor eltötte a maskot be kell zárni, különben összekad
144					if ($.mask.isLoaded()) {
145						$.mask.close();
146						setTimeout(function(){ $(overlay).expose(maskConf);  }, 150);
147					} else {
148						$(overlay).expose(maskConf);
149					}
150					//UNAS end
151				}
152				
153				// position & dimensions 
154				var top = conf.top,					
155					 left = conf.left,
156					 oWidth = overlay.outerWidth(true),
157					 oHeight = overlay.outerHeight(true);
158
159				if (typeof top == 'string')  {
160					top = top == 'center' ? Math.max((w.height() - oHeight) / 2, 0) : 
161						parseInt(top, 10) / 100 * w.height();			
162				}				
163				
164				if (left == 'center') { left = Math.max((w.width() - oWidth) / 2, 0); }
165
166				
167		 		// load effect  		 		
168				eff[0].call(self, {top: top, left: left}, function() {					
169					if (opened) {
170						e.type = "onLoad";
171						fire.trigger(e);
172					}
173				});
174
175				// mask.click closes overlay
176				if (maskConf && conf.closeOnClick) {
177					$.mask.getMask().one("click", self.close); 
178				}
179				
180				// when window is clicked outside overlay, we close
181				if (conf.closeOnClick) {
182					$(document).on("click." + uid, function(e) { 
183						if (!$(e.target).parents(overlay).length) { 
184							self.close(e); 
185						}
186					});						
187				}						
188			
189				// keyboard::escape
190				if (conf.closeOnEsc) { 
191
192					// one callback is enough if multiple instances are loaded simultaneously
193					$(document).on("keydown." + uid, function(e) {
194						if (e.keyCode == 27) { 
195							self.close(e);	 
196						}
197					});			
198				}
199
200				
201				return self; 
202			}, 
203			
204			close: function(e) {
205
206				if (!self.isOpened()) { return self; }
207				
208				e = e || $.Event();
209				e.type = "onBeforeClose";
210				fire.trigger(e);				
211				if (e.isDefaultPrevented()) { return; }				
212				
213				opened = false;
214				
215				// close effect
216				effects[conf.effect][1].call(self, function() {
217					e.type = "onClose";
218					fire.trigger(e); 
219				});
220				
221				// unbind the keyboard / clicking actions
222				$(document).off("click." + uid + " keydown." + uid);		  
223				
224				if (maskConf) {
225					$.mask.close();		
226				}
227				 
228				return self;
229			}, 
230			
231			getOverlay: function() {
232				return overlay;	
233			},
234			
235			getTrigger: function() {
236				return trigger;	
237			},
238			
239			getClosers: function() {
240				return closers;	
241			},			
242
243			isOpened: function()  {
244				return opened;
245			},
246			
247			// manipulate start, finish and speeds
248			getConf: function() {
249				return conf;	
250			}			
251			
252		});
253		
254		// callbacks	
255		$.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","), function(i, name) {
256				
257			// configuration
258			if ($.isFunction(conf[name])) { 
259				$(self).on(name, conf[name]); 
260			}
261
262			// API
263			self[name] = function(fn) {
264				if (fn) { $(self).on(name, fn); }
265				return self;
266			};
267		});
268		
269		// close button
270		closers = overlay.find(conf.close || ".close");		
271		
272		if (!closers.length && !conf.close) {
273            closers = $(`<a class="close" role="button" rel="nofollow" href="#" aria-label="${UNAS.text.button_overlay_close}"></a>`);
274            overlay.prepend(closers);
275		}
276		
277		closers.click(function(e) {
278			$.mask.close();
279			self.close(e);
280			e.preventDefault();
281		});
282
283        closers.keydown(function(e) {
284            if (e.key === ' ' || e.which === 32) {
285                e.preventDefault();
286                $(this).trigger('click');
287            }
288        });
289		
290		// autoload
291		if (conf.load) { self.load(); }
292		
293	}
294	
295	// jQuery plugin initialization
296	$.fn.overlay = function(conf) {   
297		
298		// already constructed --> return API
299		var el = this.data("overlay");
300		if (el) { return el; }	  		 
301		
302		if ($.isFunction(conf)) {
303			conf = {onBeforeLoad: conf};	
304		}
305
306		conf = $.extend(true, {}, $.tools.overlay.conf, conf);
307		
308		this.each(function() {		
309			el = new Overlay($(this), conf);
310			instances.push(el);
311			$(this).data("overlay", el);	
312		});
313		
314		return conf.api ? el: this;		
315	}; 
316	
317})(jQuery);
318

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.