I hate to say this but I think your efforts here are a bit misguided. "this"
does not reference the window everywhere. It references whatever the method
belongs to. As in my previous example, "this" points at the array inside of
[].each.

If you wanted to redefine how the few methods that reference the window
work, you should not hack the framework but instead overwrite those methods
within your own environment. Just redefine them. Still, I have a feeling
this won't really work...

On Fri, Apr 17, 2009 at 1:18 PM, csuwldcat (via Nabble) <
[email protected]<ml-user%[email protected]>
> wrote:

>
> What I am doing is like a Super Greasemonkey framework that cuts
> through all of XUL's bullshit xpcnativewrappers and garbage and let's
> people script in addons the exact same way they do a normal web page.
> Any ideas/help are really appreciated.
>
> On Apr 17, 10:11 am, csuwldcat 
> <daniel...@...<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=2651907&i=0>>
> wrote:
> > Haha this thread is getting funny, Aaron I mean the this keyword
> > reference in the lib (here are some functions inside Mootools:
> >
> >         newElement: function(tag, props){
> >                 if (Browser.Engine.trident && props){
> >                         ['name', 'type',
> 'checked'].each(function(attribute){
> >                                 if (!props[attribute]) return;
> >                                 tag += ' ' + attribute + '="' +
> props[attribute] + '"';
> >                                 if (attribute != 'checked') delete
> props[attribute];
> >                         });
> >                         tag = '<' + tag + '>';
> >                 }
> >                 return $.element(this.createElement(tag)).set(props);
> >         },
> >
> >         newTextNode: function(text){
> >                 return this.createTextNode(text);
> >         },
> >
> >         getDocument: function(){
> >                 return  this;
> >         },
> >
> >         getWindow: function(){
> >                  this.window;
> >         }
> >
> > So I want to change the 'this' ref in the library, set a new context
> > if you will.  So not THIS window object, but THAT window object.
> >
> > This is from the base event constructor:
> >
> > Syntax:
> >
> > new Event([event[, win]]);
> > Arguments:
> >
> > event - (event) An HTMLEvent Object.
> > win - (window, optional: defaults to window) The context of the event.
> >
> > I want to be able to set a context for all actions to something
> > different, jQuery does this with a context option in its $ selector
> > function.  I have hacked the core lib the to do what I want but i
> > would rather not, here is the same lines of code modified:
> >
> >         newElement: function(tag, props){
> >                 if (Browser.Engine.trident && props){
> >                         ['name', 'type',
> 'checked'].each(function(attribute){
> >                                 if (!props[attribute]) return;
> >                                 tag += ' ' + attribute + '="' +
> props[attribute] + '"';
> >                                 if (attribute != 'checked') delete
> props[attribute];
> >                         });
> >                         tag = '<' + tag + '>';
> >                 }
> >                 if(typeof tab == 'undefined'){return
> $.element(this.createElement
> > (tag)).set(props);} else{ return $(tab.document.createElement(tag)).set
> > (props); }
> >         },
> >
> >         newTextNode: function(text){
> >                 return this.createTextNode(text);
> >         },
> >
> >         getDocument: function(){
> >                 return (typeof tab == 'undefined') ? this : tab.document;
>  // this
> > line used to be: return this
> >         },
> >
> >         getWindow: function(){
> >                 return (typeof tab == 'undefined') ? this.window :
> tab.window;  //
> > this line used to be: return this.window
> >         }
> >
> > See all those tab. references, that is what I am doing to give these
> > functions new contexts in which to operate on.  I am doing so because
> > I am writing a compatibility layer for working fluidly across FF tab
> > documents from a central XUL overlay via FF addon.  You see the this
> > natively referred to in Mootools kept referencing the wrond window,
> > the XUL overlay window of the FF addon.  I had to make sure it always
> > thought in terms of the tab I was intending to deal with, thus the
> > mods.
> >
> > What I needed was a way to change the refs globally in the Mootools
> > object, so that the context can be changed fluidly.  Any thoughts?  I
> > am submitting this framework to Rey Bango and it is going to be a
> > tutorial thing on MDC, it would benefit us all if there was a better
> > way to change contexts than through lib modifications.
> >
> > - Daniel
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/-Moo--How-do-I-change-the-this-keyword-ref-in-the-Mootools-lib-object--tp2649230p2651907.html
> To start a new topic under MooTools Users, email
> [email protected]<ml-node%[email protected]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>


-----
The MooTools Tutorial:  http://www.mootorial.com www.mootorial.com 
Clientcide:  http://www.clientcide.com www.clientcide.com 
-- 
View this message in context: 
http://n2.nabble.com/-Moo--How-do-I-change-the-this-keyword-ref-in-the-Mootools-lib-object--tp2649230p2651940.html
Sent from the MooTools Users mailing list archive at Nabble.com.

Reply via email to