PageSourceSearch

https://www.yorknational.com/modules/register_popup/js/register_popup.js

js yorknational.com collected 2026-09-27 10:05:06 UTC 17,704 bytes, 497 lines download raw bytes

1/**
2 * This scripts popup a registration form.
3 */
4var global_target_el = '';
5var is_superbox_loaded_register = false;
6var closeButtonisset = false;
7var search_criteria=1;
8jQuery(document).ready(function() {
9	
10	$(document).keyup(function(e) {
11	  if (e.keyCode === 27) {
12	  	$("html").removeClass("noscroll");
13	  }
14	});
15	
16	var uid = jQuery('.save-search-container a').attr('uid');
17	if(uid==0)
18	{
19		jQuery(function(){
20		    init_superbox_register();
21		  });
22	}
23	
24	//Prevents all scrolling on body when superbox is open
25	//need at least jQuery 1.7 to bind .on(), hence the version-checking
26	try {
27	    var $wholeArea = jQuery(window).add('#superbox-wrapper');
28        $wholeArea.on('touchmove touchstart mousewheel scroll DOMMouseScroll', function(e) {
29             if ( jQuery('html').hasClass('noscroll') && e.target == e.currentTarget ) {
30                //only body scroll gets halted
31                e.preventDefault();
32                //console.log('scrolling blocked');
33                return false;
34             }
35        });
36        //Make body scrollable after superbox closes
37        jQuery('body').on('click touch', '#superbox-overlay, #superbox-wrapper', function() {
38            bodyNoScrollDisable();
39        });
40	} catch(e) {
41	    console.warn('Need at least jQuery 1.7 to bind event listeners');
42	}
43	
44	var is_sourceId_porperty = 0;
45	
46	
47	
48	
49	$("#message_windowpopup").click(function(event) {
50		if ($("#message_windowpopup").children(".windowpopup").length) {
51			$("#message_windowpopup").hide();
52		}
53	});
54
55});
56
57// This function is used for Featured Listing Ajax loader porperty.
58/*function featureListingLoader_popup(listing_obj) {
59	jQuery(listing_obj).attr('rel', 'superbox[iframe][' + 620 + 'x' + 400 + ']');
60	
61	is_sourceId_porperty = 1;
62	var $target = jQuery(event.target);
63    var destination = '';
64    if ($target.is("img") || $target.is("span")) {
65      var $parent = $target.parent();
66      destination = $parent[0];
67	  global_target_el = $parent[0];
68      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
69      var propertyURLPosition = destination.href.indexOf('destination=');
70      if (-1 != propertyURLPosition) {
71        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
72      }
73	  var op = '';
74      if ($(global_target_el).attr("data-op")) {
75	    op = $(global_target_el).attr("data-op");
76	  }
77      var page = window.location;
78      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?op="+op+"&destination=" + destination+'&source_id=29';
79      $parent[0].href = form_url;
80      
81    }
82    else if ($target.is("a")) {
83      destination = $target[0].href;
84      global_target_el = $target[0];
85	  var op = '';
86      if ($(global_target_el).attr("data-op")) {
87	    op = $(global_target_el).attr("data-op");
88	  }
89      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
90      var propertyURLPosition = destination.indexOf('destination=');
91      if (-1 != propertyURLPosition) {
92        destination = destination.substr(propertyURLPosition + 'destination='.length);
93      }
94
95      var page = window.location;
96      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?op="+op+"&destination=" + destination+'&source_id=29';
97      $target[0].href = form_url;
98    }
99    start_superbox_controllers();
100    jQuery.superbox();
101    return false;
102}*/
103
104function featureListingLoader_popup(listing_obj) {
105						var event = window.event || arguments.callee.caller.arguments[0];
106						event.preventDefault();
107	jQuery(listing_obj).attr("rel", "superbox[iframe][620x400]");
108	is_sourceId_porperty = 1;
109	var $target = jQuery(event.target);
110    var destination = "";
111    if ($target.is("img")) {
112      var $parent = $target.parent();
113      destination = $parent[0];
114	  global_target_el = $parent[0];
115	  var op = $(global_target_el).attr("data-op");
116      // Prevent multiple calls to this function from stacking the registration URL again and again
117      var propertyURLPosition = destination.href.indexOf("destination=");
118      if (-1 != propertyURLPosition) {
119        destination.href = destination.href.substr(propertyURLPosition + "destination=".length);
120      }
121
122      var page = window.location;
123      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?op="+op+"&destination=" + destination+"&source_id=29";
124      $parent[0].href = form_url;
125    }
126    else if ($target.is("a")) {
127      event.stopImmediatePropagation();
128      destination = $target[0].href;
129      global_target_el = $target[0];
130	  var op = $(global_target_el).attr("data-op");
131      // Prevent multiple calls to this function from stacking the registration URL again and again
132      var propertyURLPosition = destination.indexOf("destination=");
133      if (-1 != propertyURLPosition) {
134        destination = destination.substr(propertyURLPosition + "destination=".length);
135      }
136
137      var page = window.location;
138      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?op="+op+"&destination=" + destination+"&source_id=29";
139      $target[0].href = form_url;
140    }
141    start_superbox_controllers();
142	
143 }
144
145var controller_started = 0;
146function start_superbox_controllers() {
147	//if (controller_started) return;
148	controller_started = 1;
149    //Central function for all custom Superbox overrides
150    if ( $('#superbox-wrapper').css('display') == 'none' ) {
151        //recurse until superbox is displayed
152        window.setTimeout(start_superbox_controllers, 500);
153        return;
154    }
155    bodyNoScrollEnable();
156    setUpCloseButton();
157}
158
159function setUpCloseButton() {
160    if (!closeButtonisset) {
161          jQuery('#superbox').on('click touch', '.close a', function() {
162              bodyNoScrollDisable();
163          });
164          closeButtonisset = true;
165    }
166}
167
168//These Enabled/Disable functions are used to
169//Prevent body scrolling on mobile
170var scroll_enabled = 0;
171var last_scroll_val = 0;
172function bodyNoScrollEnable() {
173    var scroll = $(document).scrollTop();
174    if (scroll > 0) {
175    	last_scroll_val = scroll;
176    }
177    jQuery('html').addClass('noscroll');
178    jQuery('#superbox-wrapper').css('top', last_scroll_val + 'px');
179    scroll_enabled = 1;
180    setTimeout(function(){
181    	var scroll = $(document).scrollTop();
182    	jQuery('html').addClass('noscroll');
183    }, 400);
184    //console.log('no scroll ENABLED');
185}
186function bodyNoScrollDisable() {
187	controller_started = 0;
188    jQuery('html').removeClass('noscroll');
189    jQuery('#superbox-wrapper').css('top', 0);
190    try {
191    	if (global_target_el != undefined) {
192        	global_target_el.href = global_target_el.href.replace('/register?', '/register_page?');
193        }
194    } catch (e) {
195        console.error(e);
196    }
197    
198    //console.log('no scroll DISABLED');
199    last_scroll_val = 0;
200}
201
202/**
203 * Get registration form Popup.
204 */
205function get_register_form_popup(event) {
206  if ( true == is_superbox_loaded_register) {  
207    // Save the destination and load the form
208    var $target = jQuery(event.target);
209    var destination = '';
210    if ($target.is("img")) {
211      var $parent = $target.parent();
212      destination = $parent[0];
213
214      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
215      var propertyURLPosition = destination.href.indexOf('destination=');
216      if (-1 != propertyURLPosition) {
217        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
218      }
219
220      var page = window.location;
221      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref=save_search&destination=" + destination;
222      $parent[0].href = form_url;
223    }
224    else if ($target.is("a")) {
225      destination = $target[0].href;
226      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
227      var propertyURLPosition = destination.indexOf('destination=');
228      if (-1 != propertyURLPosition) {
229        destination = destination.substr(propertyURLPosition + 'destination='.length);
230      }
231
232      var page = window.location;
233      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref=save_search&destination=" + destination+'&search_criteria='+search_criteria;
234      $target[0].href = form_url;
235    }
236    start_superbox_controllers();
237    
238  }
239}
240
241
242/**
243 * Get registration form Popup.
244 */
245function get_register_form_popup2(event, isSaveSearch) {
246    is_sourceId_porperty = 1;
247    if (event == undefined) {
248    	var event = window.event || arguments.callee.caller.arguments[0];
249    }
250    
251    event.preventDefault();
252	var $target = jQuery(event.target);
253    var destination = '';
254    var opref_save_search = '';
255  	if(isSaveSearch == 'save_search') {
256  		//console.log(parent.window.location);
257  		if (parent.window.location.pathname == '/propertySearch') {
258  			var search_criteria = get_search_criteria();
259  			$("#edit-visitUrl").val(search_criteria);
260  		}
261  		opref_save_search = isSaveSearch;
262  	}
263    if ($target.is("img") || $target.is("span")) {
264      var $parent = $target.parent();
265      var un = 0;
266      destination = $parent[0];
267      if (destination.href == undefined) {
268      	un = 1;
269      	destination = $parent[0].parentNode;
270      }
271	  global_target_el = destination;
272	  $(global_target_el).attr('rel', 'superbox[iframe][' + 620 + 'x' + 400 + ']');
273	  jQuery.superbox();
274      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
275      var propertyURLPosition = destination.href.indexOf('destination=');
276      if (-1 != propertyURLPosition) {
277        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
278      }
279	  var op = '';
280      if ($(global_target_el).attr("data-op")) {
281	    op = $(global_target_el).attr("data-op");
282	  }
283      var page = window.location;
284
285      var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref="+opref_save_search+"&op="+op+"&destination=" + destination+'&source_id=29';
286      if (!un) {
287      	$parent[0].href = form_url;
288      }
289      else {
290      	$parent[0].parentNode.href = form_url;
291      }
292
293    }
294    else if ($target.is("a")) {
295      destination = $target[0].href;
296      global_target_el = $target[0];
297      $(global_target_el).attr('rel', 'superbox[iframe][' + 620 + 'x' + 400 + ']');
298      jQuery.superbox();
299      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
300      var propertyURLPosition = destination.indexOf('destination=');
301      if (-1 != propertyURLPosition) {
302        destination = destination.substr(propertyURLPosition + 'destination='.length);
303      }
304	  var op = '';
305      if ($(global_target_el).attr("data-op")) {
306	    op = $(global_target_el).attr("data-op");
307	  }
308	  
309	  if ($(global_target_el).attr('class') == 'save-search-gmap-widget') {
310	  	search_criteria = get_search_criteria_mapWidget();
311	  }
312
313      var page = window.location;
314      
315      if (isSaveSearch == 'vow_registration_custom') {
316      	var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref=vow_registration_custom&op="+op+"&destination=" + destination;
317      }
318      else {
319        var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref="+opref_save_search+"&op="+op+"&source_id=29&destination=" + destination+'&search_criteria='+search_criteria;
320      }
321      
322      // If Saved Search button clicked.
323      if ($(global_target_el).attr('class') == 'save-search-gmap-widget') {
324      	var map_widget_addr = $("#gmap-location-widget").val();
325        form_url = form_url+'&mparams='+get_search_criteria_mapWidget()+'gmapseave_search=1&map_widget_addr='+map_widget_addr; 
326      }
327      
328      $target[0].href = form_url;
329    }
330    jQuery.superbox();
331    start_superbox_controllers();
332    if(isSaveSearch != 'vow_registration' && isSaveSearch != 'old_themes' && !scroll_enabled) {
333      bodyNoScrollEnable();
334      setUpCloseButton();
335    }
336    return false;
337  }
338
339/**
340 * Initialize superbox
341 * @param search_cri is the parameter use to set global variable search_criteria
342 */
343function init_superbox_register(search_cri) {
344	search_criteria=search_cri;
345  if (false == is_superbox_loaded_register) { 
346	
347    var elements = superbox_elements_register();
348    
349    for (var i in elements) {
350      var element = elements[i]; 
351      jQuery(element.selector).attr('rel', 'superbox[iframe][' + element.width + 'x' + element.height + ']');
352    }
353    jQuery.superbox();
354    is_superbox_loaded_register = true;
355  }
356}
357
358/**
359 * Gets an array of elements that should be tagged with the superbox
360 * Also tries to call the superbox_elements_by_theme() function to allow each theme to modify / add to the array
361 * The returned array is structured as follows:
362 * 
363 * array[0] = {selector: element_selector, width: width_of_superbox, height: height_of_superbox}
364 * 
365 */
366function superbox_elements_register() {
367  var elements = new Array(); // Holds the elements
368  var default_width = 620;  // Default width of the superbox window
369  var default_height = 400; // Default height of the superbox window
370  
371elements.push({'selector': '.save-search-container a', 'width': default_width, 'height': default_height});
372//elements.push({'selector': '.cls_hidden a', 'width': default_width, 'height': default_height});
373
374  return elements;  
375}
376
377function update_target() {
378	 // Save the destination and load the form
379    var $target = jQuery(event.target);
380    var destination = '';
381    if ($target.is("img")) {
382      var $parent = $target.parent();
383      destination = $parent[0];
384      global_target_el = $parent[0];
385	  if ($(global_target_el).attr('data-op') != undefined) {
386	  	return;
387	  }
388      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
389      var propertyURLPosition = destination.href.indexOf('destination=');
390      if (-1 != propertyURLPosition) {
391        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
392      }
393
394      var page = window.location;
395      var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
396      $parent[0].href = form_url;
397
398    }
399    else if ($target.is("a")) {
400      destination = $target[0].href;
401      global_target_el = $target[0];
402	  if ($(global_target_el).attr('data-op') != undefined) {
403	  	return;
404	  }
405      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
406      var propertyURLPosition = destination.indexOf('destination=');
407      if (-1 != propertyURLPosition) {
408        destination = destination.substr(propertyURLPosition + 'destination='.length);
409      }
410
411      var page = window.location;
412      var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
413      $target[0].href = form_url;
414    }
415}
416
417
418function check_for_existing_user2(event, obj) {
419	is_sourceId_porperty = 1;
420    if (event == undefined) {
421    	var event = window.event || arguments.callee.caller.arguments[0];
422    }
423    
424    event.preventDefault();
425	var $target = jQuery(event.target);
426    var destination = '';
427    var opref_save_search = '';
428
429    if ($target.is("img") || $target.is("span")) {
430      var $parent = $target.parent();
431      var un = 0;
432      destination = $parent[0];
433      if (destination.href == undefined) {
434      	un = 1;
435      	destination = $parent[0].parentNode;
436      }
437	  global_target_el = destination;
438	  $(global_target_el).attr('rel', 'superbox[iframe][' + 620 + 'x' + 400 + ']');
439	  jQuery.superbox();
440      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
441      var propertyURLPosition = destination.href.indexOf('destination=');
442      if (-1 != propertyURLPosition) {
443        destination.href = destination.href.substr(propertyURLPosition + 'destination='.length);
444      }
445	  var op = '';
446      if ($(global_target_el).attr("data-op")) {
447	    op = $(global_target_el).attr("data-op");
448	  }
449      var page = window.location;
450	  var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
451      //var form_url = page.protocol + "//" + page.host + "/protected/login" + "?opref="+opref_save_search+"&op="+op+"&destination=" + destination+'&source_id=29';
452      if (!un) {
453      	$parent[0].href = form_url;
454      }
455      else {
456      	$parent[0].parentNode.href = form_url;
457      }
458		jQuery.superbox();
459    	start_superbox_controllers();
460    }
461    else if ($target.is("a")) {
462      destination = $target[0].href;
463      global_target_el = $target[0];
464      $(global_target_el).attr('rel', 'superbox[iframe][' + 620 + 'x' + 400 + ']');
465      jQuery.superbox();
466      // Prevent multiple calls to this function from 'stacking' the registration URL again and again
467      var propertyURLPosition = destination.indexOf('destination=');
468      if (-1 != propertyURLPosition) {
469        destination = destination.substr(propertyURLPosition + 'destination='.length);
470      }
471	  var op = '';
472      if ($(global_target_el).attr("data-op")) {
473	    op = $(global_target_el).attr("data-op");
474	  }
475      var page = window.location;
476      var form_url = page.protocol + "//" + page.host + "/protectedpropertydetails/register" + "?destination=" + destination;
477      $target[0].href = form_url;
478      jQuery.superbox();
479      start_superbox_controllers();
480    }
481
482    if(obj != 'old_themes') {
483      bodyNoScrollEnable();
484      setUpCloseButton();
485    }
486}
487
488function inIframe () {
489    try {
490        return window.self !== window.top;
491    } catch (e) {
492        return true;
493    }
494}
495
496
497

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.