[jQuery] Re: [jQuery][ANN] jQuery.batch 1.0

2008-05-09 Thread Alexandre Plennevaux
Brandon, i believe this is a clever little plugin. I i understand correctly,
here is a real life example i experienced just 2 days ago  where i had such
markup:


li class=hello
img width=316 src=photos/sombra/Image_001.jpg/
img width=629 src=photos/sombra/Image_002.jpg/
img width=630 src=photos/sombra/Image_003.jpg/
img width=638 src=photos/sombra/Image_004.jpg/
img width=631 src=photos/sombra/Image_005.jpg/
img width=630 src=photos/sombra/Image_006.jpg/
img width=629 src=photos/sombra/Image_007.jpg/
/li


I needed to resize the LI element according to its children IMG element attr
width. What i did is loop through the jquery collection looking for the
width attribute value.

with your plugin it would be just

var newWidth = $('li.hello').attrs('width');
$('li.hello').animate({width: newWidth},slow);

Am i correct?




On Fri, May 9, 2008 at 5:40 AM, Brandon Aaron [EMAIL PROTECTED]
wrote:

 jQuery.batch is a small extension (951 bytes min'd, 520 bytes gzipped) to
 jQuery that allows you to batch the results of any jQuery method, plugin
 into an array. By default the batch plugin aliases the getter methods in
 jQuery by adding an 's' to the end (attrs, offsets, vals ...). You can also
 just call $(...).batch('methodName', arg1, arg*n).

 Download: http://plugins.jquery.com/project/batch
 Blog post: http://blog.brandonaaron.net/2008/05/08/jquery-batch/

 --
 Brandon Aaron




-- 
Alexandre Plennevaux
LAb[au]

http://www.lab-au.com


[jQuery] Re: [jQuery][ANN] jQuery.batch 1.0

2008-05-09 Thread Brandon Aaron
Close but in your example newWidths is an array of numbers. In your case
you'll want a way to extract the largest width from the array and then use
that value to animate the li width. Maybe something like this.

var width = $('li.hello img').widths().sort().revers()[0];
$('li.hello').animate({ width: width }, 'slow');

Thanks for a nice real-world example. :)

In testing this I found a bug and created a new release 1.0.1.

--
Brandon Aaron

On Fri, May 9, 2008 at 2:08 AM, Alexandre Plennevaux [EMAIL PROTECTED]
wrote:

 Brandon, i believe this is a clever little plugin. I i understand
 correctly, here is a real life example i experienced just 2 days ago  where
 i had such markup:


 li class=hello
 img width=316 src=photos/sombra/Image_001.jpg/
 img width=629 src=photos/sombra/Image_002.jpg/
 img width=630 src=photos/sombra/Image_003.jpg/
 img width=638 src=photos/sombra/Image_004.jpg/
 img width=631 src=photos/sombra/Image_005.jpg/
 img width=630 src=photos/sombra/Image_006.jpg/
 img width=629 src=photos/sombra/Image_007.jpg/
 /li


 I needed to resize the LI element according to its children IMG element
 attr width. What i did is loop through the jquery collection looking for the
 width attribute value.

 with your plugin it would be just

 var newWidth = $('li.hello').attrs('width');
 $('li.hello').animate({width: newWidth},slow);

 Am i correct?




 On Fri, May 9, 2008 at 5:40 AM, Brandon Aaron [EMAIL PROTECTED]
 wrote:

 jQuery.batch is a small extension (951 bytes min'd, 520 bytes gzipped) to
 jQuery that allows you to batch the results of any jQuery method, plugin
 into an array. By default the batch plugin aliases the getter methods in
 jQuery by adding an 's' to the end (attrs, offsets, vals ...). You can also
 just call $(...).batch('methodName', arg1, arg*n).

 Download: http://plugins.jquery.com/project/batch
 Blog post: http://blog.brandonaaron.net/2008/05/08/jquery-batch/

 --
 Brandon Aaron




 --
 Alexandre Plennevaux
 LAb[au]

 http://www.lab-au.com


[jQuery] Re: [jQuery][ANN] jQuery.batch 1.0

2008-05-09 Thread Brandon Aaron

I misspelled reverse in my code example... It should be:

var width = $('li.hello img').widths().sort().reverse()[0];
$('li.hello').animate({ width: width }, 'slow');

--
Brandon Aaron

On May 9, 9:47 am, Brandon Aaron [EMAIL PROTECTED] wrote:
 Close but in your example newWidths is an array of numbers. In your case
 you'll want a way to extract the largest width from the array and then use
 that value to animate the li width. Maybe something like this.

 var width = $('li.hello img').widths().sort().revers()[0];
 $('li.hello').animate({ width: width }, 'slow');

 Thanks for a nice real-world example. :)

 In testing this I found a bug and created a new release 1.0.1.

 --
 Brandon Aaron

 On Fri, May 9, 2008 at 2:08 AM, Alexandre Plennevaux [EMAIL PROTECTED]
 wrote:

  Brandon, i believe this is a clever little plugin. I i understand
  correctly, here is a real life example i experienced just 2 days ago  where
  i had such markup:

  li class=hello
  img width=316 src=photos/sombra/Image_001.jpg/
  img width=629 src=photos/sombra/Image_002.jpg/
  img width=630 src=photos/sombra/Image_003.jpg/
  img width=638 src=photos/sombra/Image_004.jpg/
  img width=631 src=photos/sombra/Image_005.jpg/
  img width=630 src=photos/sombra/Image_006.jpg/
  img width=629 src=photos/sombra/Image_007.jpg/
  /li

  I needed to resize the LI element according to its children IMG element
  attr width. What i did is loop through the jquery collection looking for the
  width attribute value.

  with your plugin it would be just

  var newWidth = $('li.hello').attrs('width');
  $('li.hello').animate({width: newWidth},slow);

  Am i correct?

  On Fri, May 9, 2008 at 5:40 AM, Brandon Aaron [EMAIL PROTECTED]
  wrote:

  jQuery.batch is a small extension (951 bytes min'd, 520 bytes gzipped) to
  jQuery that allows you to batch the results of any jQuery method, plugin
  into an array. By default the batch plugin aliases the getter methods in
  jQuery by adding an 's' to the end (attrs, offsets, vals ...). You can also
  just call $(...).batch('methodName', arg1, arg*n).

  Download:http://plugins.jquery.com/project/batch
  Blog post:http://blog.brandonaaron.net/2008/05/08/jquery-batch/

  --
  Brandon Aaron

  --
  Alexandre Plennevaux
  LAb[au]

 http://www.lab-au.com


[jQuery] Re: [jQuery][ANN] jQuery.batch 1.0

2008-05-09 Thread Alexandre Plennevaux
Hi Brandon!

in your blog post you ask for suggested features.

Frankly i'm stunned by how in one line you addition all the widths values
(although i didn't expect less from you). Personally, I had to loop through
the returned array in order to achieve that.
Wouldn't it be a nice feature to add some built-in manipulations to the
batch? i'm thinking 'sum' to add them all and return the result, 'concat',
'join:,'  to join each with a comma in-between, 'average' to get the average
of all integer values, etc. a kind of built-in callbacks if you like for
most common operations.

$('li.hello img').widths('sum');


thank you!

alexandre


On Fri, May 9, 2008 at 5:01 PM, Brandon Aaron [EMAIL PROTECTED]
wrote:


 I misspelled reverse in my code example... It should be:

 var width = $('li.hello img').widths().sort().reverse()[0];
 $('li.hello').animate({ width: width }, 'slow');

 --
 Brandon Aaron

 On May 9, 9:47 am, Brandon Aaron [EMAIL PROTECTED] wrote:
  Close but in your example newWidths is an array of numbers. In your case
  you'll want a way to extract the largest width from the array and then
 use
  that value to animate the li width. Maybe something like this.
 
  var width = $('li.hello img').widths().sort().revers()[0];
  $('li.hello').animate({ width: width }, 'slow');
 
  Thanks for a nice real-world example. :)
 
  In testing this I found a bug and created a new release 1.0.1.
 
  --
  Brandon Aaron
 
  On Fri, May 9, 2008 at 2:08 AM, Alexandre Plennevaux 
 [EMAIL PROTECTED]
  wrote:
 
   Brandon, i believe this is a clever little plugin. I i understand
   correctly, here is a real life example i experienced just 2 days ago
  where
   i had such markup:
 
   li class=hello
   img width=316
 src=photos/sombra/Image_001.jpg/
   img width=629
 src=photos/sombra/Image_002.jpg/
   img width=630
 src=photos/sombra/Image_003.jpg/
   img width=638
 src=photos/sombra/Image_004.jpg/
   img width=631
 src=photos/sombra/Image_005.jpg/
   img width=630
 src=photos/sombra/Image_006.jpg/
   img width=629
 src=photos/sombra/Image_007.jpg/
   /li
 
   I needed to resize the LI element according to its children IMG element
   attr width. What i did is loop through the jquery collection looking
 for the
   width attribute value.
 
   with your plugin it would be just
 
   var newWidth = $('li.hello').attrs('width');
   $('li.hello').animate({width: newWidth},slow);
 
   Am i correct?
 
   On Fri, May 9, 2008 at 5:40 AM, Brandon Aaron [EMAIL PROTECTED]
 
   wrote:
 
   jQuery.batch is a small extension (951 bytes min'd, 520 bytes gzipped)
 to
   jQuery that allows you to batch the results of any jQuery method,
 plugin
   into an array. By default the batch plugin aliases the getter methods
 in
   jQuery by adding an 's' to the end (attrs, offsets, vals ...). You can
 also
   just call $(...).batch('methodName', arg1, arg*n).
 
   Download:http://plugins.jquery.com/project/batch
   Blog post:http://blog.brandonaaron.net/2008/05/08/jquery-batch/
 
   --
   Brandon Aaron
 
   --
   Alexandre Plennevaux
   LAb[au]
 
  http://www.lab-au.com




-- 
Alexandre Plennevaux
LAb[au]

http://www.lab-au.com


[jQuery] Re: [jQuery][ANN] jQuery.batch 1.0

2008-05-09 Thread Brandon Aaron
Oh ... you want to make sure the width of the li adds up to the width of all
the images? The earlier snippet just made sure the li was as wide as the
widest image. You could do something like this to add up all the widths.

var width = 0;
$.each( $('li.hello img').widths(), function(i,w){ width += w; });
$('li.hello').animate({ width: width }, 'slow');

As for the feature suggestion ... I think it is an interesting idea. It
might be a little out of scope for this little extension/plugin but I'll
have to give it some more thought. Most of the things you mentioned are
already very easy to do with arrays and probably easy to extend the Array
object to do them otherwise.

--
Brandon Aaron

On Fri, May 9, 2008 at 10:57 AM, Alexandre Plennevaux [EMAIL PROTECTED]
wrote:

 Hi Brandon!

 in your blog post you ask for suggested features.

 Frankly i'm stunned by how in one line you addition all the widths values
 (although i didn't expect less from you). Personally, I had to loop through
 the returned array in order to achieve that.
 Wouldn't it be a nice feature to add some built-in manipulations to the
 batch? i'm thinking 'sum' to add them all and return the result, 'concat',
 'join:,'  to join each with a comma in-between, 'average' to get the average
 of all integer values, etc. a kind of built-in callbacks if you like for
 most common operations.

 $('li.hello img').widths('sum');


 thank you!

 alexandre



 On Fri, May 9, 2008 at 5:01 PM, Brandon Aaron [EMAIL PROTECTED]
 wrote:


 I misspelled reverse in my code example... It should be:

 var width = $('li.hello img').widths().sort().reverse()[0];
 $('li.hello').animate({ width: width }, 'slow');

 --
 Brandon Aaron

 On May 9, 9:47 am, Brandon Aaron [EMAIL PROTECTED] wrote:
  Close but in your example newWidths is an array of numbers. In your case
  you'll want a way to extract the largest width from the array and then
 use
  that value to animate the li width. Maybe something like this.
 
  var width = $('li.hello img').widths().sort().revers()[0];
  $('li.hello').animate({ width: width }, 'slow');
 
  Thanks for a nice real-world example. :)
 
  In testing this I found a bug and created a new release 1.0.1.
 
  --
  Brandon Aaron
 
  On Fri, May 9, 2008 at 2:08 AM, Alexandre Plennevaux 
 [EMAIL PROTECTED]
  wrote:
 
   Brandon, i believe this is a clever little plugin. I i understand
   correctly, here is a real life example i experienced just 2 days ago
  where
   i had such markup:
 
   li class=hello
   img width=316
 src=photos/sombra/Image_001.jpg/
   img width=629
 src=photos/sombra/Image_002.jpg/
   img width=630
 src=photos/sombra/Image_003.jpg/
   img width=638
 src=photos/sombra/Image_004.jpg/
   img width=631
 src=photos/sombra/Image_005.jpg/
   img width=630
 src=photos/sombra/Image_006.jpg/
   img width=629
 src=photos/sombra/Image_007.jpg/
   /li
 
   I needed to resize the LI element according to its children IMG
 element
   attr width. What i did is loop through the jquery collection looking
 for the
   width attribute value.
 
   with your plugin it would be just
 
   var newWidth = $('li.hello').attrs('width');
   $('li.hello').animate({width: newWidth},slow);
 
   Am i correct?
 
   On Fri, May 9, 2008 at 5:40 AM, Brandon Aaron 
 [EMAIL PROTECTED]
   wrote:
 
   jQuery.batch is a small extension (951 bytes min'd, 520 bytes
 gzipped) to
   jQuery that allows you to batch the results of any jQuery method,
 plugin
   into an array. By default the batch plugin aliases the getter methods
 in
   jQuery by adding an 's' to the end (attrs, offsets, vals ...). You
 can also
   just call $(...).batch('methodName', arg1, arg*n).
 
   Download:http://plugins.jquery.com/project/batch
   Blog post:http://blog.brandonaaron.net/2008/05/08/jquery-batch/
 
   --
   Brandon Aaron
 
   --
   Alexandre Plennevaux
   LAb[au]
 
  http://www.lab-au.com




 --
 Alexandre Plennevaux
 LAb[au]

 http://www.lab-au.com