Commit 3a0b0d64 authored by Ivan Tyagov's avatar Ivan Tyagov

Highlight search words if coming from search page.

parent ad5e66e0
...@@ -1300,6 +1300,11 @@ button.formbt > span{\n ...@@ -1300,6 +1300,11 @@ button.formbt > span{\n
display:none;\n display:none;\n
}\n }\n
\n \n
/* Search words highliting */\n
.highlight{\n
background-color: yellow;\n
}\n
\n
</tal:block> </tal:block>
]]></unicode> </value> ]]></unicode> </value>
...@@ -1318,7 +1323,7 @@ button.formbt > span{\n ...@@ -1318,7 +1323,7 @@ button.formbt > span{\n
</item> </item>
<item> <item>
<key> <string>output_encoding</string> </key> <key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value> <value> <string>iso-8859-15</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts00782283.02</string> </value> <value> <string>ts07451662.42</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -171,8 +171,96 @@ function initialize_form(){\n ...@@ -171,8 +171,96 @@ function initialize_form(){\n
})\n })\n
}\n }\n
}\n }\n
\n \n
$(document).ready(initialize_form); // function make_pdf_navigation_asynchronous_form(){\n
// /*\n
// Make default PDF navigation in preview in asynchronous way.\n
// */\n
// \n
// function splitUrl(url){\n
// jQuery.url.setUrl(image_src)\n
// base_url = jQuery.url.attr("base") + jQuery.url.attr("path");\n
// query_dict = {"display": jQuery.url.param("display"), \n
// "format": jQuery.url.param("format"),\n
// "resolution:int": jQuery.url.param("resolution:int"),\n
// "frame": parseInt(jQuery.url.param("frame"))};\n
// query_string = $.param(query_dict);\n
// console.log(base_url);\n
// console.log(query_string); \n
// }\n
// \n
// function loadThumbnail(event){\n
// event.preventDefault();\n
// navigation_url = this.href;\n
// \n
// image = $("div.pdf-preview-content img");\n
// image_url = image.attr("src");\n
// \n
// // read current image URL\n
// jQuery.url.setUrl(image_url);\n
// base_url = jQuery.url.attr("base") + jQuery.url.attr("path");\n
// query_dict = {"display": jQuery.url.param("display"), \n
// "format": jQuery.url.param("format"),\n
// "resolution:int": jQuery.url.param("resolution:int")};\n
// \n
// \n
// // get frame index from navigation link\n
// jQuery.url.setUrl(navigation_url);\n
// frame = parseInt(jQuery.url.param("selection_index"))\n
// query_dict["frame"]=frame;\n
// \n
// // construct new thumbnail URL\n
// query_string = $.param(query_dict);\n
// new_image_url = base_url + "?" +query_string;\n
// console.log(new_image_url);\n
// \n
// image.attr("src", new_image_url);\n
// \n
// }\n
// \n
// pdf_preview_navigation = $(\'div.pdf-preview-navigation\');\n
// if(pdf_preview_navigation.length){\n
// \n
// // XXX: set hooks\n
// $("div.pdf-preview-navigation a img.first").parent("a").click(loadThumbnail);\n
// $("div.pdf-preview-navigation a img.previous").parent("a").click(loadThumbnail);\n
// $("div.pdf-preview-navigation a img.next").parent("a").click(loadThumbnail);\n
// $("div.pdf-preview-navigation a img.last").parent("a").click(loadThumbnail); \n
// \n
// }\n
// }\n
// $(document).ready(make_pdf_navigation_asynchronous_form);\n
\n
\n
jQuery.fn.highlight = function (str, className) {\n
/*\n
Highlight search word in HTML content.\n
*/\n
var regex = new RegExp(str, "gi");\n
return this.each(function () {\n
this.innerHTML = this.innerHTML.replace(regex, function(matched) {return "<span class=\\"" + className + "\\">" + matched + "</span>";});\n
});\n
};\n
\n
function highlight_search_word(){\n
/*\n
Use referer to get search text (if coming from GET search page) and highlight found words.\n
*/\n
query_array = queryStringToArray(document.referrer)\n
search_text = query_array["search_text"]\n
if (search_text!=undefined){\n
container = $("div.content")\n
// multiple words\n
search_word_list = search_text.split("%20")\n
for(var i=0; i<search_word_list.length; i++) {\n
container.highlight(search_word_list[i], "highlight")\n
}\n
}\n
}\n
\n
$(document).ready(highlight_search_word);\n
$(document).ready(initialize_form);\n
]]></string> </value> ]]></string> </value>
</item> </item>
...@@ -182,7 +270,7 @@ $(document).ready(initialize_form); ...@@ -182,7 +270,7 @@ $(document).ready(initialize_form);
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>5038</int> </value> <value> <int>8097</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
1799 1800
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment