PageSourceSearch

https://movegistics.com/wp-content/themes/btheme/js/jquery.jmpopups-0.5.1.js

js movegistics.com collected 2026-09-29 14:44:01 UTC 8,877 bytes, 300 lines download raw bytes

1/**
2 * jmpopups
3 * Copyright (c) 2009 Otavio Avila (http://otavioavila.com)
4 * Licensed under GNU Lesser General Public License
5 * 
6 * @docs http://jmpopups.googlecode.com/
7 * @version 0.5.1
8 * 
9 */
10
11
12(function($) {
13	var openedPopups = [];
14	var popupLayerScreenLocker = false;
15    var focusableElement = [];
16	var setupJqueryMPopups = {
17		screenLockerBackground: "#000",
18		screenLockerOpacity: "0.5"
19	};
20
21	$.setupJMPopups = function(settings) {
22		setupJqueryMPopups = jQuery.extend(setupJqueryMPopups, settings);
23		return this;
24	}
25
26	$.openPopupLayer = function(settings) {
27		if (typeof(settings.name) != "undefined" && !checkIfItExists(settings.name)) {
28			settings = jQuery.extend({
29				width: "auto",
30				height: "auto",
31				parameters: {},
32				target: "",
33				success: function() {},
34				error: function() {},
35				beforeClose: function() {},
36				afterClose: function() {},
37				reloadSuccess: null,
38				cache: false
39			}, settings);
40			loadPopupLayerContent(settings, true);
41			return this;
42		}
43	}
44	
45	$.closePopupLayer = function(name) {
46		if (name) {
47			for (var i = 0; i < openedPopups.length; i++) {
48				if (openedPopups[i].name == name) {
49					var thisPopup = openedPopups[i];
50					
51					openedPopups.splice(i,1)
52					
53					thisPopup.beforeClose();
54					
55					$("#popupLayer_" + name).fadeOut(function(){
56						$("#popupLayer_" + name).remove();
57					
58						focusableElement.pop();
59	
60						if (focusableElement.length > 0) {
61							$(focusableElement[focusableElement.length-1]).focus();
62						}
63	
64						thisPopup.afterClose();
65						hideScreenLocker(name);
66					});
67					
68					
69   
70					break;
71				}
72			}
73		} else {
74			if (openedPopups.length > 0) {
75				$.closePopupLayer(openedPopups[openedPopups.length-1].name);
76			}
77		}
78		
79		return this;
80	}
81	
82	$.reloadPopupLayer = function(name, callback) {
83		if (name) {
84			for (var i = 0; i < openedPopups.length; i++) {
85				if (openedPopups[i].name == name) {
86					if (callback) {
87						openedPopups[i].reloadSuccess = callback;
88					}
89					
90					loadPopupLayerContent(openedPopups[i], false);
91					break;
92				}
93			}
94		} else {
95			if (openedPopups.length > 0) {
96				$.reloadPopupLayer(openedPopups[openedPopups.length-1].name);
97			}
98		}
99		
100		return this;
101	}
102
103	function setScreenLockerSize() {
104		if (popupLayerScreenLocker) {
105			$('#popupLayerScreenLocker').height($(document).height() + "px");
106			$('#popupLayerScreenLocker').width($(document.body).outerWidth(true) + "px");
107		}
108	}
109	
110	function checkIfItExists(name) {
111		if (name) {
112			for (var i = 0; i < openedPopups.length; i++) {
113				if (openedPopups[i].name == name) {
114					return true;
115				}
116			}
117		}
118		return false;
119	}
120	
121	function showScreenLocker() {
122		if ($("#popupLayerScreenLocker").length) {
123			if (openedPopups.length == 1) {
124				popupLayerScreenLocker = true;
125				setScreenLockerSize();
126				$('#popupLayerScreenLocker').fadeIn();
127			}
128   
129			/*if ($.browser.msie && $.browser.version < 7) {
130				$("select:not(.hidden-by-jmp)").addClass("hidden-by-jmp hidden-by-" + openedPopups[openedPopups.length-1].name).css("visibility","hidden");
131			}*/
132   			
133			$('#popupLayerScreenLocker').css("z-index",parseInt(openedPopups.length == 1 ? 999 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 1);
134		} else {
135			$("body").append("<div id='popupLayerScreenLocker'><!-- --></div>");
136			$("#popupLayerScreenLocker").css({
137				position: "absolute",
138				background: setupJqueryMPopups.screenLockerBackground,
139				left: "0",
140				top: "0",
141				opacity: setupJqueryMPopups.screenLockerOpacity,
142				display: "none"
143			});
144			showScreenLocker();
145
146            $("#popupLayerScreenLocker").click(function() {
147                //$.closePopupLayer();
148            });
149		}
150	}
151	
152	function hideScreenLocker(popupName) {
153		if (openedPopups.length == 0) {
154			screenlocker = false;
155			$('#popupLayerScreenLocker').fadeOut();
156		} else {
157			$('#popupLayerScreenLocker').css("z-index",parseInt($("#popupLayer_" + openedPopups[openedPopups.length - 1].name).css("z-index")) - 1);
158		}
159   
160		/*if ($.browser.msie && $.browser.version < 7) {
161			$("select.hidden-by-" + popupName).removeClass("hidden-by-jmp hidden-by-" + popupName).css("visibility","visible");
162		}*/
163	}
164	
165	function setPopupLayersPosition(popupElement, animate) {
166		if (popupElement) {
167            if (popupElement.width() < $(window).width()) {
168				var leftPosition = (document.documentElement.offsetWidth - popupElement.width()) / 2;
169			} else {
170				var leftPosition = document.documentElement.scrollLeft + 5;
171			}
172
173			if (popupElement.height() < $(window).height()) {
174				var topPosition = document.documentElement.scrollTop + ($(window).height() - popupElement.height()) / 2;
175			} else {
176				var topPosition = document.documentElement.scrollTop + 5;
177			}
178			
179			var positions = {
180				left: leftPosition + "px",
181				top: topPosition + "px"
182			};
183			
184			if (!animate) {
185				popupElement.css(positions);
186			} else {
187				popupElement.animate(positions, "slow");
188			}
189                        
190            setScreenLockerSize();
191		} else {
192			for (var i = 0; i < openedPopups.length; i++) {
193				setPopupLayersPosition($("#popupLayer_" + openedPopups[i].name), true);
194			}
195		}
196	}
197
198    function showPopupLayerContent(popupObject, newElement, data) {
199        var idElement = "popupLayer_" + popupObject.name;
200
201        if (newElement) {
202			showScreenLocker();
203			
204			$("body").append("<div id='" + idElement + "'><!-- --></div>");
205			
206			var zIndex = parseInt(openedPopups.length == 1 ? 1000 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 2;
207		}  else {
208			var zIndex = $("#" + idElement).css("z-index");
209		}
210
211        var popupElement = $("#" + idElement);
212		
213		popupElement.css({
214			visibility: "hidden",
215			width: popupObject.width == "auto" ? "" : popupObject.width + "px",
216			height: popupObject.height == "auto" ? "" : popupObject.height + "px",
217			position: "absolute",
218			"z-index": zIndex
219		});
220		
221		var linkAtTop = "<a href='#' class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;'>&nbsp;</a><input class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;' />";
222		var linkAtBottom = "<a href='#' class='jmp-link-at-bottom' style='position:absolute; left:-9999px; bottom:-1px;'>&nbsp;</a><input class='jmp-link-at-bottom' style='position:absolute; left:-9999px; top:-1px;' />";
223
224		popupElement.html(linkAtTop + data + linkAtBottom);
225		
226		setPopupLayersPosition(popupElement);
227
228        popupElement.css("display","none");
229        popupElement.css("visibility","visible");
230		
231		if (newElement) {
232        	popupElement.fadeIn();
233		} else {
234			popupElement.show();
235		}
236
237        $("#" + idElement + " .jmp-link-at-top, " +
238		  "#" + idElement + " .jmp-link-at-bottom").focus(function(){
239			$(focusableElement[focusableElement.length-1]).focus();
240		});
241		
242		var jFocusableElements = $("#" + idElement + " a:visible:not(.jmp-link-at-top, .jmp-link-at-bottom), " +
243								   "#" + idElement + " *:input:visible:not(.jmp-link-at-top, .jmp-link-at-bottom)");
244						   
245		if (jFocusableElements.length == 0) {
246			var linkInsidePopup = "<a href='#' class='jmp-link-inside-popup' style='position:absolute; left:-9999px;'>&nbsp;</a>";
247			popupElement.find(".jmp-link-at-top").after(linkInsidePopup);
248			focusableElement.push($(popupElement).find(".jmp-link-inside-popup")[0]);
249		} else {
250			jFocusableElements.each(function(){
251				if (!$(this).hasClass("jmp-link-at-top") && !$(this).hasClass("jmp-link-at-bottom")) {
252					focusableElement.push(this);
253					return false;
254				}
255			});
256		}
257		
258		$(focusableElement[focusableElement.length-1]).focus();
259
260		popupObject.success();
261		
262		if (popupObject.reloadSuccess) {
263			popupObject.reloadSuccess();
264			popupObject.reloadSuccess = null;
265		}
266    }
267	
268	function loadPopupLayerContent(popupObject, newElement) {
269		if (newElement) {
270			openedPopups.push(popupObject);
271		}
272		
273		if (popupObject.target != "") {
274            showPopupLayerContent(popupObject, newElement, $("#" + popupObject.target).html());
275        } else {
276            $.ajax({
277                url: popupObject.url,
278                data: popupObject.parameters,
279				cache: popupObject.cache,
280                dataType: "html",
281                method: "GET",
282                success: function(data) {
283                    showPopupLayerContent(popupObject, newElement, data);
284                },
285				error: popupObject.error
286            });
287		}
288	}
289	
290	$(window).resize(function(){
291		setScreenLockerSize();
292		setPopupLayersPosition();
293	});
294	
295	$(document).keydown(function(e){
296		if (e.keyCode == 27) {
297			$.closePopupLayer();
298		}
299	});
300})(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.