From 0561710016027f4a29e44fc54501d3ed88e9e954 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sun, 4 Aug 2013 14:48:36 -0400 Subject: [PATCH] highlight search results --- public/css/style.less | 5 +---- public/src/forum/search.js | 14 ++++++++++++++ public/templates/search.tpl | 7 +++---- 3 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 public/src/forum/search.js diff --git a/public/css/style.less b/public/css/style.less index a60ba220b3..5a44a064b0 100644 --- a/public/css/style.less +++ b/public/css/style.less @@ -832,7 +832,6 @@ body .navbar .nodebb-inline-block { .search-result-post { width: 100%; - height: 50px; line-height: 16px; padding: 5px; overflow:hidden; @@ -843,7 +842,5 @@ body .navbar .nodebb-inline-block { height:48px; padding-right:10px; } - span { - padding-left:10px; - } + } \ No newline at end of file diff --git a/public/src/forum/search.js b/public/src/forum/search.js new file mode 100644 index 0000000000..9412915cc7 --- /dev/null +++ b/public/src/forum/search.js @@ -0,0 +1,14 @@ +(function() { + + $(document).ready(function() { + var searchQuery = $('#topics-container').attr('data-search-query'); + + $('.search-result-text').each(function(){ + var text = $(this).html(); + var regex = new RegExp(searchQuery, 'gi'); + text = text.replace(regex, ''+searchQuery+''); + $(this).html(text); + }); + }); + +})(); \ No newline at end of file diff --git a/public/templates/search.tpl b/public/templates/search.tpl index 19a369600f..c08f82e7c5 100644 --- a/public/templates/search.tpl +++ b/public/templates/search.tpl @@ -12,7 +12,7 @@
- \ No newline at end of file