diff --git a/app/assets/javascripts/results/result_texts.js b/app/assets/javascripts/results/result_texts.js index b102adeb1..8363f9c84 100644 --- a/app/assets/javascripts/results/result_texts.js +++ b/app/assets/javascripts/results/result_texts.js @@ -88,3 +88,11 @@ $(document).ready(function() { initHighlightjs(); }); applyEditResultTextCallback(); + + + +$(document).ready(function() { + setTimeout(function(){ + SmartAnnotation.init('[data-atwho-res-edit]'); + }, 2000); +}); diff --git a/app/assets/javascripts/sitewide/atwho_tasks.js b/app/assets/javascripts/sitewide/atwho_tasks.js index 1a6d4981a..798939544 100644 --- a/app/assets/javascripts/sitewide/atwho_tasks.js +++ b/app/assets/javascripts/sitewide/atwho_tasks.js @@ -1,4 +1,4 @@ -(function() { +var SmartAnnotation = (function() { 'use strict'; // utilities @@ -21,7 +21,7 @@ return publicApi; })(); - function smartAnnotation(field) { + function setAtWho(field) { // helper methods for AtWho callback function _templateEval(_tpl, map) { @@ -34,11 +34,12 @@ return res; } - function _matchHighlighter(li, query) { + function _matchHighlighter(li, query, search_filter) { var re, li2, prevVal, newVal; if (!query) { return li; } + resourcesChecker(query, search_filter); li2 = $(li); re = new RegExp(query, 'gi'); prevVal = @@ -66,8 +67,8 @@ // check if query has some hits and disables the buttons without it function resourcesChecker(query, search_filter) { - debugger; - var src_btn; + var src_btn, $element; + switch (search_filter) { case 'task#': src_btn = 'tsk'; @@ -88,16 +89,26 @@ function(data){ if(data) { _.each($('.atwho-header .btn'), function(el) { - if(data[$(el).data('filter')].length === 0) { - $(el).prop('disabled', true); - $(el) + $element = $(el); + if(data[$element.data('filter')].length === 0) { + $element.prop('disabled', true); + $element .removeClass('btn-primary') .addClass('btn-default'); $('[data-filter="' + src_btn +'"]') .removeClass('btn-default') .addClass('btn-primary'); } else { - $(el).prop('disabled', false); + $element.prop('disabled', false); + if($element.data('filter') == src_btn) { + $element + .removeClass('btn-default') + .addClass('btn-primary'); + } else { + $element + .removeClass('btn-primary') + .addClass('btn-default'); + } } }); } @@ -163,7 +174,7 @@ _a + "-" + _y + "0-9_ \'\.\+\-]*)$|" + "(#|task#|project#|sample#|experiment#)([^\\x00-\\xff]*)$", 'gi'); query_obj = regexp.exec($(field).val()); - new_query = query_obj.input.replace(query_obj[0], ''); + new_query = query_obj.input.replace(query_obj[1], ''); $.getJSON( link, @@ -182,7 +193,8 @@ .addClass('btn-primary'); reinitializeOnListHide(); - initButtons(new_query, query_obj[0]); + initButtons(new_query, + selectedBtn.html()); } else { $(field).atwho('destroy'); init(); @@ -194,13 +206,13 @@ function generateFilterMenu(active, res_data) { var header = '
<%= auto_link(simple_format(comment.message), +
<%= auto_link(simple_format(smart_annotation_parser(comment.message)), link: :urls, html: { target: '_blank' }) %>