Index: trunk/phase3/skins/common/edit.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | window.currentFocused = undefined; |
3 | 3 | |
4 | 4 | // this function adds a toolbar button to the mwEditButtons list |
5 | | -window.addButton = function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId ) { |
| 5 | +window.addButton = function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) { |
6 | 6 | // Don't generate buttons for browsers which don't fully |
7 | 7 | // support it. |
8 | 8 | mwEditButtons.push({ |
— | — | @@ -10,7 +10,8 @@ |
11 | 11 | 'speedTip': speedTip, |
12 | 12 | 'tagOpen': tagOpen, |
13 | 13 | 'tagClose': tagClose, |
14 | | - 'sampleText': sampleText |
| 14 | + 'sampleText': sampleText, |
| 15 | + 'selectText': selectText |
15 | 16 | }); |
16 | 17 | }; |
17 | 18 | |
— | — | @@ -29,7 +30,7 @@ |
30 | 31 | image.title = item.speedTip; |
31 | 32 | image.style.cursor = 'pointer'; |
32 | 33 | image.onclick = function() { |
33 | | - insertTags( item.tagOpen, item.tagClose, item.sampleText ); |
| 34 | + insertTags( item.tagOpen, item.tagClose, item.sampleText, item.selectText ); |
34 | 35 | // click tracking |
35 | 36 | if ( ( typeof $ != 'undefined' ) && ( typeof $.trackAction != 'undefined' ) ) { |
36 | 37 | $.trackAction( 'oldedit.' + item.speedTip.replace(/ /g, "-") ); |
— | — | @@ -77,7 +78,7 @@ |
78 | 79 | |
79 | 80 | // apply tagOpen/tagClose to selection in textarea, |
80 | 81 | // use sampleText instead of selection if there is none |
81 | | -window.insertTags = function( tagOpen, tagClose, sampleText ) { |
| 82 | +window.insertTags = function( tagOpen, tagClose, sampleText, selectText) { |
82 | 83 | if ( typeof $ != 'undefined' && typeof $.fn.textSelection != 'undefined' && currentFocused && |
83 | 84 | ( currentFocused.nodeName.toLowerCase() == 'iframe' || currentFocused.id == 'wpTextbox1' ) ) { |
84 | 85 | $( '#wpTextbox1' ).textSelection( |
— | — | @@ -109,15 +110,17 @@ |
110 | 111 | // insert tags |
111 | 112 | checkSelectedText(); |
112 | 113 | range.text = tagOpen + selText + tagClose; |
113 | | - // mark sample text as selected |
114 | | - if ( isSample && range.moveStart ) { |
115 | | - if ( window.opera ) { |
116 | | - tagClose = tagClose.replace(/\n/g,''); |
| 114 | + // mark sample text as selected if not switched off by option |
| 115 | + if ( selectText !== false ) { |
| 116 | + if ( isSample && range.moveStart ) { |
| 117 | + if ( window.opera ) { |
| 118 | + tagClose = tagClose.replace(/\n/g,''); |
| 119 | + } |
| 120 | + range.moveStart('character', - tagClose.length - selText.length); |
| 121 | + range.moveEnd('character', - tagClose.length); |
117 | 122 | } |
118 | | - range.moveStart('character', - tagClose.length - selText.length); |
119 | | - range.moveEnd('character', - tagClose.length); |
| 123 | + range.select(); |
120 | 124 | } |
121 | | - range.select(); |
122 | 125 | // restore window scroll position |
123 | 126 | if ( document.documentElement && document.documentElement.scrollTop ) { |
124 | 127 | document.documentElement.scrollTop = winScroll; |
— | — | @@ -139,7 +142,7 @@ |
140 | 143 | + tagOpen + selText + tagClose |
141 | 144 | + txtarea.value.substring(endPos, txtarea.value.length); |
142 | 145 | // set new selection |
143 | | - if ( isSample ) { |
| 146 | + if ( isSample && ( selectText !== false )) { |
144 | 147 | txtarea.selectionStart = startPos + tagOpen.length; |
145 | 148 | txtarea.selectionEnd = startPos + tagOpen.length + selText.length; |
146 | 149 | } else { |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -2387,6 +2387,7 @@ |
2388 | 2388 | $close = $tool['close'], |
2389 | 2389 | $sample = $tool['sample'], |
2390 | 2390 | $cssId = $tool['id'], |
| 2391 | + $select = $tool['select'], |
2391 | 2392 | ); |
2392 | 2393 | |
2393 | 2394 | $paramList = implode( ',', |