PageSourceSearch

http://www.kuzpark.ru/kuzpark/ecob/js/jquery.radio.js

js kuzpark.ru collected 2026-10-04 13:23:29 UTC 3,018 bytes, 124 lines download raw bytes

1jQuery(document).ready(function(){
2
3jQuery(".niceRadio").each(
4/* при загрузке страницы меняем обычные на стильные radio */
5function() {
6     
7     changeRadioStart(jQuery(this));
8     
9});
10
11
12});
13
14
15function changeRadio(el)
16/* 
17	функция смены вида и значения radio при клике на контейнер
18*/
19{
20
21	var el = el,
22		input = el.find("input").eq(0);
23	var nm=input.attr("name");
24		
25	jQuery(".niceRadio input").each(
26	
27	function() {
28     
29		if(jQuery(this).attr("name")==nm)
30		{
31			jQuery(this).parent().removeClass("radioChecked");
32		}
33	   
34	   
35	});					  
36	
37	
38	if(el.attr("class").indexOf("niceRadioDisabled")==-1)
39	{	
40		el.addClass("radioChecked");
41		input.attr("checked", true);
42	}
43	
44    return true;
45}
46
47function changeVisualRadio(input)
48{
49/*
50	меняем вид radio при смене значения
51*/
52	var wrapInput = input.parent();
53	var nm=input.attr("name");
54		
55	jQuery(".niceRadio input").each(
56	
57	function() {
58     
59		if(jQuery(this).attr("name")==nm)
60		{
61			jQuery(this).parent().removeClass("radioChecked");
62		}
63	   
64	   
65	});
66
67	if(input.attr("checked")) 
68	{
69		wrapInput.addClass("radioChecked");
70	}
71}
72
73function changeRadioStart(el)
74/* 
75	новый контрол выглядит так <span class="niceRadio"><input type="radio" name="[name radio]" id="[id radio]" [checked="checked"] /></span>
76	новый контрол получает теже name, id и другие атрибуты что и были у обычного
77*/
78{
79
80try
81{
82var el = el,
83	radioName = el.attr("name"),
84	radioId = el.attr("id"),
85	radioChecked = el.attr("checked"),
86	radioDisabled = el.attr("disabled"),
87	radioTab = el.attr("tabindex"),
88	radioValue = el.attr("value");
89	if(radioChecked)
90		el.after("<span class='niceRadio radioChecked'>"+
91			"<input type='radio'"+
92			"name='"+radioName+"'"+
93			"id='"+radioId+"'"+
94			"checked='"+radioChecked+"'"+
95			"tabindex='"+radioTab+"'"+
96			"value='"+radioValue+"' /></span>");
97	else
98		el.after("<span class='niceRadio'>"+
99			"<input type='radio'"+
100			"name='"+radioName+"'"+
101			"id='"+radioId+"'"+
102			"tabindex='"+radioTab+"'"+
103			"value='"+radioValue+"' /></span>");
104	
105	/* если контрол disabled - добавляем соответсвующий класс для нужного вида и добавляем атрибут disabled для вложенного radio */		
106	if(radioDisabled)
107	{
108		el.next().addClass("niceRadioDisabled");
109		el.next().find("input").eq(0).attr("disabled","disabled");
110	}
111	
112	/* цепляем обработчики стилизированным radio */		
113	el.next().bind("mousedown", function(e) { changeRadio(jQuery(this)) });
114	if(jQuery.browser.msie)	el.next().find("input").eq(0).bind("click", function(e) { changeVisualRadio(jQuery(this)) });	
115	else el.next().find("input").eq(0).bind("change", function(e) { changeVisualRadio(jQuery(this)) });
116	el.remove();
117}
118catch(e)
119{
120	// если ошибка, ничего не делаем
121}
122
123    return true;
124}

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.