diff options
Diffstat (limited to 'skins/common/edit.js')
-rw-r--r-- | skins/common/edit.js | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/skins/common/edit.js b/skins/common/edit.js index 423205f8..f986c854 100644 --- a/skins/common/edit.js +++ b/skins/common/edit.js @@ -1,8 +1,7 @@ -var currentFocused; +window.currentFocused = undefined; -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where javascript is not enabled -function addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) { +// this function adds a toolbar button to the mwEditButtons list +window.addButton = function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) { // Don't generate buttons for browsers which don't fully // support it. mwEditButtons.push({ @@ -13,11 +12,10 @@ function addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId 'tagClose': tagClose, 'sampleText': sampleText }); -} +}; -// this function generates the actual toolbar buttons with localized text -// we use it to avoid creating the toolbar where JavaScript is not enabled -function mwInsertEditButton( parent, item ) { +// this function adds one toolbar button from a mwEditButtons/mwCustomEditButtons item +window.mwInsertEditButton = function( parent, item ) { var image = document.createElement( 'img' ); image.width = 23; image.height = 22; @@ -33,17 +31,19 @@ function mwInsertEditButton( parent, item ) { image.onclick = function() { insertTags( item.tagOpen, item.tagClose, item.sampleText ); // click tracking - if ( ( typeof $j != 'undefined' ) && ( typeof $j.trackAction != 'undefined' ) ) { - $j.trackAction( 'oldedit.' + item.speedTip.replace(/ /g, "-") ); + if ( ( typeof $ != 'undefined' ) && ( typeof $.trackAction != 'undefined' ) ) { + $.trackAction( 'oldedit.' + item.speedTip.replace(/ /g, "-") ); } return false; }; parent.appendChild( image ); return true; -} +}; -function mwSetupToolbar() { +// this function generates the actual toolbar buttons with localized text +// we use it to avoid creating the toolbar where javascript is not enabled +window.mwSetupToolbar = function() { var toolbar = document.getElementById( 'toolbar' ); if ( !toolbar ) { return false; @@ -73,14 +73,14 @@ function mwSetupToolbar() { mwInsertEditButton( toolbar, mwCustomEditButtons[i] ); } return true; -} +}; // apply tagOpen/tagClose to selection in textarea, // use sampleText instead of selection if there is none -function insertTags( tagOpen, tagClose, sampleText ) { - if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' && +window.insertTags = function( tagOpen, tagClose, sampleText ) { + if ( typeof $ != 'undefined' && typeof $.fn.textSelection != 'undefined' && currentFocused && ( currentFocused.nodeName.toLowerCase() == 'iframe' || currentFocused.id == 'wpTextbox1' ) ) { - $j( '#wpTextbox1' ).textSelection( + $( '#wpTextbox1' ).textSelection( 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose } ); return; @@ -160,13 +160,13 @@ function insertTags( tagOpen, tagClose, sampleText ) { } } -} +}; /** * Restore the edit box scroll state following a preview operation, * and set up a form submission handler to remember this state */ -function scrollEditBox() { +window.scrollEditBox = function() { var editBox = document.getElementById( 'wpTextbox1' ); var scrollTop = document.getElementById( 'wpScrolltop' ); var editForm = document.getElementById( 'editform' ); @@ -178,7 +178,7 @@ function scrollEditBox() { scrollTop.value = editBox.scrollTop; } ); } -} +}; hookEvent( 'load', scrollEditBox ); hookEvent( 'load', mwSetupToolbar ); hookEvent( 'load', function() { @@ -217,10 +217,10 @@ hookEvent( 'load', function() { // HACK: make currentFocused work with the usability iframe // With proper focus detection support (HTML 5!) this'll be much cleaner - if ( typeof $j != 'undefined' ) { - var iframe = $j( '.wikiEditor-ui-text iframe' ); + if ( typeof $ != 'undefined' ) { + var iframe = $( '.wikiEditor-ui-text iframe' ); if ( iframe.length > 0 ) { - $j( iframe.get( 0 ).contentWindow.document ) + $( iframe.get( 0 ).contentWindow.document ) .add( iframe.get( 0 ).contentWindow.document.body ) // for IE .focus( function() { currentFocused = iframe.get( 0 ); } ); } |