[Proto-Scripty] Re: not send data in URL?

2010-07-21 Thread geoffcox

 That sort of thing. But I'd use a form and add an observer on the
 submit. This would allow for graceful degradation.

OK - thanks,

Geoff

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Prototype Class, Event Listeners and Referencing Self

2010-07-21 Thread Doc Torbin
I have the following snippet of code which illustrates a problem that
I'm having.  I have an event listener within a class that I'd like to
have be self aware.  I'd like it to be able to call another function
within the Class but I haven't found the right method to have it do
so.  Please advise:

!DOCTYPE html
html
head
script type=text/javascript src=../prototype.js/script
style type=text/css
#box{position:fixed;width:100px;border:3px solid 
#000;background-
color:#00ff00;font-size:14pt;font-weight:bold;text-
align:center;padding:50px 25px;cursor:pointer;}
/style
script type=text/javascript
var MyOBJ = new Class.create();
MyOBJ.prototype = {
initialize: function(){
try{

$('box').addEventListener(click,this.takeAction,false);
}
catch(error){alert(error);}
},
takeAction: function(event){
alert(I got to this function without 
issue.);
this.anotherAction();
},
anotherAction: function(){
alert(I won't get here.);
}
}

document.observe(dom:loaded, function(){
var spriteOBJ = new MyOBJ();
});
/script
/head
body
div id=boxBOX/div
/body
/html

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Prototype Class, Event Listeners and Referencing Self

2010-07-21 Thread T.J. Crowder
Hi,

If you really want `takeAction` to be a public property on the
instance, you typically use Function#bind for this; example in the
docs:
http://api.prototypejs.org/language/function/prototype/bind/

Basically, Function#bind creates a function that, when called, will
turn around and call the original function in a way that `this` is set
correctly, passing along any arguments. The function is defined is in
a small context so it's not closing over a bunch of extraneous stuff.

Alternately, if you're setting up a number of event handlers that
*don't* actually need to be instance methods, they just need access to
`this`, AND the code within them is small, you can use your
initializer closure to do that more directly:

var Thingy = Class.create({
initialize: function() {
var self = this;

$('foo').observe('click', fooClick);
$('bar').observe('click', barClick);

function fooClick(event) {
self.doSomething();
}

function barClick(event) {
self.doSomething();
self.doSomethingElse();
}
},
doSomething: function() {
alert(I did something.);
},
doSomethingElse: function() {
alert(I did something else.);
}
});

That avoids creating multiple small closures (one for each event
handler), but note that a new copy of each of those functions is
created for each instance, so if they're more than a line or two of
code, #bind is the way to go. More on closures here:
http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html

Off-topic, but:

* Your use of Class.create is a couple of years behind Prototype. As
of 1.6, the correct use is to pass the object containing the method
definitions *into* Class.create, not to replace the prototype
afterward. Example above.
* Rather than using addEventListener directly (which will fail on IE7
(8?) and below), use Prototype's observe method instead:
http://api.prototypejs.org/dom/event/observe/

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Jul 20, 6:13 pm, Doc Torbin mtor...@gmail.com wrote:
 I have the following snippet of code which illustrates a problem that
 I'm having.  I have an event listener within a class that I'd like to
 have be self aware.  I'd like it to be able to call another function
 within the Class but I haven't found the right method to have it do
 so.  Please advise:

 !DOCTYPE html
 html
         head
                 script type=text/javascript src=../prototype.js/script
                 style type=text/css
                         #box{position:fixed;width:100px;border:3px solid 
 #000;background-
 color:#00ff00;font-size:14pt;font-weight:bold;text-
 align:center;padding:50px 25px;cursor:pointer;}
                 /style
                 script type=text/javascript
                         var MyOBJ = new Class.create();
                         MyOBJ.prototype = {
                                 initialize: function(){
                                         try{
                                                 
 $('box').addEventListener(click,this.takeAction,false);
                                         }
                                         catch(error){alert(error);}
                                 },
                                 takeAction: function(event){
                                         alert(I got to this function without 
 issue.);
                                         this.anotherAction();
                                 },
                                 anotherAction: function(){
                                         alert(I won't get here.);
                                 }
                         }

                         document.observe(dom:loaded, function(){
                                 var spriteOBJ = new MyOBJ();
                         });
                 /script
         /head
         body
                 div id=boxBOX/div
         /body
 /html

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Prototype and WYSIWYG editors weird FF bug

2010-07-21 Thread T.J. Crowder
Hi,

Oh, of course. Remember that HTML and JavaScript are not parsed by the
same parsers, and you can confuse the HTML parser when you put script
tags in *inline* JavaScript you've included within a script tag. What
happens if you change this:

'script type=text/javascript language=javascript src=http://
localhost/PearCMS2/Public/JavaScripts/ThirdParty/prototype.js/
script' + \n

to:

'scr' + 'ipt type=text/javascript language=javascript
src=http://localhost/PearCMS2/Public/JavaScripts/ThirdParty/
prototype.js/scr' + 'ipt' + \n

...so the HTML parser doesn't get confused?

-- T.J.

On Jul 20, 5:22 pm, Gindi Bar Yahav g.b.ya...@gmail.com wrote:
 Oh, the problem occured when I'm tring to write the HTML content into
 the editor.
 there are no problem when I don't attach the prototype.js file

 +       '       script type=text/javascript language=javascript
 src=http://localhost/PearCMS2/Public/JavaScripts/ThirdParty
 (took from the code in my first post)
 when i'm setting it, firefox gives me an error of set style, its not
 like i'm acualy using it here... and when I comment this line all goes
 well except for the fact that the DOM did not pached with prototype.

 sorry for the confusion... :(
 very very thanks, regards, yahav.

 On 20 יולי, 19:06, T.J. Crowder t...@crowdersoftware.com wrote:



  Hi,

  I meant where in _your_ code (but that's still useful info), e.g.,
  this call to setStyle:

      this.editorFrame.setStyle( 'border: 1px inset;' );

  (BTW, the semicolon inside the quotes there is an error, although most
  browsers will ignore it.)

  ...or this one:

      this.editorFrame.setStyle( {
          width:          100%,
          height:         editorTextareaDims.height + 'px',
          className:      this.editorTextarea.className
      });

  ...and though actually, as they're both on editorFrame, I'm not sure
  how much it matters.

  Fundamentally, using Prototype's setStyle on an iframe seems to work,
  whether freshly-created or 
  not:http://jsbin.com/epano3http://jsbin.com/epano3/2

  So it may be worthwhile trying to figure out what's different in your
  code vs. that working example.

  HTH,
  --
  T.J. Crowder
  Independent Software Consultant
  tj / crowder software / comwww.crowdersoftware.com

  On Jul 20, 4:20 pm, Gindi Bar Yahav g.b.ya...@gmail.com wrote:

   OK, the bug in here
   setStyle: function(element, styles) {
   2206 element = $(element);
   2207 var elementStyle = element.style, match;
   2208 if (Object.isString(styles)) {
   2209 element.style.cssText += ';' + styles;
   2210 return styles.include('opacity') ?
   2211 element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) :
   element;
   2212 }
   2213 for (var property in styles)
   2214 if (property == 'opacity') element.setOpacity(styles[property]);
   2215 else
   2216 elementStyle[(property == 'float' || property == 'cssFloat') ?
   2217 (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' :
   'styleFloat') :
   2218 property] = styles[property];
   2219
   2220 return element;
   2221 },

   element is null
   [Break on this error] var elementStyle = element.style, match;

   (copied from firebug)

   thanks :)

   occured when uncommenting the prototype.js attach linke.

   On 20 יולי, 15:23, T.J. Crowder t...@crowdersoftware.com wrote:

Hi,

I don't think it's possible to help with this without a lot more
information. What's `editorDocument`, for instance? You said that the
failure occurs in `setStyle`; so you're going to need to show us your
call to `setStyle` at the very least (or your call to whatever else in
Prototype called `setStyle`). I don't think the code you've shown
calls Prototype at all, although without knowing what `editorDocument`
is...
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / comwww.crowdersoftware.com

On Jul 20, 1:34 am, Gindi Bar Yahav g.b.ya...@gmail.com wrote:

 Hey.
 I have a question that I'll be glad if you can help me.

 I'm building a WYSIWYG editor based on prototype and I want to extend
 prototype to the frame itself.

 I've written this code

 var htmlContent                         =       ;
                                 htmlContent                           
           =       '!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01
 Transitional//EN http://www.w3.org/TR/html4/loose.dtd;' + \n
                                                                       
                   +       html\n
                                                                       
                   +         head\n
                                                                       
                   +       '       script type=text/javascript 
 language=javascript
 src=http://localhost/PearCMS2/Public/JavaScripts/ThirdParty/
 prototype.js/script' + \n
                                                             

[Proto-Scripty] Re: Prototype Class, Event Listeners and Referencing Self

2010-07-21 Thread T.J. Crowder
Hi Guillaume,

Just #bind is sufficient. You almost never need #bindAsEventListener:
http://proto-scripty.wikidot.com/prototype:tip-you-probably-don-t-need-bindaseventlistener

-- T.J. :-)

On Jul 21, 10:18 am, Guillaume Lepicard guillaume.lepic...@gmail.com
wrote:
 Hi, you need to bind the listener function to your object:
  $('box').addEventListener(click,this.takeAction.bindAsEventListener(this) 
 ,false);

 more 
 details:http://api.prototypejs.org/language/function/prototype/bindaseventlis...



 On Tue, Jul 20, 2010 at 7:13 PM, Doc Torbin mtor...@gmail.com wrote:
  I have the following snippet of code which illustrates a problem that
  I'm having.  I have an event listener within a class that I'd like to
  have be self aware.  I'd like it to be able to call another function
  within the Class but I haven't found the right method to have it do
  so.  Please advise:

  !DOCTYPE html
  html
         head
                 script type=text/javascript
  src=../prototype.js/script
                 style type=text/css
                         #box{position:fixed;width:100px;border:3px solid
  #000;background-
  color:#00ff00;font-size:14pt;font-weight:bold;text-
  align:center;padding:50px 25px;cursor:pointer;}
                 /style
                 script type=text/javascript
                         var MyOBJ = new Class.create();
                         MyOBJ.prototype = {
                                 initialize: function(){
                                         try{

   $('box').addEventListener(click,this.takeAction,false);
                                         }
                                         catch(error){alert(error);}
                                 },
                                 takeAction: function(event){
                                         alert(I got to this function
  without issue.);
                                         this.anotherAction();
                                 },
                                 anotherAction: function(){
                                         alert(I won't get here.);
                                 }
                         }

                         document.observe(dom:loaded, function(){
                                 var spriteOBJ = new MyOBJ();
                         });
                 /script
         /head
         body
                 div id=boxBOX/div
         /body
  /html

  --
  You received this message because you are subscribed to the Google Groups
  Prototype  script.aculo.us group.
  To post to this group, send email to
  prototype-scriptacul...@googlegroups.com.
  To unsubscribe from this group, send email to
  prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculou 
  s%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Prototype Class, Event Listeners and Referencing Self

2010-07-21 Thread Guillaume Lepicard
Hi TJ,
Thanks for pointing this !
When I first read the API doc (in the old format), explanations were not
that clear or i misunderstoos them ; but then looking in the new API doc,
it's much more clear ; and thanks for the
proto-scripty.wikidot.comhttp://proto-scripty.wikidot.com/prototype:tip-you-probably-don-t-need-bindaseventlistener
i
wasn't aware of !


On Wed, Jul 21, 2010 at 12:05 PM, T.J. Crowder t...@crowdersoftware.comwrote:

 Hi Guillaume,

 Just #bind is sufficient. You almost never need #bindAsEventListener:

 http://proto-scripty.wikidot.com/prototype:tip-you-probably-don-t-need-bindaseventlistener

 -- T.J. :-)

 On Jul 21, 10:18 am, Guillaume Lepicard guillaume.lepic...@gmail.com
 wrote:
  Hi, you need to bind the listener function to your object:
 
  $('box').addEventListener(click,this.takeAction.bindAsEventListener(this)
 ,false);
 
  more details:
 http://api.prototypejs.org/language/function/prototype/bindaseventlis...
 
 
 
  On Tue, Jul 20, 2010 at 7:13 PM, Doc Torbin mtor...@gmail.com wrote:
   I have the following snippet of code which illustrates a problem that
   I'm having.  I have an event listener within a class that I'd like to
   have be self aware.  I'd like it to be able to call another function
   within the Class but I haven't found the right method to have it do
   so.  Please advise:
 
   !DOCTYPE html
   html
  head
  script type=text/javascript
   src=../prototype.js/script
  style type=text/css
  #box{position:fixed;width:100px;border:3px solid
   #000;background-
   color:#00ff00;font-size:14pt;font-weight:bold;text-
   align:center;padding:50px 25px;cursor:pointer;}
  /style
  script type=text/javascript
  var MyOBJ = new Class.create();
  MyOBJ.prototype = {
  initialize: function(){
  try{
 
$('box').addEventListener(click,this.takeAction,false);
  }
  catch(error){alert(error);}
  },
  takeAction: function(event){
  alert(I got to this function
   without issue.);
  this.anotherAction();
  },
  anotherAction: function(){
  alert(I won't get here.);
  }
  }
 
  document.observe(dom:loaded, function(){
  var spriteOBJ = new MyOBJ();
  });
  /script
  /head
  body
  div id=boxBOX/div
  /body
   /html
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Prototype  script.aculo.us group.
   To post to this group, send email to
   prototype-scriptacul...@googlegroups.com.
   To unsubscribe from this group, send email to
   prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.comprototype-scriptaculou
 s%2bunsubscr...@googlegroups.com s%252bunsubscr...@googlegroups.com
   .
   For more options, visit this group at
  http://groups.google.com/group/prototype-scriptaculous?hl=en.

 --
 You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To post to this group, send email to
 prototype-scriptacul...@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Effect.multiple and toggle

2010-07-21 Thread Richard Quadling
On 20 July 2010 23:37, Febo ilpuccio.f...@gmail.com wrote:
 Thanks Richard and Ralph,

 I'm studing the code but my feeling is that Effect.toggle can't handle
 the Object which is always passed by Effect.multiple as last parameter
 or let's say effect.

 I don't know very much JavaScript, so I came up with this solution.
 I added a funciton to public/javascripts/prototype.js

  Toggle: function(element, options) {
    element = $(element);
    effect = ($(options)['effect'] || 'appear').toLowerCase();
    Effect.toggle(element, effect, options);
  }

 calling the multiple function:

 Effect.multiple(['id_1','id_2',...,'id_n'], Effect.Toggle,
 {'effect':'appear'})

 I tested the curry but without success, perhaps I'm not so good in JS
 so I didn't catch the concept of curry.
 If you have a better solution, let me know.

 The problem with the class solution is that I have a table and I want
 to hide some rows of this table, I set the class of each row to odd/
 even for zebra colouring.

 On 20 Lug, 19:08, Richard Quadling rquadl...@gmail.com wrote:
 On 20 July 2010 17:59, Ralph Brickley i...@topsoftweb.com wrote:



  This is a revelation to me. I didn't know Effect had a multiple. Also, 
  what is curry?

  My solution has been to tag those elements with a class, ie div 
  class=effects

  Then use $$('effects') to get each item and all effects... On each

  Sent from my iPhone

  On Jul 20, 2010, at 9:08 AM, Richard Quadling rquadl...@gmail.com wrote:

  On 20 July 2010 15:55, Febo ilpuccio.f...@gmail.com wrote:
  Hello,
  I'd like to use the toggle effect on multiple object at the same time
  I tried with

  Effect.multiple(['id_1','id_2','id_n'], Effect.toggle)

  but it doesn't work, also I don't know where/how to pass the 'appear'
  parameter

  I'm used to call toggle in this way:
  Effect.toggle('my_id_of_interest','appear')

  At a guess, you need to curry() [1] the parameter.

  So, can you try ...

  Effect.multiple(['id_1','id_2','id_n'], Effect.toggle.curry('appear'));

  Regards,

  Richard.

  [1]http://api.prototypejs.org/language/function/prototype/curry/

 Curries (burns in) arguments to a function, returning a new function
 that when called with call the original passing in the curried
 arguments (along with any new ones)

 The linkhttp://api.prototypejs.org/language/function/prototype/curry/
 is the documentation for curry.

 So, Effect.toggle.curry('appear') returns a new function which, when
 called, will call the Effect.toggle function with  'appear' as the
 first parameter, along with any other parameters supplied by the
 Effect.multiple() function.

 Is it the same as $$('effects').invoke('toggle', 'appear');

 Hmm. On the surface, probably yes. But I'm not an expert here.

 One difference is that Effect.multiple allows you to supply any ids.

 I suppose ...

 Effect.multiple($$('effects'), Effect.toggle.curry('appear'));

 could also be a similar approach.

Ah. Yes. toggle requires the element first. Using curry() puts the
parameters the wrong way round.

Sorry about that.

So...

Effect.multiple
 (
 ['id1', 'id2'],
 function(el) { Effect.toggle(el, 'appear');}
 );

maybe.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Effect.multiple and toggle

2010-07-21 Thread Richard Quadling
On 21 July 2010 13:10, Richard Quadling rquadl...@gmail.com wrote:
 On 20 July 2010 23:37, Febo ilpuccio.f...@gmail.com wrote:
 Thanks Richard and Ralph,

 I'm studing the code but my feeling is that Effect.toggle can't handle
 the Object which is always passed by Effect.multiple as last parameter
 or let's say effect.

 I don't know very much JavaScript, so I came up with this solution.
 I added a funciton to public/javascripts/prototype.js

  Toggle: function(element, options) {
    element = $(element);
    effect = ($(options)['effect'] || 'appear').toLowerCase();
    Effect.toggle(element, effect, options);
  }

 calling the multiple function:

 Effect.multiple(['id_1','id_2',...,'id_n'], Effect.Toggle,
 {'effect':'appear'})

 I tested the curry but without success, perhaps I'm not so good in JS
 so I didn't catch the concept of curry.
 If you have a better solution, let me know.

 The problem with the class solution is that I have a table and I want
 to hide some rows of this table, I set the class of each row to odd/
 even for zebra colouring.

 On 20 Lug, 19:08, Richard Quadling rquadl...@gmail.com wrote:
 On 20 July 2010 17:59, Ralph Brickley i...@topsoftweb.com wrote:



  This is a revelation to me. I didn't know Effect had a multiple. Also, 
  what is curry?

  My solution has been to tag those elements with a class, ie div 
  class=effects

  Then use $$('effects') to get each item and all effects... On each

  Sent from my iPhone

  On Jul 20, 2010, at 9:08 AM, Richard Quadling rquadl...@gmail.com wrote:

  On 20 July 2010 15:55, Febo ilpuccio.f...@gmail.com wrote:
  Hello,
  I'd like to use the toggle effect on multiple object at the same time
  I tried with

  Effect.multiple(['id_1','id_2','id_n'], Effect.toggle)

  but it doesn't work, also I don't know where/how to pass the 'appear'
  parameter

  I'm used to call toggle in this way:
  Effect.toggle('my_id_of_interest','appear')

  At a guess, you need to curry() [1] the parameter.

  So, can you try ...

  Effect.multiple(['id_1','id_2','id_n'], Effect.toggle.curry('appear'));

  Regards,

  Richard.

  [1]http://api.prototypejs.org/language/function/prototype/curry/

 Curries (burns in) arguments to a function, returning a new function
 that when called with call the original passing in the curried
 arguments (along with any new ones)

 The linkhttp://api.prototypejs.org/language/function/prototype/curry/
 is the documentation for curry.

 So, Effect.toggle.curry('appear') returns a new function which, when
 called, will call the Effect.toggle function with  'appear' as the
 first parameter, along with any other parameters supplied by the
 Effect.multiple() function.

 Is it the same as $$('effects').invoke('toggle', 'appear');

 Hmm. On the surface, probably yes. But I'm not an expert here.

 One difference is that Effect.multiple allows you to supply any ids.

 I suppose ...

 Effect.multiple($$('effects'), Effect.toggle.curry('appear'));

 could also be a similar approach.

 Ah. Yes. toggle requires the element first. Using curry() puts the
 parameters the wrong way round.

 Sorry about that.

 So...

 Effect.multiple
  (
  ['id1', 'id2'],
  function(el) { Effect.toggle(el, 'appear');}
  );

 maybe.


On http://script.aculo.us/, opening the console command line (using
Google Chrome).

Entered

Effect.multiple(['header','ninja'],function(el){Effect.toggle(el, 'appear');})

and the 2 elements fade out.

Repeat the all and they fade back in.

So this looks like a winner.

In essence the curry() call was doing ...


Effect.multiple(['header','ninja'],function(el){Effect.toggle('appear',el);})

which is why it wasn't working for you. Sorry again.

Regards,

Richard.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Re: Effect.multiple and toggle

2010-07-21 Thread Febo
Dear Richard,

amazing :-)

thanks a lot.
They should update the wiki with this tip.

On 21 Lug, 14:23, Richard Quadling rquadl...@gmail.com wrote:
 On 21 July 2010 13:10, Richard Quadling rquadl...@gmail.com wrote:



  On 20 July 2010 23:37, Febo ilpuccio.f...@gmail.com wrote:
  Thanks Richard and Ralph,

  I'm studing the code but my feeling is that Effect.toggle can't handle
  the Object which is always passed by Effect.multiple as last parameter
  or let's say effect.

  I don't know very much JavaScript, so I came up with this solution.
  I added a funciton to public/javascripts/prototype.js

   Toggle: function(element, options) {
     element = $(element);
     effect = ($(options)['effect'] || 'appear').toLowerCase();
     Effect.toggle(element, effect, options);
   }

  calling the multiple function:

  Effect.multiple(['id_1','id_2',...,'id_n'], Effect.Toggle,
  {'effect':'appear'})

  I tested the curry but without success, perhaps I'm not so good in JS
  so I didn't catch the concept of curry.
  If you have a better solution, let me know.

  The problem with the class solution is that I have a table and I want
  to hide some rows of this table, I set the class of each row to odd/
  even for zebra colouring.

  On 20 Lug, 19:08, Richard Quadling rquadl...@gmail.com wrote:
  On 20 July 2010 17:59, Ralph Brickley i...@topsoftweb.com wrote:

   This is a revelation to me. I didn't know Effect had a multiple. Also, 
   what is curry?

   My solution has been to tag those elements with a class, ie div 
   class=effects

   Then use $$('effects') to get each item and all effects... On each

   Sent from my iPhone

   On Jul 20, 2010, at 9:08 AM, Richard Quadling rquadl...@gmail.com 
   wrote:

   On 20 July 2010 15:55, Febo ilpuccio.f...@gmail.com wrote:
   Hello,
   I'd like to use the toggle effect on multiple object at the same time
   I tried with

   Effect.multiple(['id_1','id_2','id_n'], Effect.toggle)

   but it doesn't work, also I don't know where/how to pass the 'appear'
   parameter

   I'm used to call toggle in this way:
   Effect.toggle('my_id_of_interest','appear')

   At a guess, you need to curry() [1] the parameter.

   So, can you try ...

   Effect.multiple(['id_1','id_2','id_n'], Effect.toggle.curry('appear'));

   Regards,

   Richard.

   [1]http://api.prototypejs.org/language/function/prototype/curry/

  Curries (burns in) arguments to a function, returning a new function
  that when called with call the original passing in the curried
  arguments (along with any new ones)

  The linkhttp://api.prototypejs.org/language/function/prototype/curry/
  is the documentation for curry.

  So, Effect.toggle.curry('appear') returns a new function which, when
  called, will call the Effect.toggle function with  'appear' as the
  first parameter, along with any other parameters supplied by the
  Effect.multiple() function.

  Is it the same as $$('effects').invoke('toggle', 'appear');

  Hmm. On the surface, probably yes. But I'm not an expert here.

  One difference is that Effect.multiple allows you to supply any ids.

  I suppose ...

  Effect.multiple($$('effects'), Effect.toggle.curry('appear'));

  could also be a similar approach.

  Ah. Yes. toggle requires the element first. Using curry() puts the
  parameters the wrong way round.

  Sorry about that.

  So...

  Effect.multiple
   (
   ['id1', 'id2'],
   function(el) { Effect.toggle(el, 'appear');}
   );

  maybe.

 Onhttp://script.aculo.us/, opening the console command line (using
 Google Chrome).

 Entered

 Effect.multiple(['header','ninja'],function(el){Effect.toggle(el, 'appear');})

 and the 2 elements fade out.

 Repeat the all and they fade back in.

 So this looks like a winner.

 In essence the curry() call was doing ...

 Effect.multiple(['header','ninja'],function(el){Effect.toggle('appear',el);})

 which is why it wasn't working for you. Sorry again.

 Regards,

 Richard.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Template + element.update question

2010-07-21 Thread pedz
I have a list of columns.  Each column has a Template.  The Templates
contain td#{stuff}/td

I create one long string doing something like:

str = ;
$A(columns).each(   str = str + template.evaluate(obj);  )

Then I do: row.update(str);

If I do it this way, the td's disappear.  I print the string to
console.log and its has the td's in it.

So, for now I switched and I do something like

row.update(); // clear the row's contents.
$A(columns).each(  row.insert(template.evaluate(obj)); ... )

I am using Firefox 3.6 and my prototype is 1.6.0.3.

Somewhere in the cobwebs of my mind, I remember something about adding
td's to a tr is broken or has restrictions or something like that but
I can't figure out what I am half remembering.

Is my original code suppose to work?  If not, why?

Thank you,
Perry

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] How do I remove and stash an observer?

2010-07-21 Thread Walter Lee Davis
I have a video editing app that I'm working on where you can add  
captions to your movie up to a total number of purchased captions.  
When you reach that limit, I disable the buttons that add more  
captions by using Element.stopObserving and changing the button image  
to reflect this disabled nature.


Now the client would like me to add purchase more to the same  
screen, so I would like to know if I can memoize the listener from an  
element, disable it, and then re-enable it from memory later in the  
same session. I know that this page will work the way it is if I  
reload the page after a successful purchase of new captions, but it's  
a big page, and I'd like to avoid that if I can.


Any ideas?

Thanks,

Walter

--
You received this message because you are subscribed to the Google Groups Prototype 
 script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.