2017-01-10 23:02:20 +00:00
|
|
|
/* eslint-disable func-names, space-before-function-paren, consistent-return, no-var, no-else-return, prefer-arrow-callback, max-len */
|
2016-12-14 05:26:26 +00:00
|
|
|
|
2016-07-27 03:32:10 +00:00
|
|
|
// 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>
|
|
|
|
//
|
2016-07-24 20:45:11 +00:00
|
|
|
(function() {
|
|
|
|
$.fn.syntaxHighlight = function() {
|
|
|
|
var $children;
|
2016-12-09 00:15:08 +00:00
|
|
|
|
2016-07-24 20:45:11 +00:00
|
|
|
if ($(this).hasClass('js-syntax-highlight')) {
|
2016-07-27 03:32:10 +00:00
|
|
|
// Given the element itself, apply highlighting
|
2016-07-24 20:45:11 +00:00
|
|
|
return $(this).addClass(gon.user_color_scheme);
|
|
|
|
} else {
|
2016-07-27 03:32:10 +00:00
|
|
|
// Given a parent element, recurse to any of its applicable children
|
2016-07-24 20:45:11 +00:00
|
|
|
$children = $(this).find('.js-syntax-highlight');
|
|
|
|
if ($children.length) {
|
|
|
|
return $children.syntaxHighlight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-02-10 06:50:50 +00:00
|
|
|
}).call(window);
|