[Proto-Scripty] Re: Finding Class methods

2011-03-18 Thread mmerlin
greg,

Nothing to do with Prototype.  Standard javascript / DOM


 If I do:
 for (m in c) console.log(m)
 I get a nice list of all variables and methods, but typeof m always
 returns 'string'.

for (a in b)
always sets 'a' to be a string.  It is the 'name' of the property in
'b'.

Try console.log(typeof c.m)

--
Phil

-- 
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: Is there a way to determine if a parameter to a function is a Template?

2010-09-06 Thread mmerlin
TJ, that explains the symptoms I was getting when writing a piece of
*Reflection* code to explore the DOM and javascript library code.  I
made it work, but did not understand WHY I needed to massage some
things to get reasonable results.

Got to keep learning :)
--
Phil

-- 
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] Event Delegation matching outside of 'boundary' element

2010-05-29 Thread mmerlin
Environment: Prototype 1.7 rc2; XAMPP on Ubutnu 10.4 (running as
VirtualBox vm); browsers: FF3.6.3 (localhost on Ubuntu 10.4); FF3.6.3
(Win XP SP3 over lan); IE8.0.6001 (Win XP SP3 over lan)

Using Element.on [$(ele).on( 'click', '.special', callback);] triggers
a callback for clicks inside of ele where ele and none of its
descendants match '.special' **IF** an ancestor of ele has the
special class.  The returned element for the event is that ancestor
element.  The same thing happens for other 'delegated' events.  Is
that the intended functionality?
Tracing the rc2 code, this seems to be lines 5679:5682.
handleEvent: function(event) {
 var element = event.findElement(this.selector);
 if (element) this.callback.call(this.element, event, element);
}

Should 5681:
if (element) this.callback.call(this.element, event, element);
be changed to something like:
if (element  element.descendantOf(this.element))
this.callback.call(this.element, event, element);

That check could of course be added to the callback code.  I just did
not expect event delegation to trigger and match elements outside of
the specified 'root' element.  If really do want to trigger events for
cases like this, another alternative would be so set element to
this.element, as the 'limit' for the delegation.

-- 
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: Blur, Focus, Event Delegation

2010-05-29 Thread mmerlin
I wrote my own code from a completely different direction before I saw
this.  That code adds new events to the standard code that do bubble.
It looks cleaner than what I did.  I added a 'wrapper' around the
standard code, with extra handling for the problem cases.  I also
added a descendant check that is not in the regular code (which I also
found after writing mine):

/* handle bubbling for blur and focus events, so that they can be used
with event delegation
 *
 * Usage: $(element).bubbleUp( eventName, selector, callback );
 */
Element.addMethods(
{
bubbleUp: function( element, eventName, selector, callback )
{
var localEle = $(element);
if( arguments.length  4 )
{
//With no selector, there is no Event 
delegation, and no special
handling needed
return localEle.on( eventName, selector );// 
selector is the
callback
}
if( eventName !== 'blur'  eventName !== 'focus' ) {
return localEle.on( eventName, selector, 
callback );
}//End if( eventName !== 'blur'  eventName !== 
'focus' ) {

if( localEle.addEventListener )
{
return localEle.addEventListener(
eventName,
function( triggerEvent )
{
var matchElement = 
triggerEvent.findElement( selector );
// Documentation says 
findElement returns 'document' when no
match; symptoms says 'undefined' instead
if( matchElement  
matchElement.descendantOf( localEle ))
{
callback.bind( this )( 
triggerEvent, matchElement );
}
},
true
);
}
else // !( localEle.addEventListener )
{
return localEle.on(
eventName === 
'focus'?'focusin':'focusout', // IE supports
[bubbling of] focusin and focusout
selector, callback //Extension: use 
local function, and replace
event.type with blur or focus before calling callback ??
);
}//End else !( localEle.addEventListener )
}//End bubbleUp: function
}
);

On May 28, 2:28 am, Радослав Станков rstan...@gmail.com wrote:
 Hi, as I said in this ticket, you can use this 
 code:http://gist.github.com/162593

 for bubbling focus/blur. I have been using it for months and never
 have a single problem with this approach  :)

-- 
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: Event Delegation matching outside of 'boundary' element

2010-05-29 Thread mmerlin
I don't think you understood my question.  I understand that event
delegation means that events bubble up from the element the event
actually occurred on, to the ancestor element that the event
[listener] was attached to.  And that the events that reach that
listener / handler are filtered based on the selector specified.  And
that the element returned is the ancestor of the element where the
event originated.  However, I did not expect to get events where that
ancestor element was ALSO an ancestor (not descendant) of the element
that the handler was attached to.

ele_matching_selector ... ele_with_handler ... ele_triggering_event

So descendant elements of ele_with_handler can trigger events, and the
handler sees them.  However, when using a selector, events on elements
that do not [match themselves] or have an ancestor matching the
selector get 'suppressed' before reaching the handler.  I would have
expected that if there was a matching ancestor, but that ancestor is
outside the 'scope' of ele_with_handler, that the event would also be
suppressed.

The way it works now, if an ancestor of ele_with_handler matches the
selection condition, no event filtering will occur for events on
descendants of ele_with_handler.

On May 29, 6:13 pm, Tobie Langel tobie.lan...@gmail.com wrote:
  The same thing happens for other 'delegated' events.  Is
  that the intended functionality?

 Yes. That's the very definition of event delegation.

 Best,

 Tobie

-- 
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: Blur, Focus, Event Delegation

2010-05-27 Thread mmerlin
Thanks,

I went over to lighthouse and found:
https://prototype.lighthouseapp.com/projects/8886/tickets/666-make-focus-blur-bubbles
so it is 'scheduled' for 2.0

If I need it (beyond my exploration code), I'll just have to roll my
own for now :(

--
Phil

-- 
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] Blur, Focus, Event Delegation

2010-05-26 Thread mmerlin
Not sure if this is a bug report, feature request, help request, or
even just a complaint about the state of the world :)

Using Prototype 1.7 rc2, I have been exploring event delegation with
the new Element#on functionality, using the css selector filter.  My
initial tests with click (and dblclick) events worked fine, but when I
moved on to blur and focus, things broke.
The blur and focus events work fine as long as the the '.on' is for
the actual (in my sample) input fields, but the events do not trigger
(bubble) if I set the handler on an ancestor element.
It is *possible* to get the functionality (bubbling) to work, by
bypassing some of the prototype functionality, using .addEventListener
(for most browsers), and .observe with 'focusin' and 'focusout' events
(for IE).  (I found a sample for that at http://www.ruby-forum.com/topic/159048,
tried a variation of the code at http://pastie.org/pastes/186221).
That though falls back on the old techniques, where the handler needs
do something like findElement to figure out what the 'requested' event
should be associated with.

So:

Is there a way to get $(ele).on( some_event, css_selector ) ...
to trigger for blur and focus events on descendant elements of ele
with rc2?

Is that 'intended' to work with the latest code, since it is supposed
to provide first-class support for event delegation?

The 'basic' code I am trying to use is:
DelegationExplorer.start( ele, 'click', '.special' );
DelegationExplorer.start( ele, 'dblclick', '.special' );
DelegationExplorer.start( ele, 'blur', '.special' );
DelegationExplorer.start( ele, 'focus', '.special' );
...
 start: function(){
...
this.handlers[localEvn][eleId] = $(eleId).on( localEvn, localSel,
function( triggerEvent, matchElement ) {
 DelegationExplorer.genericHandler( triggerEvent, matchElement );
});

were ele is an ancestor of an input field [type=text or textarea].  I
have debug / introspection / reporting code in genericHandler to tell
which events are getting through.  Click and dblclick get reported,
blur and focus do not.

Using:
this.handlers[localEvn][eleId] = $(eleId).on( localEvn,
function( triggerEvent, matchElement ) {
 DelegationExplorer.directHandler( triggerEvent, matchElement );
});
triggers just fine, when eleId is the actual input field.

The 'fudge' to get [most of] the functionality (without the css
filter) is:
var myRoot = $('frm');
if( myRoot.addEventListener )
{
myRoot.addEventListener( 'focus', DelegationExplorer.directHandler,
true );
myRoot.addEventListener( 'blur', DelegationExplorer.directHandler,
true );
} else {
// IE supports focusin and focusout
myRoot.observe( 'focusin', DelegationExplorer.directHandler );
myRoot.observe( 'focusout', DelegationExplorer.directHandler );
}
where frm is again an ancestor of the input fields

--
mMerlin

-- 
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: storying and destroying metadata

2010-05-25 Thread mmerlin
1.7 rc2 is supposed to handle the cleanup for you in most cases.  See
http://www.prototypejs.org/2010/5/13/prototype-1-7-rc2 (use
Element.purge)

On May 21, 1:06 am, orbiter dkarapet...@gmail.com wrote:
 I recently discovered Element.store and Element.retrieve and I'm
 wondering a little about the semantics. Mainly I'm interested in the
 following use case: If I store some data and then delete the object on
 which I stored the data from the DOM tree what happens to the stored
 data? Do I need to worry about explicitly cleaning up everything I've
 stored before deleting the object or is that taken care of
 automatically?

 --
 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 
 athttp://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.