PageSourceSearch

https://tipto.co.uk/scripts/compile/client.php?type=js&namespace=/…/components/Auth/js/registrationAjax.js

js tipto.co.uk collected 2026-10-09 01:06:51 UTC 20,323 bytes, 613 lines download raw bytes

1var refresh = false;
2
3$(document).ready(function () {
4	// Login form handlers.	
5	$('#account-auth-loginForm-submit').bind('click', function () {
6		$('#account-auth-loginForm').submit();
7		return false;
8	});
9
10	$('#account-passwordRecovery-dialog').dialog({
11		autoOpen: false,
12		width: 300,
13		minWidth: 300,
14		height: "auto",
15		minHeight: 310,
16		resizable: true,
17		modal: true,
18		draggable: false
19	});
20
21	$('#account-auth-loginForm-forgotPassword').bind('click', function () {
22		if (refresh) {
23			$.post('/password-recovery/ajax-form/', {}, showRecoveryDialog);
24		} else {
25			showRecoveryDialog();
26		}
27		return false;
28	});
29});
30
31function showRecoveryDialog(data) {
32	refreshRecoveryDialog(data);
33	$('#account-passwordRecovery-dialog').dialog('open');
34}
35
36function refreshRecoveryDialog(data) {
37	if (data != undefined) {
38		$('#account-passwordRecovery-dialog').html(data);
39	}
40
41	// Add handlers for buttons and keys.
42	$('#account-passwordRecovery-cancel').bind('click', function () {
43		$('#account-passwordRecovery-dialog').dialog('close');
44		return false;
45	})
46	$('#account-passwordRecovery-getPassword').bind('click', sendRecoveryDialog);
47	$('#account-passwordRecovery-recoveryForm').bind('submit', sendRecoveryDialog);
48}
49
50function sendRecoveryDialog() {
51	refresh = true;
52	$.post('/password-recovery/ajax-send/', { email: $('#account-passwordRecovery-email').val(), secureimage: $('.account-passwordRecovery #captcha_code').val() }, refreshRecoveryDialog);
53	return false;
54}
55/*
56	Author: MindFreakTheMon.com
57	jQuery 1.3.* Required
58	Script was tested on IE7,8; FF3.5; Opera 10.01;
59	Chrome ans Safari understands HTML5-placeholder attribute, so there is no need in this script for them.
60*/
61
62(function($)
63{
64	if(!$) return false;
65
66	$.fn.extend({
67		storeEvents: function(b) {
68			return this.each(function() {
69				var copy = function(j) {
70					var o = {};
71	
72					for(i in j) {
73						o[i] = typeof(j[i]) == 'object' ? arguments.callee(j[i]) : j[i];
74					}
75	
76					return o;
77				};
78				
79				$.data(this, 'storedEvents', copy($(this).data('events')));
80				
81				if(b) {
82					$(this).unbind();
83				}
84			});
85		},
86		restoreEvents: function(b) {
87			return this.each(function() {
88				var events = $.data(this, 'storedEvents');
89	
90				if(events) {
91					if(!b) {
92						$(this).unbind();
93					}
94	
95					for(var type in events) {
96						for(var handler in events[type]) {
97							$.event.add(this, type, events[type][handler], events[type][handler].data);
98						}
99					}
100				}
101			});
102		},
103		copyAttr: function(e, p, v) {
104			return this.each(function() {
105				var a = {}, i, n, m;
106				
107				if(p === true) {
108					for(i = 0, v = $.makeArray(v); i < this.attributes.length; i++) {
109						n = this.attributes[i].nodeName;
110						m = this.attributes[i].nodeValue;
111	
112						if(m && $.inArray(n, v) == -1) {
113							a[n] =m;
114						}
115					}
116				} else {				
117					for(i = 0, p = $.makeArray(p); i < p.length; i++) {
118						if(typeof $(this).attr(p[i]) == 'string') {
119							a[p[i]] = $(this).attr(p[i]);
120						}
121					}
122				}
123				
124				$(this).attr(a);
125			});			
126		},
127		blurfocus: function(options) {
128			return this.each(function() {
129				if($.browser.safari) {
130					return false;
131				}
132				
133				var text = $(this).attr('placeholder');
134				options = $.extend({
135					className: 'placeholded',
136					classNameHide: 'placeholded-hide',
137					handle_send: true,
138					handle_password: true},
139				options || {});
140				
141				if($(this).is(':password') && options.handle_password) {
142					$(this).data('placeholded_type', 'password');
143				}
144				
145				var blur = function(e) {
146					if($(this).val().length == 0) {
147						if($(this).data('placeholded_type') == 'password') {
148							var input = $('<input type="text" name="' + $(this).attr('name') + '" />'), events = $(this).storeEvents(true).data('storedEvents');
149							$(this).copyAttr(input, true, ['type', 'name']).replaceWith(input);
150							input.blur().data('placeholded_type', 'password').data('storedEvents', events).restoreEvents();
151							
152							/**
153							 * Save attribute class
154							 * 
155							 * @author Roman Makarov <[email protected]>
156							 */
157							input.addClass($(this).attr('class'));
158						} else {
159							var input = $(this);
160						}
161
162						/**
163						 * Old version
164						 */
165						//input.attr('readonly', true).val(text).addClass(options.className);
166						
167						/**
168						 * New version
169						 * 
170						 * @author Roman Makarov <[email protected]>
171						 */
172						input.val(text).addClass(options.className).removeClass(options.classNameHide);
173					}
174				}, focus = function(e) {
175					if($(this).val() == text && $(this).hasClass(options.className)) {
176						if($(this).data('placeholded_type') == 'password') {
177							var input = $('<input type="password" name="' + $(this).attr('name') + '" />'), events = $(this).storeEvents(true).data('storedEvents');
178							$(this).copyAttr(input, true, ['type', 'name']).replaceWith(input);
179							input.focus().data('placeholded_type', 'password').data('storedEvents', events).restoreEvents();
180							
181							/**
182							 * Save attribute class
183							 * 
184							 * @author Roman Makarov <[email protected]>
185							 */
186							input.addClass($(this).attr('class'));
187						} else {
188							var input = $(this);
189						}
190						
191						/**
192						 * Old version
193						 */
194						//input.val('').removeAttr('readonly').removeClass(options.className);
195						
196						/**
197						 * New version for equatorlearning
198						 * 
199						 * @author Roman Makarov <[email protected]>
200						 */
201						input.val('').addClass(options.classNameHide).removeClass(options.className);
202					}
203				}, click = function() {
204					focus.call(this);
205					$(this).storeEvents(true).focus().restoreEvents();
206				}, keydown = function(e) {
207					if(e.keyCode == 9) {
208						if(!$.browser.msie) {
209							blur.call(this);
210						}
211	
212						e.stopPropagation();				
213					}
214				};
215				
216				if($(this).is(':password, :text, textarea')) {
217					$(this).val($(this).val() == text ? '' : $(this).val()).blur(blur).focus(focus).click(click).keydown(keydown).blur();
218					
219					if(options.handle_send) {
220						$(this).parents('form:eq(0)').each(function() {
221							if($(this).data('placeholder_form') != 'handled') {
222								events = $(this).data('placeholder_form', 'handled').storeEvents().data('storedEvents');
223								eval('var anonfunc = function(){ ' + ($(this).attr('onsubmit') || '') + ' };');
224								events.submit = $.extend(true, {'spec_sub': function(){ $(this).find('.' + options.className).focus(); }},  events.submit, {'anonfunc': anonfunc, 'spec_aft': function(e){ if(e.isDefaultPrevented()) $(this).find(':input').blur(); }});
225								$(this).removeAttr('onsubmit').data('storedEvents', events).restoreEvents();
226							}
227						});
228					}
229				}
230			});
231		}
232	});
233	
234	$(function() {
235		$(":input[placeholder]").each(function(){ $(this).blurfocus($(this).attr('placeholder')); });
236	});
237})(jQuery);function registrationAjaxStart(button) {
238	var url = $(button).attr('attr-data')+'?ajax=true';
239	$('.registration-wrap_popup-form-loading').show();
240	//$.ajaxSetup({async: true});  
241	$.post(url, {}, registrationAjaxStep);
242}
243
244function registrationAjaxStep(data) {
245	$('.registration-wrap_bg').removeClass('active');
246	$('.registration-wrap_popup').removeClass('active');
247	if (data != undefined) {
248		data = data.replace("/package/C2/root/js/jquery.js", "");
249		data = data.replace("/root/js/jquery.js", "-");
250		$('.registration-wrap_popup-form').html(data);
251		registrationAjaxResize();
252		if(registrationAjaxRefreshScript()){
253			$('.registration-wrap_bg').addClass('active');
254			$('.registration-wrap_popup').addClass('active');
255			$('.registration-wrap_popup-form-loading').hide();
256		}
257	}else{
258		$('.registration-wrap_bg').removeClass('active');
259		$('.registration-wrap_popup').removeClass('active');
260	}
261}
262
263function registrationAjaxResize() {
264	var winH = $(window).height();
265	var popupH = $('.registration-wrap_popup').height();
266	if(winH>popupH){
267		$('.registration-wrap_popup').css('top',$(window).scrollTop()+(winH-popupH)/2+'px'); 
268	}else{
269		$('.registration-wrap_popup').css('top',$(window).scrollTop()+'px'); 
270	}
271	
272	
273}
274
275function registrationAjaxRefreshScript() {
276	jQuery.each($("#account-registration-form").find('input'), function(){
277		$(this).bind('keypress keydown keyup', function(e){
278		   if(e.keyCode == 13) { e.preventDefault(); }
279		});
280	});
281	
282	if($('#registration_email_predefined').val()!=undefined){
283		$('#account-auth-loginForm-email').val($('#registration_email_predefined').val());
284	}
285	
286	if($('#registration_autohide_popup').val()!=undefined){
287		return false;
288	}
289	
290	$("#reg-close-popup").click(function() {
291		$('.registration-wrap_bg').removeClass('active');
292		$('.registration-wrap_popup').removeClass('active');
293	});
294	
295	$('#account-registration-back').bind('click', function () {
296		var url = $(this).attr('href');
297		$.post(url, {}, registrationAjaxStep);
298		return false;
299	});
300	
301	$.each($('.registration-wrap_popup-form .addStudentInformation table tr td.inputPlace input'), function () {
302		if($(this).attr('attr-tip')!==undefined){
303			$(this).closest('tr').find('.tip-input').html($(this).attr('attr-tip'));
304			$(this).bind('focus', function () {
305				$(this).closest('tr').find('.tip-input').show();
306			});
307			$(this).bind('focusout', function () {
308				$(this).closest('tr').find('.tip-input').hide();
309			});
310		}
311	});
312	
313	$.each($('.registration-wrap_popup-form .addStudentInformation table tr td.inputPlace select'), function () {
314		if($(this).attr('attr-tip')!==undefined){
315			$(this).closest('tr').find('.tip-input').html($(this).attr('attr-tip'));
316			$(this).bind('focus', function () {
317				$(this).closest('tr').find('.tip-input').show();
318			});
319			$(this).bind('focusout', function () {
320				$(this).closest('tr').find('.tip-input').hide();
321			});
322		}
323	});
324	
325	
326	$(".optionsAGroup").click(function(){
327		if($('.optionsAGroup').hasClass('optionsSelected')){
328			$('.optionsAGroup').removeClass('optionsSelected');
329			$('.optionsADrop').hide();
330		}else{
331			$('.optionsAGroup').addClass('optionsSelected');
332			$('.optionsADrop').show();
333		}
334	});
335	
336	$(".optionsBGroup").click(function(){
337		if($('.optionsBGroup').hasClass('optionsSelected')){
338			$('.optionsBGroup').removeClass('optionsSelected');
339			$('.optionsBDrop').hide();
340		}else{
341			$('.optionsBGroup').addClass('optionsSelected');
342			$('.optionsBDrop').show();
343		}
344	});
345	
346	
347	// Call necessary handle plugins.
348	$('input.account-profile-organistionToggle').toggleOrganisation('account-profile-noAffiliations');
349        $('input.account-profile-organistionToggleAgency').toggleAgency();
350        
351	$('#account-registration-saveChanges').bind('click', function () {
352		var errorText='';
353		var errorNumber = false;
354		for($i=0; $i<20; $i++){
355			if ($('#organisations-'+$i+'-organisation').attr('value') == 'ABTA' || 
356				$('#organisations-'+$i+'-organisation').attr('value') == 'ATOL' ||
357				$('#organisations-'+$i+'-organisation').attr('value') == 'IATA' ||
358				$('#organisations-'+$i+'-organisation').attr('value') == 'TTA' ||
359				$('#organisations-'+$i+'-organisation').attr('value') == 'ARC' || 
360				$('#organisations-'+$i+'-organisation').attr('value') == 'CLIA' || 
361				$('#organisations-'+$i+'-organisation').attr('value') == 'TRUE' ||
362				$('#organisations-'+$i+'-organisation').attr('value') == 'Other'){
363				
364				if ($('#organisations-'+$i+'-number').attr('disabled') == false){
365					if ($('#organisations-'+$i+'-number').attr('value') == ''){
366						errorNumber = true;
367						errorText = 'Please ' + $('#organisations-'+$i+'-number').attr('placeholder-data');
368						$('#organisations-'+$i+'-number').css({'border-color': 'red'});
369					}else{
370						$('#organisations-'+$i+'-number').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
371					}
372				}else{
373					$('#organisations-'+$i+'-number').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
374				}
375			}
376		}
377		if ($('input#organisationsGroupOtherHomeworkers').attr('disabled')== false){
378		    if ($('input#organisationsGroupOtherHomeworkers').attr('value')== ''){
379		        errorNumber = true;
380				errorText = 'Please enter details';
381		        $('input#organisationsGroupOtherHomeworkers').css({'border-color': 'red'});
382		    }else{
383		        $('input#organisationsGroupOtherHomeworkers').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
384		    }
385		}else{
386		    $('input#organisationsGroupOtherHomeworkers').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
387		}
388		if ($('input#organisationsGroupOtherAgency').attr('disabled')== false){
389		    if ($('input#organisationsGroupOtherAgency').attr('value')== ''){
390		        errorNumber = true;
391				errorText = 'Please enter details';
392		        $('input#organisationsGroupOtherAgency').css({'border-color': 'red'});
393		    }else{
394		        $('input#organisationsGroupOtherAgency').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
395		    }
396		}else{
397		    $('input#organisationsGroupOtherAgency').css({'border-color': '#ABADB3 #DBDFE6 #DBDFE6'});
398		}
399		
400		if($('.optionsA').hasClass('optionsAUS')){
401			var errorNumberNew = true;	
402			$('.optionsAUS .account-profile-organistionToggleAgency').each(function(){
403				if($(this).attr('checked')==true){
404					errorNumberNew = false;
405				}
406			});
407			if(errorNumberNew == true){
408				errorNumber = true;	
409				errorText = 'Please make your selection';
410			}
411		}
412		
413		if($('.optionsB').hasClass('optionsBUS')){
414			var errorNumberNew = true;	
415			$('.optionsBUS .account-profile-organistionToggleAgency').each(function(){
416				if($(this).attr('checked')==true){
417					errorNumberNew = false;
418				}
419			});
420			if(errorNumberNew == true){
421				errorNumber = true;	
422				errorText = 'Please make your selection';
423			}
424		}
425		
426		if (errorNumber == true){
427			alert(errorText, 'Error');
428		}else{
429			var errorNumber = true;
430			if($('#organisations-0-number').attr('disabled') == undefined){
431				var organisationPageIs = false;
432			}else{
433				var organisationPageIs = true;
434			}
435			for($i=0; $i<20; $i++){
436				if ($('#organisations-'+$i+'-number').attr('disabled') == false){
437					errorNumber = false;
438				}
439			}
440			if (organisationPageIs && errorNumber){
441				if($('#account-profile-noAffiliations').attr('checked')){
442					//$('#account-registration-form').submit();
443					$('.registration-wrap_popup-form-loading').show();
444					 $.post( $('#account-registration-form').attr("action"), $('#account-registration-form').serialize(),registrationAjaxStep);
445				}else{					
446					alert('Please select at least one organisation option before proceeding', 'Error');
447				}
448			}else{
449				//$('#account-registration-form').submit();
450				$('.registration-wrap_popup-form-loading').show();
451				$.post( $('#account-registration-form').attr("action"), $('#account-registration-form').serialize(),registrationAjaxStep);
452			}
453		}
454		return false;
455	});
456	
457	return true;
458}
459
460/**
461 * JQuery plugin for remaking checkboxes to radio boxes.
462 * 
463 * @author Anton Vasilyev <[email protected]>
464 */
465(function ($) {
466	/**
467	 * Main plugin method.
468	 * 	
469	 * @return {void}
470	 * @author Anton Vasilyev <[email protected]>
471	 */
472	$.fn.radioCheckbox = function() {
473		var checkboxes = this;		 
474		 
475		 // Bind handlers for every found checkbox.
476		 $.each(this, function () {
477		 	 $(this).bind('click', function () {
478		 	 	checkboxes.attr('checked', 0);
479				$(this).attr('checked', 1);
480			 });
481		 });
482	}
483})(jQuery);
484
485(function($) {
486$.fn.toggleAgency = function() {
487// Bind handlers for every found radio.
488     $.each(this, function () {
489         $(this).bind('click', function () {
490             if($(this).val() == 1000 ){
491                 $('input#organisationsGroupOtherHomeworkers').attr('disabled', true);
492                 $('input#organisationsGroupOtherAgency').attr('disabled', false);
493             }else if($(this).val() == 2000){
494                 $('input#organisationsGroupOtherHomeworkers').attr('disabled', false);
495                 $('input#organisationsGroupOtherAgency').attr('disabled', true);
496			}else if($(this).val() == 600 ){
497				if($(this).attr('checked')){
498                  $('input#organisationsGroupOtherAgency').attr('disabled', false);
499				}else{
500				  $('input#organisationsGroupOtherAgency').attr('disabled', true);
501				}
502            }else if($(this).val() == 700){
503				if($(this).attr('checked')){
504                  $('input#organisationsGroupOtherHomeworkers').attr('disabled', false);
505				  }else{
506				  $('input#organisationsGroupOtherHomeworkers').attr('disabled', true);
507				}
508             }else{
509				
510				if($(this).val()>=500){
511                  //$('input#organisationsGroupOtherHomeworkers').attr('disabled', true);
512				  $('.noneOptB').attr('checked', false);
513                }else if($(this).val()>=400){
514					//$('input#organisationsGroupOtherAgency').attr('disabled', true);
515					$('.noneOptA').attr('checked', false);
516                }else{
517					if($(this).hasClass('noneOptA')){
518						$('input#organisationsGroupOtherAgency').attr('disabled', true);
519						$('.optionA input.account-profile-organistionToggleAgency').attr('checked', false);
520						$(this).attr('checked', true);
521					}else if($(this).hasClass('noneOptB')){
522						$('input#organisationsGroupOtherHomeworkers').attr('disabled', true);
523						$('.optionB input.account-profile-organistionToggleAgency').attr('checked', false);
524						$(this).attr('checked', true);
525					}else{
526						$('input#organisationsGroupOtherAgency').attr('disabled', true);
527						$('input#organisationsGroupOtherHomeworkers').attr('disabled', true);
528					}
529                }
530             }
531        });
532    });
533}
534})(jQuery);
535/**
536 * JQuery plugin for toggle organisation's inputs.
537 * 
538 * @author Anton Vasilyev <[email protected]>
539 */
540(function($) {
541	/**
542	 * Main plugin method.
543	 * 
544	 * @param {string} noAffilations		Identifier of checkbox.			
545	 * @return {void}
546	 * @author Anton Vasilyev <[email protected]>
547	 */
548	$.fn.toggleOrganisation = function(noAffilations) {
549		 var boxes = this;		 
550		 
551		 // Bind handlers for every found checkbox.
552		 $.each(this, function () {
553			 $(this).bind('click', function () {
554				 var disabled = true;
555				 if ($(this).attr('checked')) {
556					 disabled = false;
557					 $('input', $(this).parent().next()).attr('placeholder',$('input', $(this).parent().next()).attr('placeholder-data'));
558				 }else{
559					 $('input', $(this).parent().next()).attr('placeholder','');
560				 }
561					 
562				 $('input', $(this).parent().prev()).attr('disabled', disabled);
563				 $('input', $(this).parent().next()).attr('disabled', disabled);
564				 
565				 $('#' + noAffilations).attr('checked', _noAffilations());
566				 //$('input', $(this).parent().prev()).val());
567			 });			 
568			 if ($('input', $(this).parent().prev()).val() == 'CLIA'||$('input', $(this).parent().prev()).val() == 'BTA (GTMC)'||$('input', $(this).parent().prev()).val() == 'AITO'){
569			 $('input', $(this).parent().next()).val('yes');
570			 $('input', $(this).parent().next()).css('display','none');
571			 }
572		 })
573		 
574		// Special handler for checkbox labeled no affilations.
575		$('#' + noAffilations).bind('click', function () {
576			$.each(boxes, function () {
577				$(this).attr('checked', false); 
578				$('input', $(this).parent().prev()).attr('disabled', true);
579				$('input', $(this).parent().next()).attr('disabled', true);
580				$('input', $(this).parent().next()).attr('placeholder','');
581			});
582			
583			if (!$(this).attr('checked')) {
584				return false;
585			}
586		});
587		
588		/**
589		 * Checks no affilations.
590		 * 
591		 * @return {bool}
592		 * @author Anton Vasilyev <[email protected]>
593		 */
594		function _noAffilations()
595		{
596			var noAffilations = true;
597			for (var i = 0; i < boxes.length; i++) {
598				noAffilations &= !$(boxes[i]).attr('checked');
599			}
600			return noAffilations;
601		}
602		
603		// Set default value for no affilations checkbox 
604		$('#' + noAffilations).attr('checked', _noAffilations());
605	} 
606})(jQuery);
607
608$(document).ready(function(){
609	$('.registration-wrap_popup-content_close').click(function() {
610		$('.registration-wrap_bg').removeClass('active');
611		$('.registration-wrap_popup').removeClass('active');
612	});
613});

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.