Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9e8e978f3e
3 changed files with 144 additions and 23 deletions
108
inc/jquery.highlight.js
Normal file
108
inc/jquery.highlight.js
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* jQuery Highlight plugin
|
||||
*
|
||||
* Based on highlight v3 by Johann Burkard
|
||||
* http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
|
||||
*
|
||||
* Code a little bit refactored and cleaned (in my humble opinion).
|
||||
* Most important changes:
|
||||
* - has an option to highlight only entire words (wordsOnly - false by default),
|
||||
* - has an option to be case sensitive (caseSensitive - false by default)
|
||||
* - highlight element tag and class names can be specified in options
|
||||
*
|
||||
* Usage:
|
||||
* // wrap every occurrance of text 'lorem' in content
|
||||
* // with <span class='highlight'> (default options)
|
||||
* $('#content').highlight('lorem');
|
||||
*
|
||||
* // search for and highlight more terms at once
|
||||
* // so you can save some time on traversing DOM
|
||||
* $('#content').highlight(['lorem', 'ipsum']);
|
||||
* $('#content').highlight('lorem ipsum');
|
||||
*
|
||||
* // search only for entire word 'lorem'
|
||||
* $('#content').highlight('lorem', { wordsOnly: true });
|
||||
*
|
||||
* // don't ignore case during search of term 'lorem'
|
||||
* $('#content').highlight('lorem', { caseSensitive: true });
|
||||
*
|
||||
* // wrap every occurrance of term 'ipsum' in content
|
||||
* // with <em class='important'>
|
||||
* $('#content').highlight('ipsum', { element: 'em', className: 'important' });
|
||||
*
|
||||
* // remove default highlight
|
||||
* $('#content').unhighlight();
|
||||
*
|
||||
* // remove custom highlight
|
||||
* $('#content').unhighlight({ element: 'em', className: 'important' });
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2009 Bartek Szopka
|
||||
*
|
||||
* Licensed under MIT license.
|
||||
*
|
||||
*/
|
||||
|
||||
jQuery.extend({
|
||||
highlight: function (node, re, nodeName, className) {
|
||||
if (node.nodeType === 3) {
|
||||
var match = node.data.match(re);
|
||||
if (match) {
|
||||
var highlight = document.createElement(nodeName || 'span');
|
||||
highlight.className = className || 'highlight';
|
||||
var wordNode = node.splitText(match.index);
|
||||
wordNode.splitText(match[0].length);
|
||||
var wordClone = wordNode.cloneNode(true);
|
||||
highlight.appendChild(wordClone);
|
||||
wordNode.parentNode.replaceChild(highlight, wordNode);
|
||||
return 1; //skip added node in parent
|
||||
}
|
||||
} else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
|
||||
!/(script|style)/i.test(node.tagName) && // ignore script and style nodes
|
||||
!(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
jQuery.fn.unhighlight = function (options) {
|
||||
var settings = { className: 'highlight', element: 'span' };
|
||||
jQuery.extend(settings, options);
|
||||
|
||||
return this.find(settings.element + "." + settings.className).each(function () {
|
||||
var parent = this.parentNode;
|
||||
parent.replaceChild(this.firstChild, this);
|
||||
parent.normalize();
|
||||
}).end();
|
||||
};
|
||||
|
||||
jQuery.fn.highlight = function (words, options) {
|
||||
var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
|
||||
jQuery.extend(settings, options);
|
||||
|
||||
if (words.constructor === String) {
|
||||
words = [words];
|
||||
}
|
||||
words = jQuery.grep(words, function(word, i){
|
||||
return word != '';
|
||||
});
|
||||
words = jQuery.map(words, function(word, i) {
|
||||
return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||||
});
|
||||
if (words.length == 0) { return this; };
|
||||
|
||||
var flag = settings.caseSensitive ? "" : "i";
|
||||
var pattern = "(" + words.join("|") + ")";
|
||||
if (settings.wordsOnly) {
|
||||
pattern = "\\b" + pattern + "\\b";
|
||||
}
|
||||
var re = new RegExp(pattern, flag);
|
||||
|
||||
return this.each(function () {
|
||||
jQuery.highlight(this, re, settings.element, settings.className);
|
||||
});
|
||||
};
|
||||
|
|
@ -69,9 +69,9 @@ h1 { font-size:20pt; font-weight:bold; font-style:italic; margin-bottom:20px; }
|
|||
|
||||
/* Small tab on the left of each link with edit/delete buttons. */
|
||||
.button_edit, .button_delete { border-radius:0; box-shadow:none; border-style:none; border-width:0; padding:0; background:none; }
|
||||
.linkeditbuttons {
|
||||
position:absolute;
|
||||
left:-1px;
|
||||
.linkeditbuttons {
|
||||
position:absolute;
|
||||
left:-1px;
|
||||
padding:4px 2px 2px 2px;
|
||||
background-color:#f0f0f0;
|
||||
|
||||
|
@ -111,7 +111,7 @@ cursor:pointer;
|
|||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
|
||||
width:auto;
|
||||
padding:0 10px 5px 10px;
|
||||
margin: auto;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#pageheader a
|
||||
|
@ -305,7 +305,7 @@ font-size:9pt;
|
|||
background-color: transparent;
|
||||
background-color: rgba(0, 0, 0, 0.4); /* FF3+, Saf3+, Opera 10.10+, Chrome, IE9 */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#66000000,endColorstr=#66000000); /* IE6IE9 */
|
||||
text-shadow:2px 2px 1px #000000;
|
||||
text-shadow:2px 2px 1px #000000;
|
||||
}
|
||||
|
||||
/* Minimal customisation for jQuery widgets */
|
||||
|
@ -336,7 +336,7 @@ box-shadow:2px 2px 20px 2px #333333;
|
|||
|
||||
div.daily
|
||||
{
|
||||
font-family: Georgia, 'DejaVu Serif', Norasi, serif;
|
||||
font-family: Georgia, 'DejaVu Serif', Norasi, serif;
|
||||
background-color: #E6D6BE;
|
||||
/* Background paper texture by BashCorpo:
|
||||
http://www.bashcorpo.dk/textures.php
|
||||
|
@ -355,7 +355,7 @@ div.daily
|
|||
#daily_col3 { float:left;position:relative; width:33%;}
|
||||
|
||||
div.dailyAbout
|
||||
{
|
||||
{
|
||||
float:left;
|
||||
border: 1px solid black;
|
||||
font-size: 8pt;
|
||||
|
@ -363,21 +363,21 @@ div.dailyAbout
|
|||
left:10px;
|
||||
top: 15px;
|
||||
padding: 5px 5px 5px 5px;
|
||||
text-align:center;
|
||||
text-align:center;
|
||||
}
|
||||
div.dailyAbout a { color: #890500; }
|
||||
div.dailyTitle
|
||||
{
|
||||
{
|
||||
font-weight: bold;
|
||||
font-size: 44pt;
|
||||
text-align:center;
|
||||
text-align:center;
|
||||
padding:10px 20px 0px 20px;
|
||||
}
|
||||
div.dailyDate
|
||||
{
|
||||
{
|
||||
font-size: 12pt;
|
||||
font-weight:bold;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
text-align:center;
|
||||
padding:0px 20px 30px 20px;
|
||||
}
|
||||
|
||||
|
@ -391,19 +391,19 @@ div.dailyEntry
|
|||
div.dailyEntry a { text-decoration:none; color: #890500; }
|
||||
div.dailyEntryTags { font-size:7.75pt; }
|
||||
div.dailyEntryTitle { font-size:18pt; font-weight:bold;}
|
||||
div.dailyEntryThumbnail
|
||||
{
|
||||
width:100%;
|
||||
text-align:center;
|
||||
background-color:rgb(128,128,128);
|
||||
div.dailyEntryThumbnail
|
||||
{
|
||||
width:100%;
|
||||
text-align:center;
|
||||
background-color:rgb(128,128,128);
|
||||
background:url(../images/50pc_transparent.png);
|
||||
padding:4px 0px 2px 0px;
|
||||
}
|
||||
div.dailyEntryDescription
|
||||
{
|
||||
{
|
||||
margin-top: 10px;
|
||||
margin-bottom: 30px;
|
||||
text-align:justify;
|
||||
margin-bottom: 30px;
|
||||
text-align:justify;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ div.dailyEntryDescription
|
|||
}
|
||||
|
||||
/* For lazy images loading in picture wall.
|
||||
using http://www.appelsiini.net/projects/lazyload
|
||||
using http://www.appelsiini.net/projects/lazyload
|
||||
*/
|
||||
.lazyimage { display:none; }
|
||||
|
||||
|
@ -462,4 +462,7 @@ div.dailyDate { font-size: 11pt;padding:0px; display:block; }
|
|||
div.dailyEntryTitle { font-size:16pt; font-weight:bold;}
|
||||
div.dailyEntryDescription { font-size:10pt; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Highlight search results */
|
||||
.highlight { background-color: #FFFF33; }
|
||||
|
|
|
@ -19,3 +19,13 @@ $(document).ready(function()
|
|||
});
|
||||
</script>
|
||||
{/if}
|
||||
|
||||
{if="empty($GLOBALS['disablejquery']) && isset($_GET['searchterm'])"}
|
||||
<script src="inc/jquery.highlight.js#"></script>
|
||||
<script language="JavaScript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#linklist li').highlight("{$search_crits}");
|
||||
});
|
||||
</script>
|
||||
{/if}
|
||||
|
|
Reference in a new issue