Index: trunk/phase3/includes/ResourceLoaderModule.php |
— | — | @@ -1123,11 +1123,11 @@ |
1124 | 1124 | // Startup function |
1125 | 1125 | $configuration = FormatJson::encode( $this->getConfig( $context ) ); |
1126 | 1126 | $registrations = self::getModuleRegistrations( $context ); |
1127 | | - $out .= "window.startUp = function() {\n\t$registrations\n\tmediaWiki.config.set( $configuration );\n};"; |
| 1127 | + $out .= "var startUp = function() {\n\t$registrations\n\tmediaWiki.config.set( $configuration );\n};"; |
1128 | 1128 | |
1129 | 1129 | // Conditional script injection |
1130 | 1130 | $scriptTag = Xml::escapeJsString( Html::linkedScript( $wgLoadScript . '?' . wfArrayToCGI( $query ) ) ); |
1131 | | - $out .= "if ( isCompatible() ) {\n\tdocument.write( '$scriptTag' );\n}\ndelete window['isCompatible'];"; |
| 1131 | + $out .= "if ( isCompatible() ) {\n\tdocument.write( '$scriptTag' );\n}\ndelete isCompatible;"; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | return $out; |
Index: trunk/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -758,10 +758,9 @@ |
759 | 759 | |
760 | 760 | } )( jQuery ); |
761 | 761 | |
762 | | - |
763 | 762 | /* Auto-register from pre-loaded startup scripts */ |
764 | 763 | |
765 | | -if ( typeof window['startUp'] === 'function' ) { |
766 | | - window['startUp'](); |
767 | | - delete window['startUp']; |
| 764 | +if ( typeof startUp === 'function' ) { |
| 765 | + startUp(); |
| 766 | + delete startUp; |
768 | 767 | } |
\ No newline at end of file |
Index: trunk/phase3/resources/startup.js |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | * * Opera 9+ |
16 | 16 | * * Chrome 1+ |
17 | 17 | */ |
18 | | -window.isCompatible = function() { |
| 18 | +var isCompatible = function() { |
19 | 19 | // IE < 6 |
20 | 20 | if ( navigator.appVersion.indexOf( 'MSIE' ) !== -1 && parseFloat( navigator.appVersion.split( 'MSIE' )[1] ) < 6 ) { |
21 | 21 | return false; |
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js |
— | — | @@ -488,32 +488,49 @@ |
489 | 489 | .appendTo( context.$ui ); |
490 | 490 | }, |
491 | 491 | /** |
492 | | - * Save scrollTop and cursor position for IE. |
| 492 | + * Save scrollTop and cursor position for IE |
493 | 493 | */ |
494 | | - 'saveStuffForIE': function() { |
495 | | - // Only need this for IE in textarea mode |
496 | | - if ( !$.browser.msie || context.$iframe ) |
497 | | - return; |
498 | | - var IHateIE = { |
499 | | - 'scrollTop' : context.$textarea.scrollTop(), |
500 | | - 'pos': context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } ) |
501 | | - }; |
502 | | - context.$textarea.data( 'IHateIE', IHateIE ); |
| 494 | + 'saveCursorAndScrollTop': function() { |
| 495 | + if ( $.client.name === 'msie' ) { |
| 496 | + var IHateIE = { |
| 497 | + 'scrollTop' : context.$textarea.scrollTop(), |
| 498 | + 'pos': context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } ) |
| 499 | + }; |
| 500 | + context.$textarea.data( 'IHateIE', IHateIE ); |
| 501 | + } |
503 | 502 | }, |
504 | 503 | /** |
505 | | - * Restore scrollTo and cursor position for IE. |
| 504 | + * Restore scrollTo and cursor position for IE |
506 | 505 | */ |
507 | | - 'restoreStuffForIE': function() { |
508 | | - // Only need this for IE in textarea mode |
509 | | - if ( !$.browser.msie || context.$iframe ) |
510 | | - return; |
511 | | - var IHateIE = context.$textarea.data( 'IHateIE' ); |
512 | | - if ( !IHateIE ) |
513 | | - return; |
514 | | - context.$textarea.scrollTop( IHateIE.scrollTop ); |
515 | | - context.$textarea.textSelection( 'setSelection', { start: IHateIE.pos[0], end: IHateIE.pos[1] } ); |
516 | | - context.$textarea.data( 'IHateIE', null ); |
517 | | - } |
| 506 | + 'restoreCursorAndScrollTop': function() { |
| 507 | + if ( $.client.name === 'msie' ) { |
| 508 | + var IHateIE = context.$textarea.data( 'IHateIE' ); |
| 509 | + if ( IHateIE ) { |
| 510 | + context.$textarea.scrollTop( IHateIE.scrollTop ); |
| 511 | + context.$textarea.textSelection( 'setSelection', { start: IHateIE.pos[0], end: IHateIE.pos[1] } ); |
| 512 | + context.$textarea.data( 'IHateIE', null ); |
| 513 | + } |
| 514 | + } |
| 515 | + }, |
| 516 | + /** |
| 517 | + * Save text selection for IE |
| 518 | + */ |
| 519 | + 'saveSelection': function() { |
| 520 | + if ( $.client.name === 'msie' ) { |
| 521 | + context.$textarea.focus(); |
| 522 | + context.savedSelection = document.selection.createRange(); |
| 523 | + } |
| 524 | + }, |
| 525 | + /** |
| 526 | + * Restore text selection for IE |
| 527 | + */ |
| 528 | + 'restoreSelection': function() { |
| 529 | + if ( $.client.name === 'msie' && context.savedSelection !== null ) { |
| 530 | + context.$textarea.focus(); |
| 531 | + context.savedSelection.select(); |
| 532 | + context.savedSelection = null; |
| 533 | + } |
| 534 | + }, |
518 | 535 | }; |
519 | 536 | |
520 | 537 | /* |
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | .append( |
113 | 113 | $( $.wikiEditor.modules.toolbar.fn.buildCharacter( data[type][character], actions ) ) |
114 | 114 | .mousedown( function( e ) { |
115 | | - context.fn.saveStuffForIE(); |
| 115 | + context.fn.saveCursorAndScrollTop(); |
116 | 116 | // No dragging! |
117 | 117 | e.preventDefault(); |
118 | 118 | return false; |
— | — | @@ -350,7 +350,7 @@ |
351 | 351 | .data( 'action', tool.action ) |
352 | 352 | .data( 'context', context ) |
353 | 353 | .mousedown( function( e ) { |
354 | | - context.fn.saveStuffForIE(); |
| 354 | + context.fn.saveCursorAndScrollTop(); |
355 | 355 | // No dragging! |
356 | 356 | e.preventDefault(); |
357 | 357 | return false; |
— | — | @@ -376,7 +376,7 @@ |
377 | 377 | .data( 'action', tool.list[option].action ) |
378 | 378 | .data( 'context', context ) |
379 | 379 | .mousedown( function( e ) { |
380 | | - context.fn.saveStuffForIE(); |
| 380 | + context.fn.saveCursorAndScrollTop(); |
381 | 381 | // No dragging! |
382 | 382 | e.preventDefault(); |
383 | 383 | return false; |
— | — | @@ -493,7 +493,7 @@ |
494 | 494 | .html( html ) |
495 | 495 | .children() |
496 | 496 | .mousedown( function( e ) { |
497 | | - context.fn.saveStuffForIE(); |
| 497 | + context.fn.saveCursorAndScrollTop(); |
498 | 498 | // No dragging! |
499 | 499 | e.preventDefault(); |
500 | 500 | return false; |
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.dialogs.js |
— | — | @@ -502,7 +502,7 @@ |
503 | 503 | 'wikieditor-toolbar-tool-link-cancel': function() { |
504 | 504 | // Clear any saved selection state |
505 | 505 | var context = $(this).data( 'context' ); |
506 | | - context.fn.restoreStuffForIE(); |
| 506 | + context.fn.restoreCursorAndScrollTop(); |
507 | 507 | $(this).dialog( 'close' ); |
508 | 508 | } |
509 | 509 | }, |
— | — | @@ -515,8 +515,8 @@ |
516 | 516 | // Pre-fill the text fields based on the current selection |
517 | 517 | var context = $(this).data( 'context' ); |
518 | 518 | // Restore and immediately save selection state, needed for inserting stuff later |
519 | | - context.fn.restoreStuffForIE(); |
520 | | - context.fn.saveStuffForIE(); |
| 519 | + context.fn.restoreCursorAndScrollTop(); |
| 520 | + context.fn.saveCursorAndScrollTop(); |
521 | 521 | var selection = context.$textarea.textSelection( 'getSelection' ); |
522 | 522 | $( '#wikieditor-toolbar-link-int-target' ).focus(); |
523 | 523 | // Trigger the change event, so the link status indicator is up to date |
— | — | @@ -649,7 +649,7 @@ |
650 | 650 | 'wikieditor-toolbar-tool-reference-cancel': function() { |
651 | 651 | // Clear any saved selection state |
652 | 652 | var context = $( this ).data( 'context' ); |
653 | | - context.fn.restoreStuffForIE(); |
| 653 | + context.fn.restoreCursorAndScrollTop(); |
654 | 654 | $( this ).dialog( 'close' ); |
655 | 655 | } |
656 | 656 | }, |
— | — | @@ -657,8 +657,8 @@ |
658 | 658 | // Pre-fill the text fields based on the current selection |
659 | 659 | var context = $(this).data( 'context' ); |
660 | 660 | // Restore and immediately save selection state, needed for inserting stuff later |
661 | | - context.fn.restoreStuffForIE(); |
662 | | - context.fn.saveStuffForIE(); |
| 661 | + context.fn.restoreCursorAndScrollTop(); |
| 662 | + context.fn.saveCursorAndScrollTop(); |
663 | 663 | var selection = context.$textarea.textSelection( 'getSelection' ); |
664 | 664 | // set focus |
665 | 665 | $( '#wikieditor-toolbar-reference-text' ).focus(); |
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js |
— | — | @@ -542,30 +542,26 @@ |
543 | 543 | t = nextT; |
544 | 544 | } |
545 | 545 | }, |
| 546 | + 'saveCursorAndScrollTop': function() { |
| 547 | + // Stub out textarea behavior |
| 548 | + return; |
| 549 | + }, |
| 550 | + 'restoreCursorAndScrollTop': function() { |
| 551 | + // Stub out textarea behavior |
| 552 | + return; |
| 553 | + }, |
546 | 554 | 'saveSelection': function() { |
547 | | - if ( !$.browser.msie ) { |
548 | | - // Only IE needs this |
549 | | - return; |
550 | | - } |
551 | | - if ( typeof context.$iframe != 'undefined' ) { |
| 555 | + if ( $.client.name === 'msie' ) { |
552 | 556 | context.$iframe[0].contentWindow.focus(); |
553 | 557 | context.savedSelection = context.$iframe[0].contentWindow.document.selection.createRange(); |
554 | | - } else { |
555 | | - context.$textarea.focus(); |
556 | | - context.savedSelection = document.selection.createRange(); |
557 | 558 | } |
558 | 559 | }, |
559 | 560 | 'restoreSelection': function() { |
560 | | - if ( !$.browser.msie || context.savedSelection === null ) { |
561 | | - return; |
562 | | - } |
563 | | - if ( typeof context.$iframe != 'undefined' ) { |
| 561 | + if ( $.client.name === 'msie' && context.savedSelection !== null ) { |
564 | 562 | context.$iframe[0].contentWindow.focus(); |
565 | | - } else { |
566 | | - context.$textarea.focus(); |
| 563 | + context.savedSelection.select(); |
| 564 | + context.savedSelection = null; |
567 | 565 | } |
568 | | - context.savedSelection.select(); |
569 | | - context.savedSelection = null; |
570 | 566 | }, |
571 | 567 | /** |
572 | 568 | * Update the history queue |