Aha, one of my favourite boolean-type if/else thingies ;)
Thanks once more, Josh - this not only works faster, it does
unexpectedly clever stuff :))

At some point I will have to do some serious optimisation on this site
- it leaks like a sub-prime mortgage investor ;) For now, though, I'm
loving all the jQuery gorgeousness!

Cheers :)

On Apr 24, 5:48 pm, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> Cool, glad it worked!  That's a nice-looking site.
>
> One thing, I forgot to use my own optimization:
>
> var zmax = 0;
>
> $( '.draggable' ).click( function () {
>        $( this ).siblings( '.draggable' ).each(function() {
>              var cur =  $( this ).css( 'zIndex');
>               zmax = cur > zmax ? cur : zmax;   // use 'cur' here instead of 
> $( this ).css( 'zIndex')
>      });
>      $( this ).css( 'zIndex', zmax+1 );
>  });
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "jQuery (English)" <jquery-en@googlegroups.com>
> Sent: Wednesday, April 23, 2008 8:23 PM
> Subject: [jQuery] Re: Can you improve my Bring-to-Front code?
>
> > Wow, brilliant, Josh!  :D
>
> > It was missing an extra
> > });
> > at the end, but that's it afaik.
>
> > If you want play with it, it's here (development page; only the first
> > half-dozen are real divs at 
> > present)http://vanilla-spa.homeholistics.com/products.php
>
> > Nice one :)
>
> > On Apr 24, 1:20 am, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> >> Give this a try.  It will set the clicked div to the highest current 
> >> z-index
> >> plus 1, without disturbing the other divs (untested):
>
> >> var zmax = 0;
>
> >> $( '.draggable' ).click( function () {
> >>       $( this ).siblings( '.draggable' ).each(function() {
> >>             var cur =  $( this ).css( 'zIndex');
> >>              zmax = cur > zmax ? $( this ).css( 'zIndex') : zmax;
> >>     });
> >>     $( this ).css( 'zIndex', zmax+1 );
>
> >> });
> >> ----- Original Message -----
> >> From: <[EMAIL PROTECTED]>
> >> To: "jQuery (English)" <jquery-en@googlegroups.com>
> >> Sent: Wednesday, April 23, 2008 4:22 PM
> >> Subject: [jQuery] Re: Can you improve my Bring-to-Front code?
>
> >> > Bother, I got Scite to fill in all the spaces & returns before
> >> > posting, too! Sorry the lines got mangled :/
>
> >> > On Apr 24, 12:18 am, "[EMAIL PROTECTED]"
> >> > <[EMAIL PROTECTED]> wrote:
> >> >> Hi :)
>
> >> >> Fed up trying to figure out why my wonderful drag layers don't work in
> >> >> IE, I decided to get on with some more pretty stuff :) As we have
> >> >> layers fading in & out, and draggable, I reckon users will expect that
> >> >> clicking on a partially visible layer will bring it to front - like in
> >> >> desktop windows.
>
> >> >> So - well, I partially achieved it ;) You can bring a couple of layers
> >> >> to front, but my snippet doesn't handle the changed order well so it
> >> >> can't bring a previously-promoted layer further forwards.
>
> >> >> I'm OK with it for now, but I thought this would be useful for lots of
> >> >> other jQuery users ... and, if your Javascript is better than mine
> >> >> (very likely!), perhaps you'll be kind enough to post back an improved
> >> >> version?
>
> >> >> Cheers!
> >> >> Cherry
>
> >> >> $( '.draggable' ).click( function () {
> >> >>         var i = 1; i++;
> >> >>                 otherZ = $
> >> >> ( this ).siblings( '.draggable' ).css( 'zIndex' );
> >> >>                 myZ = parseInt(otherZ) + i;
> >> >>                 $( this ).css( 'zIndex', myZ );
> >> >>                 reset;
> >> >>                 });

Reply via email to