mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-07 05:03:26 +08:00
Refactor code a bit, add dismiss button to header
This commit is contained in:
parent
7835753d3c
commit
0ee5b98977
2 changed files with 27 additions and 21 deletions
|
@ -5,6 +5,8 @@
|
|||
'focus',
|
||||
'[data-atwho-users-edit]',
|
||||
function() {
|
||||
// Only initialize if URL is present and
|
||||
// atwho is not initialized yet
|
||||
if (
|
||||
$(document.body).is('[data-atwho-users-url]') &&
|
||||
_.isUndefined($(this).data('atwho'))
|
||||
|
@ -54,29 +56,21 @@
|
|||
return res;
|
||||
},
|
||||
highlighter: function(li, query) {
|
||||
function highlight(el, sel, re) {
|
||||
var prevVal = el.find(sel).html();
|
||||
var newVal = prevVal.replace(re, '<strong>$&</strong>');
|
||||
el.find(sel).html(newVal);
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return li;
|
||||
}
|
||||
|
||||
var li2 = $(li);
|
||||
var $li = $(li);
|
||||
var re = new RegExp(query, 'gi');
|
||||
var prevVal =
|
||||
li2
|
||||
.find('[data-val=full-name]')
|
||||
.html();
|
||||
var newVal =
|
||||
prevVal
|
||||
.replace(re, '<strong>$&</strong>');
|
||||
li2.find('[data-val=full-name]').html(newVal);
|
||||
prevVal =
|
||||
li2
|
||||
.find('[data-val=email]')
|
||||
.html();
|
||||
newVal =
|
||||
prevVal
|
||||
.replace(re, '<strong>$&</strong>');
|
||||
li2.find('[data-val=email]').html(newVal);
|
||||
return li2[0].outerHTML;
|
||||
highlight($li, '[data-val=full-name]', re);
|
||||
highlight($li, '[data-val=email]', re);
|
||||
return $li[0].outerHTML;
|
||||
},
|
||||
beforeInsert: function(value, li) {
|
||||
var res = '';
|
||||
|
@ -101,6 +95,9 @@
|
|||
'<strong><%= I18n.t("atwho.users.dismiss_1") %></strong> ' +
|
||||
'<%= I18n.t("atwho.users.dismiss_2") %>' +
|
||||
'</div>' +
|
||||
'<div class="dismiss">' +
|
||||
'<span class="glyphicon glyphicon-remove"></span>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
limit: <%= Constants::ATWHO_SEARCH_LIMIT %>,
|
||||
|
|
|
@ -1787,10 +1787,19 @@ th.custom-field .modal-tooltiptext {
|
|||
display: inline;
|
||||
margin-right: 15px;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: $color-black;
|
||||
}
|
||||
div strong {
|
||||
color: $color-black;
|
||||
}
|
||||
|
||||
.dismiss {
|
||||
color: $color-emperor;
|
||||
}
|
||||
|
||||
.dismiss:hover {
|
||||
color: $color-black;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue