Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5545,7 +5545,126 @@ |
5546 | 5546 | } |
5547 | 5547 | } ); |
5548 | 5548 | } )( jQuery ); |
5549 | | -/** |
| 5549 | +/*! |
| 5550 | + * jQuery iFrame Inheritance |
| 5551 | + * |
| 5552 | + * Copyright (c) 2009 Eric Garside (http://eric.garside.name) |
| 5553 | + * Dual licensed under: |
| 5554 | + * MIT: http://www.opensource.org/licenses/mit-license.php |
| 5555 | + * GPLv3: http://www.opensource.org/licenses/gpl-3.0.html |
| 5556 | + */ |
| 5557 | +( function( $ ) { |
| 5558 | + |
| 5559 | +// Create a function in the Global Namespace so we can access it from the iFrame by calling parent.inherit() |
| 5560 | +this.inherit = function( child ) { |
| 5561 | + // First, bind a copy of jQuery down into the DOM of the iFrame, so we can hook in functionality. Things may get a |
| 5562 | + // bit confusing here, as we're creating this function in the parent, but have to set it up internally to get called |
| 5563 | + // as if it were in the child. |
| 5564 | + child.jQueryInherit = this.parent.jQuery; |
| 5565 | + // Bind a special ready callback binding function, to handle the scope of responding to the document.ready hook |
| 5566 | + // instead of the parent's document.ready |
| 5567 | + child.jQueryInherit.fn.ready = function( fn ) { |
| 5568 | + // Attach the listeners |
| 5569 | + child.jQueryInherit.hooks.bindReady(); |
| 5570 | + // If the DOM is already ready |
| 5571 | + if ( child.jQueryInherit.hooks.isReady ) { |
| 5572 | + // Simply trigger the callback |
| 5573 | + fn.call( child.document, child.jQueryInherit ); |
| 5574 | + } else { |
| 5575 | + // Otherwise, remember it so we can trigger it later |
| 5576 | + child.jQueryInherit.hooks.readyList.push( fn ); |
| 5577 | + } |
| 5578 | + return this; |
| 5579 | + }; |
| 5580 | + // Create a namespace for hooking some functionality to the iFrame, like document.ready detection and handling |
| 5581 | + var hooks = child.jQueryInherit.hooks = { |
| 5582 | + isReady: false, |
| 5583 | + readyBound: false, |
| 5584 | + readyList: [], |
| 5585 | + // Mimic the readyBind() function in the child, so it can set up the listeners for document.ready |
| 5586 | + bindReady: function() { |
| 5587 | + if ( hooks.readyBound ) { |
| 5588 | + return; |
| 5589 | + } |
| 5590 | + hooks.readyBound = true; |
| 5591 | + // Mozilla, Opera, and webkit nightlies support |
| 5592 | + if ( child.document.addEventListener ) { |
| 5593 | + child.document.addEventListener( |
| 5594 | + "DOMContentLoaded", |
| 5595 | + function() { |
| 5596 | + child.document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
| 5597 | + hooks.ready(); |
| 5598 | + }, |
| 5599 | + false |
| 5600 | + ); |
| 5601 | + } |
| 5602 | + // For IE |
| 5603 | + else if ( child.document.attachEvent ) { |
| 5604 | + // Ensure firing before onload, maybe late but safe also for iframes |
| 5605 | + child.document.attachEvent( |
| 5606 | + "onreadystatechange", |
| 5607 | + function(){ |
| 5608 | + if ( child.document.readyState === "complete" ) { |
| 5609 | + child.document.detachEvent( "onreadystatechange", arguments.callee ); |
| 5610 | + hooks.ready(); |
| 5611 | + } |
| 5612 | + } |
| 5613 | + ); |
| 5614 | + // If IE and not an iframe continually check to see if the document is ready |
| 5615 | + if ( child.document.documentElement.doScroll && child == child.top ) { |
| 5616 | + if ( !hooks.isReady ) { |
| 5617 | + try { |
| 5618 | + // If IE is used, use the trick by Diego Perini http://javascript.nwbox.com/IEContentLoaded/ |
| 5619 | + child.document.documentElement.doScroll( "left" ); |
| 5620 | + } catch ( error ) { |
| 5621 | + setTimeout( arguments.callee, 0 ); |
| 5622 | + return; |
| 5623 | + } |
| 5624 | + // And execute any waiting functions |
| 5625 | + hooks.ready(); |
| 5626 | + } |
| 5627 | + } |
| 5628 | + } |
| 5629 | + // A fallback to window.onload, that will always work |
| 5630 | + jQuery.event.add( child, "load", hooks.ready ); |
| 5631 | + }, |
| 5632 | + // Hook the ready trigger to fire off the hook bindings |
| 5633 | + ready: function() { |
| 5634 | + // Make sure the DOM is not already loaded |
| 5635 | + if ( !hooks.isReady ) { |
| 5636 | + // Remember that the DOM is ready |
| 5637 | + hooks.isReady = true; |
| 5638 | + // If there are functions bound... |
| 5639 | + if ( hooks.readyList ) { |
| 5640 | + // Execute them all |
| 5641 | + jQuery.each( hooks.readyList, function() { |
| 5642 | + this.call( child.document, child.jQueryInherit ); |
| 5643 | + } ); |
| 5644 | + // Reset the list of functions |
| 5645 | + hooks.readyList = null; |
| 5646 | + } |
| 5647 | + // Trigger any bound ready events |
| 5648 | + jQuery( child.document ).triggerHandler( 'ready' ); |
| 5649 | + } |
| 5650 | + } |
| 5651 | + }; |
| 5652 | + return child.jQuery = child.$j = function( selector, context ) { |
| 5653 | + // Test and see if we're handling a shortcut bind for the document.ready function. This occurs when the selector |
| 5654 | + // is a function. Because firefox throws xpconnect objects around in iFrames, the standard |
| 5655 | + // jQuery.isFunction test returns false negatives. |
| 5656 | + // PATCHED: Disable this check because it breaks subtly on IE7 and we don't use $j( function() { ... } ) anyway |
| 5657 | + if ( false && selector.constructor.toString().match( /Function/ ) != null ) { |
| 5658 | + return child.jQueryInherit.fn.ready( selector ); |
| 5659 | + } |
| 5660 | + // Otherwise, just let the jQuery init function handle the rest. Be sure we pass in proper context of the |
| 5661 | + // child document, or we'll never select anything useful. |
| 5662 | + else { |
| 5663 | + return child.jQueryInherit.fn.init( selector || this.document, context || this.document ); |
| 5664 | + } |
| 5665 | + }; |
| 5666 | +} |
| 5667 | + |
| 5668 | +} )( jQuery );/** |
5550 | 5669 | * Plugin that fills a <select> with namespaces |
5551 | 5670 | */ |
5552 | 5671 | |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -372,7 +372,14 @@ |
373 | 373 | $.fn.extend({delayedBind:function(timeout,event,data,callback){var encEvent=encodeEvent(event);return this.each(function(){var that=this;if(!($(this).data('_delayedBindBound-'+encEvent+'-'+timeout))){$(this).data('_delayedBindBound-'+encEvent+'-'+timeout,true);$(this).bind(event,function(){var timerID=$(this).data('_delayedBindTimerID-'+encEvent+'-'+timeout);if(typeof timerID!='undefined') |
374 | 374 | clearTimeout(timerID);timerID=setTimeout(function(){$(that).trigger('_delayedBind-'+encEvent+'-'+timeout);},timeout);$(this).data('_delayedBindTimerID-'+encEvent+'-'+timeout,timerID);});} |
375 | 375 | $(this).bind('_delayedBind-'+encEvent+'-'+timeout,data,callback);});},delayedBindCancel:function(timeout,event){var encEvent=encodeEvent(event);return this.each(function(){var timerID=$(this).data('_delayedBindTimerID-'+encEvent+'-'+timeout);if(typeof timerID!='undefined') |
376 | | -clearTimeout(timerID);});},delayedBindUnbind:function(timeout,event,callback){var encEvent=encodeEvent(event);return this.each(function(){$(this).unbind('_delayedBind-'+encEvent+'-'+timeout,callback);});}});})(jQuery);(function($){$.fn.namespaceSelector=function(defaultNS){if(typeof defaultNS=='undefined') |
| 376 | +clearTimeout(timerID);});},delayedBindUnbind:function(timeout,event,callback){var encEvent=encodeEvent(event);return this.each(function(){$(this).unbind('_delayedBind-'+encEvent+'-'+timeout,callback);});}});})(jQuery);(function($){this.inherit=function(child){child.jQueryInherit=this.parent.jQuery;child.jQueryInherit.fn.ready=function(fn){child.jQueryInherit.hooks.bindReady();if(child.jQueryInherit.hooks.isReady){fn.call(child.document,child.jQueryInherit);}else{child.jQueryInherit.hooks.readyList.push(fn);} |
| 377 | +return this;};var hooks=child.jQueryInherit.hooks={isReady:false,readyBound:false,readyList:[],bindReady:function(){if(hooks.readyBound){return;} |
| 378 | +hooks.readyBound=true;if(child.document.addEventListener){child.document.addEventListener("DOMContentLoaded",function(){child.document.removeEventListener("DOMContentLoaded",arguments.callee,false);hooks.ready();},false);} |
| 379 | +else if(child.document.attachEvent){child.document.attachEvent("onreadystatechange",function(){if(child.document.readyState==="complete"){child.document.detachEvent("onreadystatechange",arguments.callee);hooks.ready();}});if(child.document.documentElement.doScroll&&child==child.top){if(!hooks.isReady){try{child.document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;} |
| 380 | +hooks.ready();}}} |
| 381 | +jQuery.event.add(child,"load",hooks.ready);},ready:function(){if(!hooks.isReady){hooks.isReady=true;if(hooks.readyList){jQuery.each(hooks.readyList,function(){this.call(child.document,child.jQueryInherit);});hooks.readyList=null;} |
| 382 | +jQuery(child.document).triggerHandler('ready');}}};return child.jQuery=child.$j=function(selector,context){if(false&&selector.constructor.toString().match(/Function/)!=null){return child.jQueryInherit.fn.ready(selector);} |
| 383 | +else{return child.jQueryInherit.fn.init(selector||this.document,context||this.document);}};}})(jQuery);(function($){$.fn.namespaceSelector=function(defaultNS){if(typeof defaultNS=='undefined') |
377 | 384 | defaultNS=0;return this.each(function(){for(var id in wgFormattedNamespaces){var opt=$('<option />').attr('value',id).text(wgFormattedNamespaces[id]);if(id==defaultNS) |
378 | 385 | opt.attr('selected','selected');opt.appendTo($(this));}});};})(jQuery);(function($){$.suggestions={cancel:function(context){if(context.data.timerID!=null){clearTimeout(context.data.timerID);} |
379 | 386 | if(typeof context.config.cancel=='function'){context.config.cancel.call(context.data.$textbox);}},restore:function(context){context.data.$textbox.val(context.data.prevText);},update:function(context,delayed){function maybeFetch(){if(context.data.$textbox.val()!==context.data.prevText){context.data.prevText=context.data.$textbox.val();if(typeof context.config.fetch=='function'){context.config.fetch.call(context.data.$textbox,context.data.$textbox.val());}}} |
Index: trunk/extensions/UsabilityInitiative/Makefile |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | js/plugins/jquery.collapsibleTabs.js\ |
26 | 26 | js/js2stopgap/jquery.cookie.js\ |
27 | 27 | js/plugins/jquery.delayedBind.js\ |
| 28 | + js/plugins/jquery.inherit.js\ |
28 | 29 | js/plugins/jquery.namespaceSelect.js\ |
29 | 30 | js/plugins/jquery.suggestions.js\ |
30 | 31 | js/js2stopgap/jquery.textSelection.js\ |