PageSourceSearch

https://npo-ecofood.ru/local/js/basic/jquery.tabs2.js?15710474132537

js npo-ecofood.ru collected 2026-10-10 02:26:12 UTC 2,537 bytes, 113 lines download raw bytes

1;(function($) {
2
3	var TabView = function(node) {
4		this.node = node;
5		this.tabs = [];
6
7		this.init();
8	}
9
10	TabView.prototype.init = function() { 
11		var i, child, related = null, idRelated,
12			find = new $.sigma.finder(this.node);
13		
14		child = find('button', 'data-role');
15		for(i = 0; i < child.length; i++) {
16			idRelated = '';
17			if(child[i].tagName.toLowerCase() == 'a')
18				idRelated = child[i].href.substr(1);
19			else
20				idRelated = child[i].getAttribute('rel');
21
22			if(idRelated && idRelated.length)
23				related = document.getElementById(idRelated);
24
25			if(related && (this.findTab(idRelated)<0))
26				this.add(child[i], related, idRelated);
27			else 
28				child[i].style.display = 'none';
29		}
30		
31		i = this.getActiveTab();
32		if(i < 0) i = 0;
33		this.openTab(i);
34	}
35
36	TabView.prototype.findTab = function(code)
37	{
38		for(var i = 0; i < this.tabs.length; i++)
39			if(this.tabs[i].code == code)
40				return i;
41		return -1;		
42	}
43
44	TabView.prototype.add = function(button, related, code)
45	{
46		var that = this, index;
47
48		if(button && related) {
49			index = this.tabs.length;
50			button.onclick = function() {
51				that.openTab(index);
52				return false;
53			}
54			this.tabs[index] = {
55				button: button,
56				related: related,
57				code: code
58			}
59			// related.style.display = 'none';
60		}	
61	}
62
63	TabView.prototype.getActiveTab = function() {
64		var value, pos, index = -1, i;
65
66		value = location.hash || '';
67		pos = value.indexOf('tab-');
68		if(pos >= 0) {
69			value = value.substr(pos + 4);
70			index = this.findTab(value);
71		}
72		else {
73			for(i = 0; i < this.tabs.length; i++)
74				if(this.tabs[i].button.className.indexOf('btn-active') >= 0)
75					index = i;
76		}
77		
78		return index;
79	}
80
81	TabView.prototype.openTab = function(n) {
82		var i, item;
83		if(n >= this.tabs.length)
84			return;
85		
86		for(i = 0; i < this.tabs.length; i++) {
87			item = this.tabs[i];
88			if(n == i) {
89				$.sigma.addClass(item.button, 'btn-active');
90				$.sigma.addClass(item.related, 'tab-active');
91				//item.related.style.display = '';
92			}
93			else {
94				$.sigma.delClass(item.button, 'btn-active');
95				$.sigma.delClass(item.related, 'tab-active');
96				//item.related.style.display = 'none';
97			}
98		}
99	}
100
101	$.fn.TabView = function() 
102	{
103		return this.each(function() {
104			var obj = new TabView(this);
105			$(this).bind('open', function(e, n) {
106				n = (typeof n == 'undefined') ? -1 : parseInt(n);
107				if(isNaN(n)) n = -1;
108				obj.openTab(n);
109			});
110		});
111	}
112
113})(jQuery);

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.