[Proto-Scripty] Re: yes, but Mootoolls do that -ImageMenu-

2009-08-26 Thread lvdesign

Hi,

Yes is like a vertical accordion and this .v2 seems to me a very well
soluce with mouse action.

Thanks very much for comments and recommendation

let's go to script

Friendly,

LV

On Aug 25, 10:25 pm, Jarkko Laine jarks...@gmail.com wrote:
 On 25.8.2009, at 23.16, lvdesign wrote:



  Hi,
  Thank you for this base of soluce.

  So, I begin  with  a slide menu picture witch using these Effects
  (move and morph) to anime.

  I thought with the .js of Moot, we could transposing with the right
  verbose in proto/scriptaculous.

  But this library is perhaps just to limited for this kind of
  animation?

 Google for scriptaculous accordion and you'll find plenty of  
 existing solutions. Like Alex mentioned, you might need to modify the  
 one you choose a bit to work onmouseover instead of onclick, but that  
 shouldn't take a whole lot of time.

 Cheers,
 //jarkko

 --
 Jarkko 
 Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce.comhttp://odesign.fi
--~--~-~--~~~---~--~~
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-scriptaculous@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] complete handler for effects.js

2009-08-26 Thread Scott Haines

In case anyone has run into the need to have an onComplete style
handler for effects.js I have made a successful addition to the source
code.

Step 1:
In the main effect.js code skip to about line 100, it should look like
this:

DefaultOptions: {
duration:   1.0,   // seconds
fps:100,   // 100= assume 66fps max.
sync:   false, // true for combining
from:   0.0,
to: 1.0,
delay:  0.0,
queue:  'parallel',
complete:   0,
  },

You are adding 'complete: 0,' to the defaults, this will allow you to
run a subsequent function once the effect has completed. (This is the
first step of three).

Step 2:
Register the function within the Effect you would like to extend the
onComplete handler to. I needed this for the Effect.Fade and
Effect.Appear functions.

Example: Effect.Fade (starts around line 535)

Effect.Fade = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  var options = Object.extend({
from: element.getOpacity() || 1.0,
to:   0.0,
afterFinishInternal: function(effect) {
 if(effect.options.complete != 0){
 effect.options.complete();
 }
  if (effect.options.to!=0) return;
  effect.element.hide().setStyle({opacity: oldOpacity});
}
  }, arguments[1] || { });
  return new Effect.Opacity(element,options);
};

*on the afterFinishInternal you know that the effect has finished, so
you then ask whether or not the option for complete (onComplete) was
issued and piped into the function, if so you allow Javascript to read
the string as a function and you are golden.

Step 3: Using the onComplete (complete) option in your code.

example:
function fadeObj(obj,func){
Effect.Fade($(obj),{duration:1,complete:func});
}

function setInStone(){
 alert('onComplete handler working for effects.js');
}

usage:
fadeObj('fadediv',setInStone);

I hope this helps anyone else who ran into the same issue. I wanted to
simulate the functionality of the caurina Tweener methods from
actionscript 3, or the complete handler from the SPRY lib in the more
useful effect.js.

Cheers,
Scott Haines
Newfront Creative
http://www.newfrontcreative.com




--~--~-~--~~~---~--~~
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-scriptaculous@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: this keyword inside of the map function

2009-08-26 Thread Daniel Rubin

Andy Daykin wrote:
 The way that my script is working on that page http://andydaykin.com/Home 
 (http://andydaykin.com/Home/public/js/Home.js is the link to the javascript 
 file) is how I want it to work, but I want to make my script fit the 
 prototype conventions a little bit more.
 
 So if I try and make instance variables, the doSlide function can't see 
 them. As I stated before the scope of this inside of the map function is 
 what is causing the problem I believe. The click handler (doSlide) won't 
 recognize an instance variable.
 
 For instance if I say this.varName in my init function, and try and access 
 this.varName in the doSlide function, the variable won't be recognized.
 
 To solve this I am using var varName outside of the class, but I would 
 like to do this the proper way.
 
 -Andy
Alright, I'll just post how I believe it should work.

//
initialize: function (parentDiv, featuresWrapper) {
var features = $(featuresWrapper).descendants ();
$(parentDiv).descendants ().map (function (e, i) {
$(e).observe ('click',
  this.doSlide.bind (this, features[i].id));
}, this);

slides = $$('.featureImage').map (function (e) {
return e.id;
});
},
//

 1) I threw out the dom:loaded-handling stuff: The particular SlideShow
object should be created in such a handler, of course, but listening
for the event in the constructor would limit the class' use to this
application only.
Instead, put
  var mySlide = new SlideShow ('featureList', 'featuresWrapper');
in your global dom:loaded handler in the main HTML file.  (But make
sure to load Home.js first.)

 2) The featuresWrapper Element is passed as constructor arg now, too.
No point in hard-coding it, I think.

 3) Note this as the second parameter to the map-call.  That's the
context-param T. J. pointed out.  By passing this, we ensure
that this is the same inside and outside the mapping-function.

 4) The mapping-function takes a second parameter i, which is just
the old counter i, but readily provided by the map-iteration.

I hope this works -- I have not tested it myself.

Have fun
Daniel



 --
 From: Daniel Rubin dru...@dimedis.de
 Sent: Tuesday, August 25, 2009 3:06 AM
 To: prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function
 
 Andy Daykin wrote:
 The doSlide function was what I was referring to. I tried using TJ's
 suggestion of using this as the 2nd parameter, but the handler still 
 wasn't
 getting called. You can find a prototype of what I am doing at
 http://andydaykin.com/Home. The slideshow (images obviously missing) is 
 on
 the main page. The javascript file for the class is
 http://andydaykin.com/Home/public/js/Home.js
 Could you please provide the current state once more? Perhaps stripped
 down to the vital parts of HTML and scripts? I think we need to have a
 look at the details here.

 Daniel



 --
 From: Daniel Rubin dru...@dimedis.de
 Sent: Friday, August 21, 2009 3:38 AM
 To: prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function

 Andy Daykin wrote:
 I tried the first suggestion, but the function still isn't getting
 called.
 Exactly which function do you refer to? The map-iterator-func (function
 (e) { ... }) or the click-handler (this.doSlide)?

 Daniel



 TJ, can you explain more, or show an example of what the context param
 would
 look like? Should I just put the doSlide function as the 2nd parameter?

 -Andy

 --
 From: T.J. Crowder t...@crowdersoftware.com
 Sent: Thursday, August 20, 2009 3:56 AM
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function

 Hi,

 Rather than binding it, use the second parameter to map (aka collect
 [1]), that's what the second param (context) is for.  You'll find
 that most of the Enumerable methods that take callbacks also take a
 context parameter so the callback can be a method.

 [1] http://prototypejs.org/api/enumerable/collect

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available


 On Aug 20, 8:34 am, Daniel Rubin dru...@dimedis.de wrote:
 Andy Daykin wrote:
 Hello, I am having some difficulties writing a class, in my code I
 have
 a class where I need to be able to bind event listeners to values. 
 In
 my code I want the variable pointerIndex to be accessible outside of
 the initialize function, but right now it is not. If I make a global
 variable for pointerIndex I can solve the problem, but I would 
 rather
 have a class variable using the this keyword.

[Proto-Scripty] Re: can I get a list of event listeners on an element?

2009-08-26 Thread T.J. Crowder

Hi,

Prototype doesn't have an official API call that gives you the event
handlers for an element. If you look at the source, it's fairly easy
to get them (in particular the stopObserving source is helpful), but
in a way that's undocumented and subject to change. (It changed quite
a bit between 1.6.0 and 1.6.1, for instance.)

It may well not be appropriate to move an event handler from one
element to another.  Consider this:

function foo(container) {
container.down('.flargle').observe('change', function(event) {
if (this.value.length == 0) {
container.addClassName('error');
} else {
container.removeClassName('error');
}
});
}

If you clone the container, including its flargle element, the handler
will not function as expected -- it'll update the original container,
not the new one.  Now, I'm not saying that's a smart way to implement
that function, but I suspect there's a more realistic version of this
scenario (a corrolation between the observed element and some data
bound to the handler function in some way, in this case via a closure)
that I just didn't come up with on first thought.

Now, if you're in control of the code and know things like that aren't
being done, you could safely transfer the event handlers to cloned
elements.  But I wonder if refactoring (perhaps refactoring involving
event delegation) could obviate the need for doing this...

FWIW,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Aug 25, 10:45 pm, Kevin Porter k...@9ballpool.co.uk wrote:
 Hi,

 Can I get a list of registered listeners/observers on an element?

 What I'm trying to do is dynamically replace an element with another
 element, but want to preserve the events.

 I don't want to resort to something like:

 new_element.onclick = old_element.onclick;

 as the prototype docs advise against using .onclick, .onmouseover etc.

 If prototype doesn't provide a way to do this, is there a bare JS way to
 do it (ie to get a list of events that were registered with
 addEventListener)? I googled but couldn't find this.

 regards,

 - Kev

 --
 Kevin Porter
 Advanced Web Construction 
 Ltdhttp://webutils.co.ukhttp://billiardsearch.nethttp://9ballpool.co.uk

 AJAX Blackjack - real-time multi-player blackjack game with no flash, java or 
 software downloads required -http://blackjack.webutils.co.uk
--~--~-~--~~~---~--~~
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-scriptaculous@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: complete handler for effects.js

2009-08-26 Thread Alex McAuley

You have put a trailing comma on the last option wich will cause an error in 
IE !!!...


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: Scott Haines sc...@newfrontproductions.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Wednesday, August 26, 2009 2:36 AM
Subject: [Proto-Scripty] complete handler for effects.js



 In case anyone has run into the need to have an onComplete style
 handler for effects.js I have made a successful addition to the source
 code.

 Step 1:
 In the main effect.js code skip to about line 100, it should look like
 this:

 DefaultOptions: {
duration:   1.0,   // seconds
fps:100,   // 100= assume 66fps max.
sync:   false, // true for combining
from:   0.0,
to: 1.0,
delay:  0.0,
queue:  'parallel',
complete:   0,
  },

 You are adding 'complete: 0,' to the defaults, this will allow you to
 run a subsequent function once the effect has completed. (This is the
 first step of three).

 Step 2:
 Register the function within the Effect you would like to extend the
 onComplete handler to. I needed this for the Effect.Fade and
 Effect.Appear functions.

 Example: Effect.Fade (starts around line 535)

 Effect.Fade = function(element) {
  element = $(element);
  var oldOpacity = element.getInlineOpacity();
  var options = Object.extend({
from: element.getOpacity() || 1.0,
to:   0.0,
afterFinishInternal: function(effect) {
 if(effect.options.complete != 0){
  effect.options.complete();
 }
  if (effect.options.to!=0) return;
  effect.element.hide().setStyle({opacity: oldOpacity});
}
  }, arguments[1] || { });
  return new Effect.Opacity(element,options);
 };

 *on the afterFinishInternal you know that the effect has finished, so
 you then ask whether or not the option for complete (onComplete) was
 issued and piped into the function, if so you allow Javascript to read
 the string as a function and you are golden.

 Step 3: Using the onComplete (complete) option in your code.

 example:
 function fadeObj(obj,func){
 Effect.Fade($(obj),{duration:1,complete:func});
 }

 function setInStone(){
 alert('onComplete handler working for effects.js');
 }

 usage:
 fadeObj('fadediv',setInStone);

 I hope this helps anyone else who ran into the same issue. I wanted to
 simulate the functionality of the caurina Tweener methods from
 actionscript 3, or the complete handler from the SPRY lib in the more
 useful effect.js.

 Cheers,
 Scott Haines
 Newfront Creative
 http://www.newfrontcreative.com




 
 


--~--~-~--~~~---~--~~
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-scriptaculous@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: Ajax requests again

2009-08-26 Thread Alex McAuley

Really?


I thought the explination was a simple one.

To recap

A global way of knowing what is going on inside Ajax requests including.

1. The element that triggered the call
2. The container (if Ajax.Updater) the response is going to.


Yes i have looked at Responders and i am using them now to lock (disable) 
input elements but as i cannot get the element that triggered the call i 
have to lock the whole document which is not neccesary and slow - it would 
be better to find the parent or inputs above the callee and lock them while 
the request is going on (to stop people pushing the button twice etc etc) 
then unlock on onComplete.

My way is working fine at the moment ... but ... it would be quicker and 
more efficient if i could in some way get the nodes/elements i desire on a 
global basis as part fo the framework and not hacked ontop of it.

Hope this clears things up a bit


Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: Timo timo.kiss...@gmail.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Tuesday, August 25, 2009 4:11 PM
Subject: [Proto-Scripty] Re: Ajax requests again



 On 20 Aug., 17:15, Alex Mcauley webmas...@thecarmarketplace.com
 wrote:
 earlier on in the month i posted on how to do some things with Ajax
 requests genericaly like adding a loading message to all requests and
 i got a couple of responses but not many.

 I've been giving it alot of thought and i cam up with addMethods as a
 way to add some things to the Ajax Class...

 Could anyone give me an example of how to do this with addMethods -
 just a hello world will do then i can take it from there

 I am not sure I understand what you are trying to achieve (and I
 couldn't find the older topic you mention),
 but did you look at Ajax.Responders? [http://www.prototypejs.org/api/
 ajax/responders]

 Timo

 
 


--~--~-~--~~~---~--~~
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-scriptaculous@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: Ajax requests again

2009-08-26 Thread T.J. Crowder

Alex,

 1. Element that triggered the call (if any)

if any doesn't make any difference to the question -- again, you
can't get that information from Ajax.Request or Ajax.Updater, because
it's not passed into them (whether it exists or not). You can only get
that information if you pass it into something of your own.

Sorry if I'm completely missing what you're talking about, but I think
a wrapper solution is your best bet.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Aug 26, 9:53 am, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 My mistake...

 i meant.

 1. Element that triggered the call (if any)
 2. Element receiving the response (if any)

 Alex Mcauleyhttp://www.thevacancymarket.com



 - Original Message -
 From: T.J. Crowder t...@crowdersoftware.com
 To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
 Sent: Wednesday, August 26, 2009 9:47 AM
 Subject: [Proto-Scripty] Re: Ajax requests again

 Alex,

  1. The element that triggered the call

 What element?  Ajax calls can be initiated by any code, anywhere, and
 don't necessarily have anything to do with any element triggering
 them.  For example:

     function pollForData() {
         new Ajax.Request(pollurl, {
             onSuccess: function(resp) {
                 doSomethingWithTheData(resp);
             },
             onComplete: function() {
                 window.setTimeout(pollForData, pollForDataInterval);
             }
         });
     }
     document.observe(dom:loaded, function() {
         window.setTimeout(pollForData, pollForDataInterval);
     });

 There's no element associated with the call. Even in cases where there
 is (a request triggered by a button click, for instance), we don't
 pass that element into Ajax.Request in any defined way, so there's no
 defined way for you to get it.

 I think your requirement is at a level above Ajax.Request and
 Ajax.Updater, and that you should put your own infrastructure in place
 for it. For example:

     var MoreAjax = {
         react: function(element, url, options) {
             var completeCallback;

             element = $(element);
             element.disable();
             if (!options) options = {};
             completeCallback = options.onComplete;
             options.onComplete = function() {
                 element.enable();
                 if (completeCallback) {
                     completeCallback.apply(undefined, arguments);
                 }
             };
         }
     };

 That defines an explicit way for you to say this call was triggered
 by this element and it provides automatic element disabling/
 enabling.  So in a click handler:

     $('mybutton').observe('click', function(event) {
         event.stop();
         MoreAjax.react(this, 'myurl', {
             parameters: this.up('form').serialize({hash: true}),
             onSuccess: function(resp) {
                 // Some nifty thing
             }
         });
     });

 Voila, the button is disabled during the request and enabled when it's
 done.

 I'm sure that function as written (er, dashed off) is completely wrong
 for what you're trying to do, it just illustrates the idea.

 In my apps, I never use Ajax.Request or Ajax.Updater directly.  I
 always have wrappers that factor out the complexity in ways
 appropriate to the application.

 FWIW!
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 26, 9:25 am, Alex McAuley webmas...@thecarmarketplace.com
 wrote:
  Really?

  I thought the explination was a simple one.

  To recap

  A global way of knowing what is going on inside Ajax requests including.

  1. The element that triggered the call
  2. The container (if Ajax.Updater) the response is going to.

  Yes i have looked at Responders and i am using them now to lock (disable)
  input elements but as i cannot get the element that triggered the call i
  have to lock the whole document which is not neccesary and slow - it would
  be better to find the parent or inputs above the callee and lock them
  while
  the request is going on (to stop people pushing the button twice etc etc)
  then unlock on onComplete.

  My way is working fine at the moment ... but ... it would be quicker and
  more efficient if i could in some way get the nodes/elements i desire on a
  global basis as part fo the framework and not hacked ontop of it.

  Hope this clears things up a bit

  Alex Mcauleyhttp://www.thevacancymarket.com

  - Original Message -
  From: Timo timo.kiss...@gmail.com
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Tuesday, August 25, 2009 4:11 PM
  Subject: [Proto-Scripty] Re: Ajax requests again

   On 20 Aug., 17:15, Alex Mcauley webmas...@thecarmarketplace.com
   wrote:
   earlier on in the month i posted on how to do some things with Ajax
   requests genericaly like adding 

[Proto-Scripty] Re: ? of format of evalScripts

2009-08-26 Thread bill
Alex McAuley wrote:
 var request=new Ajax.Updater('element','/url',{
   method:   'post',  
   evalScripts:  true,
   parameters :
{
 id: id,
 page: page
}   
  
  
   }); 
   request=null;  
  
 - works fine...
  
 Its probably a syntax error in your returning javascript
  
 Alex Mcauley
 http://www.thevacancymarket.com

Thanks Alex, my error was trying to put evalScripts:True after the 
parameters bracket.

 - Original Message -
 *From:* bill mailto:will...@techservsys.com
 *To:* prototype-scriptaculous@googlegroups.com
 mailto:prototype-scriptaculous@googlegroups.com
 *Sent:* Tuesday, August 25, 2009 2:26 PM
 *Subject:* [Proto-Scripty] ? of format of evalScripts

 My function is:
 new Ajax.Updater('showMessageDiv', 'mail/process_message.php', {
 parameters:  $('showMessageDiv').down('form').serialize(true),
 onFailure: function(response) {
  alert (mail.js: failure to submit form - getmessage);
 }
 });

 When I try to add evalScripts:true so I can download and evaluate
 scripts I get a syntax error,  no matter what I try.

 Would someone please show me the correct format to add
 evalScripts:true the this function ?

 -- 
 Bill Drescher
 william {at} TechServSys {dot} com



 


-- 
Bill Drescher
william {at} TechServSys {dot} com


--~--~-~--~~~---~--~~
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-scriptaculous@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: Ajax requests again

2009-08-26 Thread Alex McAuley

Omg lol this is my point...

All you have itterated is what i have worked out for myself already and 
replied subsequently to that effect (friday i think).

Regards

Alex Mcauley
http://www.thevacancymarket.com
- Original Message - 
From: T.J. Crowder t...@crowdersoftware.com
To: Prototype  script.aculo.us prototype-scriptaculous@googlegroups.com
Sent: Wednesday, August 26, 2009 10:40 AM
Subject: [Proto-Scripty] Re: Ajax requests again



Alex,

 1. Element that triggered the call (if any)

if any doesn't make any difference to the question -- again, you
can't get that information from Ajax.Request or Ajax.Updater, because
it's not passed into them (whether it exists or not). You can only get
that information if you pass it into something of your own.

Sorry if I'm completely missing what you're talking about, but I think
a wrapper solution is your best bet.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Aug 26, 9:53 am, Alex McAuley webmas...@thecarmarketplace.com
wrote:
 My mistake...

 i meant.

 1. Element that triggered the call (if any)
 2. Element receiving the response (if any)

 Alex Mcauleyhttp://www.thevacancymarket.com



 - Original Message -
 From: T.J. Crowder t...@crowdersoftware.com
 To: Prototype  script.aculo.us 
 prototype-scriptaculous@googlegroups.com
 Sent: Wednesday, August 26, 2009 9:47 AM
 Subject: [Proto-Scripty] Re: Ajax requests again

 Alex,

  1. The element that triggered the call

 What element? Ajax calls can be initiated by any code, anywhere, and
 don't necessarily have anything to do with any element triggering
 them. For example:

 function pollForData() {
 new Ajax.Request(pollurl, {
 onSuccess: function(resp) {
 doSomethingWithTheData(resp);
 },
 onComplete: function() {
 window.setTimeout(pollForData, pollForDataInterval);
 }
 });
 }
 document.observe(dom:loaded, function() {
 window.setTimeout(pollForData, pollForDataInterval);
 });

 There's no element associated with the call. Even in cases where there
 is (a request triggered by a button click, for instance), we don't
 pass that element into Ajax.Request in any defined way, so there's no
 defined way for you to get it.

 I think your requirement is at a level above Ajax.Request and
 Ajax.Updater, and that you should put your own infrastructure in place
 for it. For example:

 var MoreAjax = {
 react: function(element, url, options) {
 var completeCallback;

 element = $(element);
 element.disable();
 if (!options) options = {};
 completeCallback = options.onComplete;
 options.onComplete = function() {
 element.enable();
 if (completeCallback) {
 completeCallback.apply(undefined, arguments);
 }
 };
 }
 };

 That defines an explicit way for you to say this call was triggered
 by this element and it provides automatic element disabling/
 enabling. So in a click handler:

 $('mybutton').observe('click', function(event) {
 event.stop();
 MoreAjax.react(this, 'myurl', {
 parameters: this.up('form').serialize({hash: true}),
 onSuccess: function(resp) {
 // Some nifty thing
 }
 });
 });

 Voila, the button is disabled during the request and enabled when it's
 done.

 I'm sure that function as written (er, dashed off) is completely wrong
 for what you're trying to do, it just illustrates the idea.

 In my apps, I never use Ajax.Request or Ajax.Updater directly. I
 always have wrappers that factor out the complexity in ways
 appropriate to the application.

 FWIW!
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 26, 9:25 am, Alex McAuley webmas...@thecarmarketplace.com
 wrote:
  Really?

  I thought the explination was a simple one.

  To recap

  A global way of knowing what is going on inside Ajax requests including.

  1. The element that triggered the call
  2. The container (if Ajax.Updater) the response is going to.

  Yes i have looked at Responders and i am using them now to lock 
  (disable)
  input elements but as i cannot get the element that triggered the call i
  have to lock the whole document which is not neccesary and slow - it 
  would
  be better to find the parent or inputs above the callee and lock them
  while
  the request is going on (to stop people pushing the button twice etc 
  etc)
  then unlock on onComplete.

  My way is working fine at the moment ... but ... it would be quicker and
  more efficient if i could in some way get the nodes/elements i desire on 
  a
  global basis as part fo the framework and not hacked ontop of it.

  Hope this clears things up a bit

  Alex Mcauleyhttp://www.thevacancymarket.com

  - Original Message -
  From: Timo timo.kiss...@gmail.com
  To: Prototype  script.aculo.us
  prototype-scriptaculous@googlegroups.com
  Sent: Tuesday, August 25, 2009 4:11 PM
  Subject: [Proto-Scripty] Re: Ajax requests again

   On 20 Aug., 17:15, Alex Mcauley webmas...@thecarmarketplace.com
   wrote:
   earlier on in the 

[Proto-Scripty] Re: More useful clone method

2009-08-26 Thread watermark86

1.6.1rc3 added Element.clone (which calls cloneNode).

On Aug 25, 5:46 pm, Matt Foster mattfoste...@gmail.com wrote:
 Good luck with this,  let us know if it works out.

 Quick glance at your code I can see an obvious error...

          var newElement = element.clone(true); //clone the node

 Element doesn't have a clone method.  The native DOM element does have
 a cloneNode method though.

 --

 http://positionabsolute.net

 On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote:

  I'm using 1.6.1rc3 to have access to Element.storage.  I need to write
  a function that deep clones an element and copies the Element.observe
  events as well as the Element.Storage items with it.  I've managed to
  write the code that can copy one or the other.

  The problem comes in when I try to do both (copy the storage items and
  the events.)  I suppose due to Event.observe using the Element.storage
  item, I can't seem to have the items that I've stored with
  Element.store to copy while maintaining the Event.observe events that
  I've copied.

  I can copy the observe events or the element.store events, but not
  both.  Below is some terrible code for review.  Thanks for any help or
  insults.

  deepClone: function(element) {
          //deep clone node
          var newElement = element.clone(true); //clone the node

          //stop observing because of IE BS
          newElement.stopObserving();

          //copy the item
          var registry = Element.retrieve(element,
  'prototype_event_registry');
          if (!Object.isUndefined(registry)) {
                  registry.each( function(pair) {
                          var eventName = pair.key, responders = pair.value;
                          responders.each( function(r) {
                                  Element.observe(newElement, eventName, 
  r.handler);
                  });
                  });
          }

      //for all of the descendants, copy the event handlers
      var srcdecend = element.descendants();
      var dstdecend = newElement.descendants();
      var numdecend = srcdecend.length;

      for(var i = 0; i  numdecend; ++i) {
          //stop observing because of IE BS
                  dstdecend[i].stopObserving();
          //copy the registry
          var registry = Element.retrieve(srcdecend[i],
  'prototype_event_registry');
                  if (!Object.isUndefined(registry)) {
                          registry.each( function(pair) {
                                  var eventName = pair.key, responders = 
  pair.value;
                                  responders.each( function(r) {
                                          Element.observe(dstdecend[i], 
  eventName, r.handler);
                          });
                          });
                  }
      }

      return newElement;
    }
--~--~-~--~~~---~--~~
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-scriptaculous@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: $H need help

2009-08-26 Thread Kevin Porter

Nah, it doesn't like the 'input.id' as an object key. Object keys must 
be literals.

He'll have to assign that key with .set() before passing the hash into 
the update() function.

- Kev


ColinFine wrote:

 On Aug 26, 1:09 am, buda www...@pochta.ru wrote:
   
 I need to put into hash pairs:

 input1.id : input1.getValue
 
 inputN.id : inputN.getValue

 where N may be from 5 to 25

 
 In that case, update is the right tool, and I can't see anything wrong
 with your initial syntax. Could the error be somewhere else? Or might
 you have a stray comma at the end of your object (h.update
 ({ input.id: input.getValue(), });)?  (IE objects to that, rightly,
 but Firefox is more forgiving).

 



   


-- 
Kevin Porter
Advanced Web Construction Ltd
http://webutils.co.uk
http://billiardsearch.net
http://9ballpool.co.uk

AJAX Blackjack - real-time multi-player blackjack game with no flash, java or 
software downloads required - http://blackjack.webutils.co.uk



--~--~-~--~~~---~--~~
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-scriptaculous@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: More useful clone method

2009-08-26 Thread watermark86

Well, I have x-mas presents.  I give it it works for me status.
I've tested this bit of code with firefox and it seems to work with
every scenario I can throw at it.  I'm sure there is room for speed
improvements and I know it doesn't conform to coding style, but it
works.  It would be great if prototype officially extended
Element.clone with this functionality.

deepClone: function(element) {
var newElement = element.clone(true); //clone the node

//stop observing all events on the newElement (IE (and some
others?) copies them)
newElement.stopObserving();

//copy storage
Element.getStorage(newElement);
(Element.Storage[newElement._prototypeUID[0]]=new Hash
(Element.getStorage(element))).unset('prototype_event_registry');

//copy the events on the parent
if (!Object.isUndefined(registry = Element.retrieve(element,
'prototype_event_registry'))) {
registry.each( function(pair) {
var eventName = pair.key, responders = pair.value;
responders.each( function(r) {
Element.observe(newElement, eventName, 
r.handler);
});
});
}

//get all of the descendants
var srcdecend = element.descendants();
var dstdecend = newElement.descendants();
var numdecend = srcdecend.length;

//foreach of the descendants
for(var i = 0; i  numdecend; ++i) {
//stop observing all events on the newElement (IE (and some
others?) copies them)
dstdecend[i].stopObserving();
//copy storage
Element.getStorage(dstdecend[i]);

(Element.Storage[dstdecend[i]._prototypeUID[0]]=Element.getStorage
(srcdecend[i]).clone()).unset('prototype_event_registry');
//copy the events on each child to it's new corrisponding child
var registry = Element.retrieve(srcdecend[i],
'prototype_event_registry');
if (!Object.isUndefined(registry)) {
registry.each( function(pair) {
var eventName = pair.key, responders = 
pair.value;
responders.each( function(r) {
Element.observe(dstdecend[i], 
eventName, r.handler);
});
});
}
}

return newElement;
  }

On Aug 26, 9:43 am, watermark86 watermar...@gmail.com wrote:
 1.6.1rc3 added Element.clone (which calls cloneNode).

 On Aug 25, 5:46 pm, Matt Foster mattfoste...@gmail.com wrote:

  Good luck with this,  let us know if it works out.

  Quick glance at your code I can see an obvious error...

           var newElement = element.clone(true); //clone the node

  Element doesn't have a clone method.  The native DOM element does have
  a cloneNode method though.

  --

 http://positionabsolute.net

  On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote:

   I'm using 1.6.1rc3 to have access to Element.storage.  I need to write
   a function that deep clones an element and copies the Element.observe
   events as well as the Element.Storage items with it.  I've managed to
   write the code that can copy one or the other.

   The problem comes in when I try to do both (copy the storage items and
   the events.)  I suppose due to Event.observe using the Element.storage
   item, I can't seem to have the items that I've stored with
   Element.store to copy while maintaining the Event.observe events that
   I've copied.

   I can copy the observe events or the element.store events, but not
   both.  Below is some terrible code for review.  Thanks for any help or
   insults.

   deepClone: function(element) {
           //deep clone node
           var newElement = element.clone(true); //clone the node

           //stop observing because of IE BS
           newElement.stopObserving();

           //copy the item
           var registry = Element.retrieve(element,
   'prototype_event_registry');
           if (!Object.isUndefined(registry)) {
                   registry.each( function(pair) {
                           var eventName = pair.key, responders = pair.value;
                           responders.each( function(r) {
                                   Element.observe(newElement, eventName, 
   r.handler);
                   });
                   });
           }

       //for all of the descendants, copy the event handlers
       var srcdecend = element.descendants();
       var dstdecend = newElement.descendants();
       var numdecend = srcdecend.length;

       for(var i = 0; i  numdecend; ++i) {
           //stop observing because of IE BS
                   dstdecend[i].stopObserving();
           //copy the registry
           var registry = Element.retrieve(srcdecend[i],
   'prototype_event_registry');
                   if (!Object.isUndefined(registry)) {
                           

[Proto-Scripty] Re: Usage of AJAX responder to monitor AJAX calls and call custom javascript on AJAX call completion

2009-08-26 Thread krishna81m

I am trying to achieve something similar to using asynchronous =
false which waits until the AJAX call is completed!!
--~--~-~--~~~---~--~~
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-scriptaculous@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: KEY_DOWN event

2009-08-26 Thread Ooypunk

I see now I made a mistake in my question. I know where it is in the
manual and I know what it's for, I just don't know hów to... For
catching the mouse-events the manual is clear enough (there's a clear
example in the next paragraph), but there is no example for catching
the keyboard events.

About the contribution: I still don't know how to use the catching of
keyboard events, so I can't make a piece of code to send as
contribution. But once I do know, I will!

On Aug 25, 11:13 pm, T.J. Crowder t...@crowdersoftware.com wrote:
 Hi,

  Only thing left for me to complain is that I still don't know what
  names like KEY_DOWN are for...

 They're for the keyboard events; see the link in my previous post.

  ...and that
  there's nothing in the manual (hint).

 Isn't there?[1, fourth paragraph]  But by all means, feel free to post
 a documentation ticket to Lighthouse with a patch in markdown format,
 contributions are welcome. :-) Details.[2]

 [1]http://prototypejs.org/api/event
 [2]http://prototypejs.org/contribute
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available

 On Aug 25, 1:07 pm, Ooypunk ooyp...@gmail.com wrote:

  OK, then I'll go with that. Thanks!

  Only thing left for me to complain is that I still don't know what
  names like KEY_DOWN are for, or how they should be used, and that
  there's nothing in the manual (hint).

  On Aug 25, 11:37 am, T.J. Crowder t...@crowdersoftware.com wrote:

   Hi,

   If you want to know whether the control key was down when the mouse
   was clicked, then yes, the ctrlKey property of the mouse click event
   object is what you want.

       element.observe('click', function(event) {
           if (event.ctrlKey) {
               // Something cool here
           }
       }

  https://developer.mozilla.org/en/DOM/event.ctrlKey

   If you're looking to receive an event (separate from the click) when
   the control key is pressed, that varies quite a bit by 
   browser:http://unixpapa.com/js/key.html

   But my impression is that you're just looking for it when the mouse is
   clicked, which is much more reliable.

   HTH,
   --
   T.J. Crowder
   tj / crowder software / com
   Independent Software Engineer, consulting services available

   On Aug 25, 12:09 am, Ooypunk ooyp...@gmail.com wrote:

Hi,

I was looking for a way to capture a mouse-click plus ctrl-button. As
I am using Prototype now for some time (it's great!), I thought
Prototype could help me with this too.
Sure, the manual is clear enough of how to capture a mouse-click event
(that works fine here), but how about the ctrl-button? According to
the manual, there's a list of key codes to be used (KEY_DOWN, for
example), but there is no KEY_CTRL and there is nowhere to be found
how they should be used.
It says it's self explanatory, but for me it isn't. :(

I think I can get it to work with event.ctrlKey, but I have a feeling,
this is not the way.

Thanks in advance.

Ooypunk

PS. I hope I made my problem clear enough, I know I'm not very good at
explaining, especially because english is not my mother tongue.
--~--~-~--~~~---~--~~
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-scriptaculous@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: this keyword inside of the map function

2009-08-26 Thread Andy Daykin

Thanks a lot! It's working perfectly now!

-Andy

--
From: Daniel Rubin dru...@dimedis.de
Sent: Wednesday, August 26, 2009 3:01 AM
To: prototype-scriptaculous@googlegroups.com
Subject: [Proto-Scripty] Re: this keyword inside of the map function


 Andy Daykin wrote:
 The way that my script is working on that page http://andydaykin.com/Home
 (http://andydaykin.com/Home/public/js/Home.js is the link to the 
 javascript
 file) is how I want it to work, but I want to make my script fit the
 prototype conventions a little bit more.

 So if I try and make instance variables, the doSlide function can't see
 them. As I stated before the scope of this inside of the map function is
 what is causing the problem I believe. The click handler (doSlide) won't
 recognize an instance variable.

 For instance if I say this.varName in my init function, and try and 
 access
 this.varName in the doSlide function, the variable won't be recognized.

 To solve this I am using var varName outside of the class, but I would
 like to do this the proper way.

 -Andy
 Alright, I'll just post how I believe it should work.

 //
 initialize: function (parentDiv, featuresWrapper) {
var features = $(featuresWrapper).descendants ();
$(parentDiv).descendants ().map (function (e, i) {
$(e).observe ('click',
  this.doSlide.bind (this, features[i].id));
}, this);

slides = $$('.featureImage').map (function (e) {
return e.id;
});
 },
 //

 1) I threw out the dom:loaded-handling stuff: The particular SlideShow
object should be created in such a handler, of course, but listening
for the event in the constructor would limit the class' use to this
application only.
Instead, put
  var mySlide = new SlideShow ('featureList', 'featuresWrapper');
in your global dom:loaded handler in the main HTML file.  (But make
sure to load Home.js first.)

 2) The featuresWrapper Element is passed as constructor arg now, too.
No point in hard-coding it, I think.

 3) Note this as the second parameter to the map-call.  That's the
context-param T. J. pointed out.  By passing this, we ensure
that this is the same inside and outside the mapping-function.

 4) The mapping-function takes a second parameter i, which is just
the old counter i, but readily provided by the map-iteration.

 I hope this works -- I have not tested it myself.

 Have fun
 Daniel



 --
 From: Daniel Rubin dru...@dimedis.de
 Sent: Tuesday, August 25, 2009 3:06 AM
 To: prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function

 Andy Daykin wrote:
 The doSlide function was what I was referring to. I tried using TJ's
 suggestion of using this as the 2nd parameter, but the handler still
 wasn't
 getting called. You can find a prototype of what I am doing at
 http://andydaykin.com/Home. The slideshow (images obviously missing) is
 on
 the main page. The javascript file for the class is
 http://andydaykin.com/Home/public/js/Home.js
 Could you please provide the current state once more? Perhaps stripped
 down to the vital parts of HTML and scripts? I think we need to have a
 look at the details here.

 Daniel



 --
 From: Daniel Rubin dru...@dimedis.de
 Sent: Friday, August 21, 2009 3:38 AM
 To: prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function

 Andy Daykin wrote:
 I tried the first suggestion, but the function still isn't getting
 called.
 Exactly which function do you refer to? The map-iterator-func 
 (function
 (e) { ... }) or the click-handler (this.doSlide)?

 Daniel



 TJ, can you explain more, or show an example of what the context 
 param
 would
 look like? Should I just put the doSlide function as the 2nd 
 parameter?

 -Andy

 --
 From: T.J. Crowder t...@crowdersoftware.com
 Sent: Thursday, August 20, 2009 3:56 AM
 To: Prototype  script.aculo.us
 prototype-scriptaculous@googlegroups.com
 Subject: [Proto-Scripty] Re: this keyword inside of the map function

 Hi,

 Rather than binding it, use the second parameter to map (aka collect
 [1]), that's what the second param (context) is for.  You'll find
 that most of the Enumerable methods that take callbacks also take a
 context parameter so the callback can be a method.

 [1] http://prototypejs.org/api/enumerable/collect

 HTH,
 --
 T.J. Crowder
 tj / crowder software / com
 Independent Software Engineer, consulting services available


 On Aug 20, 8:34 am, Daniel Rubin dru...@dimedis.de wrote:
 Andy Daykin wrote:
 Hello, I am having some difficulties writing a class, in my code I
 have
 a class where I need to be able