2015-09-10 15:28:42 -04:00
|
|
|
# Syntax Highlighter
|
|
|
|
#
|
2015-08-25 18:24:53 -04:00
|
|
|
# Applies a syntax highlighting color scheme CSS class to any element with the
|
|
|
|
# `js-syntax-highlight` class
|
|
|
|
#
|
|
|
|
# ### Example Markup
|
|
|
|
#
|
|
|
|
# <div class="js-syntax-highlight"></div>
|
|
|
|
#
|
2015-09-04 17:07:24 -04:00
|
|
|
$.fn.syntaxHighlight = ->
|
2015-09-10 15:28:42 -04:00
|
|
|
if $(this).hasClass('js-syntax-highlight')
|
|
|
|
# Given the element itself, apply highlighting
|
|
|
|
$(this).addClass(gon.user_color_scheme)
|
|
|
|
else
|
|
|
|
# Given a parent element, recurse to any of its applicable children
|
|
|
|
$children = $(this).find('.js-syntax-highlight')
|
|
|
|
$children.syntaxHighlight() if $children.length
|
2015-09-04 17:07:24 -04:00
|
|
|
|
2015-08-25 18:24:53 -04:00
|
|
|
$(document).on 'ready page:load', ->
|
2015-09-04 17:07:24 -04:00
|
|
|
$('.js-syntax-highlight').syntaxHighlight()
|