Changeset 1994
- Timestamp:
- 10/18/2015 08:49:38 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/style/trac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/style/trac/wp-trac.css
r1992 r1994 1645 1645 content: "\f210"; /* dashicons-editor-spellcheck */ 1646 1646 } 1647 1648 .wikitoolbar a#code-php:before { 1649 content: 'PHP'; 1650 font-size: 13px; 1651 font-weight: bold; 1652 position: relative; 1653 left: -3px; 1654 top: 2px; 1655 } 1656 1647 1657 #field-description-help, 1648 1658 label[for=comment] { -
sites/trunk/wordpress.org/public_html/style/trac/wp-trac.js
r1993 r1994 247 247 } 248 248 249 // Add custom buttons to the formatting toolbar 250 // http://trac.edgewall.org/browser/tags/trac-1.0.9/trac/htdocs/js/wikitoolbar.js 251 (function($) { 252 function extendWikiFormattingToolbar() { 253 var $textarea = $( this ), textarea = $textarea[0], $wikitoolbar; 254 if ( 'undefined' === typeof document.selection && 'undefined' === typeof textarea.setSelectionRange ) { 255 return; 256 } 257 258 $wikitoolbar = $textarea.parents( 'div.trac-resizable' ).siblings( 'div.wikitoolbar' ); 259 260 // after = ID of an existing button 261 function addButton( id, title, after, fn ) { 262 var $button = $( '<a />', { 'href': '#', 'id': id, 'title': title, 'tabIndex': 400 } ); 263 $button.on( 'click', function() { 264 if ( false === $textarea.prop( 'disabled' ) && false === $textarea.prop( 'readonly' ) ) { 265 try { fn(); } catch (e) { } 266 } 267 return false; 268 }); 269 $wikitoolbar.find( after ).after( $button ); 270 } 271 272 function encloseSelection( prefix, suffix ) { 273 var start, end, sel, scrollPos, subst; 274 textarea.focus(); 275 if ( 'undefined' !== typeof document.selection ) { 276 sel = document.selection.createRange().text; 277 } else if ( 'undefined' !== typeof textarea.setSelectionRange ) { 278 start = textarea.selectionStart; 279 end = textarea.selectionEnd; 280 scrollPos = textarea.scrollTop; 281 sel = textarea.value.substring( start, end ); 282 } 283 if ( sel.match( / $/ ) ) { // exclude ending space char, if any 284 sel = sel.substring( 0, sel.length - 1 ); 285 suffix = suffix + ' '; 286 } 287 subst = prefix + sel + suffix; 288 if ( 'undefined' !== typeof document.selection) { 289 var range = document.selection.createRange().text = subst; 290 textarea.caretPos -= suffix.length; 291 } else if ( 'undefined' !== typeof textarea.setSelectionRange ) { 292 textarea.value = textarea.value.substring( 0, start ) + subst + textarea.value.substring( end ); 293 if ( sel ) { 294 textarea.setSelectionRange( start + subst.length, start + subst.length ); 295 } else { 296 textarea.setSelectionRange( start + prefix.length, start + prefix.length ); 297 } 298 textarea.scrollTop = scrollPos; 299 } 300 } 301 302 addButton( 'code-php', 'PHP Code block: {{{#!php example }}}', '#code', function() { 303 encloseSelection( "{{{#!php\n<?php\n", "\n}}}\n" ); 304 }); 305 } 306 $( 'textarea.wikitext' ).each( extendWikiFormattingToolbar ); 307 })(jQuery); 308 249 309 // Force 'Attachments' and 'Modify Ticket' to be shown 250 310 $('#attachments').removeClass('collapsed');
Note: See TracChangeset
for help on using the changeset viewer.