This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.html
207 lines (178 loc) · 9.76 KB
/
index.html
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Page Description">
<meta name="author" content="nguyenluat">
<title>Page Title</title>
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/jquery.mentiony.css" >
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css">
<style>
textarea {width: 100%}
.mentiony-container, .mentiony-content{width: 100%!important;}
.demo-item{ height: 300px;}
.demo-item .demo, .demo-item .demo > *{ height: 100%; }
.demo-item .code, .demo-item .code > *{ height: 100%; }
.demo-item .code, .demo-item .code > pre > code{ padding: 0; background: none }
.demo-item .code > pre > code{
width: 999px !important;
display: block;
}
pre.prettyprint {
background-color: #693d3d!important;
}
</style>
</head>
<body>
<div class="container">
<h2>Jquery-metiony demo - user guide</h2>
<p class="help-block">This plugin focus on mention. If you wanna do <b>fuzzy search</b> + <b>highlight</b> search result, feel free integrate those plugin by your self</p>
<p class="help-block">There are so many feature that need to improve. Currently, I do not use Jquery anymore, so no improvement of this repository will be made</p>
<p class="help-block">
These is textarea was transformed to div[contenteditable].<br>
Try to type @John to mention anyone whose name John.<br>
Use keyboard ← ↑ → ↓ or mouse to select.<br>
</p>
<div class="row demo-item">
<div class="col-sm-12"><h4>Mention anyone by @name</h4></div>
<div class="col-sm-6 demo">
<textarea id="t1" name="mention1" class="mention1" rows="6">Try to @John</textarea>
</div>
<div class="col-sm-6 code">
<pre class="prettyprint">
<code class="javascript">
$('textarea.mention1').mentiony({
onDataRequest: function (mode, keyword, onDataRequestCompleteCallback) {
var data = [
{ id:1, name:'Nguyen Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:2, name:'Dinh Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:3, name:'Max Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:4, name:'John Neo', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:5, name:'John Dinh', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:6, name:'Test User', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:7, name:'Test User 2', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:8, name:'No Test', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:9, name:'The User Foo', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:10, name:'Foo Bar', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
];
data = jQuery.grep(data, function( item ) {
return item.name.toLowerCase().indexOf(keyword.toLowerCase()) > -1;
});
// Call this to populate mention.
onDataRequestCompleteCallback.call(this, data);
},
timeOut: 0,
debug: 1,
});
</code>
</pre>
</div>
</div>
<div class="row demo-item">
<div class="col-sm-12"><h4>Use RESTAPI as data source</h4></div>
<div class="col-sm-6 demo">
<textarea id="t2" name="mention2" class="mention2" rows="6">Try to @ then wait 500ms for the server responding, (assuming server response time is 500ms)</textarea>
</div>
<div class="col-sm-6 code">
<pre class="prettyprint">
<code class="javascript">
$('textarea[name="mention2"]').mentiony({
onDataRequest: function (mode, keyword, onDataRequestCompleteCallback) {
$.ajax({
method: "GET",
url: "js/example.json?query="+ keyword,
dataType: "json",
success: function (response) {
var data = response;
// NOTE: Assuming this filter process was done on server-side
data = jQuery.grep(data, function( item ) {
return item.name.toLowerCase().indexOf(keyword.toLowerCase()) > -1;
});
// End server-side
// Call this to populate mention.
onDataRequestCompleteCallback.call(this, data);
}
});
},
timeOut: 500, // Timeout to show mention after press @
debug: 1, // show debug info
});
</code>
</pre>
</div>
</div>
<div class="row demo-item">
<div class="col-sm-12"><h4>Feel free to styling your mentioned items:</h4></div>
<div class="col-sm-6 demo" id="red-mention-item">
<style>
#red-mention-item .mention-area .highlight a.mentiony-link {background: #ea0000}
</style>
<textarea id="t3" name="mention3" class="mention1" rows="6">Can run multiple instance on 1 pages. Try to @John</textarea>
</div>
<div class="col-sm-6 code">
<pre class="prettyprint">
<code class="css">
#red-mention-item .mention-area .highlight a.mentiony-link {background: #ea0000}
</code>
</pre>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?lang=javascript&skin=desert"></script>
<script src="js/jquery.mentiony.js"></script>
<script>
$('textarea.mention1').mentiony({
onDataRequest: function (mode, keyword, onDataRequestCompleteCallback) {
var data = [
{ id:1, name:'Nguyen Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:2, name:'Dinh Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:3, name:'Max Luat', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:4, name:'John Neo', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:5, name:'John Dinh', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:6, name:'Test User', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:7, name:'Test User 2', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:8, name:'No Test', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:9, name:'The User Foo', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
{ id:10, name:'Foo Bar', 'avatar':'https://goo.gl/WXAP1U', 'info':'Vietnam' , href: 'http://a.co/id'},
];
data = jQuery.grep(data, function( item ) {
return item.name.toLowerCase().indexOf(keyword.toLowerCase()) > -1;
});
// Call this to populate mention.
onDataRequestCompleteCallback.call(this, data);
},
timeOut: 0,
debug: 1,
});
</script>
<script>
$('textarea[name="mention2"]').mentiony({
onDataRequest: function (mode, keyword, onDataRequestCompleteCallback) {
$.ajax({
method: "GET",
url: "js/example.json?query="+ keyword,
dataType: "json",
success: function (response) {
var data = response;
// NOTE: Assuming this filter process was done on server-side
data = jQuery.grep(data, function( item ) {
return item.name.toLowerCase().indexOf(keyword.toLowerCase()) > -1;
});
// End server-side
// Call this to populate mention.
onDataRequestCompleteCallback.call(this, data);
}
});
},
timeOut: 500, // Timeout to show mention after press @
debug: 1, // show debug info
});
</script>
</div>
</body>
</html>