+++ /dev/null
-/*\r
- * Accordion 1.5 - jQuery menu widget\r
- *\r
- * Copyright (c) 2007 Jörn Zaefferer, Frank Marcia\r
- *\r
- * http://bassistance.de/jquery-plugins/jquery-plugin-accordion/\r
- *\r
- * Dual licensed under the MIT and GPL licenses:\r
- * http://www.opensource.org/licenses/mit-license.php\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * Revision: $Id: jquery.accordion.js 2951 2007-08-28 07:21:13Z joern.zaefferer $\r
- *\r
- */\r
-\r
-(function($) {\r
-\r
-$.ui = $.ui || {}\r
-\r
-$.ui.accordion = {};\r
-$.extend($.ui.accordion, {\r
- defaults: {\r
- selectedClass: "selected",\r
- alwaysOpen: true,\r
- animated: 'slide',\r
- event: "click",\r
- header: "a"\r
- },\r
- animations: {\r
- slide: function(settings, additions) {\r
- settings = $.extend({\r
- easing: "swing",\r
- duration: 300\r
- }, settings, additions);\r
- if ( !settings.toHide.size() ) {\r
- settings.toShow.animate({height: "show"}, {\r
- duration: settings.duration,\r
- easing: settings.easing,\r
- complete: settings.finished\r
- });\r
- return;\r
- }\r
- var hideHeight = settings.toHide.height(),\r
- showHeight = settings.toShow.height(),\r
- difference = showHeight / hideHeight;\r
- settings.toShow.css({ height: 0, overflow: 'hidden' }).show();\r
- settings.toHide.filter(":hidden").each(settings.finished).end().filter(":visible").animate({height:"hide"},{\r
- step: function(n){\r
- settings.toShow.height(Math.ceil( (hideHeight - (n)) * difference ));\r
- },\r
- duration: settings.duration,\r
- easing: settings.easing,\r
- complete: settings.finished\r
- });\r
- },\r
- bounceslide: function(settings) {\r
- this.slide(settings, {\r
- easing: settings.down ? "bounceout" : "swing",\r
- duration: settings.down ? 1000 : 200\r
- });\r
- },\r
- easeslide: function(settings) {\r
- this.slide(settings, {\r
- easing: "easeinout",\r
- duration: 700\r
- })\r
- }\r
- }\r
-});\r
-\r
-$.fn.extend({\r
- nextUntil: function(expr) {\r
- var match = [];\r
- \r
- // We need to figure out which elements to push onto the array\r
- this.each(function(){\r
- // Traverse through the sibling nodes\r
- for( var i = this.nextSibling; i; i = i.nextSibling ) {\r
- // Make sure that we're only dealing with elements\r
- if ( i.nodeType != 1 ) continue;\r
- \r
- // If we find a match then we need to stop\r
- if ( $.filter( expr, [i] ).r.length ) break;\r
- \r
- // Otherwise, add it on to the stack\r
- match.push( i );\r
- }\r
- });\r
- \r
- return this.pushStack( match );\r
- },\r
- // the plugin method itself\r
- accordion: function(settings) {\r
- if ( !this.length )\r
- return this;\r
- \r
- // setup configuration\r
- settings = $.extend({}, $.ui.accordion.defaults, settings);\r
- \r
- if ( settings.navigation ) {\r
- var current = this.find("a").filter(function() { return this.href == location.href; });\r
- if ( current.length ) {\r
- if ( current.filter(settings.header).length ) {\r
- settings.active = current;\r
- } else {\r
- settings.active = current.parent().parent().prev();\r
- current.addClass("current");\r
- }\r
- }\r
- }\r
- \r
- // calculate active if not specified, using the first header\r
- var container = this,\r
- headers = container.find(settings.header),\r
- active = findActive(settings.active),\r
- running = 0;\r
-\r
- if ( settings.fillSpace ) {\r
- var maxHeight = this.parent().height();\r
- headers.each(function() {\r
- maxHeight -= $(this).outerHeight();\r
- });\r
- var maxPadding = 0;\r
- headers.nextUntil(settings.header).each(function() {\r
- maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());\r
- }).height(maxHeight - maxPadding);\r
- } else if ( settings.autoheight ) {\r
- var maxHeight = 0;\r
- headers.nextUntil(settings.header).each(function() {\r
- maxHeight = Math.max(maxHeight, $(this).height());\r
- }).height(maxHeight);\r
- }\r
-\r
- headers\r
- .not(active || "")\r
- .nextUntil(settings.header)\r
- .hide();\r
- active.parent().andSelf().addClass(settings.selectedClass);\r
- \r
- \r
- function findActive(selector) {\r
- return selector != undefined\r
- ? typeof selector == "number"\r
- ? headers.filter(":eq(" + selector + ")")\r
- : headers.not(headers.not(selector))\r
- : selector === false\r
- ? $("<div>")\r
- : headers.filter(":eq(0)");\r
- }\r
- \r
- function toggle(toShow, toHide, data, clickedActive, down) {\r
- var finished = function(cancel) {\r
- running = cancel ? 0 : --running;\r
- if ( running )\r
- return;\r
- // trigger custom change event\r
- container.trigger("change", data);\r
- };\r
- \r
- // count elements to animate\r
- running = toHide.size() == 0 ? toShow.size() : toHide.size();\r
- \r
- if ( settings.animated ) {\r
- if ( !settings.alwaysOpen && clickedActive ) {\r
- toShow.slideToggle(settings.animated);\r
- finished(true);\r
- } else {\r
- $.ui.accordion.animations[settings.animated]({\r
- toShow: toShow,\r
- toHide: toHide,\r
- finished: finished,\r
- down: down\r
- });\r
- }\r
- } else {\r
- if ( !settings.alwaysOpen && clickedActive ) {\r
- toShow.toggle();\r
- } else {\r
- toHide.hide();\r
- toShow.show();\r
- }\r
- finished(true);\r
- }\r
- }\r
- \r
- function clickHandler(event) {\r
- // called only when using activate(false) to close all parts programmatically\r
- if ( !event.target && !settings.alwaysOpen ) {\r
- active.toggleClass(settings.selectedClass);\r
- var toHide = active.nextUntil(settings.header);\r
- var toShow = active = $([]);\r
- toggle( toShow, toHide );\r
- return;\r
- }\r
- // get the click target\r
- var clicked = $(event.target);\r
- \r
- // due to the event delegation model, we have to check if one\r
- // of the parent elements is our actual header, and find that\r
- if ( clicked.parents(settings.header).length )\r
- while ( !clicked.is(settings.header) )\r
- clicked = clicked.parent();\r
- \r
- var clickedActive = clicked[0] == active[0];\r
- \r
- // if animations are still active, or the active header is the target, ignore click\r
- if(running || (settings.alwaysOpen && clickedActive) || !clicked.is(settings.header))\r
- return;\r
-\r
- // switch classes\r
- active.parent().andSelf().toggleClass(settings.selectedClass);\r
- if ( !clickedActive ) {\r
- clicked.parent().andSelf().addClass(settings.selectedClass);\r
- }\r
-\r
- // find elements to show and hide\r
- var toShow = clicked.nextUntil(settings.header),\r
- toHide = active.nextUntil(settings.header),\r
- data = [clicked, active, toShow, toHide],\r
- down = headers.index( active[0] ) > headers.index( clicked[0] );\r
- \r
- active = clickedActive ? $([]) : clicked;\r
- toggle( toShow, toHide, data, clickedActive, down );\r
-\r
- return !toShow.length;\r
- };\r
- function activateHandler(event, index) {\r
- // IE manages to call activateHandler on normal clicks\r
- if ( arguments.length == 1 )\r
- return;\r
- // call clickHandler with custom event\r
- clickHandler({\r
- target: findActive(index)[0]\r
- });\r
- };\r
-\r
- return container\r
- .bind(settings.event, clickHandler)\r
- .bind("activate", activateHandler);\r
- },\r
- activate: function(index) {\r
- return this.trigger('activate', [index]);\r
- }\r
-});\r
-\r
-})(jQuery);
\ No newline at end of file