JQuery Accordion Menu Widget - Version 2.2

Version Description

  • Added: Option to show count of number of child links
  • Edit: Plugin updated to use jquery plugin version 2.3
  • Edit: Cookie name set based on widget ID
Download this release

Release Info

Developer remix4
Plugin Icon wp plugin JQuery Accordion Menu Widget
Version 2.2
Comparing to
See all releases

Code changes from version 2.1 to 2.2

dcwp_jquery_accordion.php CHANGED
@@ -5,7 +5,7 @@
5
  Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation, accordion
6
  Description: Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery. Features include - handles multiple levels, saved state using cookies and option of selecting "click" or "hover" events for triggering the menu.
7
  Author: Lee Chestnutt
8
- Version: 2.1
9
  Author URI: http://www.designchemical.com
10
  */
11
 
@@ -24,7 +24,7 @@ class dc_jqaccordion {
24
  wp_enqueue_script( 'jquery' );
25
  wp_enqueue_script( 'jqueryhoverintent', dc_jqaccordion::get_plugin_directory() . '/js/jquery.hoverIntent.minified.js', array('jquery') );
26
  wp_enqueue_script( 'jquerycookie', dc_jqaccordion::get_plugin_directory() . '/js/jquery.cookie.js', array('jquery') );
27
- wp_enqueue_script( 'dcjqaccordion', dc_jqaccordion::get_plugin_directory() . '/js/jquery.dcjqaccordion.2.0.js', array('jquery') );
28
  }
29
  add_action( 'wp_footer', array('dc_jqaccordion', 'footer') );
30
 
5
  Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation, accordion
6
  Description: Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery. Features include - handles multiple levels, saved state using cookies and option of selecting "click" or "hover" events for triggering the menu.
7
  Author: Lee Chestnutt
8
+ Version: 2.2
9
  Author URI: http://www.designchemical.com
10
  */
11
 
24
  wp_enqueue_script( 'jquery' );
25
  wp_enqueue_script( 'jqueryhoverintent', dc_jqaccordion::get_plugin_directory() . '/js/jquery.hoverIntent.minified.js', array('jquery') );
26
  wp_enqueue_script( 'jquerycookie', dc_jqaccordion::get_plugin_directory() . '/js/jquery.cookie.js', array('jquery') );
27
+ wp_enqueue_script( 'dcjqaccordion', dc_jqaccordion::get_plugin_directory() . '/js/jquery.dcjqaccordion.2.3.js', array('jquery') );
28
  }
29
  add_action( 'wp_footer', array('dc_jqaccordion', 'footer') );
30
 
dcwp_jquery_accordion_widget.php CHANGED
@@ -32,6 +32,7 @@ class dc_jqaccordion_widget extends WP_Widget {
32
  'menuClose' => 'on',
33
  'autoClose' => 'on',
34
  'saveState' => 'on',
 
35
  'speed' => 'slow',
36
  'disableLink' => 'on',
37
  'skin' => 'demo.css'
@@ -81,6 +82,7 @@ class dc_jqaccordion_widget extends WP_Widget {
81
  $instance['menuClose'] = $new_instance['menuClose'];
82
  $instance['saveState'] = $new_instance['saveState'];
83
  $instance['disableLink'] = $new_instance['disableLink'];
 
84
  $instance['classParent'] = strip_tags( stripslashes($new_instance['classParent']) );
85
  $instance['classActive'] = strip_tags( stripslashes($new_instance['classActive']) );
86
  $instance['event'] = strip_tags( stripslashes($new_instance['event']) );
@@ -99,6 +101,7 @@ class dc_jqaccordion_widget extends WP_Widget {
99
  if(! isset($instance['saveState']) ){ $instance['saveState'] = 'false'; }
100
  if(! isset($instance['menuClose']) ){ $instance['menuClose'] = 'false'; }
101
  if(! isset($instance['disableLink']) ){ $instance['disableLink'] = 'false'; }
 
102
  $classParent = isset( $instance['classParent'] ) ? $instance['classParent'] : '';
103
  $classActive = isset( $instance['classActive'] ) ? $instance['classActive'] : '';
104
  $event = isset( $instance['event'] ) ? $instance['event'] : '';
@@ -150,7 +153,10 @@ class dc_jqaccordion_widget extends WP_Widget {
150
  <label for="<?php echo $this->get_field_id('disableLink'); ?>"><?php _e( 'Disable Parent Links' , 'dcjq-accordion' ); ?></label><br />
151
 
152
  <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('menuClose'); ?>" name="<?php echo $this->get_field_name('menuClose'); ?>"<?php checked( $menuClose, 'true' ); ?> />
153
- <label for="<?php echo $this->get_field_id('menuClose'); ?>"><?php _e( 'Close Menu (hover only)' , 'dcjq-accordion' ); ?></label>
 
 
 
154
  </p>
155
  <p>
156
  <label for="<?php echo $this->get_field_id('hoverDelay'); ?>"><?php _e('Hover Delay:', 'dcjq-accordion'); ?>
@@ -248,6 +254,9 @@ class dc_jqaccordion_widget extends WP_Widget {
248
 
249
  $menuClose = $wpdcjqaccordion['menuClose'];
250
  if($menuClose == ''){$menuClose = 'false';};
 
 
 
251
 
252
  $hoverDelay = $wpdcjqaccordion['hoverDelay'];
253
  if($hoverDelay == ''){$hoverDelay = 600;};
@@ -263,7 +272,9 @@ class dc_jqaccordion_widget extends WP_Widget {
263
  menuClose: <?php echo $menuClose; ?>,
264
  autoClose: <?php echo $autoClose; ?>,
265
  saveState: <?php echo $saveState; ?>,
 
266
  disableLink: <?php echo $disableLink; ?>,
 
267
  speed: '<?php echo $wpdcjqaccordion['speed']; ?>'
268
  });
269
  });
32
  'menuClose' => 'on',
33
  'autoClose' => 'on',
34
  'saveState' => 'on',
35
+ 'showCount' => 'off',
36
  'speed' => 'slow',
37
  'disableLink' => 'on',
38
  'skin' => 'demo.css'
82
  $instance['menuClose'] = $new_instance['menuClose'];
83
  $instance['saveState'] = $new_instance['saveState'];
84
  $instance['disableLink'] = $new_instance['disableLink'];
85
+ $instance['showCount'] = $new_instance['showCount'];
86
  $instance['classParent'] = strip_tags( stripslashes($new_instance['classParent']) );
87
  $instance['classActive'] = strip_tags( stripslashes($new_instance['classActive']) );
88
  $instance['event'] = strip_tags( stripslashes($new_instance['event']) );
101
  if(! isset($instance['saveState']) ){ $instance['saveState'] = 'false'; }
102
  if(! isset($instance['menuClose']) ){ $instance['menuClose'] = 'false'; }
103
  if(! isset($instance['disableLink']) ){ $instance['disableLink'] = 'false'; }
104
+ if(! isset($instance['showCount']) ){ $instance['showCount'] = 'false'; }
105
  $classParent = isset( $instance['classParent'] ) ? $instance['classParent'] : '';
106
  $classActive = isset( $instance['classActive'] ) ? $instance['classActive'] : '';
107
  $event = isset( $instance['event'] ) ? $instance['event'] : '';
153
  <label for="<?php echo $this->get_field_id('disableLink'); ?>"><?php _e( 'Disable Parent Links' , 'dcjq-accordion' ); ?></label><br />
154
 
155
  <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('menuClose'); ?>" name="<?php echo $this->get_field_name('menuClose'); ?>"<?php checked( $menuClose, 'true' ); ?> />
156
+ <label for="<?php echo $this->get_field_id('menuClose'); ?>"><?php _e( 'Close Menu (hover only)' , 'dcjq-accordion' ); ?></label><br />
157
+
158
+ <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('showCount'); ?>" name="<?php echo $this->get_field_name('showCount'); ?>"<?php checked( $showCount, 'true' ); ?> />
159
+ <label for="<?php echo $this->get_field_id('showCount'); ?>"><?php _e( 'Show Count' , 'dcjq-accordion' ); ?></label><br />
160
  </p>
161
  <p>
162
  <label for="<?php echo $this->get_field_id('hoverDelay'); ?>"><?php _e('Hover Delay:', 'dcjq-accordion'); ?>
254
 
255
  $menuClose = $wpdcjqaccordion['menuClose'];
256
  if($menuClose == ''){$menuClose = 'false';};
257
+
258
+ $showCount = $wpdcjqaccordion['showCount'];
259
+ if($showCount == ''){$showCount = 'false';};
260
 
261
  $hoverDelay = $wpdcjqaccordion['hoverDelay'];
262
  if($hoverDelay == ''){$hoverDelay = 600;};
272
  menuClose: <?php echo $menuClose; ?>,
273
  autoClose: <?php echo $autoClose; ?>,
274
  saveState: <?php echo $saveState; ?>,
275
+ showCount: <?php echo $showCount; ?>,
276
  disableLink: <?php echo $disableLink; ?>,
277
+ cookie: '<?php echo $widget_id; ?>',
278
  speed: '<?php echo $wpdcjqaccordion['speed']; ?>'
279
  });
280
  });
js/jquery.dcjqaccordion.2.0.js DELETED
@@ -1,205 +0,0 @@
1
- /*
2
- * DC jQuery Accordion - jQuery accordion menu widget
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
-
12
- //define the new for the plugin ans how to call it
13
-
14
- $.fn.dcAccordion = function(options) {
15
- //set default options
16
- var defaults = {
17
- classParent : 'dcjq-parent',
18
- classActive : 'active',
19
- eventType : 'click',
20
- hoverDelay : 300,
21
- menuClose : true,
22
- autoClose : true,
23
- speed : 'slow',
24
- saveState : true,
25
- disableLink : true
26
- };
27
-
28
- //call in the default otions
29
- var options = $.extend(defaults, options);
30
- var $dcAccordionItem = this;
31
-
32
- //act upon the element that is passed into the design
33
- return $dcAccordionItem.each(function(options){
34
-
35
- setUpAccordion();
36
-
37
- if(defaults.saveState == true){
38
- cookieId = $(this).parent().attr('id');
39
- checkCookie();
40
- }
41
- resetAccordion();
42
-
43
- if(defaults.eventType == 'hover'){
44
-
45
- var config = {
46
- sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
47
- interval: defaults.hoverDelay, // number = milliseconds for onMouseOver polling interval
48
- over: linkOver, // function = onMouseOver callback (REQUIRED)
49
- timeout: defaults.hoverDelay, // number = milliseconds delay before onMouseOut
50
- out: linkOut // function = onMouseOut callback (REQUIRED)
51
- };
52
- $('li a',$dcAccordionItem).hoverIntent(config);
53
-
54
- var configMenu = {
55
- sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
56
- interval: 1000, // number = milliseconds for onMouseOver polling interval
57
- over: menuOver, // function = onMouseOver callback (REQUIRED)
58
- timeout: 1000, // number = milliseconds delay before onMouseOut
59
- out: menuOut // function = onMouseOut callback (REQUIRED)
60
- };
61
- $($dcAccordionItem).hoverIntent(configMenu);
62
-
63
- // Disable parent links
64
- if(defaults.disableLink == true){
65
- $('li a',$dcAccordionItem).click(function(e){
66
- if($(this).next('ul').length >0){
67
- e.preventDefault();
68
- }
69
- });
70
- }
71
-
72
- } else {
73
-
74
- $('li a',$dcAccordionItem).click(function(e){
75
-
76
- $activeLi = $(this).parent('li');
77
- $parentsLi = $activeLi.parents('li');
78
- $parentsUl = $activeLi.parents('ul');
79
-
80
- // Prevent browsing to link if has child links
81
- if(defaults.disableLink == true){
82
- if($(this).next('ul').length >0){
83
- e.preventDefault();
84
- }
85
- }
86
-
87
- // Auto close sibling menus
88
- if(defaults.autoClose == true){
89
- autoCloseAccordion($parentsLi, $parentsUl);
90
- }
91
-
92
- if ($('> ul',$activeLi).is(':visible')){
93
- $('ul',$activeLi).slideUp(defaults.speed);
94
- $('a',$activeLi).removeClass(defaults.classActive);
95
- } else {
96
- $(this).next().slideToggle(defaults.speed);
97
- $('> a',$activeLi).addClass(defaults.classActive);
98
- }
99
-
100
- // Write cookie if save state is on
101
- if(defaults.saveState == true){
102
- createCookie();
103
- }
104
- });
105
- }
106
- // Set up accordion
107
- function setUpAccordion(){
108
- $arrow = '<span class="dcjq-icon"></span>';
109
- $('> ul',$dcAccordionItem).show();
110
- $('li',$dcAccordionItem).each(function(){
111
- var classParentLi = defaults.classParent+'-li';
112
- if($('> ul',this).length > 0){
113
- $(this).addClass(classParentLi);
114
- $('> a',this).addClass(defaults.classParent).append($arrow);
115
- }
116
- });
117
- $('> ul',$dcAccordionItem).hide();
118
- }
119
- });
120
-
121
- function linkOver(){
122
-
123
- $activeLi = $(this).parent('li');
124
- $parentsLi = $activeLi.parents('li');
125
- $parentsUl = $activeLi.parents('ul');
126
-
127
- // Auto close sibling menus
128
- if(defaults.autoClose == true){
129
- autoCloseAccordion($parentsLi, $parentsUl);
130
- }
131
-
132
- if ($('> ul',$activeLi).is(':visible')){
133
- $('ul',$activeLi).slideUp(defaults.speed);
134
- $('a',$activeLi).removeClass(defaults.classActive);
135
- } else {
136
- $(this).next().slideToggle(defaults.speed);
137
- $('> a',$activeLi).addClass(defaults.classActive);
138
- }
139
-
140
- // Write cookie if save state is on
141
- if(defaults.saveState == true){
142
- createCookie();
143
- }
144
-
145
- }
146
-
147
- function linkOut(){
148
- }
149
-
150
- function menuOver(){
151
- }
152
-
153
- function menuOut(){
154
- if(defaults.menuClose == true){
155
- $('ul',$dcAccordionItem).slideUp(defaults.speed);
156
- // Reset active links
157
- $('a',$dcAccordionItem).removeClass(defaults.classActive);
158
- createCookie();
159
- }
160
- }
161
-
162
- // Auto-Close Open Menu Items
163
- function autoCloseAccordion($parentsLi, $parentsUl){
164
- $('ul',$dcAccordionItem).not($parentsUl).slideUp(defaults.speed);
165
- // Reset active links
166
- $('a',$dcAccordionItem).removeClass(defaults.classActive);
167
- $('> a',$parentsLi).addClass(defaults.classActive);
168
- }
169
-
170
- // Retrieve cookie value and set active items
171
- function checkCookie(){
172
- var cookieVal = $.cookie(cookieId);
173
- if(cookieVal != null){
174
- // create array from cookie string
175
- var activeArray = cookieVal.split(',');
176
- $.each(activeArray, function(index,value){
177
- var $cookieLi = $('li:eq('+value+')',$dcAccordionItem);
178
- $('> a',$cookieLi).addClass(defaults.classActive);
179
- var $parentsLi = $cookieLi.parents('li');
180
- $('> a',$parentsLi).addClass(defaults.classActive);
181
- });
182
- }
183
- }
184
-
185
- // Reset accordion using active links
186
- function resetAccordion(){
187
- $('ul',$dcAccordionItem).hide();
188
- $allActiveLi = $('a.'+defaults.classActive,$dcAccordionItem);
189
- $allActiveLi.next().show();
190
- }
191
-
192
- // Write cookie
193
- function createCookie(){
194
- var activeIndex = [];
195
- // Create array of active items index value
196
- $('li a.active',$dcAccordionItem).each(function(i){
197
- var $arrayItem = $(this).parent('li');
198
- var itemIndex = $('li',$dcAccordionItem).index($arrayItem);
199
- activeIndex.push(itemIndex);
200
- });
201
- // Store in cookie
202
- $.cookie(cookieId, activeIndex, { path: '/' });
203
- }
204
- };
205
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/{jquery.dcjqaccordion.2.1.js → jquery.dcjqaccordion.2.3.js} RENAMED
@@ -1,206 +1,172 @@
1
  /*
2
- * DC jQuery Accordion - jQuery accordion menu widget
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
-
12
- //define the new for the plugin ans how to call it
13
-
14
- $.fn.dcAccordion = function(options) {
15
- //set default options
16
  var defaults = {
17
  classParent : 'dcjq-parent',
18
- classActive : 'active',
19
  eventType : 'click',
20
  hoverDelay : 300,
21
  menuClose : true,
22
  autoClose : true,
23
  speed : 'slow',
24
  saveState : true,
25
- disableLink : true
26
- };
27
-
28
  //call in the default otions
29
- var options = $.extend(defaults, options);
30
-
31
- //act upon the element that is passed into the design
32
- return this.each(function(options){
33
-
34
- var $dcAccordionItem = this;
35
  setUpAccordion();
36
-
37
  if(defaults.saveState == true){
38
- cookieId = $(this).parent().attr('id');
39
- checkCookie();
40
  }
41
- resetAccordion();
42
-
43
- if(defaults.eventType == 'hover'){
44
-
45
  var config = {
46
  sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
47
  interval: defaults.hoverDelay, // number = milliseconds for onMouseOver polling interval
48
  over: linkOver, // function = onMouseOver callback (REQUIRED)
49
  timeout: defaults.hoverDelay, // number = milliseconds delay before onMouseOut
50
  out: linkOut // function = onMouseOut callback (REQUIRED)
51
- };
52
- $('li a',$dcAccordionItem).hoverIntent(config);
53
-
54
  var configMenu = {
55
  sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
56
  interval: 1000, // number = milliseconds for onMouseOver polling interval
57
  over: menuOver, // function = onMouseOver callback (REQUIRED)
58
  timeout: 1000, // number = milliseconds delay before onMouseOut
59
  out: menuOut // function = onMouseOut callback (REQUIRED)
60
- };
61
- $($dcAccordionItem).hoverIntent(configMenu);
62
-
63
  // Disable parent links
64
- if(defaults.disableLink == true){
65
- $('li a',$dcAccordionItem).click(function(e){
66
  if($(this).next('ul').length >0){
67
  e.preventDefault();
68
  }
69
  });
70
- }
71
-
72
- } else {
73
-
74
- $('li a',$dcAccordionItem).click(function(e){
75
-
76
  $activeLi = $(this).parent('li');
77
  $parentsLi = $activeLi.parents('li');
78
- $parentsUl = $activeLi.parents('ul');
79
-
80
  // Prevent browsing to link if has child links
81
  if(defaults.disableLink == true){
82
  if($(this).next('ul').length >0){
83
  e.preventDefault();
84
  }
85
- }
86
-
87
  // Auto close sibling menus
88
  if(defaults.autoClose == true){
89
  autoCloseAccordion($parentsLi, $parentsUl);
90
- }
91
-
92
  if ($('> ul',$activeLi).is(':visible')){
93
  $('ul',$activeLi).slideUp(defaults.speed);
94
  $('a',$activeLi).removeClass(defaults.classActive);
95
  } else {
96
  $(this).next().slideToggle(defaults.speed);
97
  $('> a',$activeLi).addClass(defaults.classActive);
98
- }
99
-
100
  // Write cookie if save state is on
101
  if(defaults.saveState == true){
102
- createCookie();
103
- }
104
- });
105
- }
106
  // Set up accordion
107
- function setUpAccordion(){
108
- $arrow = '<span class="dcjq-icon"></span>';
109
- $('> ul',$dcAccordionItem).show();
110
- $('li',$dcAccordionItem).each(function(){
111
  var classParentLi = defaults.classParent+'-li';
112
- if($('> ul',this).length > 0){
113
- $(this).addClass(classParentLi);
114
- $('> a',this).addClass(defaults.classParent).append($arrow);
115
  }
116
  });
117
- $('> ul',$dcAccordionItem).hide();
118
- }
119
-
120
- // Retrieve cookie value and set active items
121
- function checkCookie(){
122
- var cookieVal = $.cookie(cookieId);
123
- if(cookieVal != null){
124
- // create array from cookie string
125
- var activeArray = cookieVal.split(',');
126
- $.each(activeArray, function(index,value){
127
- var $cookieLi = $('li:eq('+value+')',$dcAccordionItem);
128
- $('> a',$cookieLi).addClass(defaults.classActive);
129
- var $parentsLi = $cookieLi.parents('li');
130
- $('> a',$parentsLi).addClass(defaults.classActive);
131
- });
132
  }
133
- }
134
-
135
- // Write cookie
136
- function createCookie(){
137
- var activeIndex = [];
138
-
139
- // Create array of active items index value
140
- $('li a.active',$dcAccordionItem).each(function(i){
141
- var $arrayItem = $(this).parent('li');
142
- var itemIndex = $('li',$dcAccordionItem).index($arrayItem);
143
- activeIndex.push(itemIndex);
144
- });
145
- // Store in cookie
146
- $.cookie(cookieId, activeIndex, { path: '/' });
147
- }
148
-
149
- function linkOver(){
150
-
151
  $activeLi = $(this).parent('li');
152
  $parentsLi = $activeLi.parents('li');
153
- $parentsUl = $activeLi.parents('ul');
154
-
155
  // Auto close sibling menus
156
  if(defaults.autoClose == true){
157
- autoCloseAccordion($parentsLi, $parentsUl);
158
- }
159
-
160
  if ($('> ul',$activeLi).is(':visible')){
161
- $('ul',$activeLi).slideUp(defaults.speed);
162
- $('a',$activeLi).removeClass(defaults.classActive);
163
- } else {
164
- $(this).next().slideToggle(defaults.speed);
165
- $('> a',$activeLi).addClass(defaults.classActive);
166
- }
167
-
168
  // Write cookie if save state is on
169
  if(defaults.saveState == true){
170
- createCookie();
171
  }
172
-
173
- }
174
-
175
  function linkOut(){
176
- }
177
-
178
  function menuOver(){
179
- }
180
-
181
- function menuOut(){
182
  if(defaults.menuClose == true){
183
- $('ul',$dcAccordionItem).slideUp(defaults.speed);
184
  // Reset active links
185
- $('a',$dcAccordionItem).removeClass(defaults.classActive);
186
- createCookie();
187
  }
188
- }
189
-
190
  // Auto-Close Open Menu Items
191
  function autoCloseAccordion($parentsLi, $parentsUl){
192
- $('ul',$dcAccordionItem).not($parentsUl).slideUp(defaults.speed);
193
  // Reset active links
194
- $('a',$dcAccordionItem).removeClass(defaults.classActive);
195
  $('> a',$parentsLi).addClass(defaults.classActive);
196
- }
197
-
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  // Reset accordion using active links
199
  function resetAccordion(){
200
- $('ul',$dcAccordionItem).hide();
201
- $allActiveLi = $('a.'+defaults.classActive,$dcAccordionItem);
202
  $allActiveLi.next().show();
 
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
- });
205
  };
206
  })(jQuery);
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',
16
  eventType : 'click',
17
  hoverDelay : 300,
18
  menuClose : true,
19
  autoClose : true,
20
  speed : 'slow',
21
  saveState : true,
22
+ disableLink : true,
23
+ cookie : 'dcjq-accordion'
24
+ };
25
  //call in the default otions
26
+ var options = $.extend(defaults, options);
27
+ var $dcAccordionObj = this;
28
+ return $dcAccordionObj.each(function(options){
 
 
 
29
  setUpAccordion();
 
30
  if(defaults.saveState == true){
31
+ checkCookie(defaults.cookie, $dcAccordionObj);
 
32
  }
33
+ resetAccordion();
34
+ if(defaults.eventType == 'hover'){
 
 
35
  var config = {
36
  sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
37
  interval: defaults.hoverDelay, // number = milliseconds for onMouseOver polling interval
38
  over: linkOver, // function = onMouseOver callback (REQUIRED)
39
  timeout: defaults.hoverDelay, // number = milliseconds delay before onMouseOut
40
  out: linkOut // function = onMouseOut callback (REQUIRED)
41
+ };
42
+ $('li a',$dcAccordionObj).hoverIntent(config);
 
43
  var configMenu = {
44
  sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
45
  interval: 1000, // number = milliseconds for onMouseOver polling interval
46
  over: menuOver, // function = onMouseOver callback (REQUIRED)
47
  timeout: 1000, // number = milliseconds delay before onMouseOut
48
  out: menuOut // function = onMouseOut callback (REQUIRED)
49
+ };
50
+ $($dcAccordionObj).hoverIntent(configMenu);
 
51
  // Disable parent links
52
+ if(defaults.disableLink == true){
53
+ $('li a',$dcAccordionObj).click(function(e){
54
  if($(this).next('ul').length >0){
55
  e.preventDefault();
56
  }
57
  });
58
+ }
59
+ } else {
60
+ $('li a',$dcAccordionObj).click(function(e){
 
 
 
61
  $activeLi = $(this).parent('li');
62
  $parentsLi = $activeLi.parents('li');
63
+ $parentsUl = $activeLi.parents('ul');
 
64
  // Prevent browsing to link if has child links
65
  if(defaults.disableLink == true){
66
  if($(this).next('ul').length >0){
67
  e.preventDefault();
68
  }
69
+ }
 
70
  // Auto close sibling menus
71
  if(defaults.autoClose == true){
72
  autoCloseAccordion($parentsLi, $parentsUl);
73
+ }
 
74
  if ($('> ul',$activeLi).is(':visible')){
75
  $('ul',$activeLi).slideUp(defaults.speed);
76
  $('a',$activeLi).removeClass(defaults.classActive);
77
  } else {
78
  $(this).next().slideToggle(defaults.speed);
79
  $('> a',$activeLi).addClass(defaults.classActive);
80
+ }
 
81
  // Write cookie if save state is on
82
  if(defaults.saveState == true){
83
+ createCookie(defaults.cookie, $dcAccordionObj);
84
+ }
85
+ });
86
+ }
87
  // Set up accordion
88
+ function setUpAccordion(){
89
+ $arrow = '<span class="'+defaults.classArrow+'"></span>';
90
+ $('> ul',$dcAccordionObj).show();
91
+ $('li',$dcAccordionObj).each(function(){
92
  var classParentLi = defaults.classParent+'-li';
93
+ if($('> ul',this).length > 0){
94
+ $('> a',this).addClass(defaults.classParent).append($arrow);
 
95
  }
96
  });
97
+ $('> ul',$dcAccordionObj).hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }
99
+ });
100
+ function linkOver(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  $activeLi = $(this).parent('li');
102
  $parentsLi = $activeLi.parents('li');
103
+ $parentsUl = $activeLi.parents('ul');
 
104
  // Auto close sibling menus
105
  if(defaults.autoClose == true){
106
+ autoCloseAccordion($parentsLi, $parentsUl);
107
+ }
 
108
  if ($('> ul',$activeLi).is(':visible')){
109
+ $('ul',$activeLi).slideUp(defaults.speed);
110
+ $('a',$activeLi).removeClass(defaults.classActive);
111
+ } else {
112
+ $(this).next().slideToggle(defaults.speed);
113
+ $('> a',$activeLi).addClass(defaults.classActive);
114
+ }
 
115
  // Write cookie if save state is on
116
  if(defaults.saveState == true){
117
+ createCookie(defaults.cookie, $dcAccordionObj);
118
  }
119
+ }
 
 
120
  function linkOut(){
121
+ }
 
122
  function menuOver(){
123
+ }
124
+ function menuOut(){
 
125
  if(defaults.menuClose == true){
126
+ $('ul',$dcAccordionObj).slideUp(defaults.speed);
127
  // Reset active links
128
+ $('a',$dcAccordionObj).removeClass(defaults.classActive);
129
+ createCookie(defaults.cookie, $dcAccordionObj);
130
  }
131
+ }
 
132
  // Auto-Close Open Menu Items
133
  function autoCloseAccordion($parentsLi, $parentsUl){
134
+ $('ul',$dcAccordionObj).not($parentsUl).slideUp(defaults.speed);
135
  // Reset active links
136
+ $('a',$dcAccordionObj).removeClass(defaults.classActive);
137
  $('> a',$parentsLi).addClass(defaults.classActive);
138
+ }
139
+ // Retrieve cookie value and set active items
140
+ function checkCookie(cookieId, obj){
141
+ var cookieVal = $.cookie(cookieId);
142
+ if(cookieVal != null){
143
+ // create array from cookie string
144
+ var activeArray = cookieVal.split(',');
145
+ $.each(activeArray, function(index,value){
146
+ var $cookieLi = $('li:eq('+value+')',obj);
147
+ $('> a',$cookieLi).addClass(defaults.classActive);
148
+ var $parentsLi = $cookieLi.parents('li');
149
+ $('> a',$parentsLi).addClass(defaults.classActive);
150
+ });
151
+ }
152
+ }
153
  // Reset accordion using active links
154
  function resetAccordion(){
155
+ $('ul',$dcAccordionObj).hide();
156
+ $allActiveLi = $('a.'+defaults.classActive,$dcAccordionObj);
157
  $allActiveLi.next().show();
158
+ }
159
+ // Write cookie
160
+ function createCookie(cookieId, obj){
161
+ var activeIndex = [];
162
+ // Create array of active items index value
163
+ $('li a.'+defaults.classActive,obj).each(function(i){
164
+ var $arrayItem = $(this).parent('li');
165
+ var itemIndex = $('li',obj).index($arrayItem);
166
+ activeIndex.push(itemIndex);
167
+ });
168
+ // Store in cookie
169
+ $.cookie(cookieId, activeIndex, { path: '/' });
170
  }
 
171
  };
172
  })(jQuery);
readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: http://www.designchemical.com
4
  Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation, widget
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
- Stable tag: 2.1
8
 
9
  Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery.
10
 
11
  == Description ==
12
 
13
- Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery. Features include - handles multiple levels, saved state using cookies and option of selecting "click" or "hover" events for triggering the menu. Uses the jquery cookie plugin by [Klaus Hartl](http://www.stilbuero.de).
14
 
15
  = Menu Options =
16
 
@@ -21,6 +21,7 @@ The widget has several parameters that can be configured to help cutomise the ve
21
  * Save menu state (uses cookies) - Selecting this will allow the menu to remember its open/close state when browsing to a new page.
22
  * Disable parent links - If selected, any menu items that have child elements will have their links disabled and will only open/close their relevant sub-menus. Do not select this if you want the user to still be able to browse to that item's page.
23
  * Close menu (hover only) - If checked the menu will automatically fully close after 1 second when the mouse moves off the menu - only available if event type is "hover"
 
24
  * Hover delay - This setting adds a delay to the hover event to help prevent the menu opening/closing accidentally. A higher number means the cursor must stop moving for longer before the menu action will trigger
25
  * Animation Speed - The speed at which the menu will open/close
26
  * Skin - Several sample skins are available to give examples of css that can be used to style your accordion menu
@@ -53,6 +54,11 @@ Another likely cause is due to other non-functioning plugins, which may have err
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
56
  = 2.1 =
57
  * Edit: Security for dynamic skins
58
 
4
  Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation, widget
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 2.2
8
 
9
  Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery.
10
 
11
  == Description ==
12
 
13
+ Creates a widget, which allows you to create vertical accordion menus from any Wordpress custom menu using jQuery. Features include - handles multiple levels, saved state using cookies, add count of number of links and option of selecting "click" or "hover" events for triggering the menu. Uses the jquery cookie plugin by [Klaus Hartl](http://www.stilbuero.de).
14
 
15
  = Menu Options =
16
 
21
  * Save menu state (uses cookies) - Selecting this will allow the menu to remember its open/close state when browsing to a new page.
22
  * Disable parent links - If selected, any menu items that have child elements will have their links disabled and will only open/close their relevant sub-menus. Do not select this if you want the user to still be able to browse to that item's page.
23
  * Close menu (hover only) - If checked the menu will automatically fully close after 1 second when the mouse moves off the menu - only available if event type is "hover"
24
+ * Show Count - If checked the menu will automatically add a count showing the number of links under each parent menu item
25
  * Hover delay - This setting adds a delay to the hover event to help prevent the menu opening/closing accidentally. A higher number means the cursor must stop moving for longer before the menu action will trigger
26
  * Animation Speed - The speed at which the menu will open/close
27
  * Skin - Several sample skins are available to give examples of css that can be used to style your accordion menu
54
 
55
  == Changelog ==
56
 
57
+ = 2.2 =
58
+ * Added: Option to show count of number of child links
59
+ * Edit: Plugin updated to use jquery plugin version 2.3
60
+ * Edit: Cookie name set based on widget ID
61
+
62
  = 2.1 =
63
  * Edit: Security for dynamic skins
64
 
screenshot-1.png CHANGED
Binary file