JQuery Accordion Menu Widget - Version 1.0

Version Description

  • First release

=

Download this release

Release Info

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

Version 1.0

Files changed (50) hide show
  1. dcwp_jquery_accordion.php +58 -0
  2. dcwp_jquery_accordion_widget.php +252 -0
  3. js/jquery.cookie.js +96 -0
  4. js/jquery.dcjqaccordion.js +122 -0
  5. readme.txt +52 -0
  6. screenshot-1.png +0 -0
  7. screenshot-2.png +0 -0
  8. skin.php +14 -0
  9. skins/black.css +8 -0
  10. skins/blue.css +8 -0
  11. skins/clean.css +8 -0
  12. skins/demo.css +8 -0
  13. skins/graphite.css +10 -0
  14. skins/grey.css +9 -0
  15. skins/images/arr_black.gif +0 -0
  16. skins/images/arr_white.gif +0 -0
  17. skins/images/arrow.png +0 -0
  18. skins/images/arrow1.png +0 -0
  19. skins/images/arrow2.gif +0 -0
  20. skins/images/arrow_black_down.png +0 -0
  21. skins/images/arrow_black_right.png +0 -0
  22. skins/images/arrow_grey.png +0 -0
  23. skins/images/arrow_grey_down.png +0 -0
  24. skins/images/arrow_grey_down_x.png +0 -0
  25. skins/images/arrow_grey_right.png +0 -0
  26. skins/images/arrow_grey_right_x.png +0 -0
  27. skins/images/arrow_red_down.png +0 -0
  28. skins/images/arrow_red_right.png +0 -0
  29. skins/images/arrow_right.png +0 -0
  30. skins/images/arrv_white.gif +0 -0
  31. skins/images/bcgWepButton.gif +0 -0
  32. skins/images/bg_black.png +0 -0
  33. skins/images/bg_clean.png +0 -0
  34. skins/images/bg_clean_on.png +0 -0
  35. skins/images/bg_graphite.png +0 -0
  36. skins/images/bg_graphite_arrow.png +0 -0
  37. skins/images/bg_green_blue.png +0 -0
  38. skins/images/bg_grey.png +0 -0
  39. skins/images/bullet.png +0 -0
  40. skins/images/bullet_active.png +0 -0
  41. skins/images/checkers.png +0 -0
  42. skins/images/checkers_x.png +0 -0
  43. skins/images/graphite_arrow_down.png +0 -0
  44. skins/images/graphite_arrow_right.png +0 -0
  45. skins/images/minus_grey.png +0 -0
  46. skins/images/minus_red.png +0 -0
  47. skins/images/opacity.png +0 -0
  48. skins/images/plus_grey.png +0 -0
  49. skins/images/plus_red.png +0 -0
  50. skins/images/stripes.png +0 -0
dcwp_jquery_accordion.php ADDED
@@ -0,0 +1,58 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: jQuery Vertical Accordion Menu
4
+ Plugin URI: http://www.designchemical.com/blog/index.php/wordpress-plugins/wordpress-plugin-jquery-vertical-accordion-menu-widget/
5
+ Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation
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.
7
+ Author: Lee Chestnutt
8
+ Version: 1.0
9
+ Author URI: http://www.designchemical.com
10
+ */
11
+
12
+ global $registered_skins;
13
+
14
+ class dc_jqaccordion {
15
+
16
+ function dc_jqaccordion(){
17
+ global $registered_skins;
18
+
19
+ if(!is_admin()){
20
+ // Header styles
21
+ add_action( 'wp_head', array('dc_jqaccordion', 'header') );
22
+
23
+ // Scripts
24
+ wp_enqueue_script( 'jquery' );
25
+ wp_enqueue_script( 'jquerycookie', dc_jqaccordion::get_plugin_directory() . '/js/jquery.cookie.js', array('jquery') );
26
+ wp_enqueue_script( 'dcjqaccordion', dc_jqaccordion::get_plugin_directory() . '/js/jquery.dcjqaccordion.js', array('jquery') );
27
+ }
28
+ add_action( 'wp_footer', array('dc_jqaccordion', 'footer') );
29
+
30
+ $registered_skins = array();
31
+ }
32
+
33
+ function header(){
34
+ //echo "\n\t";
35
+ }
36
+
37
+ function footer(){
38
+ //echo "\n\t";
39
+ }
40
+
41
+ function options(){}
42
+
43
+ function get_plugin_directory(){
44
+ return WP_PLUGIN_URL . '/jquery-vertical-accordion-menu';
45
+ }
46
+
47
+ };
48
+
49
+ // Include the widget
50
+ include_once('dcwp_jquery_accordion_widget.php');
51
+
52
+ // Initialize the plugin.
53
+ $dcjqaccordion = new dc_jqaccordion();
54
+
55
+ // Register the widget
56
+ add_action('widgets_init', create_function('', 'return register_widget("dc_jqaccordion_widget");'));
57
+
58
+ ?>
dcwp_jquery_accordion_widget.php ADDED
@@ -0,0 +1,252 @@
1
+ <?php
2
+
3
+ class dc_jqaccordion_widget extends WP_Widget {
4
+ /** constructor */
5
+ function dc_jqaccordion_widget() {
6
+
7
+ $name = 'jQuery Accordion Menu';
8
+ $desc = 'Vertical Accordion From Custom Menus';
9
+ $id_base = 'dc_jqaccordion_widget';
10
+ $css_class = '';
11
+ $alt_option = 'widget_dcjq_accordion_navigation';
12
+
13
+ $widget_ops = array(
14
+ 'classname' => $css_class,
15
+ 'description' => __( $desc, 'dcjq-accordion' ),
16
+ );
17
+ parent::WP_Widget( 'nav_menu', __('Custom Menu'), $widget_ops );
18
+
19
+ $this->WP_Widget($id_base, __($name, 'dcjqaccordion'), $widget_ops);
20
+ $this->alt_option_name = $alt_option;
21
+
22
+ add_action( 'wp_head', array(&$this, 'styles'), 10, 1 );
23
+ add_action( 'wp_footer', array(&$this, 'footer'), 10, 1 );
24
+
25
+ $this->defaults = array(
26
+ 'title' => '',
27
+ 'classParent' => 'dcjq-parent',
28
+ 'classActive' => 'active',
29
+ 'autoClose' => 'on',
30
+ 'saveState' => 'on',
31
+ 'disableLink' => 'on',
32
+ 'speed' => 'slow',
33
+ 'skin' => 'demo.css'
34
+ );
35
+ }
36
+
37
+ function widget($args, $instance) {
38
+ extract( $args );
39
+ // Get menu
40
+
41
+ if(! isset($instance['speed']) ){ $instance['speed'] = 'slow'; }
42
+
43
+ $widget_options = wp_parse_args( $instance, $this->defaults );
44
+ extract( $widget_options, EXTR_SKIP );
45
+
46
+ $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
47
+
48
+ if ( !$nav_menu )
49
+ return;
50
+
51
+ $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
52
+
53
+
54
+
55
+ echo $args['before_widget'];
56
+
57
+
58
+
59
+
60
+ if ( !empty($instance['title']) )
61
+ echo $args['before_title'] . $instance['title'] . $args['after_title'];
62
+
63
+ ?>
64
+
65
+ <div class="dcjq-accordion" id="<?php echo $this->id; ?>">
66
+
67
+ <?php
68
+
69
+
70
+
71
+ wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu, 'container' => false ) );
72
+
73
+ ?>
74
+
75
+ </div>
76
+ <?php
77
+
78
+ echo $args['after_widget'];
79
+ }
80
+
81
+ /** @see WP_Widget::update */
82
+ function update( $new_instance, $old_instance ) {
83
+ $instance['title'] = strip_tags( stripslashes($new_instance['title']) );
84
+ $instance['nav_menu'] = (int) $new_instance['nav_menu'];
85
+ $instance['autoClose'] = $new_instance['autoClose'];
86
+ $instance['saveState'] = $new_instance['saveState'];
87
+ $instance['disableLink'] = $new_instance['disableLink'];
88
+ $instance['classParent'] = strip_tags( stripslashes($new_instance['classParent']) );
89
+ $instance['classActive'] = strip_tags( stripslashes($new_instance['classActive']) );
90
+ $instance['event'] = strip_tags( stripslashes($new_instance['event']) );
91
+ $instance['skin'] = $new_instance['skin'];
92
+ $instance['speed'] = $new_instance['speed'];
93
+
94
+ return $instance;
95
+ }
96
+
97
+ /** @see WP_Widget::form */
98
+ function form($instance) {
99
+ $title = isset( $instance['title'] ) ? $instance['title'] : '';
100
+ $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
101
+ if(! isset($instance['autoClose']) ){ $instance['autoClose'] = 'false'; }
102
+ if(! isset($instance['saveState']) ){ $instance['saveState'] = 'false'; }
103
+ if(! isset($instance['disableLink']) ){ $instance['disableLink'] = 'false'; }
104
+ $classParent = isset( $instance['classParent'] ) ? $instance['classParent'] : '';
105
+ $classActive = isset( $instance['classActive'] ) ? $instance['classActive'] : '';
106
+ $event = isset( $instance['event'] ) ? $instance['event'] : '';
107
+ $skin = isset( $instance['skin'] ) ? $instance['skin'] : '';
108
+ $speed = isset( $instance['speed'] ) ? $instance['speed'] : '';
109
+
110
+ $widget_options = wp_parse_args( $instance, $this->defaults );
111
+ extract( $widget_options, EXTR_SKIP );
112
+
113
+ // Get menus
114
+ $menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
115
+
116
+ // If no menus exists, direct the user to go and create some.
117
+ if ( !$menus ) {
118
+ echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
119
+ return;
120
+ }
121
+ ?>
122
+ <p>
123
+ <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
124
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
125
+ </p>
126
+ <p>
127
+ <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
128
+ <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
129
+ <?php
130
+ foreach ( $menus as $menu ) {
131
+ $selected = $nav_menu == $menu->term_id ? ' selected="selected"' : '';
132
+ echo '<option'. $selected .' value="'. $menu->term_id .'">'. $menu->name .'</option>';
133
+ }
134
+ ?>
135
+ </select>
136
+ </p>
137
+ <p>
138
+ <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('autoClose'); ?>" name="<?php echo $this->get_field_name('autoClose'); ?>"<?php checked( $autoClose, 'true' ); ?> />
139
+ <label for="<?php echo $this->get_field_id('autoClose'); ?>"><?php _e( 'Auto Close Open Menus' , 'dcjq-accordion' ); ?></label><br />
140
+
141
+ <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('saveState'); ?>" name="<?php echo $this->get_field_name('saveState'); ?>"<?php checked( $saveState, 'true'); ?> />
142
+ <label for="<?php echo $this->get_field_id('saveState'); ?>"><?php _e( 'Save Menu State (uses cookies)' , 'dcjq-accordion' ); ?></label><br />
143
+
144
+ <input type="checkbox" value="true" class="checkbox" id="<?php echo $this->get_field_id('disableLink'); ?>" name="<?php echo $this->get_field_name('disableLink'); ?>"<?php checked( $disableLink, 'true' ); ?> />
145
+ <label for="<?php echo $this->get_field_id('disableLink'); ?>"><?php _e( 'Disable Parent Links' , 'dcjq-accordion' ); ?></label><br />
146
+ </p>
147
+
148
+ <p><label for="<?php echo $this->get_field_id('skin'); ?>"><?php _e('Skin:', 'dcjq-accordion'); ?> <?php
149
+
150
+ // http://www.codewalkers.com/c/a/File-Manipulation-Code/List-files-in-a-directory-no-subdirectories/
151
+
152
+ echo "<select name='".$this->get_field_name('skin')."' id='".$this->get_field_id('skin')."'>";
153
+ echo "<option value='no-theme' ".selected( $skin, 'no-theme', false).">No theme</option>";
154
+
155
+ //The path to the style directory
156
+ $dirpath = plugin_dir_path(__FILE__) . 'skins/';
157
+
158
+ $dh = opendir($dirpath);
159
+ while (false !== ($file = readdir($dh))) {
160
+ //Don't list subdirectories
161
+ if (!is_dir("$dirpath/$file")) {
162
+ //Remove file extension
163
+ echo "<option value='$file' ".selected($skin, $file, false).">" . htmlspecialchars(ucfirst(preg_replace('/\..*#x2F;', '', $file))) . '</option>';
164
+ }
165
+ }
166
+ closedir($dh);
167
+ echo "</select>"; ?> </label><br />
168
+ </p>
169
+
170
+ <p><label for="<?php echo $this->get_field_id('speed'); ?>"><?php _e('Animation Speed:', 'dcjq-accordion'); ?>
171
+ <select name="<?php echo $this->get_field_name('speed'); ?>" id="<?php echo $this->get_field_id('speed'); ?>" >
172
+ <option value='slow' <?php selected( $speed, 'slow'); ?> >Slow</option>
173
+ <option value='normal' <?php selected( $speed, 'normal'); ?> >Normal</option>
174
+ <option value='fast' <?php selected( $speed, 'fast'); ?> >Fast</option>
175
+ </select>
176
+ </label>
177
+ </p>
178
+ <input type="hidden" id="<?php echo $this->get_field_id('event'); ?>" name="<?php echo $this->get_field_name('event'); ?>" value="click" />
179
+ <input type="hidden" id="<?php echo $this->get_field_id('classParent'); ?>" name="<?php echo $this->get_field_name('classParent'); ?>" value="dcjq-parent" />
180
+ <input type="hidden" id="<?php echo $this->get_field_id('classActive'); ?>" name="<?php echo $this->get_field_name('classActive'); ?>" value="active" />
181
+ <div class="widget-control-actions alignright">
182
+ <p><small><a href="http://www.designchemical.com/blog/index.php/wordpress-plugins/wordpress-plugin-jquery-vertical-accordion-menu-widget/"><?php esc_attr_e('Visit plugin site', 'dcjq-accordion'); ?></a></small></p>
183
+ </div>
184
+
185
+ <?php
186
+ }
187
+
188
+ /** Adds ID based dropdown menu skin to the header. */
189
+ function styles(){
190
+
191
+ if(!is_admin()){
192
+
193
+
194
+ $all_widgets = $this->get_settings();
195
+
196
+ foreach ($all_widgets as $key => $wpdcjqaccordion){
197
+ $widget_id = $this->id_base . '-' . $key;
198
+ if(is_active_widget(false, $widget_id, $this->id_base)){
199
+
200
+ $skin = $wpdcjqaccordion['skin'];
201
+ if('no-theme'!=$skin){
202
+ echo "\n\t<link rel=\"stylesheet\" href=\"".dc_jqaccordion::get_plugin_directory()."/skin.php?widget_id=".$key."&skin=".strtolower($skin)."\" type=\"text/css\" media=\"screen\" />";
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ /** Adds ID based activation script to the footer */
210
+ function footer(){
211
+
212
+ if(!is_admin()){
213
+
214
+ $all_widgets = $this->get_settings();
215
+
216
+ foreach ($all_widgets as $key => $wpdcjqaccordion){
217
+
218
+ $widget_id = $this->id_base . '-' . $key;
219
+
220
+ if(is_active_widget(false, $widget_id, $this->id_base)){
221
+
222
+ $autoClose = $wpdcjqaccordion['autoClose'];
223
+ if($autoClose == ''){$autoClose = 'false';};
224
+
225
+ $saveState = $wpdcjqaccordion['saveState'];
226
+ if($saveState == ''){$saveState = 'false';};
227
+
228
+ $disableLink = $wpdcjqaccordion['disableLink'];
229
+ if($disableLink == ''){$disableLink = 'false';};
230
+
231
+ ?>
232
+ <script type="text/javascript">
233
+ jQuery(document).ready(function($) {
234
+ jQuery('#<?php echo $widget_id; ?> .menu').dcAccordion({
235
+ classParent: '<?php echo $wpdcjqaccordion['classParent']; ?>',
236
+ classActive: '<?php echo $wpdcjqaccordion['classActive']; ?>',
237
+ event: '<?php echo $wpdcjqaccordion['event']; ?>',
238
+ autoClose: <?php echo $autoClose; ?>,
239
+ saveState: <?php echo $saveState; ?>,
240
+ disableLink: <?php echo $disableLink; ?>,
241
+ speed: '<?php echo $wpdcjqaccordion['speed']; ?>'
242
+ });
243
+ });
244
+ </script>
245
+
246
+ <?php
247
+
248
+ }
249
+ }
250
+ }
251
+ }
252
+ } // class dc_jqaccordion_widget
js/jquery.cookie.js ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Cookie plugin
3
+ *
4
+ * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
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
+ /**
12
+ * Create a cookie with the given name and value and other optional parameters.
13
+ *
14
+ * @example $.cookie('the_cookie', 'the_value');
15
+ * @desc Set the value of a cookie.
16
+ * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
17
+ * @desc Create a cookie with all available options.
18
+ * @example $.cookie('the_cookie', 'the_value');
19
+ * @desc Create a session cookie.
20
+ * @example $.cookie('the_cookie', null);
21
+ * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
22
+ * used when the cookie was set.
23
+ *
24
+ * @param String name The name of the cookie.
25
+ * @param String value The value of the cookie.
26
+ * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
27
+ * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
28
+ * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
29
+ * If set to null or omitted, the cookie will be a session cookie and will not be retained
30
+ * when the the browser exits.
31
+ * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
32
+ * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
33
+ * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
34
+ * require a secure protocol (like HTTPS).
35
+ * @type undefined
36
+ *
37
+ * @name $.cookie
38
+ * @cat Plugins/Cookie
39
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
40
+ */
41
+
42
+ /**
43
+ * Get the value of a cookie with the given name.
44
+ *
45
+ * @example $.cookie('the_cookie');
46
+ * @desc Get the value of a cookie.
47
+ *
48
+ * @param String name The name of the cookie.
49
+ * @return The value of the cookie.
50
+ * @type String
51
+ *
52
+ * @name $.cookie
53
+ * @cat Plugins/Cookie
54
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
55
+ */
56
+ jQuery.cookie = function(name, value, options) {
57
+ if (typeof value != 'undefined') { // name and value given, set cookie
58
+ options = options || {};
59
+ if (value === null) {
60
+ value = '';
61
+ options.expires = -1;
62
+ }
63
+ var expires = '';
64
+ if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
65
+ var date;
66
+ if (typeof options.expires == 'number') {
67
+ date = new Date();
68
+ date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
69
+ } else {
70
+ date = options.expires;
71
+ }
72
+ expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
73
+ }
74
+ // CAUTION: Needed to parenthesize options.path and options.domain
75
+ // in the following expressions, otherwise they evaluate to undefined
76
+ // in the packed version for some reason...
77
+ var path = options.path ? '; path=' + (options.path) : '';
78
+ var domain = options.domain ? '; domain=' + (options.domain) : '';
79
+ var secure = options.secure ? '; secure' : '';
80
+ document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
81
+ } else { // only name given, get cookie
82
+ var cookieValue = null;
83
+ if (document.cookie && document.cookie != '') {
84
+ var cookies = document.cookie.split(';');
85
+ for (var i = 0; i < cookies.length; i++) {
86
+ var cookie = jQuery.trim(cookies[i]);
87
+ // Does this cookie string begin with the name we want?
88
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
89
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
90
+ break;
91
+ }
92
+ }
93
+ }
94
+ return cookieValue;
95
+ }
96
+ };
js/jquery.dcjqaccordion.js ADDED
@@ -0,0 +1,122 @@
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 function for the plugin and 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
+ autoArrow : true,
21
+ canClose : true,
22
+ autoClose : true,
23
+ speed : 'slow',
24
+ saveState : true,
25
+ activate : 'click',
26
+ disableLink : true
27
+ };
28
+
29
+ //call in the default otions
30
+ var options = $.extend(defaults, options);
31
+ var $dcAccordionItem = this;
32
+
33
+ //act upon the element that is passed into the design
34
+ return $dcAccordionItem.each(function(options) {
35
+
36
+ setUpAccordion();
37
+
38
+ if(defaults.saveState == true){
39
+ var cookieId = $(this).parent().attr('id');
40
+ checkCookie();
41
+ }
42
+ resetAccordion();
43
+
44
+ $('li a',$dcAccordionItem).click(function(e){
45
+
46
+ var $activeLi = $(this).parent('li');
47
+ var $parentsLi = $activeLi.parents('li');
48
+ var $parentsUl = $activeLi.parents('ul');
49
+
50
+ // Prevent browsing to link if has child links
51
+ if(defaults.disableLink == true){
52
+ if($(this).next('ul').length >0){
53
+ e.preventDefault();
54
+ }
55
+ }
56
+
57
+ // Auto close sibling menus
58
+ if(defaults.autoClose == true){
59
+ $('ul',$dcAccordionItem).not($parentsUl).slideUp(defaults.speed);
60
+ // Reset active links
61
+ $('a',$dcAccordionItem).removeClass(defaults.classActive);
62
+ $('> a',$parentsLi).addClass(defaults.classActive);
63
+ }
64
+
65
+ if ($('> ul',$activeLi).is(':visible')){
66
+ $('ul',$activeLi).slideUp(defaults.speed);
67
+ $('a',$activeLi).removeClass(defaults.classActive);
68
+ } else {
69
+ $(this).next().slideToggle(defaults.speed);
70
+ $('> a',$activeLi).addClass(defaults.classActive);
71
+ }
72
+
73
+ // Write cookie if save state is on
74
+ if(defaults.saveState == true){
75
+ var activeIndex = [];
76
+ // Create array of active items index value
77
+ $('li a.active',$dcAccordionItem).each(function(i){
78
+ var $arrayItem = $(this).parent('li');
79
+ var itemIndex = $('li',$dcAccordionItem).index($arrayItem);
80
+ activeIndex.push(itemIndex);
81
+ });
82
+ // Store in cookie
83
+ $.cookie(cookieId, activeIndex);
84
+ }
85
+ });
86
+
87
+ // Set up accordion
88
+ function setUpAccordion(){
89
+ $arrow = '<span class="dcjq-icon"></span>';
90
+ $('li',$dcAccordionItem).each(function(){
91
+ var classParentLi = defaults.classParent+'-li';
92
+ if($('> ul',this).length > 0){
93
+ $(this).addClass(classParentLi);
94
+ $('> a',this).addClass(defaults.classParent).append($arrow);
95
+ }
96
+ });
97
+ }
98
+
99
+ // Retrieve cookie value and set active items
100
+ function checkCookie(){
101
+ var cookieVal = $.cookie(cookieId);
102
+ if(cookieVal != null){
103
+ // create array from cookie string
104
+ var activeArray = cookieVal.split(',');
105
+ $.each(activeArray, function(index,value){
106
+ var $cookieLi = $('li:eq('+value+')',$dcAccordionItem);
107
+ $('> a',$cookieLi).addClass(defaults.classActive);
108
+ var $parentsLi = $cookieLi.parents('li');
109
+ $('> a',$parentsLi).addClass(defaults.classActive);
110
+ });
111
+ }
112
+ }
113
+
114
+ // Reset accordion using active links
115
+ function resetAccordion(){
116
+ $('ul',$dcAccordionItem).hide();
117
+ $allActiveLi = $('a.'+defaults.classActive,$dcAccordionItem);
118
+ $allActiveLi.next().show();
119
+ }
120
+ });
121
+ };
122
+ })(jQuery);
readme.txt ADDED
@@ -0,0 +1,52 @@
1
+ === JQuery Accordion Menu Widget ===
2
+ Contributors: Remix4
3
+ Donate link: http://www.designchemical.com
4
+ Tags: jquery, dropdown, menu, vertical accordion, animated, css, navigation
5
+ Requires at least: 3.0
6
+ Tested up to: 3.05
7
+ Stable tag: 1.0
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. Uses the jquery cookie plugin by [Klaus Hartl](http://www.stilbuero.de).
14
+
15
+ = Menu Options =
16
+
17
+ The widget has several parameters that can be configured to help cutomise the vertical accordion menu:
18
+
19
+ * Auto-close open menus - If checked this will allow only one menu item to be expanded at any time. Clicking on a new menu item will automatically close the previous one.
20
+ * Save menu state (uses cookies) - Selecting this will allow the menu to remember its open/close state when browsing to a new page.
21
+ * 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.
22
+ * Skin - Several sample skins are available to give examples of css that can be used to style your accordion menu
23
+ * Animation Speed - The speed at which the menu will open/close
24
+
25
+ [__See demo__](http://www.designchemical.com/lab/wordpress/demo-wordpress-vertical-accordion-menu-plugin/)
26
+
27
+ == Installation ==
28
+
29
+ 1. Upload the plugin through `Plugins > Add New > Upload` interface or upload `jquery-vertical-accordion-menu` folder to the `/wp-content/plugins/` directory
30
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
31
+ 3. In the widgets section, select the jQuery accordion menu widget and add to one of your widget areas
32
+ 4. Select one of the WP menus, set the required settings and save your widget
33
+
34
+ == Frequently Asked Questions ==
35
+
36
+ = The menu appears on the page but does not work. Why? =
37
+
38
+ One main reason for this is that the plugin adds the required jQuery code to your template footer. Make sure that your template files contain the wp_footer() function.
39
+
40
+ Another likely cause is due to other non-functioning plugins, which may have errors and cause the plugin javascript to not load. Remove any unwanted plugins and try again. Checking with Firebug will show where these error are occuring.
41
+
42
+ == Screenshots ==
43
+
44
+ 1. Widget in edit mode
45
+ 2. Sample vertical accordion menus
46
+
47
+ == Changelog ==
48
+
49
+ = 1.0 =
50
+ * First release
51
+
52
+ == Upgrade Notice ==
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
skin.php ADDED
@@ -0,0 +1,14 @@
1
+ <?php
2
+
3
+ header("Content-type: text/css");
4
+
5
+ $id = $_GET['widget_id'];
6
+ $skin = $_GET['skin'];
7
+
8
+ if(!empty($skin)){
9
+ $css = file_get_contents('./skins/' . $skin );
10
+ $widget_skin = preg_replace('/%ID%/',$id, $css);
11
+ echo $widget_skin;
12
+ }
13
+
14
+ ?>
skins/black.css ADDED
@@ -0,0 +1,8 @@
1
+ #dc_jqaccordion_widget-%ID%{font: bold 13px Arial, sans-serif;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {padding: 10px 10px 10px 28px; background: #000 url(skins/images/bg_graphite.png) repeat-x 0 0; text-decoration:none; display: block; color: #fff; font-weight: normal;border-bottom: 1px solid #fff;}
4
+ #dc_jqaccordion_widget-%ID% ul ul a {background: #343434;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent, #dc_jqaccordion_widget-%ID% ul a.dcjq-parent:hover {background: #000 url(skins/images/graphite_arrow_right.png) no-repeat 0 0; font-weight: bold; color: #fff;}
6
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {background: #000 url(skins/images/graphite_arrow_down.png) no-repeat 0 0;}
7
+ #dc_jqaccordion_widget-%ID% ul a:hover {background: #121212;}
8
+ #dc_jqaccordion_widget-%ID% ul a:active{}
skins/blue.css ADDED
@@ -0,0 +1,8 @@
1
+ #dc_jqaccordion_widget-%ID%{ border-top: 1px solid #013d6c; border-right: 1px solid #013d6c; border-left: 1px solid #013d6c;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {padding: 10px 10px 10px 15px; background: #0D5995; text-decoration:none; display: block; color: #fff; border-bottom: 1px solid #013d6c; border-top: 1px solid #4695d3;}
4
+ #dc_jqaccordion_widget-%ID% ul ul a {padding: 10px 10px 10px 25px;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent, #dc_jqaccordion_widget-%ID% ul a.dcjq-parent:hover {padding: 10px 10px 10px 15px;}
6
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {background: #0D5995 url(skins/images/checkers.png) repeat 0 0;}
7
+ #dc_jqaccordion_widget-%ID% ul a:hover {background: #05477c;}
8
+ #dc_jqaccordion_widget-%ID% ul a:active{}
skins/clean.css ADDED
@@ -0,0 +1,8 @@
1
+ #dc_jqaccordion_widget-%ID%{border-top: 1px solid #cfcfcf; border-right: 1px solid #cfcfcf; border-left: 1px solid #cfcfcf;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {padding: 10px 15px; background: #fff url(skins/images/bg_clean.png) repeat-x top center; font-weight: bold; text-transform: uppercase; text-decoration:none; display: block; color: #222; border-bottom: 1px solid #cfcfcf;}
4
+ #dc_jqaccordion_widget-%ID% ul ul a {padding: 10px 10px 10px 25px; background: #fff; font-weight: normal; text-transform: capitalize;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent {padding: 10px 15px; background: #fff url(skins/images/bg_clean.png) repeat-x top center; font-weight: bold; text-transform: uppercase;}
6
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent:hover {background: #fff url(skins/images/bg_clean_on.png) repeat-x top center;}
7
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {}
8
+ #dc_jqaccordion_widget-%ID% ul a:hover {background: #ececec; color: #990000;}
skins/demo.css ADDED
@@ -0,0 +1,8 @@
1
+ #dc_jqaccordion_widget-%ID%{background-color: #fff; border-top: 1px solid #ccc; border-right: 1px solid #ccc; border-left: 1px solid #ccc;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {background-repeat: no-repeat; background-position: 10px center; border-top: 1px solid #fff; border-bottom: 1px solid #ccc; padding: 10px 10px 10px 32px; text-decoration:none; display: block; color: #222; font-weight: bold;}
4
+ #dc_jqaccordion_widget-%ID% ul ul a {font-weight: normal;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent {background-image: url(skins/images/plus_grey.png); font-weight: bold; background-color: #fff;}
6
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {background-image: url(skins/images/minus_grey.png); background-color: #f3f3f3;}
7
+ #dc_jqaccordion_widget-%ID% ul a:hover {color: #990000;}
8
+ #dc_jqaccordion_widget-%ID% ul a:active{}
skins/graphite.css ADDED
@@ -0,0 +1,10 @@
1
+ #dc_jqaccordion_widget-%ID%{font: bold 14px Arial, sans-serif; border-top: 1px solid #111; border-right: 1px solid #111; border-left: 1px solid #111;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {padding: 10px 10px 10px 50px; background: #000 url(skins/images/bg_black.png) repeat-x 0 -1px; text-decoration:none; display: block; color: #ddd; border-bottom: 1px solid #222; border-top: 1px solid #777; position: relative;}
4
+ #dc_jqaccordion_widget-%ID% ul ul a {background: #424549;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent, #dc_jqaccordion_widget-%ID% ul a.dcjq-parent:hover {background: #000 url(skins/images/bg_black.png) repeat-x 0 -1px;}
6
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {}
7
+ #dc_jqaccordion_widget-%ID% ul a .dcjq-icon {position: absolute; top: 0; left: 12px; width: 34px; height: 34px; background: url(skins/images/arrow_black_right.png) no-repeat 0 center;}
8
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active .dcjq-icon {background: url(skins/images/arrow_black_down.png) no-repeat 0 center;}
9
+ #dc_jqaccordion_widget-%ID% ul a:hover {background: #232323; color: #fff;}
10
+ #dc_jqaccordion_widget-%ID% ul a:active{}
skins/grey.css ADDED
@@ -0,0 +1,9 @@
1
+ #dc_jqaccordion_widget-%ID%{font: bold 14px Arial, sans-serif; border-top: 1px solid #ccc; border-right: 1px solid #ccc; border-left: 1px solid #ccc;}
2
+ #dc_jqaccordion_widget-%ID% ul, #dc_jqaccordion_widget-%ID% ul li {margin: 0; padding: 0; border: none;}
3
+ #dc_jqaccordion_widget-%ID% ul a {padding: 10px 10px 10px 50px; background: #ececec; text-decoration:none; display: block; color: #333; border-bottom: 1px solid #ccc; border-top: 1px solid #fff; position: relative; text-shadow: 1px 1px 1px #fff;}
4
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent, #dc_jqaccordion_widget-%ID% ul a.dcjq-parent:hover {background: #ececec url(skins/images/bg_grey.png) repeat-x 0 -1px;}
5
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active {}
6
+ #dc_jqaccordion_widget-%ID% ul a .dcjq-icon {position: absolute; top: 0; left: 12px; width: 34px; height: 34px; background: url(skins/images/arrow_grey_right.png) no-repeat 0 center;}
7
+ #dc_jqaccordion_widget-%ID% ul a.dcjq-parent.active .dcjq-icon {background: url(skins/images/arrow_grey_down.png) no-repeat 0 center;}
8
+ #dc_jqaccordion_widget-%ID% ul a:hover {background: #fff; color: #990000;}
9
+ #dc_jqaccordion_widget-%ID% ul a:active{}
skins/images/arr_black.gif ADDED
Binary file
skins/images/arr_white.gif ADDED
Binary file
skins/images/arrow.png ADDED
Binary file
skins/images/arrow1.png ADDED
Binary file
skins/images/arrow2.gif ADDED
Binary file
skins/images/arrow_black_down.png ADDED
Binary file
skins/images/arrow_black_right.png ADDED
Binary file
skins/images/arrow_grey.png ADDED
Binary file
skins/images/arrow_grey_down.png ADDED
Binary file
skins/images/arrow_grey_down_x.png ADDED
Binary file
skins/images/arrow_grey_right.png ADDED
Binary file
skins/images/arrow_grey_right_x.png ADDED
Binary file
skins/images/arrow_red_down.png ADDED
Binary file
skins/images/arrow_red_right.png ADDED
Binary file
skins/images/arrow_right.png ADDED
Binary file
skins/images/arrv_white.gif ADDED
Binary file
skins/images/bcgWepButton.gif ADDED
Binary file
skins/images/bg_black.png ADDED
Binary file
skins/images/bg_clean.png ADDED
Binary file
skins/images/bg_clean_on.png ADDED
Binary file
skins/images/bg_graphite.png ADDED
Binary file
skins/images/bg_graphite_arrow.png ADDED
Binary file
skins/images/bg_green_blue.png ADDED
Binary file
skins/images/bg_grey.png ADDED
Binary file
skins/images/bullet.png ADDED
Binary file
skins/images/bullet_active.png ADDED
Binary file
skins/images/checkers.png ADDED
Binary file
skins/images/checkers_x.png ADDED
Binary file
skins/images/graphite_arrow_down.png ADDED
Binary file
skins/images/graphite_arrow_right.png ADDED
Binary file
skins/images/minus_grey.png ADDED
Binary file
skins/images/minus_red.png ADDED
Binary file
skins/images/opacity.png ADDED
Binary file
skins/images/plus_grey.png ADDED
Binary file
skins/images/plus_red.png ADDED
Binary file
skins/images/stripes.png ADDED
Binary file