|
38 | 38 | // Source: https://github.com/gollum/gollum/blob/9c714e768748db4560bc017cacef4afa0c751a63/lib/gollum/public/gollum/javascript/editor/langs/markdown.js |
39 | 39 | var MarkDown = (function MarkDown() { |
40 | 40 | return { |
41 | | - "bold": { |
| 41 | + "function-bold": { |
42 | 42 | search: /^(\s*)([\s\S]*?)(\s*)$/g, |
43 | 43 | replace: "$1**$2**$3", |
44 | 44 | shortcut: "ctrl+b" |
|
48 | 48 | replace: "$1_$2_$3", |
49 | 49 | shortcut: "ctrl+i" |
50 | 50 | }, |
51 | | - "underline": { |
| 51 | + "function-underline": { |
52 | 52 | search: /^(\s*)([\s\S]*?)(\s*)$/g, |
53 | 53 | replace: "$1<ins>$2</ins>$3", |
54 | 54 | shortcut: "ctrl+u" |
55 | 55 | }, |
56 | | - "strikethrough": { |
| 56 | + "function-strikethrough": { |
57 | 57 | search: /^(\s*)([\s\S]*?)(\s*)$/g, |
58 | 58 | replace: "$1~~$2~~$3", |
59 | 59 | shortcut: "ctrl+s" |
60 | 60 | }, |
61 | 61 |
|
62 | | - "h1": { |
| 62 | + "function-h1": { |
63 | 63 | search: /(.+)([\n]?)/g, |
64 | 64 | replace: "# $1$2", |
65 | 65 | forceNewline: true, |
66 | 66 | shortcut: "ctrl+1" |
67 | 67 | }, |
68 | | - "h2": { |
| 68 | + "function-h2": { |
69 | 69 | search: /(.+)([\n]?)/g, |
70 | 70 | replace: "## $1$2", |
71 | 71 | forceNewline: true, |
72 | 72 | shortcut: "ctrl+2" |
73 | 73 | }, |
74 | | - "h3": { |
| 74 | + "function-h3": { |
75 | 75 | search: /(.+)([\n]?)/g, |
76 | 76 | replace: "### $1$2", |
77 | 77 | forceNewline: true, |
78 | 78 | shortcut: "ctrl+3" |
79 | 79 | }, |
80 | | - "h4": { |
| 80 | + "function-h4": { |
81 | 81 | search: /(.+)([\n]?)/g, |
82 | 82 | replace: "#### $1$2", |
83 | 83 | forceNewline: true, |
84 | 84 | shortcut: "ctrl+4" |
85 | 85 | }, |
86 | | - "h5": { |
| 86 | + "function-h5": { |
87 | 87 | search: /(.+)([\n]?)/g, |
88 | 88 | replace: "##### $1$2", |
89 | 89 | forceNewline: true, |
90 | 90 | shortcut: "ctrl+5" |
91 | 91 | }, |
92 | | - "h6": { |
| 92 | + "function-h6": { |
93 | 93 | search: /(.+)([\n]?)/g, |
94 | 94 | replace: "###### $1$2", |
95 | 95 | forceNewline: true, |
96 | 96 | shortcut: "ctrl+6" |
97 | 97 | }, |
98 | 98 |
|
99 | | - "link": { |
| 99 | + "function-link": { |
100 | 100 | exec: function(button, selText, commentForm, next) { |
101 | 101 | var selTxt = selText.trim(), |
102 | 102 | isUrl = selTxt && /(?:https?:\/\/)|(?:www\.)/.test(selTxt), |
|
108 | 108 | }, |
109 | 109 | shortcut: "ctrl+l" |
110 | 110 | }, |
111 | | - "image": { |
| 111 | + "function-image": { |
112 | 112 | exec: function(button, selText, commentForm, next) { |
113 | 113 | var selTxt = selText.trim(), |
114 | 114 | isUrl = selTxt && /(?:https?:\/\/)|(?:www\.)/.test(selTxt), |
|
121 | 121 | shortcut: "ctrl+g" |
122 | 122 | }, |
123 | 123 |
|
124 | | - "ul": { |
| 124 | + "function-ul": { |
125 | 125 | search: /(.+)([\n]?)/g, |
126 | 126 | replace: String.format("{0} $1$2", listCharacter), |
127 | 127 | forceNewline: true, |
128 | 128 | shortcut: "alt+ctrl+u" |
129 | 129 | }, |
130 | | - "ol": { |
| 130 | + "function-ol": { |
131 | 131 | exec: function(button, selText, commentForm, next) { |
132 | 132 | var repText = ""; |
133 | 133 | if (!selText) { |
|
145 | 145 | }, |
146 | 146 | shortcut: "alt+ctrl+o" |
147 | 147 | }, |
148 | | - "checklist": { |
| 148 | + "function-checklist": { |
149 | 149 | search: /(.+)([\n]?)/g, |
150 | 150 | replace: String.format("{0} [ ] $1$2", listCharacter), |
151 | 151 | forceNewline: true, |
152 | 152 | shortcut: "alt+ctrl+t" |
153 | 153 | }, |
154 | 154 |
|
155 | | - "code": { |
| 155 | + "function-code": { |
156 | 156 | exec: function(button, selText, commentForm, next) { |
157 | 157 | var rt = selText.indexOf("\n") > -1 ? "$1\n```\n$2\n```$3" : "$1`$2`$3"; |
158 | 158 | next(selText.replace(/^(\s*)([\s\S]*?)(\s*)$/g, rt)); |
159 | 159 | }, |
160 | 160 | shortcut: "ctrl+k" |
161 | 161 | }, |
162 | | - "code-syntax": { |
| 162 | + "function-code-syntax": { |
163 | 163 | exec: function(button, selText, commentForm, next) { |
164 | 164 | var rt = "$1\n```" + button.dataset.value + "\n$2\n```$3"; |
165 | 165 | next(selText.replace(/^(\s*)([\s\S]*?)(\s*)$/g, rt)); |
166 | 166 | } |
167 | 167 | }, |
168 | 168 |
|
169 | | - "blockquote": { |
| 169 | + "function-blockquote": { |
170 | 170 | search: /(.+)([\n]?)/g, |
171 | 171 | replace: "> $1$2", |
172 | 172 | forceNewline: true, |
173 | 173 | shortcut: "ctrl+q" |
174 | 174 | }, |
175 | | - "rule": { |
| 175 | + "function-rule": { |
176 | 176 | append: String.format("\n{0}\n", lineCharacter), |
177 | 177 | forceNewline: true, |
178 | 178 | shortcut: "ctrl+r" |
179 | 179 | }, |
180 | | - "table": { |
| 180 | + "function-table": { |
181 | 181 | append: "\n" + |
182 | 182 | "| Head | Head | Head |\n" + |
183 | 183 | "| :--- | :----: | ----: |\n" + |
|
187 | 187 | shortcut: "alt+shift+t" |
188 | 188 | }, |
189 | 189 |
|
190 | | - "clear": { |
| 190 | + "function-clear": { |
191 | 191 | exec: function(button, selText, commentForm, next) { |
192 | 192 | commentForm.value = ""; |
193 | 193 | next(""); |
194 | 194 | }, |
195 | 195 | shortcut: "alt+ctrl+x" |
196 | 196 | }, |
197 | 197 |
|
198 | | - "snippets-tab": { |
| 198 | + "function-snippets-tab": { |
199 | 199 | exec: function(button, selText, commentForm, next) { |
200 | 200 | next("\t"); |
201 | 201 | } |
202 | 202 | }, |
203 | | - "snippets-useragent": { |
| 203 | + "function-snippets-useragent": { |
204 | 204 | exec: function(button, selText, commentForm, next) { |
205 | 205 | next("`" + navigator.userAgent + "`"); |
206 | 206 | } |
207 | 207 | }, |
208 | | - "snippets-contributing": { |
| 208 | + "function-snippets-contributing": { |
209 | 209 | exec: function(button, selText, commentForm, next) { |
210 | 210 | next("Please, always consider reviewing the [guidelines for contributing](../blob/master/CONTRIBUTING.md) to this repository."); |
211 | 211 | } |
212 | 212 | }, |
213 | 213 |
|
214 | | - "emoji": { |
| 214 | + "function-emoji": { |
215 | 215 | exec: function(button, selText, commentForm, next) { |
216 | 216 | next(button.dataset.value); |
217 | 217 | } |
|
221 | 221 |
|
222 | 222 | var editorHTML = (function editorHTML() { |
223 | 223 | return '<div id="gollum-editor-function-buttons" style="float: left;">' + |
| 224 | + |
| 225 | + /* Bold, italic, underline & Strikethrough; */ |
224 | 226 | ' <div class="button-group btn-group">' + |
225 | | - ' <a href="#" data-function="bold" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Bold (ctrl+b)">' + |
| 227 | + ' <a href="#" id="function-bold" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Bold (ctrl+b)">' + |
226 | 228 | ' <b style="font-weight: bolder;">B</b>' + |
227 | 229 | ' </a>' + |
228 | | - ' <a href="#" data-function="italic" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Italic (ctrl+i)">' + |
| 230 | + ' <a href="#" id="function-italic" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Italic (ctrl+i)">' + |
229 | 231 | ' <em>i</em>' + |
230 | 232 | ' </a>' + |
231 | | - ' <a href="#" data-function="underline" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Underline (ctrl+u)">' + |
| 233 | + ' <a href="#" id="function-underline" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Underline (ctrl+u)">' + |
232 | 234 | ' <ins>U</ins>' + |
233 | 235 | ' </a>' + |
234 | | - ' <a href="#" data-function="strikethrough" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Strikethrough (ctrl+s)">' + |
| 236 | + ' <a href="#" id="function-strikethrough" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Strikethrough (ctrl+s)">' + |
235 | 237 | ' <s>S</s>' + |
236 | 238 | ' </a>' + |
237 | 239 | ' </div>' + |
238 | 240 |
|
| 241 | + /* Headers (1 - 6); */ |
239 | 242 | ' <div class="button-group btn-group">' + |
240 | 243 | ' <div class="select-menu js-menu-container js-select-menu tooltipped tooltipped-ne" aria-label="Headers">' + |
241 | | - ' <span class="btn btn-sm minibutton select-menu-button icon-only js-menu-target" aria-label="Headers" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
242 | | - ' <span class="js-select-button">h#</span>' + |
243 | | - ' </span>' + |
| 244 | + ' <a id="function-h1" class="btn btn-sm minibutton select-menu-button icon-only js-menu-target function-button function-dummy" aria-label="Headers" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
| 245 | + ' <span class="js-select-button">h#</span>' + |
| 246 | + ' </a>' + |
244 | 247 | ' <div class="select-menu-modal-holder js-menu-content js-navigation-container" style="top:26px; z-index:22;">' + |
245 | 248 | ' <div class="select-menu-modal" style="width:auto; overflow:visible;">' + |
246 | 249 | ' <div class="select-menu-header">' + |
247 | 250 | ' <span class="select-menu-title">Choose header</span>' + |
248 | 251 | ' <span class="octicon octicon-remove-close js-menu-close"></span>' + |
249 | 252 | ' </div>' + |
250 | 253 | ' <div class="button-group btn-group" style="min-width:175px;">' + |
251 | | - ' <a href="#" data-function="h1" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 1 (ctrl+1)">' + |
| 254 | + ' <a href="#" id="function-h1" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 1 (ctrl+1)">' + |
252 | 255 | ' <b class="select-menu-item-text js-select-button-text">h1</b>' + |
253 | 256 | ' </a>' + |
254 | | - ' <a href="#" data-function="h2" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 2 (ctrl+2)">' + |
| 257 | + ' <a href="#" id="function-h2" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 2 (ctrl+2)">' + |
255 | 258 | ' <b class="select-menu-item-text js-select-button-text">h2</b>' + |
256 | 259 | ' </a>' + |
257 | | - ' <a href="#" data-function="h3" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 3 (ctrl+3)">' + |
| 260 | + ' <a href="#" id="function-h3" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 3 (ctrl+3)">' + |
258 | 261 | ' <b class="select-menu-item-text js-select-button-text">h3</b>' + |
259 | 262 | ' </a>' + |
260 | | - ' <a href="#" data-function="h4" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 4 (ctrl+4)">' + |
| 263 | + ' <a href="#" id="function-h4" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 4 (ctrl+4)">' + |
261 | 264 | ' <b class="select-menu-item-text js-select-button-text">h4</b>' + |
262 | 265 | ' </a>' + |
263 | | - ' <a href="#" data-function="h5" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 5 (ctrl+5)">' + |
| 266 | + ' <a href="#" id="function-h5" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 5 (ctrl+5)">' + |
264 | 267 | ' <b class="select-menu-item-text js-select-button-text">h5</b>' + |
265 | 268 | ' </a>' + |
266 | | - ' <a href="#" data-function="h6" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 6 (ctrl+6)">' + |
| 269 | + ' <a href="#" id="function-h6" class="btn btn-sm minibutton function-button js-navigation-item js-menu-close tooltipped tooltipped-s" aria-label="Header 6 (ctrl+6)">' + |
267 | 270 | ' <b class="select-menu-item-text js-select-button-text">h6</b>' + |
268 | 271 | ' </a>' + |
269 | 272 | ' </div>' + |
|
272 | 275 | ' </div>' + |
273 | 276 | ' </div>' + |
274 | 277 |
|
| 278 | + /* Link & image; */ |
275 | 279 | ' <div class="button-group btn-group">' + |
276 | | - ' <a href="#" data-function="link" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Link (ctrl+l)">' + |
| 280 | + ' <a href="#" id="function-link" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Link (ctrl+l)">' + |
277 | 281 | ' <span class="octicon octicon-link"></span>' + |
278 | 282 | ' </a>' + |
279 | | - ' <a href="#" data-function="image" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Image (ctrl+g)">' + |
| 283 | + ' <a href="#" id="function-image" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Image (ctrl+g)">' + |
280 | 284 | ' <span class="octicon octicon-file-media"></span>' + |
281 | 285 | ' </a>' + |
282 | 286 | ' </div>' + |
| 287 | + |
| 288 | + /* Lists (unordered, ordered & task); */ |
283 | 289 | ' <div class="button-group btn-group">' + |
284 | | - ' <a href="#" data-function="ul" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Unordered List (alt+ctrl+u)">' + |
| 290 | + ' <a href="#" id="function-ul" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Unordered List (alt+ctrl+u)">' + |
285 | 291 | ' <span class="octicon octicon-list-unordered"></span>' + |
286 | 292 | ' </a>' + |
287 | | - ' <a href="#" data-function="ol" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Ordered List (alt+ctrl+o)">' + |
| 293 | + ' <a href="#" id="function-ol" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Ordered List (alt+ctrl+o)">' + |
288 | 294 | ' <span class="octicon octicon-list-ordered"></span>' + |
289 | 295 | ' </a>' + |
290 | | - ' <a href="#" data-function="checklist" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Task List (alt+ctrl+t)">' + |
| 296 | + ' <a href="#" id="function-checklist" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Task List (alt+ctrl+t)">' + |
291 | 297 | ' <span class="octicon octicon-checklist"></span>' + |
292 | 298 | ' </a>' + |
293 | 299 | ' </div>' + |
294 | 300 |
|
| 301 | + /* Code (syntax); */ |
295 | 302 | ' <div class="button-group btn-group">' + |
296 | 303 | ' <div class="select-menu js-menu-container js-select-menu tooltipped tooltipped-ne" aria-label="Code (ctrl+k)">' + |
297 | | - ' <a href="#" data-function="code" class="btn btn-sm minibutton function-button">' + |
| 304 | + ' <a href="#" id="function-code" class="btn btn-sm minibutton function-button">' + |
298 | 305 | ' <span class="octicon octicon-code"></span>' + |
299 | 306 | ' </a>' + |
300 | 307 | ' <div class="select-menu-modal-holder js-menu-content js-navigation-container" style="top:26px; z-index:22;">' + |
|
313 | 320 | ' </div>' + |
314 | 321 | ' </div>' + |
315 | 322 | ' </div>' + |
316 | | - ' <a href="#" class="btn btn-sm minibutton select-menu-button js-menu-target" style="width:20px; margin-left:-1px;"></a>' + |
| 323 | + ' <a href="#" id="function-code" class="btn btn-sm minibutton select-menu-button js-menu-target function-button function-dummy" style="width:20px; margin-left:-1px;"></a>' + |
317 | 324 | ' </div>' + |
318 | 325 | ' </div>' + |
319 | 326 |
|
| 327 | + /* Blockquote, horizontal rule & table; */ |
320 | 328 | ' <div class="button-group btn-group">' + |
321 | | - ' <a href="#" data-function="blockquote" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Blockquote (ctrl+q)">' + |
| 329 | + ' <a href="#" id="function-blockquote" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Blockquote (ctrl+q)">' + |
322 | 330 | ' <span class="octicon octicon-quote"></span>' + |
323 | 331 | ' </a>' + |
324 | | - ' <a href="#" data-function="rule" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Horizontal Rule (ctrl+r)">' + |
| 332 | + ' <a href="#" id="function-rule" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Horizontal Rule (ctrl+r)">' + |
325 | 333 | ' <span class="octicon octicon-horizontal-rule"></span>' + |
326 | 334 | ' </a>' + |
327 | | - ' <a href="#" data-function="table" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Table (alt+shift+t)">' + |
| 335 | + ' <a href="#" id="function-table" class="btn btn-sm minibutton function-button tooltipped tooltipped-ne" aria-label="Table (alt+shift+t)">' + |
328 | 336 | ' <span class="octicon octicon-three-bars"></span>' + |
329 | 337 | ' </a>' + |
330 | 338 | ' </div>' + |
331 | 339 |
|
| 340 | + /* Snippets; */ |
332 | 341 | ' <div class="button-group btn-group">' + |
333 | 342 | ' <div class="select-menu js-menu-container js-select-menu tooltipped tooltipped-ne" aria-label="Snippets">' + |
334 | | - ' <span class="btn btn-sm minibutton select-menu-button js-menu-target" aria-label="Snippets" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
| 343 | + ' <a href="#" class="btn btn-sm minibutton select-menu-button js-menu-target" aria-label="Snippets" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
335 | 344 | ' <span class="octicon octicon-pin"></span>' + |
336 | | - ' </span>' + |
| 345 | + ' </a>' + |
337 | 346 | ' <div class="select-menu-modal-holder js-menu-content js-navigation-container" style="top:26px; z-index:22;">' + |
338 | 347 | ' <div class="select-menu-modal" style="overflow:visible;">' + |
339 | 348 | ' <div class="select-menu-header">' + |
|
347 | 356 | ' </div>' + |
348 | 357 | ' <div class="select-menu-list" style="overflow:visible;">' + |
349 | 358 | ' <div data-filterable-type="substring" data-filterable-for="context-snippets-filter-field">' + |
350 | | - ' <a href="#" data-function="snippets-tab" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add tab character" style="table-layout:initial;">' + |
| 359 | + ' <a href="#" id="function-snippets-tab" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add tab character" style="table-layout:initial;">' + |
351 | 360 | ' <span class="select-menu-item-text js-select-button-text">Add tab character</span>' + |
352 | 361 | ' </a>' + |
353 | | - ' <a href="#" data-function="snippets-useragent" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add UserAgent" style="table-layout:initial;">' + |
| 362 | + ' <a href="#" id="function-snippets-useragent" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add UserAgent" style="table-layout:initial;">' + |
354 | 363 | ' <span class="select-menu-item-text js-select-button-text">Add UserAgent</span>' + |
355 | 364 | ' </a>' + |
356 | | - ' <a href="#" data-function="snippets-contributing" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add contributing message" style="table-layout:initial;">' + |
| 365 | + ' <a href="#" id="function-snippets-contributing" class="function-button select-menu-item js-navigation-item tooltipped tooltipped-w" aria-label="Add contributing message" style="table-layout:initial;">' + |
357 | 366 | ' <span class="select-menu-item-text">' + |
358 | 367 | ' <span class="js-select-button-text">Contributing</span>' + |
359 | 368 | ' <span class="description">Add contributing message</span>' + |
|
367 | 376 | ' </div>' + |
368 | 377 | ' </div>' + |
369 | 378 |
|
| 379 | + /* Emoji; */ |
370 | 380 | ' <div class="button-group btn-group">' + |
371 | 381 | ' <div class="select-menu js-menu-container js-select-menu tooltipped tooltipped-ne" aria-label="Emoji">' + |
372 | | - ' <span class="btn btn-sm minibutton select-menu-button js-menu-target" aria-label="Emoji" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
| 382 | + ' <a href="#" class="btn btn-sm minibutton select-menu-button js-menu-target" aria-label="Emoji" style="padding-left:7px; padding-right:7px; width:auto; border-bottom-right-radius:3px; border-top-right-radius:3px;">' + |
373 | 383 | ' <span class="octicon octicon-octoface"></span>' + |
374 | | - ' </span>' + |
| 384 | + ' </a>' + |
375 | 385 | ' <div class="select-menu-modal-holder js-menu-content js-navigation-container" style="top:26px; z-index:22;">' + |
376 | 386 | ' <div class="select-menu-modal" style="overflow:visible;">' + |
377 | 387 | ' <div class="select-menu-header">' + |
|
393 | 403 |
|
394 | 404 | '</div>' + |
395 | 405 |
|
| 406 | + /* Clear; */ |
396 | 407 | '<div style="float:right;">' + |
397 | | - ' <a href="#" data-function="clear" class="btn btn-sm minibutton function-button tooltipped tooltipped-nw" aria-label="Clear (alt+ctrl+x)">' + |
| 408 | + ' <a href="#" id="function-clear" class="btn btn-sm minibutton function-button tooltipped tooltipped-nw" aria-label="Clear (alt+ctrl+x)">' + |
398 | 409 | ' <span class="octicon octicon-trashcan"></span>' + |
399 | 410 | ' </a>' + |
400 | 411 | '</div>'; |
|
506 | 517 | } |
507 | 518 |
|
508 | 519 | var buttonEvent = function(e) { |
509 | | - e.preventDefault(); |
510 | | - executeAction(MarkDown[this.dataset.function], this.commentForm, this); |
511 | | - return false; |
| 520 | + if (!this.classList.contains("function-dummy")) { |
| 521 | + e.preventDefault(); |
| 522 | + executeAction(MarkDown[this.id], this.commentForm, this); |
| 523 | + return false; |
| 524 | + } |
512 | 525 | }; |
513 | 526 |
|
514 | 527 | var codeSyntaxTop = ["JavaScript", "Java", "Ruby", "PHP", "Python", "CSS", "C++", "C#", "C", "HTML"]; // https://github.com/blog/2047-language-trends-on-github |
|
613 | 626 | syntaxSuggestion.setAttribute("href", "#"); |
614 | 627 | syntaxSuggestion.classList.add("function-button", "select-menu-item", "js-navigation-item"); |
615 | 628 | syntaxSuggestion.dataset.value = syntax; |
616 | | - syntaxSuggestion.dataset.function = "code-syntax"; |
| 629 | + syntaxSuggestion.id = "function-code-syntax"; |
617 | 630 | syntaxSuggestions.appendChild(syntaxSuggestion); |
618 | 631 |
|
619 | 632 | var syntaxSuggestionText = document.createElement("span"); |
|
666 | 679 | var buttons = suggester.querySelectorAll(".function-button"); |
667 | 680 | Array.prototype.forEach.call(buttons, function(button) { |
668 | 681 | button.commentForm = commentForm; |
669 | | - button.dataset.function = "emoji"; |
| 682 | + button.id = "function-emoji"; |
670 | 683 | button.addEventListener("click", buttonEvent, false); |
671 | 684 | unsafeWindow.$(button).on("navigation:keydown", function(e) { |
672 | 685 | if (e.hotkey === "enter") { |
|
0 commit comments