Welcome to mirror list, hosted at ThFree Co, Russian Federation.

syntax_highlight.coffee « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 980f0232d101a8efe4722f131197991d66e7499a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Syntax Highlighter
#
# 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>
#
$.fn.syntaxHighlight = ->
  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

$(document).on 'ready page:load', ->
  $('.js-syntax-highlight').syntaxHighlight()