[Prototype-core] Re: Thoughts about 1.6

2007-09-25 Thread Ryan Gahl
I vote an emphatic No - this would be overhead within proto-core, which
should remain as _baseline_ as possible (that's my rant and I'm sticking to
it - proto is a baseline - don't bloat it... please!). What people need to
get in the habit of doing is loading an extensions.js file (or something)
after proto (or lib-of-choice)... and do whatever overriding/wrapping there.

Your case in point...

var oldInsert = Element.insert;
Element.insert = function(...) {... fireYourCustomEvent() ...
oldInsert(...)};



On 9/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


 I had an interesting thought while testing out version 1.6 RC - I
 thought I'd solicit some opinions (and possibly make a suggestion).

 There is not a very reliable cross-browser way to implement the DOM
 mutation events - (such as DOMNodeInserted, DOMNodeRemoved,
 DOMAttrModified, etc).  However, using custom events, it should be
 possible to register listeners for equivalents and send those events
 in prototype calls, such as Element.insert, etc.

 That would allow for some pretty powerful dynamic things - that can
 observe DOM change events.  1.6 already spoofs one of those events
 in the contentloaded event...it would be pretty cool to add a bit
 more support for others as well...

 What are peoples' thoughts on this?  Or would it better be implemented
 outside of prototype (I can't think of a way to piggyback on the
 already-existing functions without writing wrapper functions and
 extending thingspossible, but it seems a bit cleaner to support it
 natively within prototype itself.


 



-- 
Ryan Gahl
Manager, Senior Software Engineer
Nth Penguin, LLC
http://www.nthpenguin.com
--
Architect
WebWidgetry.com / MashupStudio.com
Future Home of the World's First Complete Web Platform
--
Inquire: 1-262-951-6727
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl

--~--~-~--~~~---~--~~
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: Thoughts about 1.6

2007-09-25 Thread Mislav Marohnić
On 9/25/07, Ryan Gahl [EMAIL PROTECTED] wrote:


 var oldInsert = Element.insert;
 Element.insert = function(...) {... fireYourCustomEvent() ...
 oldInsert(...)};


We hear what you are saying. I don't know all the things Sam had in mind,
but I'm pretty sure he wasn't going to slow down Prototype for everyone just
for the 5% early adopters who would actually use the mutation events.

Sam and Thomas have some tricks up their sleeve regarding future versions of
Prototype, script.aculo.us and modularization. Just wait and see ...

--~--~-~--~~~---~--~~
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: Thoughts about 1.6

2007-09-25 Thread [EMAIL PROTECTED]

 I vote an emphatic No - this would be overhead within proto-core, which
 should remain as _baseline_ as possible (that's my rant and I'm sticking to
 it - proto is a baseline - don't bloat it... please!).

I see that point - and that was the type of discussion that I wanted
to spawn.  I agree that the core should not be bloated at all...but
exactly *what* should be in core or not?

 var oldInsert = Element.insert;
 Element.insert = function(...) {... fireYourCustomEvent() ...
 oldInsert(...)};

This is actually a pretty easy way to do that.  I don't have a problem
at all implementing this sort of thing outside of the prototype core.
I was just originally thinking that it would help to move Prototype
more towards its goal of creating a level-playing field of sorts - a
core library that irons out all the little cross-browser quirks that
exist (and mutation events are one of those...that was my original
thinking).

Thanks for the comments!


--~--~-~--~~~---~--~~
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: Thoughts about 1.6

2007-09-25 Thread [EMAIL PROTECTED]

 var oldInsert = Element.insert;
 Element.insert = function(...) {... fireYourCustomEvent() ...
 oldInsert(...)};

Just for reference, the way that I got this to work in Prototype 1.6
was (hopefully this accounts for all cases):

var prev = {};
[insert,remove,replace,update,wrap].each(function(s){prev[s]
= Element[s]});
var add = {
insert: function(){
var args = $A(arguments), element = $(args.shift()), insertions 
=
args[0], fireEs = [];
if (Object.isString(insertions) || Object.isNumber(insertions) 
||
Object.isElement(insertions) || (insertions 
(insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
for (position in insertions) {
position = position.toLowerCase();
if (position == before || position == after)
{
fireEs.push($(element.parentNode));
}
else
{
fireEs.push(element);
}
}
var retVal = prev.insert(element, args);
fireEs.each(function(e){
fireE.fire(nodeadded);
fireE.fire(domchanged);
});
},
remove: function(){
var args = $A(arguments), element = $(args.shift()), fireE = $
(element.parentNode);
var retVal = prev.remove(element, args);
fireE.fire(noderemoved);
fireE.fire(domchanged);
return retVal;
},
replace: function(){
var args = $A(arguments), element = $(args.shift()), fireE = $
(element.parentNode);
var retVal = prev.replace(element, args);
fireE.fire(noderemoved);
fireE.fire(nodeadded);
fireE.fire(domchanged);
return retVal;
},
update: function(){
var args = $A(arguments), element = $(args.shift());
var retVal = prev.update(element, args);
element.fire(domchanged);
return retVal;
},
wrap: function(){
var args = $A(arguments), element = $(args.shift()), fireE = $
(element.parentNode);
var retVal = prev.wrap(element, args);
fireE.fire(nodeadded);
fireE.fire(domchanged);
return retVal;
}
}
Element.addMethods(add);


--~--~-~--~~~---~--~~
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: Thoughts about 1.6

2007-09-25 Thread [EMAIL PROTECTED]

No one probably cares but me about this - but there were a few issues
with the previous code...here is some that works, and is suitable for
placing in an extension.js file:

var prev = {};
[insert,remove,replace,update,wrap].each(function(s){prev[s]
= Element[s]});
var add = {
insert: function(element, insertions){
var fireEs = [];
if (Object.isString(insertions) || Object.isNumber(insertions) 
||
Object.isElement(insertions) || (insertions 
(insertions.toElement || insertions.toHTML)))
insertions = {bottom:insertions};
for (position in insertions) {
position = position.toLowerCase();
if (position == before || position == after)
{
fireEs.push($(element.parentNode));
}
else
{
fireEs.push(element);
}
}
var retVal = prev.insert(element, insertions);
fireEs.each(function(e){
e.fire(nodeadded);
e.fire(domchanged);
});
return retVal;
},
remove: function(element){
var fireE = $(element.parentNode), retVal = 
prev.remove(element);
fireE.fire(noderemoved);
fireE.fire(domchanged);
return retVal;
},
replace: function(element, content){
var fireE = $(element.parentNode), retVal = 
prev.replace(element,
content);
fireE.fire(noderemoved);
fireE.fire(nodeadded);
fireE.fire(domchanged);
return retVal;
},
update: function(element, content){
var retVal = prev.update(element, content);
element.fire(domchanged);
return retVal;
},
wrap: function(element, wrapper, attributes){
var fireE = $(element.parentNode);
var retVal = prev.wrap(element, wrapper, attributes);
fireE.fire(nodeadded);
fireE.fire(domchanged);
return retVal;
}
}
Element.addMethods(add);


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---