/* * jQuery jacc * Version 1 * Copyright (c) 2014 Konrad Rolof (http://www.konrad-rolof.de) * requires jQuery * build under jQuery 1.10.1 * Dual licensed under the MIT and GPL (http://www.gnu.org/licenses/gpl.txt) licenses. */ (function(e){e.fn.jacc=function(t){var n=e.extend({},e.fn.jacc.defaults,t);n.elm=e(this);e.fn.jacc.startup(n);n.elm.children(n.toggler).click(function(t){t.preventDefault();n._this=e(this);n.startOption=false;e.fn.jacc.fxClose(n);e.fn.jacc.fxOpen(n)});return this};e.fn.jacc.fxOpen=function(t){if(t._this.next(t.togglerBox).is(":hidden")===true){t._this.addClass("current");t._this.next(t.togglerBox).stop().addClass("current").slideDown({duration:t.fxSpeed,easing:t.easingIn,complete:function(){if(typeof t.slideComplete=="function"){t.slideComplete()}if(t.focusSlide===true&&t.startOption===false){e("html, body").animate({scrollTop:t._this.offset().top+t.focusOffset},t.focusFxSpeed)}}})}};e.fn.jacc.fxClose=function(e){if(typeof e.onSlideUp=="function"){e.onSlideUp()}e.elm.children(e.toggler).removeClass("current");e.elm.children(e.togglerBox).removeClass("current").slideUp(e.fxSpeed,e.easingOut)};e.fn.jacc.startup=function(t){t.elm.children(t.togglerBox).hide();t._hash=window.location.hash;console.log(t._hash);if(t._hash.match(/^#topic:/)){t._hash=t._hash.replace(/#topic:/,"");if(t._hash!==""){t._this=t.elm.children("#"+t._hash);t.startOption=false;e.fn.jacc.fxOpen(t)}}else if(t.elm.find(t._hash).length!==0){t._this=e(t._hash).closest(t.togglerBox).prev(t.toggler);t.startOption=false;e.fn.jacc.fxOpen(t)}else if(t.openFirst===true){t._this=t.elm.children(t.toggler).eq(0);t.startOption=true;e.fn.jacc.fxOpen(t)}};e.fn.jacc.defaults={toggler:".toggler",togglerBox:".togglerBox",openFirst:false,fxSpeed:500,easingIn:"",easingOut:"",focusSlide:false,focusOffset:-10,focusFxSpeed:500}}(jQuery));