if statement and passing click event
I got a pretty large function, one that could essentially be condensed (if you feel so inclined).
I would like to know how I can get my if statements inside the toggle functions working properly.
I have 4 functions and 2 of them are click functions for closing (display:none). I would like to pass a listener to the toggle funciton to listen for the $close.click()
The if statement in the toggle funcitons is not doing anything.
- <script type="text/javascript" >
- $(document).ready(function()
- {
- var $contactLink = $("#contactLink");
- var $contactBox = $("#contact-container");
- var $qrLink = $("#qrLink");
- var $qrBox = $("#qr-container");
- var $qrBack = $("#qrBack");
- var $contactBack = $("#contactBack");
- $contactBox.css("display","none");
- $qrBox.css("display","none");
- $contactLink.toggle(
- function()
- {
- if($contactBox.css("display","none")){
- $contactBox.css("display","inherit");
- alert('here');
- }
- $contactBox.css("display","inherit");
- $qrBox.css("display","none");
- $contactBox.animate({marginTop:'-=378px'},400);
- $("#footer").css("overflow","visible");
- $("#contact-form").css("visibility","visible");
-
- },
- function()
- {
- $contactBox.animate({marginTop:'0px'},400);
- $("#contact-form").css("visibility","hidden");
- $("#footer").css("overflow","hidden")
- });
- $qrLink.toggle(
- function()
- {
- if($qrBox.css("display","none")){
- $qrBox.css("display","inherit");
- }
- $qrBox.css("display","inherit");
- $contactBox.css("display","none");
- $qrBox.animate({marginTop:'-=378px'},400);
- $("#footer").css("overflow","visible");
- $("#contact-qr").css("visibility","visible");
- },
- function()
- {
- $qrBox.animate({marginTop:'0px'},400);
- $("#contact-qr").css("visibility","hidden");
- $("#footer").css("overflow","hidden")
- });
-
-
- $qrBack.click(
- function()
- {
- $qrBox.animate({marginTop:'0px'},400);
- $qrBox.css("display","none");
- return false;
- });
- $contactBack.click(
- function()
- {
- $contactBox.animate({marginTop:'0px'},400);
- $contactBox.css("display","none");
- return false;
- });
-
- });
- </script>