From b6c2d6882bd416551f5c69f00a8d5834c970f285 Mon Sep 17 00:00:00 2001 From: lavigor Date: Thu, 20 Jul 2017 13:57:14 +0300 Subject: [PATCH] Add support for highlight.js. --- styles/all/template/quickreply_plugins.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/styles/all/template/quickreply_plugins.js b/styles/all/template/quickreply_plugins.js index 11d9d68..c4399fa 100644 --- a/styles/all/template/quickreply_plugins.js +++ b/styles/all/template/quickreply_plugins.js @@ -1,4 +1,4 @@ -/* global quickreply, grecaptcha, insert_text, split_lines */ +/* global quickreply, grecaptcha, hljs, insert_text, split_lines */ /* jshint -W040 */ ;(function($, window, document) { // do stuff here and use $, window and document safely @@ -546,4 +546,20 @@ }); }); } + + /***********************/ + /* highlight.js Plugin */ + /***********************/ + $(window).on('load', function() { + if (hljs && hljs.highlightBlock) { + var qrHighlightCode = function(e, elements) { + elements.find('pre code').each(function(i, block) { + hljs.highlightBlock(block); + }); + }; + + quickreply.$.qrPosts.on('qr_completed', qrHighlightCode); + quickreply.$.mainForm.on('ajax_submit_preview', qrHighlightCode); + } + }); })(jQuery, window, document);