mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 07:08:55 +00:00
highlight keywords in 'search result' and 'file view' page; bug fix for pdf view
This commit is contained in:
@@ -2846,6 +2846,10 @@ textarea:-moz-placeholder {/* for FF */
|
||||
#search-results a {
|
||||
font-weight: normal;
|
||||
}
|
||||
#search-results b {
|
||||
font-weight: bold;
|
||||
background:#ffe761;
|
||||
}
|
||||
.search-results-item {
|
||||
margin-top:15px;
|
||||
}
|
||||
|
@@ -181,6 +181,9 @@ var pdf2htmlEX = (function(){
|
||||
_.find_pages();
|
||||
_.schedule_render();
|
||||
_.load_page(idx+1);
|
||||
if (highlight_kw) {
|
||||
highlight_kw($('#file-view'));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@@ -27,7 +27,6 @@
|
||||
has_outline = $.trim(outline);
|
||||
}
|
||||
|
||||
$('#converted-html').append('<div id="pdf2html-toolbar-1"></div>');
|
||||
if (has_outline) {
|
||||
var sidebar = $('#sidebar'),
|
||||
page_container = $('#page-container'),
|
||||
@@ -36,6 +35,11 @@
|
||||
$('#outline .l').removeAttr('data-dest-detail'); // make the anchor links work
|
||||
sidebar.removeClass('hide');
|
||||
|
||||
if (highlight_kw) {
|
||||
highlight_kw(sidebar);
|
||||
}
|
||||
|
||||
$('#converted-html').append('<div id="pdf2html-toolbar-1"></div>');
|
||||
var toolbar = $('#pdf2html-toolbar-1');
|
||||
toolbar.append('<span class="icon-caret-left" title="{% trans "hide outline" %}" id="hide-outline"></span>');
|
||||
toolbar.append('<span class="icon-caret-right hide" title="{% trans "show outline" %}" id="show-outline"></span>');
|
||||
@@ -85,6 +89,7 @@
|
||||
|
||||
var file_cont = $('#file-view'), //file container
|
||||
orig_pg_total_h;
|
||||
|
||||
$('#zoom-in, #zoom-out').click(function() {
|
||||
// get orig data before zoom in/out
|
||||
var op = $(this).attr('id'),
|
||||
|
@@ -177,6 +177,42 @@ $('#file-op .history').click(function () {
|
||||
location.href = $(this).data('url');
|
||||
});
|
||||
|
||||
// if referrer is 'search result' page, define function highlight_kw
|
||||
var ref_list = document.referrer.split('?');
|
||||
if (ref_list.length > 1 && ref_list[0].indexOf('search') > 0) {
|
||||
var search_params = ref_list[1].split('&');
|
||||
var search_keyword = search_params[0].substr(2); // get 'xx' from 'q=xx'
|
||||
|
||||
var highlight_kw = function(hl_area) {
|
||||
if (window.find && window.getSelection) {
|
||||
hl_area.attr('contenteditable', true).attr('spellcheck', false);
|
||||
var sel = window.getSelection();
|
||||
sel.collapse(document.body, 0);
|
||||
|
||||
while (window.find(search_keyword)) {
|
||||
document.execCommand("HiliteColor", false, "yellow");
|
||||
sel.collapseToEnd();
|
||||
}
|
||||
hl_area.attr('contenteditable', false);
|
||||
} else if (document.body.createTextRange) {
|
||||
var textRange = document.body.createTextRange();
|
||||
while (textRange.findText(search_keyword)) {
|
||||
textRange.execCommand("BackColor", false, "yellow");
|
||||
textRange.collapse(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$(window).load(function() {
|
||||
if (highlight_kw) {
|
||||
// hl kw in file title
|
||||
highlight_kw($('#view-hd'));
|
||||
// hl kw in file content
|
||||
setTimeout(function(){ highlight_kw($('#file-view')); }, 100); // delay 100ms for 'text' file
|
||||
}
|
||||
});
|
||||
|
||||
//bottom bar
|
||||
{% include "snippets/bottom_bar.html" %}
|
||||
$('#main-panel').css('margin-bottom',0);
|
||||
|
Reference in New Issue
Block a user