From e5e65c03c4d1879c4cf4ef5e0f77a80e7eb73ece Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 4 Apr 2011 16:33:59 +0200 Subject: highlight für suche eingebaut --- public/media/css/style.css | 7 +++++ public/media/js/jquery.highlight-3.js | 53 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 public/media/js/jquery.highlight-3.js (limited to 'public') diff --git a/public/media/css/style.css b/public/media/css/style.css index f71cf8b..a521aeb 100644 --- a/public/media/css/style.css +++ b/public/media/css/style.css @@ -115,6 +115,9 @@ body { min-height: 400px; background-color: #F2F3F1; } +#content img { + border:none; +} #debug { text-align: left; @@ -480,4 +483,8 @@ td.action img { cursor:default; } +.highlight { + background-color: yellow; +} + diff --git a/public/media/js/jquery.highlight-3.js b/public/media/js/jquery.highlight-3.js new file mode 100644 index 0000000..4d339ee --- /dev/null +++ b/public/media/js/jquery.highlight-3.js @@ -0,0 +1,53 @@ +/* + +highlight v3 + +Highlights arbitrary terms. + + + +MIT license. + +Johann Burkard + + + +*/ + +jQuery.fn.highlight = function(pat) { + function innerHighlight(node, pat) { + var skip = 0; + if (node.nodeType == 3) { + var pos = node.data.toUpperCase().indexOf(pat); + if (pos >= 0) { + var spannode = document.createElement('span'); + spannode.className = 'highlight'; + var middlebit = node.splitText(pos); + var endbit = middlebit.splitText(pat.length); + var middleclone = middlebit.cloneNode(true); + spannode.appendChild(middleclone); + middlebit.parentNode.replaceChild(spannode, middlebit); + skip = 1; + } + } + else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) { + for (var i = 0; i < node.childNodes.length; ++i) { + i += innerHighlight(node.childNodes[i], pat); + } + } + return skip; + } + return this.each(function() { + innerHighlight(this, pat.toUpperCase()); + }); +}; + +jQuery.fn.removeHighlight = function() { + return this.find("span.highlight").each(function() { + this.parentNode.firstChild.nodeName; + with (this.parentNode) { + replaceChild(this.firstChild, this); + normalize(); + } + }).end(); +}; -- cgit v1.2.3-55-g7522