|
189 | 189 | if (state.annotate) { state.annotate.clear(); state.annotate = null; } |
190 | 190 | });} |
191 | 191 |
|
192 | | - function el(tag, attrs, content) { |
193 | | - var element = document.createElement(tag); |
| 192 | + function el(tag, attrs) { |
| 193 | + var element = tag ? document.createElement(tag) : document.createDocumentFragment(); |
194 | 194 | for (var key in attrs) { |
195 | 195 | element[key] = attrs[key]; |
196 | 196 | } |
|
202 | 202 | } |
203 | 203 |
|
204 | 204 | function getQueryDialog(cm) { |
205 | | - var fragment = document.createDocumentFragment(); |
206 | | - fragment.appendChild(el('span', {className: 'CodeMirror-search-label'}, cm.phrase("Search:"))); |
207 | | - fragment.appendChild(document.createTextNode(' ')); |
208 | | - fragment.appendChild(el('input', {type: 'text', 'style': 'width: 10em', className: 'CodeMirror-search-field'})); |
209 | | - fragment.appendChild(document.createTextNode(' ')); |
210 | | - fragment.appendChild(el('span', {style: 'color: #888', className: 'CodeMirror-search-hint'}, cm.phrase("(Use /re/ syntax for regexp search)"))); |
211 | | - return fragment; |
| 205 | + return el("", null, |
| 206 | + el("span", {className: "CodeMirror-search-label"}, cm.phrase("Search:")), " ", |
| 207 | + el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ", |
| 208 | + el("span", {style: "color: #888", className: "CodeMirror-search-hint"}, |
| 209 | + cm.phrase("(Use /re/ syntax for regexp search)"))); |
212 | 210 | } |
213 | 211 | function getReplaceQueryDialog(cm) { |
214 | | - var fragment = document.createDocumentFragment(); |
215 | | - fragment.appendChild(document.createTextNode(' ')); |
216 | | - fragment.appendChild(el('input', {type: 'text', 'style': 'width: 10em', className: 'CodeMirror-search-field'})); |
217 | | - fragment.appendChild(document.createTextNode(' ')); |
218 | | - fragment.appendChild(el('span', {style: 'color: #888', className: 'CodeMirror-search-hint'}, cm.phrase("(Use /re/ syntax for regexp search)"))); |
219 | | - return fragment; |
| 212 | + return el("", null, " ", |
| 213 | + el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"}), " ", |
| 214 | + el("span", {style: "color: #888", className: "CodeMirror-search-hint"}, |
| 215 | + cm.phrase("(Use /re/ syntax for regexp search)"))); |
220 | 216 | } |
221 | 217 | function getReplacementQueryDialog(cm) { |
222 | | - var fragment = document.createDocumentFragment(); |
223 | | - fragment.appendChild(el('span', {className: 'CodeMirror-search-label'}, cm.phrase("With:"))); |
224 | | - fragment.appendChild(document.createTextNode(' ')); |
225 | | - fragment.appendChild(el('input', {type: 'text', 'style': 'width: 10em', className: 'CodeMirror-search-field'})); |
226 | | - return fragment; |
| 218 | + return el("", null, |
| 219 | + el("span", {className: "CodeMirror-search-label"}, cm.phrase("With:")), " ", |
| 220 | + el("input", {type: "text", "style": "width: 10em", className: "CodeMirror-search-field"})); |
227 | 221 | } |
228 | 222 | function getDoReplaceConfirm(cm) { |
229 | | - var fragment = document.createDocumentFragment(); |
230 | | - fragment.appendChild(el('span', {className: 'CodeMirror-search-label'}, cm.phrase("Replace?"))); |
231 | | - fragment.appendChild(document.createTextNode(' ')); |
232 | | - fragment.appendChild(el('button', {}, cm.phrase("Yes"))); |
233 | | - fragment.appendChild(document.createTextNode(' ')); |
234 | | - fragment.appendChild(el('button', {}, cm.phrase("No"))); |
235 | | - fragment.appendChild(document.createTextNode(' ')); |
236 | | - fragment.appendChild(el('button', {}, cm.phrase("All"))); |
237 | | - fragment.appendChild(document.createTextNode(' ')); |
238 | | - fragment.appendChild(el('button', {}, cm.phrase("Stop"))); |
239 | | - return fragment; |
| 223 | + return el("", null, |
| 224 | + el("span", {className: "CodeMirror-search-label"}, cm.phrase("Replace?")), " ", |
| 225 | + el("button", {}, cm.phrase("Yes")), " ", |
| 226 | + el("button", {}, cm.phrase("No")), " ", |
| 227 | + el("button", {}, cm.phrase("All")), " ", |
| 228 | + el("button", {}, cm.phrase("Stop"))); |
240 | 229 | } |
241 | 230 |
|
242 | 231 | function replaceAll(cm, query, text) { |
|
253 | 242 | function replace(cm, all) { |
254 | 243 | if (cm.getOption("readOnly")) return; |
255 | 244 | var query = cm.getSelection() || getSearchState(cm).lastQuery; |
256 | | - var fragment = document.createDocumentFragment(); |
257 | | - fragment.appendChild(el('span', {className: 'CodeMirror-search-label'}, (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")))); |
258 | | - fragment.appendChild(getReplaceQueryDialog(cm)); |
| 245 | + var dialogText = all ? cm.phrase("Replace all:") : cm.phrase("Replace:") |
| 246 | + var fragment = el("", null, |
| 247 | + el("span", {className: "CodeMirror-search-label"}, dialogText), |
| 248 | + getReplaceQueryDialog(cm)) |
259 | 249 | dialog(cm, fragment, dialogText, query, function(query) { |
260 | 250 | if (!query) return; |
261 | 251 | query = parseQuery(query); |
|
0 commit comments