PageSourceSearch

https://www.school-day.com/js/popup.js

js school-day.com collected 2026-09-29 21:58:48 UTC 7,043 bytes, 244 lines download raw bytes

1
2function close_poplight2() {
3    $('#popupContainer, #fadebox1').fadeOut(); //fade out the popup
4    return false;
5};
6
7function init_poplight2_basic() {
8    //Fade in Background
9		
10    if ($('#fadebox1').length == 0) {
11        $('body').append('<div id="fadebox1"></div>'); //Add the fade layer to bottom of the body tag.
12        $('body').append('<div id="popupContainer" class="popup_block"></div>'); //Add the popup layer to bottom of the body tag.
13        
14        $('body').on('click', '#popupContainer a.close2 , #popupContainer input.close2, #fadebox1', function () { //When clicking on the fade layer...
15        	$('#popupContainer, #fadebox1').fadeOut(); //fade out the popup
16            return false;
17        });
18    }
19    $('#popupContainer').empty();
20}
21
22function open_poplight2_basic(iwidth, popCallback) {
23	
24	if (!$('#popupContainer').is(":visible")) {
25
26		var elem2 = $('#popupContainer');
27		var popMargTop = (iwidth + 80) / 2;
28		var popMargLeft = (iwidth + 80) / 2;
29
30		$('#popupContainer').css({
31			'top': 60,
32			'height': 'auto',
33			'margin-left': -popMargLeft,
34			'width': Number(iwidth)
35		});
36
37		$('#fadebox1').css({ "opacity": +'0.6', "height": $(document).height() }).fadeIn(function () {
38			$('#popupContainer').show();
39			if (popCallback != null && typeof (popCallback) != "undefined" && popCallback != '') {
40				window[popCallback]();
41			}
42			;
43		});
44	} else {
45		var elem2 = $('#popupContainer');
46		var popMargTop = (iwidth + 80) / 2;
47		var popMargLeft = (iwidth + 80) / 2;
48
49		$('#popupContainer').css({
50			'top': 60,
51			'height': 'auto',
52			'margin-left': -popMargLeft,
53			'width': Number(iwidth)
54		});
55	}
56
57    return false;
58}
59
60$(document).ready(function () {
61	//When you click on a link with class of poplight and the href starts with a # 
62	$('a.poplight[href^="#"]').click(function () {
63		var popID = $(this).attr('rel'); //Get Popup Name
64		var popURL = $(this).attr('href'); //Get Popup href to define size
65
66		//Pull Query & Variables from href URL
67		var query = popURL.split('?');
68		var dim = query[1].split('&');
69
70		var popWidth = dim[0].split('=')[1]; //Gets the first query string value
71
72		//Fade in the Popup 
73		$('#' + popID).fadeIn().css({ 'width':Number(popWidth) });
74
75		//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
76		var popMargTop = ($('#' + popID).height() + 80) / 2;
77		var popMargLeft = ($('#' + popID).width() + 80) / 2;
78
79		//Apply Margin to Popup
80		$('#' + popID).css({
81			'top':120,
82			'height':'auto',
83			'margin-left':-popMargLeft
84		});
85
86		//Fade in Background
87		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
88		$('#fade').css({'filter':'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer
89
90		return false;
91	});
92
93	//Close Popups and Fade Layer
94	$('body').on('click', 'a.close, #fade', function () { //When clicking on the close or fade layer...
95		$('#fade , .popup_block').fadeOut(function () {
96			//$('#fade, a.close').remove();
97		}); //fade them both out
98
99		return false;
100	});
101
102	$('.close2').bind('click', function () {
103	    $('#popupContainer, #fadebox1').fadeOut(); //fade out the popup
104	    return false;
105	});
106
107    $('a.poplight2[href^="#"], input.poplight2').unbind();
108	$('a.poplight2[href^="#"], input.poplight2').click(function () {
109
110		function showPopUp(popURL, popTmpl, popTmplData, popCallback) {
111			//Pull Query & Variables from href URL
112			var query = popURL.split('?');
113			var dim = query[1].split('&');
114			
115			//Fade in Background
116			if ($('#fadebox1').length == 0) {
117				$('body').append('<div id="fadebox1"></div>'); //Add the fade layer to bottom of the body tag.
118				$('body').append('<div id="popupContainer" class="popup_block"></div>'); //Add the popup layer to bottom of the body tag.
119
120				$('body').on('click', '#popupContainer a.close2 , #popupContainer input.close2, #fadebox1', function () { //When clicking on the fade layer...
121					$('#popupContainer, #fadebox1').fadeOut(); //fade out the popup
122					return false;
123				});
124
125			}
126
127			$('#popupContainer').empty();
128
129			var myTemplate = $("#" + popTmpl).template();
130			if (popTmplData != null && typeof (popTmplData) != "undefined" && popTmplData != '') {
131				//The data has to be in this format: {"name":"John"}
132				var tmplData = jQuery.parseJSON(popTmplData);
133				$.tmpl(myTemplate, tmplData).appendTo('#popupContainer');
134			} else {
135				$.tmpl(myTemplate).appendTo('#popupContainer');
136			}
137
138			var elem2 = $('#popupContainer');
139			//elem2.fadeIn().css({ 'width': dim[0].split('=')[1] });
140			var popMargTop = (elem2.height() + 80) / 2;
141			var popMargLeft = (elem2.width() + 80) / 2;
142
143			$('#popupContainer').css({
144				'top':120,
145				'height':'auto',
146				'margin-left':-popMargLeft,
147				'width':Number(dim[0].split('=')[1])
148			});
149
150			$('#fadebox1').css({ "opacity":+'0.6', "height":$(document).height() }).fadeIn(function () {
151				$('#popupContainer').show();
152				if (popCallback != null && typeof (popCallback) != "undefined" && popCallback != '') {
153					window[popCallback]();
154				}
155				;
156			});
157
158			return false;
159		}
160
161		var popURL = $(this).attr('href'); //Get Popup href to define size
162		var popTmpl = $(this).attr('tmpl'); //Get Template Name
163		var popTmplData = $(this).attr('data'); //Get Template Name
164		var popCallback = $(this).attr('cb'); //Get callback Name
165		var popPreRun = $(this).attr('prerun'); //Get pre run function Name
166
167		if (popPreRun != null && typeof (popPreRun) != "undefined" && popPreRun != '') {
168			window[popPreRun](function () {
169				showPopUp(popURL, popTmpl, popTmplData, popCallback);
170			});
171		} else {
172			showPopUp(popURL, popTmpl, popTmplData, popCallback);
173		}
174
175
176	});
177});
178
179(function ($) {
180	$.fn.serializeObject = function () {
181
182		var self = this,
183			json = {},
184			push_counters = {},
185			patterns = {
186				"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
187				"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
188				"push": /^$/,
189				"fixed": /^\d+$/,
190				"named": /^[a-zA-Z0-9_]+$/
191			};
192
193
194		this.build = function (base, key, value) {
195			base[key] = value;
196			return base;
197		};
198
199		this.push_counter = function (key) {
200			if (push_counters[key] === undefined) {
201				push_counters[key] = 0;
202			}
203			return push_counters[key]++;
204		};
205
206		$.each($(this).serializeArray(), function () {
207
208			// skip invalid keys
209			if (!patterns.validate.test(this.name)) {
210				return;
211			}
212
213			var k,
214				keys = this.name.match(patterns.key),
215				merge = this.value,
216				reverse_key = this.name;
217
218			while ((k = keys.pop()) !== undefined) {
219
220				// adjust reverse_key
221				reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
222
223				// push
224				if (k.match(patterns.push)) {
225					merge = self.build([], self.push_counter(reverse_key), merge);
226				}
227
228					// fixed
229				else if (k.match(patterns.fixed)) {
230					merge = self.build([], k, merge);
231				}
232
233					// named
234				else if (k.match(patterns.named)) {
235					merge = self.build({}, k, merge);
236				}
237			}
238
239			json = $.extend(true, json, merge);
240		});
241
242		return json;
243	};
244})(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.