From: Trevor Parscal Date: Tue, 9 Feb 2010 01:31:00 +0000 (+0000) Subject: Updated to use the textSelection plugin when possible. X-Git-Tag: 1.31.0-rc.0~37866 X-Git-Url: http://git.cyclocoop.org/%27%20.generer_url_ecrire%28_request%28%27exec%27%29%2C%27cmd=switch&outil=rss_couteau_suisse%27%29.%27?a=commitdiff_plain;h=4727fbc2da9b1a7ea8e3f030c9f470c1e5e31977;p=lhc%2Fweb%2Fwiklou.git Updated to use the textSelection plugin when possible. --- diff --git a/skins/common/edit.js b/skins/common/edit.js index e39d35b151..c2d1e2173a 100644 --- a/skins/common/edit.js +++ b/skins/common/edit.js @@ -57,11 +57,15 @@ function mwSetupToolbar() { // No toolbar if we can't find any textarea return false; } - if ( !( document.selection && document.selection.createRange ) - && textboxes[0].selectionStart === null ) { - return false; + // Only check for selection capability if the textarea is visible - errors will occur otherwise - just because + // the textarea is not visible, doesn't mean we shouldn't build out the toolbar though - it might have been replaced + // with some other kind of control + if ( textboxes[0].style.display != 'none' ) { + if ( !( document.selection && document.selection.createRange ) + && textboxes[0].selectionStart === null ) { + return false; + } } - for ( var i = 0; i < mwEditButtons.length; i++ ) { mwInsertEditButton( toolbar, mwEditButtons[i] ); } @@ -74,6 +78,12 @@ function mwSetupToolbar() { // apply tagOpen/tagClose to selection in textarea, // use sampleText instead of selection if there is none function insertTags( tagOpen, tagClose, sampleText ) { + if ( typeof $j.fn.textSelection != 'undefined' ) { + $j( '#wpTextbox1' ).textSelection( + 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose } + ); + return; + } var txtarea; if ( document.editform ) { txtarea = currentFocused;