1/************************************************************************ 2* swMenuToggler v1.0 3* Show or hide one or more Objects on click. 4* Multiple selectors are possible. View selector-specification 5* of JQuery for syntax: http://docs.jquery.com/Selectors 6* 7* Author: Christian Koban/Manfred Wischin 8* Date: 25.05.2009 9* Copyright (c) 2009 Agentur Zeitpunkt (agentur-zeitpunkt.at) 10*======================================================================== 11************ 12 13*=> BUTTON: 14* Syntax: $.swMenuToggler.button("div", "button", "initState", "closeElms"); 15* div ... Object to toggle 16* button ... Object or button to click on 17* initState...Initial status of ->div (show||hide) 18* closeElms...Object(s) to close before toggling the current element 19* callback...Name of the function that is executed after hiding/showing animation (string) 20* 21* -> EXAMPLES: 22* $.swMenuToggler.button("#contA", "#TestButton1", "show"); 23* $.swMenuToggler.button("#contA, #contB", "#TestButton1, #TestButton2", "hide"); 24************************************************************************/ 25jQuery.swMenuToggler = { 26 27 button: function(target, elmButtons, initState, closeElms, counterElms, callback) { 28 29 $(target).wrap("<div></div>"); 30 $(target).each(function() { 31 $(this).css("height", $(this).height()+"px"); 32 if (initState == "hide") $(this).parent().hide(); 33 }); 34 //display flicker fix first shown, then hidden 35 //set style display=none in html first for hidden elements! 36 $(target).css("display","block"); 37 38 $(elmButtons).click(function() { 39 $(closeElms).each(function() { 40 $.swMenuToggler.animation($(this).parent(), "hide", callback); 41 }); 42 $(counterElms).each(function() { 43 44 $.swMenuToggler.animation($(this).parent(), "show"); 45 }); 46 47 var targetDisplay = $(target).parent().css("display"); 48 if (targetDisplay == "block") { 49 $.swMenuToggler.animation($(target).parent(), "hide", callback); 50 $.swMenuToggler.animation($(counterElms), "show"); 51 } else { 52 $.swMenuToggler.animation($(target).parent(), "show", callback); 53 $.swMenuToggler.animation($(counterElms), "hide"); 54 } 55 56 $(this).blur(); 57 return false; 58 }); 59 }, 60 61 animation: function (target, value, callback) { 62 63 if (value == "hide") { 64 $(target).animate({height: 'hide'}, 700, 'easeOutCubic', function(){ 65 if (typeof callback == 'function') { // make sure the callback is a function 66 callback.call(this); // brings the scope to the callback 67 } 68 }); 69 } else if (value == "show") { 70 $(target).animate({height: 'show'}, 700, 'easeOutCubic', function(){ 71 if (typeof callback == 'function') { // make sure the callback is a function 72 callback.call(this); // brings the scope to the callback 73 } 74 }); 75 } 76 77 } 78 79 80};
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.