PageSourceSearch

https://masu.com.vn/js/jquery.dcjqaccordion.2.7.js

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