aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--inc/jquery.highlight.js108
-rw-r--r--tpl/changetag.html12
-rw-r--r--tpl/editlink.html12
-rw-r--r--tpl/includes.html1
-rw-r--r--tpl/linklist.html1
-rw-r--r--tpl/page.footer.html21
-rw-r--r--tpl/picwall.html4
7 files changed, 25 insertions, 134 deletions
diff --git a/inc/jquery.highlight.js b/inc/jquery.highlight.js
deleted file mode 100644
index 9dcf3c7a..00000000
--- a/inc/jquery.highlight.js
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 * jQuery Highlight plugin
3 *
4 * Based on highlight v3 by Johann Burkard
5 * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
6 *
7 * Code a little bit refactored and cleaned (in my humble opinion).
8 * Most important changes:
9 * - has an option to highlight only entire words (wordsOnly - false by default),
10 * - has an option to be case sensitive (caseSensitive - false by default)
11 * - highlight element tag and class names can be specified in options
12 *
13 * Usage:
14 * // wrap every occurrance of text 'lorem' in content
15 * // with <span class='highlight'> (default options)
16 * $('#content').highlight('lorem');
17 *
18 * // search for and highlight more terms at once
19 * // so you can save some time on traversing DOM
20 * $('#content').highlight(['lorem', 'ipsum']);
21 * $('#content').highlight('lorem ipsum');
22 *
23 * // search only for entire word 'lorem'
24 * $('#content').highlight('lorem', { wordsOnly: true });
25 *
26 * // don't ignore case during search of term 'lorem'
27 * $('#content').highlight('lorem', { caseSensitive: true });
28 *
29 * // wrap every occurrance of term 'ipsum' in content
30 * // with <em class='important'>
31 * $('#content').highlight('ipsum', { element: 'em', className: 'important' });
32 *
33 * // remove default highlight
34 * $('#content').unhighlight();
35 *
36 * // remove custom highlight
37 * $('#content').unhighlight({ element: 'em', className: 'important' });
38 *
39 *
40 * Copyright (c) 2009 Bartek Szopka
41 *
42 * Licensed under MIT license.
43 *
44 */
45
46jQuery.extend({
47 highlight: function (node, re, nodeName, className) {
48 if (node.nodeType === 3) {
49 var match = node.data.match(re);
50 if (match) {
51 var highlight = document.createElement(nodeName || 'span');
52 highlight.className = className || 'highlight';
53 var wordNode = node.splitText(match.index);
54 wordNode.splitText(match[0].length);
55 var wordClone = wordNode.cloneNode(true);
56 highlight.appendChild(wordClone);
57 wordNode.parentNode.replaceChild(highlight, wordNode);
58 return 1; //skip added node in parent
59 }
60 } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
61 !/(script|style)/i.test(node.tagName) && // ignore script and style nodes
62 !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
63 for (var i = 0; i < node.childNodes.length; i++) {
64 i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
65 }
66 }
67 return 0;
68 }
69});
70
71jQuery.fn.unhighlight = function (options) {
72 var settings = { className: 'highlight', element: 'span' };
73 jQuery.extend(settings, options);
74
75 return this.find(settings.element + "." + settings.className).each(function () {
76 var parent = this.parentNode;
77 parent.replaceChild(this.firstChild, this);
78 parent.normalize();
79 }).end();
80};
81
82jQuery.fn.highlight = function (words, options) {
83 var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
84 jQuery.extend(settings, options);
85
86 if (words.constructor === String) {
87 words = [words];
88 }
89 words = jQuery.grep(words, function(word, i){
90 return word != '';
91 });
92 words = jQuery.map(words, function(word, i) {
93 return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
94 });
95 if (words.length == 0) { return this; };
96
97 var flag = settings.caseSensitive ? "" : "i";
98 var pattern = "(" + words.join("|") + ")";
99 if (settings.wordsOnly) {
100 pattern = "\\b" + pattern + "\\b";
101 }
102 var re = new RegExp(pattern, flag);
103
104 return this.each(function () {
105 jQuery.highlight(this, re, settings.element, settings.className);
106 });
107};
108
diff --git a/tpl/changetag.html b/tpl/changetag.html
index b0bd0d06..b22bddea 100644
--- a/tpl/changetag.html
+++ b/tpl/changetag.html
@@ -1,6 +1,8 @@
1<!DOCTYPE html> 1<!DOCTYPE html>
2<html> 2<html>
3<head>{include="includes"}</head> 3<head>{include="includes"}
4{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
5</head>
4<body onload="document.changetag.fromtag.focus();"> 6<body onload="document.changetag.fromtag.focus();">
5<div id="pageheader"> 7<div id="pageheader">
6 {include="page.header"} 8 {include="page.header"}
@@ -12,5 +14,13 @@
12<script language="JavaScript">function confirmDeleteTag() { var agree=confirm("Are you sure you want to delete this tag from all links ?"); if (agree) return true ; else return false ; }</script> 14<script language="JavaScript">function confirmDeleteTag() { var agree=confirm("Are you sure you want to delete this tag from all links ?"); if (agree) return true ; else return false ; }</script>
13</div> 15</div>
14{include="page.footer"} 16{include="page.footer"}
17{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
18<script language="JavaScript">
19$(document).ready(function()
20{
21 $('#fromtag').autocomplete({source:'{$source}?ws=singletag',minLength:1});
22});
23</script>
24{/if}
15</body> 25</body>
16</html> \ No newline at end of file 26</html> \ No newline at end of file
diff --git a/tpl/editlink.html b/tpl/editlink.html
index ad549137..4a2c30cc 100644
--- a/tpl/editlink.html
+++ b/tpl/editlink.html
@@ -1,6 +1,8 @@
1<!DOCTYPE html> 1<!DOCTYPE html>
2<html> 2<html>
3<head>{include="includes"}</head> 3<head>{include="includes"}
4{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
5</head>
4<body 6<body
5{if condition="$link.title==''"}onload="document.linkform.lf_title.focus();" 7{if condition="$link.title==''"}onload="document.linkform.lf_title.focus();"
6{elseif condition="$link.description==''"}onload="document.linkform.lf_description.focus();" 8{elseif condition="$link.description==''"}onload="document.linkform.lf_description.focus();"
@@ -30,5 +32,13 @@
30 </div> 32 </div>
31</div> 33</div>
32{include="page.footer"} 34{include="page.footer"}
35{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
36<script language="JavaScript">
37$(document).ready(function()
38{
39 $('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});
40});
41</script>
42{/if}
33</body> 43</body>
34</html> \ No newline at end of file 44</html> \ No newline at end of file
diff --git a/tpl/includes.html b/tpl/includes.html
index e0ad00d5..2b61f1e1 100644
--- a/tpl/includes.html
+++ b/tpl/includes.html
@@ -7,4 +7,3 @@
7<link href="images/favicon.ico#" rel="shortcut icon" type="image/x-icon" /> 7<link href="images/favicon.ico#" rel="shortcut icon" type="image/x-icon" />
8<link type="text/css" rel="stylesheet" href="inc/shaarli.css?version={$version|urlencode}#" /> 8<link type="text/css" rel="stylesheet" href="inc/shaarli.css?version={$version|urlencode}#" />
9{if condition="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="inc/user.css?version={$version}#" />{/if} 9{if condition="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="inc/user.css?version={$version}#" />{/if}
10{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
diff --git a/tpl/linklist.html b/tpl/linklist.html
index bce3fa9f..ddc38cb0 100644
--- a/tpl/linklist.html
+++ b/tpl/linklist.html
@@ -68,7 +68,6 @@
68 {include="page.footer"} 68 {include="page.footer"}
69 69
70<script language="JavaScript"> 70<script language="JavaScript">
71
72// Remove any displayed QR-Code 71// Remove any displayed QR-Code
73function remove_qrcode() 72function remove_qrcode()
74{ 73{
diff --git a/tpl/page.footer.html b/tpl/page.footer.html
index 3aa47ba6..8e5869c5 100644
--- a/tpl/page.footer.html
+++ b/tpl/page.footer.html
@@ -7,24 +7,3 @@
7{if="isLoggedIn()"} 7{if="isLoggedIn()"}
8<script language="JavaScript">function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script> 8<script language="JavaScript">function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
9{/if} 9{/if}
10
11{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
12<script language="JavaScript">
13$(document).ready(function()
14{
15 $('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});
16 $('#searchtags').autocomplete({source:'{$source}?ws=tags',minLength:1});
17 $('#fromtag').autocomplete({source:'{$source}?ws=singletag',minLength:1});
18});
19</script>
20{/if}
21
22{if="empty($GLOBALS['disablejquery']) && isset($_GET['searchterm'])"}
23<script src="inc/jquery.highlight.js#"></script>
24<script language="JavaScript">
25$(document).ready(function()
26{
27 $('#linklist li').highlight("{$search_crits}");
28});
29</script>
30{/if} \ No newline at end of file
diff --git a/tpl/picwall.html b/tpl/picwall.html
index 631e0866..b78e2609 100644
--- a/tpl/picwall.html
+++ b/tpl/picwall.html
@@ -2,7 +2,9 @@
2<html> 2<html>
3<head>{include="includes"} 3<head>{include="includes"}
4{if="empty($GLOBALS['disablejquery'])"} 4{if="empty($GLOBALS['disablejquery'])"}
5 <script src="inc/jquery.lazyload.min.js#"></script> 5<script src="inc/jquery.min.js#"></script>
6<script src="inc/jquery-ui.min.js#"></script>
7<script src="inc/jquery.lazyload.min.js#"></script>
6{/if} 8{/if}
7</head> 9</head>
8<body> 10<body>