By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,366 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,366 IT Pros & Developers. It's quick & easy.

jQuery show hide needs speed added for slideUp

P: 9
This function swaps images between a close & replay GIF. Line 12 has a speed of 1 second specified for the slideDown, but no speed specified for the slideUp so it is defaulting to normal. I tried adding if(!isDown) slideTimeout = setTimeout(toggleSlideboxes, 3000 : 1000); to line 21 but ended up with a syntax error.

Expand|Select|Wrap|Line Numbers
  1. jQuery.noConflict();
  2. jQuery(document).ready(function(){
  3.   var slideTimeout //timer
  4.      , sbTrigger = jQuery('#slidebartrigger') //convenience
  5.  
  6.      , sbFirstSlide = (document.cookie.indexOf('slidedToday') == -1) //check cookie for 'already seen today'
  7.      ;
  8.   function toggleSlideboxes(){
  9.     if(slideTimeout) clearTimeout(slideTimeout);
  10.     var isDown = sbTrigger.is('.closeSlide');
  11.  
  12.     jQuery('#slidebar')['slide' + (isDown ? 'Up' : 'Down')]((isDown ? 3000 : 1000), function(){
  13.  
  14.         if(sbFirstSlide){ //if 'first time today' then clear for click-to-replay
  15.           sbTrigger.removeClass('firstSlide');
  16.           sbFirstSlide = false;
  17.         }
  18.  
  19.         sbTrigger[(isDown ? 'remove' : 'add') + 'Class']('closeSlide').one('click', toggleSlideboxes);
  20.  
  21.         if(!isDown) slideTimeout = setTimeout(toggleSlideboxes, 3000);
  22.  
  23.       });
  24.  
  25.   }
  26.  
  27.  
this is the relevant CSS

Expand|Select|Wrap|Line Numbers
  1.  #slidebartrigger {
  2.  position:relative;
  3.  background:  url(http://cincinnati.com/test/img/replayBlack.gif) no-repeat right top;
  4.  display: block;
  5.  padding: 0;
  6.  height: 13px;
  7.  width:53px;
  8.  float:right;
  9.  margin-top:-14px;
  10.  z-index:2;
  11. }
  12. #slidebartrigger.closeSlide {
  13.  background:  url(http://cincinnati.com/test/img/closeBlack.gif) no-repeat right top;
  14.  display: block;
  15.  padding: 0px;
  16.  height: -14px;
  17. }
  18. /* this is purely so that replay.jpg isn't showing during during the initial slideDown...*/
  19. #slidebartrigger.firstSlide {
  20.  background: url("http://cincinnati.com/test/img/blank.gif") no-repeat right top;
  21.  display: block;
  22.  padding: 0px;
  23.  height: 14px;
  24. }  
Jul 1 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
The ?: notation is short for if/else, so you would need something like:
Expand|Select|Wrap|Line Numbers
  1. slideTimeout = setTimeout(toggleSlideboxes, (isDown ? 3000 : 1000));
Jul 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.