[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread Ben Nolan
I don't think the little snippet will do it.

You want something like:

Behaviour = {
sheets_ : $A(),
register : function(sheet){
  this.sheets_.push(sheet);
},
apply : function(){
  this.sheets_.each(** as above **);
}
}

Ben

On 5/4/07, chris <[EMAIL PROTECTED]> wrote:
>
> Would this solution be able to reapply the Behaviour rules to elements
> that are dynamically added to the page?  Nolan's Behaviour.js has a
> Behaviour.apply() function that does this.
>
> cheers, chris
>
> On May 3, 7:12 pm, "Mislav Marohnić" <[EMAIL PROTECTED]>
> wrote:
> > On 5/3/07, snarkyFish <[EMAIL PROTECTED]> wrote:
>
> > Once, when we (the core guys) chatted working on the event branch, I though
> > of how easy it would be to re-implement Behaviour in Prototype:
> >
> > var Behaviour = {
> >   register: function(obj) {
> > Event.onReady(function(){ for (sel in obj) $$(sel).each(obj[sel]) })
> >   }
> >
> > }
> >
> > Yeah, this is it. You only need Event.onReady() for this. You can find it in
> > the event branch or you can copy it over from LowPro. Once Event.onReady()
> > gets into trunk, these 3 lines will probably be all you need.
>
>
> >
>


-- 
Regards,
Ben Nolan

Moso Interactive

skype: bennolan
cell: +49 1577 383 7542

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread chris

Would this solution be able to reapply the Behaviour rules to elements
that are dynamically added to the page?  Nolan's Behaviour.js has a
Behaviour.apply() function that does this.

cheers, chris

On May 3, 7:12 pm, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> On 5/3/07, snarkyFish <[EMAIL PROTECTED]> wrote:

> Once, when we (the core guys) chatted working on the event branch, I though
> of how easy it would be to re-implement Behaviour in Prototype:
>
> var Behaviour = {
>   register: function(obj) {
> Event.onReady(function(){ for (sel in obj) $$(sel).each(obj[sel]) })
>   }
>
> }
>
> Yeah, this is it. You only need Event.onReady() for this. You can find it in
> the event branch or you can copy it over from LowPro. Once Event.onReady()
> gets into trunk, these 3 lines will probably be all you need.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread Thomas Fuchs

Don't forget about the possibility to register a global ajax callback  
that enables automatic behaviours for newly inserted DOM elements.

YMMV if you're into JSON and/or dynamically generated DOM sections  
with the new Element(...) stuff or scripty's builder.js -- you'll  
probably want a recursive method that applies behaviours, something  
like:

$('blah').applyBehaviours();

Or use wrap() to augment Element.update()

Or

Prototype is sweet, and gets more sugar on the top all the time... :)

Best,
Thomas

Am 03.05.2007 um 19:12 schrieb Mislav Marohnić:

> On 5/3/07, snarkyFish <[EMAIL PROTECTED]> wrote:
>
> I've been using prototype and behaviour side by side for a while now.
> I am rather new to prototype, but I've yet to find anything as simple
> and clean as behaviour ( http://bennolan.com/behaviour/ ) for
> associating an event to a css selector.
>
> Once, when we (the core guys) chatted working on the event branch,  
> I though of how easy it would be to re-implement Behaviour in  
> Prototype:
> var Behaviour = {
> register: function(obj) {
> Event.onReady(function(){ for (sel in obj) $$(sel).each(obj[sel]) })
> }
> }
> Yeah, this is it. You only need Event.onReady() for this. You can  
> find it in the event branch or you can copy it over from LowPro.  
> Once Event.onReady() gets into trunk, these 3 lines will probably  
> be all you need.
>
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread snarkyFish

That's great!  Thanks Mislav, I owe you a beer.

I'd like to put my vote in for rolling that into prototype proper.
It's such a simple way to implement clean event code.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread Ben Nolan
I should update bennolan.com/behaviour/. :)

Ben

On 5/3/07, Michael Peters <[EMAIL PROTECTED]> wrote:
>
> Mislav Marohnić wrote:
>
> > Yeah, this is it. You only need Event.onReady() for this. You can find
> > it in the event branch or you can copy it over from LowPro. Once
> > Event.onReady() gets into trunk, these 3 lines will probably be all you
> > need.
>
> And it's even better than the current behaviour.js since you can apply it to
> sub-trees of the DOM instead the entire document. This is really useful when 
> you
> just update a portion of the page and want to reapply behaviours. And with the
> new work on 1.5.1 it should be way faster than behaviour.js with the recent 
> work
> on getElementBySelector().
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>
>
> >
>


-- 
Regards,
Ben Nolan

Moso Interactive

skype: bennolan
cell: +49 1577 383 7542

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread Michael Peters

Mislav Marohnić wrote:

> Yeah, this is it. You only need Event.onReady() for this. You can find
> it in the event branch or you can copy it over from LowPro. Once
> Event.onReady() gets into trunk, these 3 lines will probably be all you
> need.

And it's even better than the current behaviour.js since you can apply it to
sub-trees of the DOM instead the entire document. This is really useful when you
just update a portion of the page and want to reapply behaviours. And with the
new work on 1.5.1 it should be way faster than behaviour.js with the recent work
on getElementBySelector().

-- 
Michael Peters
Developer
Plus Three, LP


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Integration of something like ben nolan's behaviour?

2007-05-03 Thread Mislav Marohnić
On 5/3/07, snarkyFish <[EMAIL PROTECTED]> wrote:
>
>
> I've been using prototype and behaviour side by side for a while now.
> I am rather new to prototype, but I've yet to find anything as simple
> and clean as behaviour ( http://bennolan.com/behaviour/ ) for
> associating an event to a css selector.


Once, when we (the core guys) chatted working on the event branch, I though
of how easy it would be to re-implement Behaviour in Prototype:

var Behaviour = {
  register: function(obj) {
Event.onReady(function(){ for (sel in obj) $$(sel).each(obj[sel]) })
  }
}

Yeah, this is it. You only need Event.onReady() for this. You can find it in
the event branch or you can copy it over from LowPro. Once Event.onReady()
gets into trunk, these 3 lines will probably be all you need.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Integration of something like ben nolan's behaviour?

2007-05-03 Thread snarkyFish

I've been using prototype and behaviour side by side for a while now.
I am rather new to prototype, but I've yet to find anything as simple
and clean as behaviour ( http://bennolan.com/behaviour/ ) for
associating an event to a css selector.

All the parts are there within prototype, so running them side by side
is wasted code.  Am I missing something?  Can prototype do it cleaner
than this?:

var myrules = {
'#scheduleTable a.deleteButton' : function(element){
element.onclick = function(){
return confirm('continue?');
}
}
};

Behaviour.register(myrules);


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Unexpected behaviour when using $A(document.getElementsByTagName("script"))

2007-05-03 Thread jdalton

Hello Richard,

First, this is not a $A() issue.

When you called ''With Reporter' you wont get scritpaculous because
your code is
executing before scriptaculous is even rendered via the dom. (top
down)

The dom should be there onLoad though. If not try:

Event.observe(window, 'load', function(){
setTimeout(function(){
   ReportJS('AfterLoad');
}, 100);
});

Maybe dynamically added scripts need time to be seen in the dom,
I used 100 miliseconds, but if that works i am sure any amount would
like 10.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Unexpected behaviour when using $A(document.getElementsByTagName("script"))

2007-05-03 Thread Richard Quadling

Hi.

You can jump straight the *** QUESTION *** if you want.

*** BACKGROUND ***

I have my own library of extensions, arranged in a manner similar to
Scriptaculous.

By using the same mechanism to load my library files as Scriptaculous,
I can edit single files and test.

But it is not working, and I'm stuck, but I think I've found my
problem. I just need a little pointer on fixing it.

It all seems to relate to ...

$A(document.getElementsByTagName("script"))

I've put together a small test ...

The HTML file loads Prototype.js (V1.5.1), a simple inline test script
and then Scriptaculous.js (V1.7.0).

In my real code, I load Prototype, Scriptaculous and then my library.

It then reports back, via the inline code, any JS paths or INLINE.

Reports are generated when :

1 - During processing of  and therefore my inline code.
2 - After the expected loading of Scriptaculous.
3 - During processing 
4 - By the Window.onload event.

When in the  tag the output doesn't show scriptaculous. This is
probaly OK the first time, but the second time (i.e. 'After
Scriptaculous'), is isn't.
Both Body and OnLoad correctly report all the files, but
Scriptaculous's files have not loaded.

Basically the scriptaculous library never loads is files (just like
mine wouldn't).

*** QUESTION ***

It seems that the call $A(document.getElementsByTagName("script")) is
cached in some way.

Is there a way to flush this cache prior to calling it again?

Regards,

Richard Quadling.

*** MORE BACKGROUND ***

=The HTML file==




function ReportJS(s_When)
{
$A(document.getElementsByTagName("script")).each(
function(s)
{
console.info(s_When, !!s.src ? s.src : 'inline');
});
}
ReportJS('With Reporter');
function ViaOnLoad()
{
ReportJS('OnLoad');
}
Event.observe(window, 'load', ViaOnLoad);


ReportJS('After Scriptaculous');
JS Test

ReportJS('Body');

=

The test is nothing more than a report for FireBug's console.

With Reporter http://local.quickscripts/global/javascript/prototype/prototype.js
With Reporter inline
After Scriptaculous
http://local.quickscripts/global/javascript/prototype/prototype.js
After Scriptaculous inline
Body http://local.quickscripts/global/javascript/prototype/prototype.js
Body inline
Body 
http://local.quickscripts/global/javascript/script.aculo.us/scriptaculous.js
Body inline
Body inline
OnLoad http://local.quickscripts/global/javascript/prototype/prototype.js
OnLoad inline
OnLoad 
http://local.quickscripts/global/javascript/script.aculo.us/scriptaculous.js
OnLoad inline
OnLoad inline

-- 
-
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Opera 8.54

2007-05-03 Thread Mislav Marohnić
On 5/3/07, alshur <[EMAIL PROTECTED]> wrote:
>
>
> Damn, Prototype 1.5.1 final doesn't have this issue fixed...


Sorry for that. It's a serious issue that we have overlooked because of lack
of information. But, the fix Andrew provided seems smart and sufficient - we
indeed should check if __proto__ exists in the first place

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Opera 8.54

2007-05-03 Thread Andrew Sumin

Done
http://dev.rubyonrails.org/ticket/8260#preview


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Opera 8.54

2007-05-03 Thread Tobie Langel

Post a bug! (http://prototypejs.org/contribute)

- Tobie

On May 3, 4:45 am, alshur <[EMAIL PROTECTED]> wrote:
> Damn, Prototype 1.5.1 final doesn't have this issue fixed...
>
> On Apr 26, 6:49 pm, Andrew Sumin <[EMAIL PROTECTED]> wrote:> I add prototype 
> 1.5.1_rc3 to the page. All submits in Opera do
> > nothing.
>
> > If I change
>
> > SpecificElementExtensions:
> >   (document.createElement('div').__proto__ !==
> >document.createElement('form').__proto__)
>
> > to
>
> > SpecificElementExtensions:
> >   (typeof(document.createElement('div').__proto__) != 'undefined'
> > &&
> >document.createElement('div').__proto__ !==
> >document.createElement('form').__proto__)
>
> > everything works fine.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Opera 8.54

2007-05-03 Thread alshur

Damn, Prototype 1.5.1 final doesn't have this issue fixed...

On Apr 26, 6:49 pm, Andrew Sumin <[EMAIL PROTECTED]> wrote:
> I add prototype 1.5.1_rc3 to the page. All submits in Opera do
> nothing.
>
> If I change
>
> SpecificElementExtensions:
>   (document.createElement('div').__proto__ !==
>document.createElement('form').__proto__)
>
> to
>
> SpecificElementExtensions:
>   (typeof(document.createElement('div').__proto__) != 'undefined'
> &&
>document.createElement('div').__proto__ !==
>document.createElement('form').__proto__)
>
> everything works fine.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---