SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 61 of 61

Thread: Long shot but can anyone tell me how to accomplish this?

  1. #51
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Ok cool thanks for the explanation. I'll run with it then. Thanks for all your help. Could not of done it without you.

  2. #52
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,422
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    You're welcome
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  3. #53
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Morning,

    I managed to work out the ON/OFF color changing. Is this the best way to do that? http://www.websitecodetutorials.com/...ion-on-off.php

    Code css:
    #onoff li span {
    font-weight:bold;
    color:red;
    }

    $('#onoff').on("click", function() {
    if(toggleState) {
    $.cookie('animationStatus', 'on', { expires: 365, path: '/' });
    $("#onoff span").text("ON").css('color','green');
    startAnimation();
    } else {
    $.cookie('animationStatus', 'off', { expires: 365, path: '/' });
    $("#onoff span").text("OFF").css('color','red');
    stopAnimation();
    }
    toggleState = !toggleState;
    });

    var t1, t2;
    var timeouts = [];
    var w = $(document).width()
    var animationStatus = $.cookie('animationStatus');
    if (animationStatus == null || animationStatus == "on"){
    var toggleState = false;
    $("#onoff span").text("ON").css('color','green');
    startAnimation();
    } else{
    var toggleState = true;
    }
    });

  4. #54
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,422
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    Hi Eric,

    That's not bad and it will work just fine, but it's neater if you style the two button states with classes.

    Use the off state as your default class, as this is what users with JavaScript disabled will see:

    Code CSS:
    ul#onoff li span {color:red; font-weight:bold;}

    then define an "on" class:

    Code CSS:
    ul#onoff li span.on{color:green; font-weight:bold;}

    Once you have done this, you can add and remove the "on" class as necessary from within your JS.

    Code JavaScript:
    $('#onoff').on("click", function() {
      if(toggleState) {
        $.cookie('animationStatus', 'on', { expires: 365, path: '/' });
        $("#onoff span").text("ON").addClass("on");
        startAnimation();
      } else {
        $.cookie('animationStatus', 'off', { expires: 365, path: '/' });
        $("#onoff span").text("OFF").removeClass("on");
        stopAnimation();
      }
      toggleState = !toggleState;
    });

    and

    Code JavaScript:
    if (animationStatus == null || animationStatus == "on"){
      var toggleState = false;
      $("#onoff span").text("ON").addClass("on");
      startAnimation();  
    } else{
      var toggleState = true;
    }

    This has the advantage of being easier to extend with more/different styles in the future.

    HTH
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  5. #55
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Nice thats better. Thank you very much

  6. #56
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    ew-we! Finally done with that! http://www.websitecodetutorials.com/ Thats took a long time to get right. But now when its turned off older computers like mine are much happier. CPU usage goes back down to 2% instead of the 75% it was before when off. Thanks Pullo

  7. #57
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,422
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    So how about a link to my site in "Friends of mine"?


    Website is looking really cool now.
    I like it much better than the old design.
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  8. #58
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    So how about a link to my site in "Friends of mine"?


    Website is looking really cool now.
    I like it much better than the old design.
    Done!

  9. #59
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Can anyone figure out why in IE8 only when you click the animation to off the plane and the clouds disappear? Upon clicking a new page or reload they return. http://www.websitecodetutorials.com/.

    Thanks!

  10. #60
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,422
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    Hi Eric,

    The behaviour you describe doesn't happen for me.
    I still see the plane and clouds (tested on IE 10 in IE 8 emulation mode).

    Can anyone else reproduce this?
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  11. #61
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,351
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Huh. Well that's good I guess. Its happened to me since we put it together. I have just been ignoring it until now. Can one other person please look on their machine In ie8 and click th animation to OFF. Does the plane and clouds disappear or do they go to their default positions? Thanks.

    http://www.websitecodetutorials.com/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •