forked from aolarchive/jQuery-highlightTextarea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.htm
190 lines (157 loc) · 11.7 KB
/
demo.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Description" content="highlightTextarea is a jQuery plugin which allows you to highlight words and sentences into textareas.">
<title>jQuery • highlightTextarea • Demos</title>
<link type="text/css" href="src/style.css" rel="stylesheet" />
<link type="text/css" href="src/highlight.css" rel="stylesheet" />
<link type="text/css" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link type="text/css" href="jquery.highlighttextarea.css" rel="stylesheet" />
<script type="text/javascript" src="jquery.highlighttextarea.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#demo1").highlightTextarea({
words: ["Lorem ipsum","vulputate"],
color: "#ADF0FF"
});
$("#demo2").highlightTextarea({
words: ["lOrEm IpSuM","VULPUTATE"],
caseSensitive: false
});
$("#demo3").highlightTextarea({
words: ["Lorem ipsum","Nam varius","Nullam"],
resizable: true
});
$("#demo4").highlightTextarea({
words: ['\{(.+?)\}']
});
$("#demo5").highlightTextarea({
words: ["Lorem ipsum","vulputate"],
color:'#99f',
id: "demo5-wrap"
});
$("#demo6").highlightTextarea({
words: ["Lorem ipsum","vulputate"],
});
$(".disable").click(function() {
$("#demo6").highlightTextarea("disable");
return false;
});
$(".enable").click(function() {
$("#demo6").highlightTextarea("enable");
return false;
});
$(".setWords").click(function() {
$("#demo6").highlightTextarea("setWords", ["Quisque","auctor"]);
return false;
});
$(".color").click(function() {
$("#demo6").highlightTextarea("setOptions", {color: "#ADF0FF"});
return false;
});
$(".debug").click(function() {
$("#demo6").highlightTextarea("setOptions", {debug: true});
return false;
});
});
</script>
<style type="text/css">
#demo5-wrap .highlight {
padding:0 3px;
margin:0 -3px;
border-radius:0.5em;
}
</style>
</head>
<body>
<div id="the_header">
jQuery • highlightTextarea • Demos
</div>
<div id="the_page">
<dl>
<dt>Change highlighting color</dt>
<dd>
<textarea id="demo1" cols="50" rows="5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis vulputate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat.</textarea>
<pre>$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"Lorem ipsum"</span><span class="opt">,</span><span class="str">"vulputate"</span><span class="opt">],</span>
color<span class="opt">:</span> <span class="str">"#ADF0FF"</span>
<span class="opt">});</span></pre>
</dd>
<dt>Case insensitive</dt>
<dd>
<textarea id="demo2" cols="50" rows="5">Lorem IPsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis VULPutate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat.</textarea>
<pre>$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"lOrEm IpSuM"</span><span class="opt">,</span><span class="str">"VULPUTATE"</span><span class="opt">],</span>
caseSensitive<span class="opt">:</span> <span class="kwa">false</span>
<span class="opt">});</span></pre>
</dd>
<dt>Resizing (with jQueryUI)</dt>
<dd>
<textarea id="demo3" cols="50" rows="5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis vulputate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat. Cras vel velit ac sem adipiscing iaculis dapibus mollis ligula. Donec accumsan ullamcorper leo, non faucibus est tempus eget. Nam varius ullamcorper viverra. Nullam iaculis tristique placerat. Nullam ante massa, consectetur nec aliquet nec, luctus et lorem. Donec semper odio lorem, sit amet tempor metus. Fusce et tortor tellus. Sed interdum nunc non ligula convallis fringilla in eget leo. Morbi sodales mollis ante dictum eleifend.</textarea>
<pre>$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"Lorem ipsum"</span><span class="opt">,</span><span class="str">"Nam varius"</span><span class="opt">,</span><span class="str">"Nullam"</span><span class="opt">],</span>
resizable<span class="opt">:</span> <span class="kwa">true</span>
<span class="opt">});</span></pre>
</dd>
<dt>Use regular expressions (here, highlight Smarty tags)</dt>
<dd>
<textarea id="demo4" cols="50" rows="4"><ul>
{foreach from=$list item=row}
<li>{$row.name}</li>
{/foreach}
</ul></textarea>
<pre>$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"\{(.+?)\}"</span><span class="opt">]</span>
<span class="opt">});</span></pre>
</dd>
<dt>Customise highlight element</dt>
<dd>
<textarea id="demo5" cols="50" rows="5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis vulputate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat.</textarea>
<pre class="js">$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"Lorem ipsum"</span><span class="opt">,</span><span class="str">"vulputate"</span><span class="opt">],</span>
color<span class="opt">:</span> <span class="str">"#99f"</span>
<span class="opt">});</span></pre>
<pre class="css"><span class="kwd">.highlight</span> <span class="opt">{</span>
<span class="kwa">border-radius</span><span class="opt">: </span><span class="num">0.5em</span><span class="opt">;</span>
<span class="kwa">padding</span><span class="opt">: </span><span class="num">0 3px</span><span class="opt">;</span>
<span class="kwa">margin</span><span class="opt">: </span><span class="num">0</span> <span class="opt">-</span><span class="num">3px</span><span class="opt">;</span>
<span class="opt">}</span></pre>
</dd>
<dt>Use API</dt>
<dd>
<a href="#" class="disable">Disable</a> |
<a href="#" class="enable">Enable</a> |
<a href="#" class="setWords">Change words</a> |
<a href="#" class="color">Change color</a> |
<a href="#" class="debug">Debug</a>
<br>
<textarea id="demo6" cols="50" rows="5">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque at massa non erat convallis vulputate molestie nec dui. Donec auctor blandit nibh quis luctus. Donec tincidunt auctor consequat.</textarea>
<pre class="html"><span class="kwd"><a</span> <span class="kwa">class</span><span class="opt">=</span><span class="str">"disable"</span><span class="kwd">></span>Disable<span class="kwd"></a></span> | <span class="kwd"><a</span> <span class="kwa">class</span><span class="opt">=</span><span class="str">"enable"</span><span class="kwd">></span>Enable<span class="kwd"></a></span> | <span class="kwd"><a</span> <span class="kwa">class</span><span class="opt">=</span><span class="str">"setWords"</span><span class="kwd">></span>Change
words<span class="kwd"></a></span> | <span class="kwd"><a</span> <span class="kwa">class</span><span class="opt">=</span><span class="str">"color"</span><span class="kwd">></span>Change color<span class="kwd"></a></span> | <span class="kwd"><a</span> <span class="kwa">class</span><span class="opt">=</span><span class="str">"debug"</span><span class="kwd">></span>Debug<span class="kwd"></a></span></pre>
<pre class="js">$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">({</span>
words<span class="opt">: [</span><span class="str">"Lorem ipsum"</span><span class="opt">,</span><span class="str">"vulputate"</span><span class="opt">]</span>
<span class="opt">});</span>
$<span class="opt">(</span><span class="str">".disable"</span><span class="opt">).</span><span class="kwd">click</span><span class="opt">(</span>function<span class="opt">() {</span>
$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">(</span><span class="str">'disable'</span><span class="opt">);</span>
<span class="opt">});</span>
$<span class="opt">(</span><span class="str">".enable"</span><span class="opt">).</span><span class="kwd">click</span><span class="opt">(</span>function<span class="opt">() {</span>
$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">(</span><span class="str">'enable'</span><span class="opt">);</span>
<span class="opt">});</span>
$<span class="opt">(</span><span class="str">".setWords"</span><span class="opt">).</span><span class="kwd">click</span><span class="opt">(</span>function<span class="opt">() {</span>
$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">(</span><span class="str">'setWords'</span>, <span class="opt">[</span> <span class="str">'Quisque'</span><span class="opt">,</span><span class="str">'auctor'</span> <span class="opt">]);</span>
<span class="opt">});</span>
$<span class="opt">(</span><span class="str">".color"</span><span class="opt">).</span><span class="kwd">click</span><span class="opt">(</span>function<span class="opt">() {</span>
$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">(</span><span class="str">'setOptions'</span>, <span class="opt">{</span> color<span class="opt">:</span> <span class="str">'#ADF0FF'</span> <span class="opt">});</span>
<span class="opt">});</span>
$<span class="opt">(</span><span class="str">".debug"</span><span class="opt">).</span><span class="kwd">click</span><span class="opt">(</span>function<span class="opt">() {</span>
$<span class="opt">(</span><span class="str">"textarea"</span><span class="opt">).</span><span class="kwd">highlightTextarea</span><span class="opt">(</span><span class="str">'setOptions'</span>, <span class="opt">{</span> debug<span class="opt">:</span> <span class="kwa">true</span> <span class="opt">});</span>
<span class="opt">});</span></pre>
</dd>
</dl>
</div>
<div id="the_footer">© 2012 <a href="http://www.strangeplanet.fr">strangeplanet.fr</a> - Created by Damien "Mistic" Sorel</div>
</body>
</html>