Skip to main content

Bug Tracker

Side navigation

Ticket #2707: jquery.contextswitch.js


File jquery.contextswitch.js, 0.9 KB (added by morgan, October 08, 2008 06:18PM UTC)
$.fn.contents = function(selector)
{
        var context = jQuery;

        var ret = jQuery.map( this, function(elem)
        {
                if(elem.contentWindow && elem.contentWindow.jQuery && context.nodeName(elem, "iframe"))
                {
                        context = elem.contentWindow.jQuery;
                        return elem.contentDocument || elem.contentWindow.document;
                }
                else if(context.nodeName(elem, "iframe"))
                        return elem.contentDocument || elem.contentWindow.document;

                return jQuery.makeArray(elem.childNodes);
        });

        if( selector && typeof selector == "string")
                ret = jQuery.multiFilter( selector, ret );

        if(context == jQuery)
                return this.pushStack( jQuery.unique( ret ) );

        return context(jQuery.map( this, function(elem) { return elem })).pushStack( context.unique( ret ) );
}

Download in other formats:

Original Format