PageSourceSearch

https://auto-bp.ru/js/tree.js

js auto-bp.ru collected 2026-09-29 18:59:16 UTC 6,585 bytes, 201 lines download raw bytes

1var element='';
2(function($) {
3	 
4	   $.fn.tree = function(options) {
5	     
6	       //Значения по умолчанию
7		options = $.extend({
8	           
9	           img_src: 'images/scrollup.png',
10	           }, options);
11	     
12		  
13	    return this.each(function(){
14		   
15				var my_tree=new Object;
16				my_tree.$this = $(this),
17				my_tree.width = my_tree.$this.width(), 
18				my_tree.id = $(this).attr('id');
19				$(this).addClass('input_tree');
20				$(this).after("<div class='win_tree' id='win_tree_"+my_tree.id+"'  altid='"+my_tree.id+"'><input type='text' class='tree_find'/><div class='tree tree_"+my_tree.id+"'></div></div>");
21				
22				if (options.url !='' & options.url!='undefined')
23				{	
24					$.ajax({  
25						url: options.url,
26						success: function(html){ // получаем результаты
27							eval("var tree = " + html);
28							list_tree(tree,'tree_'+my_tree.id,options.parent,options.chbx,my_tree.id,$(my_tree.$this).attr('pid'));								
29							
30							$('.next_'+my_tree.id).click(function()
31								{
32									if ($(this).html()=='+') $(this).html('-');
33									 else $(this).html('+');
34									$('.tree_'+$(this).attr('name')+'_'+$(this).attr('id')).toggle();
35								});
36									
37							
38							$('.chbx_twing').click(function(){
39								var p=$('.chbx_twing_'+$(this).attr('name')),text='',id='';
40								for (i=0; i<p.length; i++)	
41									if (p[i].checked){
42										children=$(p[i]).parent().children('span');
43										parent=$(children).attr('parent');
44										text+=$('#'+parent).text()+ ' - '+$(children).text()+';';
45										id+=$(children).attr('id')+',';
46									}
47								$('#'+$(this).attr('name')).attr('pid',id).text(text);
48							});
49							
50							if (options.func!='undefined')
51							{
52								$('.tree_twing_'+my_tree.id+'_owner').dblclick(options.func);
53							}
54							
55							if (options.chbx!='undefined')
56							{
57								$('.tree_twing_'+my_tree.id+'_parent').click(function(){
58									$(my_tree.$this).attr('pid',$(this).attr('id')).text($(this).text());
59									$('.win_tree').hide();
60								});
61							}
62							
63							$("#win_tree_"+my_tree.id+" .tree_find").keyup(function(e) {
64							
65								
66								pid = $(this).parent(".win_tree").attr('altid');
67								$('.tree_'+pid+' div').show();
68								
69						
70								if ($(this).val().length > 2) 
71								{	
72									$('.tree_'+pid+' > div').hide();
73									$('.tree_'+pid+' > div .twig').hide();
74								
75									$res = $('span.tree_twing_'+pid+'_parent:contains(' + $(this).val() + ')');
76									$res.show();
77									$res.css('color', '#5f5f5f').parents('.twig_').show();
78									$res.parents('.twig').show();
79									$res.parents('._twig_').show();
80								}
81							
82							/*	if(e.keyCode == 13) {
83								
84									pid = $(this).parent(".win_tree").attr('altid');
85
86									if ( typeof num_seek == "undefined")
87										num_seek = 0;
88									else 
89										num_seek++;
90									
91									$res = $('span.tree_twing_'+pid+'_parent:contains(' + $(this).val() + ')');
92									$res.css('color', '#5f5f5f');
93									
94									if (num_seek > $res.length - 1) num_seek = 0;
95									
96									$cur = $res.eq(num_seek);
97									$('.tree_razdel_next_' + $($cur).attr('parent')).show();
98									$cur.css('color', 'red');
99									if ($cur.length > 0) $('.tree').scrollTo($cur,100);
100
101								} */
102							});
103						},		
104						error: function(){  
105							alert ("Произошла ошибка попробуйте еще раз");  
106							}   
107					}); 
108				}
109					
110					if (options.disabled!=true)
111						my_tree.$this.click(function(e){
112								if ($('#win_tree_'+$(this).attr('id')).is(':visible')) e.stopPropagation();
113
114								else  {
115									$('.win_tree').hide();
116									$('#win_tree_'+my_tree.id).css('width',my_tree.width);
117									$('#win_tree_'+my_tree.id).show();
118								}
119								
120								$('#win_tree_'+my_tree.id).click(function(e){
121									 e.stopPropagation();
122								});
123								
124								$('body').click(function(ev){
125									
126								  if ($('#win_tree_'+my_tree.id).is(':visible'))
127									$('#win_tree_'+my_tree.id).hide();
128								});
129								e.stopPropagation();
130							
131							});
132			      });
133	};
134	})(jQuery);
135	
136	
137jQuery.expr[":"].contains = function( elem, i, match, array ) {
138	    return (elem.textContent || elem.innerText || jQuery.text( elem ) || "").toLowerCase().indexOf(match[3].toLowerCase()) >= 0;
139	}
140	
141function list_tree(tree,parent,id,chbx_,tree_id,pid)
142{
143
144	var chbx='';
145	var show=0;
146	
147	for (var key in tree) {
148	
149		if (typeof tree[key]['next'] !=="undefined") next="<div class='next next_"+tree_id+"' name='"+tree_id+"' id='next_"+tree[key]['id']+"'>+</div>";
150			else next="<div class='next_none'> </div>";
151	
152		if (tree[key]['parent']!=id) next=" twig' style='display:none'>"+next;
153				else next="'>"+next;
154		
155		if (chbx_) 
156			{
157			if (tree[key]['parent']!=1) 
158				{
159					chbx="<input type='checkbox' class='chbx_twing chbx_twing_"+tree_id+"' name='"+tree_id+"' id='chbx_twing_"+tree[key]['id']+"'";
160					if (pid.indexOf(tree[key]['id']) > -1 ) 
161						{
162							chbx+= ' checked />';
163							show=1;
164							$('#next_'+tree[key]['parent']).html('-');
165						}
166						else chbx+= '/>';
167				}
168				else chbx='';
169			}
170
171			
172		if (tree[key]['parent']!=1)	
173			{
174				if (pid.indexOf(tree[key]['id']) > -1 ) 
175				{
176					show=1;
177					$('#next_'+tree[key]['parent']).html('-');
178					aa='tree_twing_'+tree_id+'_parent cur_unit';
179				}
180				else aa='tree_twing_'+tree_id+'_parent';
181			}
182			else aa='tree_twing_'+tree_id+'_owner tree_owner';
183			
184		append="<div class='twig_"+tree[key]['id']+" _twig_ tree_"+tree_id+'_next_'+tree[key]['parent']+" "+next+"<div class='twig_'>"+chbx+"<span class='tree_twing "+aa+"' id='"+tree[key]['id']+"' parent='"+tree[key]['parent']+"'>"+tree[key]['name']+"</div></span></div>";
185			
186		$('.'+parent).append(append);
187		if (typeof tree[key]['next'] !=="undefined") list_tree(tree[key]['next'], "twig_"+tree[key]['id'],id,chbx_,tree_id,pid);
188		if (show==1) $('.tree_'+tree_id+'_next_'+tree[key]['parent']).show();
189	}
190	
191}
192
193 function offsetPosition ( element ) {
194	var offsetLeft = -parseInt($('body').css('margin-left')), offsetTop = parseInt($(element).css('height'))-parseInt($('body').css('margin-top'));
195	//do { 
196		offsetLeft += element.offsetLeft;
197        offsetTop  += element.offsetTop;   
198	//	}   
199	//while ( element = element.offsetParent );    
200	return [ offsetLeft, offsetTop];
201}

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.