%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/templates/p4_new/components/p4/p.user.profile/profile/
Upload File :
Create Path :
Current File : //home/bitrix/www/bitrix/templates/p4_new/components/p4/p.user.profile/profile/script.js

BX.ready(function(){
	var listCountries = $.masksSort($.masksLoad("/phone-codes.json"), ['#'], /[0-9]|#/, "mask");
	var maskOpts = {
		inputmask: {
			definitions: {
				'#': {
					validator: "[0-9]",
					cardinality: 1
				}
			},
			showMaskOnHover: false,
			autoUnmask: true,
			clearMaskOnLostFocus: false
		},
		match: /[0-9]/,
		replace: '#',
		listKey: "mask"
	};

	if (window.location.hash.length>0){
		if (window.location.hash == "#portfolio"){
			$('a[href="#portfolio"]').click();

		}
		else if (window.location.hash == "#information")
		{
			$('a[href="#information"]').click();
		};
	};
	$('a[href="#information"]').click(function(){
		window.location.hash = "#information";
	});
	$('a[href="#portfolio"]').click(function(){
		window.location.hash = "#portfolio";
	});
	$('input[id^="PHONE"]').inputmasks($.extend(true, {}, maskOpts, {
		list: listCountries
	}));

			$('.popup_help').popover({
				trigger: 'hover',
				placement: 'top',
			});	
		$('.social_modal').each(function(){
			if ($(this).find('input').val().length > 0){
				$('.modelsocials a[href="#'+$(this).attr('id')+'"]').addClass('modelsocialsselected');			
			} else {
				$('.modelsocials a[href="#'+$(this).attr('id')+'"]').removeClass('modelsocialsselected');	
			};		
		}
		);
		$('.social_modal .ok_social').click(function() {

			if ($(this).parents('.social_modal').find('input').val().length > 0){
				$('.modelsocials a[href="#'+$(this).parents('.social_modal').attr('id')+'"]').addClass('modelsocialsselected');			
			} else {
				$('.modelsocials a[href="#'+$(this).parents('.social_modal').attr('id')+'"]').removeClass('modelsocialsselected');	
			};
			var str_form = $("form[name='lk_profile']").serialize();
			var pers_icq = str_form.indexOf("PERSONAL_ICQ");
			var sess = str_form.indexOf("sessid", pers_icq);
			if (sess > 0){
				str_form = str_form.substring(pers_icq, (sess-1));
			} else {
				str_form = str_form.substring(pers_icq);
			};
			//console.log(str_form);

			BX.ajax.post(			// Сохранение социалок
			'/local/components/p4/p.ajax.post_social/ajax.php',
			{
				'str_social': str_form,
				'sessid': BX.bitrix_sessid()
			},
			function(result){
				
			}
		);		
	});
		$('.social_modal .close_soc').click(function(){
			if ($(this).parents('.social_modal').find('input').val().length > 0){
				$('.modelsocials a[href="#'+$(this).parents('.social_modal').attr('id')+'"]').addClass('modelsocialsselected');			
			} else {
				$('.modelsocials a[href="#'+$(this).parents('.social_modal').attr('id')+'"]').removeClass('modelsocialsselected');	
			};		
		}
		);
	$("div.genre").click(function () {
		
		if($(this).find("input").attr("checked")) {
			$(this).find("input").removeAttr("checked");
		}
		else {
			$(this).find("input").attr("checked", "checked");
		};
	});
		$("#type259").click(function () {
		
		if ($(this).find("input").attr("checked")) {
			$(this).find("input").removeAttr("checked");
		}
		else {
			$(this).find("input").attr("checked", "checked");
			if ($("#type260").find("input").attr("checked")) {
				$("#type260").removeClass("tagged");
				$("#type260").find("input").removeAttr("checked");
				$("#modagendiv").hide();
			};
		};
	});
	$("#type260").click(function () {
		
		if ($(this).find("input").attr("checked")) {
			$(this).find("input").removeAttr("checked");
			$("#modagendiv").hide();
		}
		else {
			$(this).find("input").attr("checked", "checked");
			$("#modagendiv").show();
			$("#modagendiv").css("width","27%");
			if ($("#type259").find("input").attr("checked")) {
				$("#type259").removeClass("tagged");
				$("#type259").find("input").removeAttr("checked");
			};
		};
	});
	$("#cbxlang").change(function () {
		
		if ($(this).attr("checked")) {
			$(this).removeAttr("checked");
			$("#for_lang").hide();
		}
		else {
			$(this).attr("checked", "checked");
			$("#for_lang").show();
		};
	});

	
		var objSize = {};
		var objShoes = {};
		var unitsys = ["RU","UK","US","EU"];
		for (var j=0; j<unitsys.length; j++){
			objSize[unitsys[j]] = {};
			objShoes[unitsys[j]] = {};
		};

		$("select[name='SIZE'] option").each(function(){
			if ($(this).attr("class") !== "null"){			
				objSize[$(this).attr("class")][$(this).attr("data-size")+" "] = $(this).val();
			}	
		});
		$("select[name='SHOES'] option").each(function(){
			if ($(this).attr("class") !== "null"){
			objShoes[$(this).attr("class")][$(this).attr("data-size")+" "] = $(this).val();
			}	
		});
		function compareNumeric(a, b) {
		  if (a > b) return 1;
		  if (a < b) return -1;
		}
/*


		objSize["RU"].sort(compareNumeric);
		objSize["UK"].sort(compareNumeric);
		objSize["US"].sort(compareNumeric);
		objSize["EU"].sort(compareNumeric);
		objShoes["RU"].sort(compareNumeric);
		objShoes["UK"].sort(compareNumeric);
		objShoes["US"].sort(compareNumeric);
		objShoes["EU"].sort(compareNumeric);*/
			$("select[name='SIZE'] option").each(function(){
		if ($(this).attr("class") !== "null" && $(this).attr("class") !== $("select[name='SIZETYPE'] option:selected").attr("data-val")) {
				$(this).remove();
			};		
		});
		$("select[name='SHOES'] option").each(function(){
		if ($(this).attr("class") !== "null" && $(this).attr("class") !== $("select[name='SHOESTYPE'] option:selected").attr("data-val")) {
				$(this).remove();
			};		
		});
	$("select[name='SIZETYPE']").change(function(){
		$("select[name='SIZE'] :first").attr("selected","selected");
		$("select[name='SIZE'] option").each(function(){
			if ($(this).attr("class") !== "null") {
				$(this).remove();
			};			
		});
		for (var i in objSize[$("select[name='SIZETYPE'] option:selected").attr("data-val")]){
		$("select[name='SIZE']").append($('<option value="'+objSize[$("select[name='SIZETYPE'] option:selected").attr("data-val")][i]+'" class="'+$("select[name='SIZETYPE'] option:selected").attr("data-val")+
		'" data-size="'+i+'">'
		+i+'</option>'));
		};
	});
	$("select[name='SHOESTYPE']").change(function(){
		$("select[name='SHOES'] :first").attr("selected","selected");
		$("select[name='SHOES'] option").each(function(){
			if ($(this).attr("class") !== "null") {
				$(this).remove();
			};			
		});
		for (var i in objShoes[$("select[name='SHOESTYPE'] option:selected").attr("data-val")]){
		$("select[name='SHOES']").append($('<option value="'+objShoes[$("select[name='SHOESTYPE'] option:selected").attr("data-val")][i]+'" class="'+$("select[name='SHOESTYPE'] option:selected").attr("data-val")+
		'" data-size="'+i+'">'
		+i+'</option>'));
		};
	});
	$(".save_link").click(function(){
		$("input[name='lk_prof_s']").click();
	});
	$("#addlang").click(function(){
		ab = true;
		$("#for_lang .stoproc").each(function(){
		if ($(this).css("display") == "none" && ab){
			$(this).show();
			$(this).find(".lkpb_in_nm select :first").attr("selected", "selected");
			$(this).find(".lkpb_in_vs select :first").attr("selected", "selected");
			ab = false;
		};
		});
	});
	$("#for_lang .lkpb_in_nm select").change(function(){
		$(this).parents(".stoproc").find(".lkpb_in_vs select [value='1']").attr("selected", "selected");
	});
	$("#for_lang .removelang").click(function(){
		$(this).parents(".stoproc").find(".lkpb_in_nm select :first").attr("selected","selected");
		$(this).parents(".stoproc").find(".lkpb_in_vs select :first").attr("selected","selected");
		$(this).parents(".stoproc").hide();
	});

});

Zerion Mini Shell 1.0