Index: trunk/phase3/skins/common/edit.js |
— | — | @@ -57,11 +57,15 @@ |
58 | 58 | // No toolbar if we can't find any textarea |
59 | 59 | return false; |
60 | 60 | } |
61 | | - if ( !( document.selection && document.selection.createRange ) |
62 | | - && textboxes[0].selectionStart === null ) { |
63 | | - return false; |
| 61 | + // Only check for selection capability if the textarea is visible - errors will occur otherwise - just because |
| 62 | + // the textarea is not visible, doesn't mean we shouldn't build out the toolbar though - it might have been replaced |
| 63 | + // with some other kind of control |
| 64 | + if ( textboxes[0].style.display != 'none' ) { |
| 65 | + if ( !( document.selection && document.selection.createRange ) |
| 66 | + && textboxes[0].selectionStart === null ) { |
| 67 | + return false; |
| 68 | + } |
64 | 69 | } |
65 | | - |
66 | 70 | for ( var i = 0; i < mwEditButtons.length; i++ ) { |
67 | 71 | mwInsertEditButton( toolbar, mwEditButtons[i] ); |
68 | 72 | } |
— | — | @@ -74,6 +78,12 @@ |
75 | 79 | // apply tagOpen/tagClose to selection in textarea, |
76 | 80 | // use sampleText instead of selection if there is none |
77 | 81 | function insertTags( tagOpen, tagClose, sampleText ) { |
| 82 | + if ( typeof $j.fn.textSelection != 'undefined' ) { |
| 83 | + $j( '#wpTextbox1' ).textSelection( |
| 84 | + 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose } |
| 85 | + ); |
| 86 | + return; |
| 87 | + } |
78 | 88 | var txtarea; |
79 | 89 | if ( document.editform ) { |
80 | 90 | txtarea = currentFocused; |