PageSourceSearch

https://frontiersemi.com/Designs/admin/js/jquery.dcjqaccordion.2.7.js

js frontiersemi.com collected 2026-10-10 00:31:05 UTC 6,625 bytes, 225 lines download raw bytes

1/*
2 * DC jQuery Vertical Accordion Menu - jQuery vertical accordion menu plugin
3 * Copyright (c) 2011 Design Chemical
4 *
5 * Dual licensed under the MIT and GPL licenses:
6 * 	http://www.opensource.org/licenses/mit-license.php
7 * 	http://www.gnu.org/licenses/gpl.html
8 *
9 */
10
11(function($){
12
13	$.fn.dcAccordion = function(options) {
14
15		//set default options 
16		var defaults = {
17			classParent	 : 'dcjq-parent',
18			classActive	 : 'active',
19			classArrow	 : 'dcjq-icon',
20			classCount	 : 'dcjq-count',
21			classExpand	 : 'dcjq-current-parent',
22			eventType	 : 'click',
23			hoverDelay	 : 300,
24			menuClose     : true,
25			autoClose    : true,
26			autoExpand	 : false,
27			speed        : 'slow',
28			saveState	 : true,
29			disableLink	 : true,
30			showCount : false,
31//			cookie	: 'dcjq-accordion'
32		};
33
34		//call in the default otions
35		var options = $.extend(defaults, options);
36
37		this.each(function(options){
38
39			var obj = this;
40			setUpAccordion();
41//			if(defaults.saveState == true){
42//				checkCookie(defaults.cookie, obj);
43//			}
44			if(defaults.autoExpand == true){
45				$('li.'+defaults.classExpand+' > a').addClass(defaults.classActive);
46			}
47			resetAccordion();
48
49			if(defaults.eventType == 'hover'){
50
51				var config = {
52					sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
53					interval: defaults.hoverDelay, // number = milliseconds for onMouseOver polling interval
54					over: linkOver, // function = onMouseOver callback (REQUIRED)
55					timeout: defaults.hoverDelay, // number = milliseconds delay before onMouseOut
56					out: linkOut // function = onMouseOut callback (REQUIRED)
57				};
58
59				$('li a',obj).hoverIntent(config);
60				var configMenu = {
61					sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
62					interval: 1000, // number = milliseconds for onMouseOver polling interval
63					over: menuOver, // function = onMouseOver callback (REQUIRED)
64					timeout: 1000, // number = milliseconds delay before onMouseOut
65					out: menuOut // function = onMouseOut callback (REQUIRED)
66				};
67
68				$(obj).hoverIntent(configMenu);
69
70				// Disable parent links
71				if(defaults.disableLink == true){
72
73					$('li a',obj).click(function(e){
74						if($(this).siblings('ul').length >0){
75							e.preventDefault();
76						}
77					});
78				}
79
80			} else {
81			
82				$('li a',obj).click(function(e){
83
84					$activeLi = $(this).parent('li');
85					$parentsLi = $activeLi.parents('li');
86					$parentsUl = $activeLi.parents('ul');
87
88					// Prevent browsing to link if has child links
89					if(defaults.disableLink == true){
90						if($(this).siblings('ul').length >0){
91							e.preventDefault();
92						}
93					}
94
95					// Auto close sibling menus
96					if(defaults.autoClose == true){
97						autoCloseAccordion($parentsLi, $parentsUl);
98					}
99
100					if ($('> ul',$activeLi).is(':visible')){
101						$('ul',$activeLi).slideUp(defaults.speed);
102						$('a',$activeLi).removeClass(defaults.classActive);
103					} else {
104						$(this).siblings('ul').slideToggle(defaults.speed);
105						$('> a',$activeLi).addClass(defaults.classActive);
106					}
107					
108//					// Write cookie if save state is on
109//					if(defaults.saveState == true){
110//						createCookie(defaults.cookie, obj);
111//					}
112				});
113			}
114
115			// Set up accordion
116			function setUpAccordion(){
117
118				$arrow = '<span class="'+defaults.classArrow+'"></span>';
119				var classParentLi = defaults.classParent+'-li';
120				$('> ul',obj).show();
121				$('li',obj).each(function(){
122					if($('> ul',this).length > 0){
123						$(this).addClass(classParentLi);
124						$('> a',this).addClass(defaults.classParent).append($arrow);
125					}
126				});
127				$('> ul',obj).hide();
128				if(defaults.showCount == true){
129					$('li.'+classParentLi,obj).each(function(){
130						if(defaults.disableLink == true){
131							var getCount = parseInt($('ul a:not(.'+defaults.classParent+')',this).length);
132						} else {
133							var getCount = parseInt($('ul a',this).length);
134						}
135						$('> a',this).append(' <span class="'+defaults.classCount+'">
135'+getCount+'</span>');
136					});
137				}
138			}
139			
140			function linkOver(){
141
142			$activeLi = $(this).parent('li');
143			$parentsLi = $activeLi.parents('li');
144			$parentsUl = $activeLi.parents('ul');
145
146			// Auto close sibling menus
147			if(defaults.autoClose == true){
148				autoCloseAccordion($parentsLi, $parentsUl);
149
150			}
151
152			if ($('> ul',$activeLi).is(':visible')){
153				$('ul',$activeLi).slideUp(defaults.speed);
154				$('a',$activeLi).removeClass(defaults.classActive);
155			} else {
156				$(this).siblings('ul').slideToggle(defaults.speed);
157				$('> a',$activeLi).addClass(defaults.classActive);
158			}
159
160			// Write cookie if save state is on
161			if(defaults.saveState == true){
162				createCookie(defaults.cookie, obj);
163			}
164		}
165
166		function linkOut(){
167		}
168
169		function menuOver(){
170		}
171
172		function menuOut(){
173
174			if(defaults.menuClose == true){
175				$('ul',obj).slideUp(defaults.speed);
176				// Reset active links
177				$('a',obj).removeClass(defaults.classActive);
178				createCookie(defaults.cookie, obj);
179			}
180		}
181
182		// Auto-Close Open Menu Items
183		function autoCloseAccordion($parentsLi, $parentsUl){
184			$('ul',obj).not($parentsUl).slideUp(defaults.speed);
185			// Reset active links
186			$('a',obj).removeClass(defaults.classActive);
187			$('> a',$parentsLi).addClass(defaults.classActive);
188		}
189		// Reset accordion using active links
190		function resetAccordion(){
191			$('ul',obj).hide();
192			$allActiveLi = $('a.'+defaults.classActive,obj);
193			$allActiveLi.siblings('ul').show();
194		}
195		});
196
197		// Retrieve cookie value and set active items
198//		function checkCookie(cookieId, obj){
199//			var cookieVal = $.cookie(cookieId);
200//			if(cookieVal != null){
201//				// create array from cookie string
202//				var activeArray = cookieVal.split(',');
203//				$.each(activeArray, function(index,value){
204//					var $cookieLi = $('li:eq('+value+')',obj);
205//					$('> a',$cookieLi).addClass(defaults.classActive);
206//					var $parentsLi = $cookieLi.parents('li');
207//					$('> a',$parentsLi).addClass(defaults.classActive);
208//				});
209//			}
210//		}
211
212		// Write cookie
213//		function createCookie(cookieId, obj){
214//			var activeIndex = [];
215//			// Create array of active items index value
216//			$('li a.'+defaults.classActive,obj).each(function(i){
217//				var $arrayItem = $(this).parent('li');
218//				var itemIndex = $('li',obj).index($arrayItem);
219//					activeIndex.push(itemIndex);
220//				});
221//			// Store in cookie
222//			$.cookie(cookieId, activeIndex, { path: '/' });
223//		}
224	};
225})(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.