jquery-atwho-rails 0.4.5 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,338 @@
1
+ //@ sourceMappingURL=jquery.caret.map
2
+ /*
3
+ Implement Github like autocomplete mentions
4
+ http://ichord.github.com/At.js
5
+
6
+ Copyright (c) 2013 chord.luo@gmail.com
7
+ Licensed under the MIT license.
8
+ */
9
+
10
+
11
+ /*
12
+ 本插件操作 textarea 或者 input 内的插入符
13
+ 只实现了获得插入符在文本框中的位置,我设置
14
+ 插入符的位置.
15
+ */
16
+
17
+
18
+ (function() {
19
+ (function(factory) {
20
+ if (typeof define === 'function' && define.amd) {
21
+ return define(['jquery'], factory);
22
+ } else {
23
+ return factory(window.jQuery);
24
+ }
25
+ })(function($) {
26
+ "use strict";
27
+ var EditableCaret, InputCaret, Mirror, Utils, methods, oDocument, oFrame, oWindow, pluginName;
28
+ pluginName = 'caret';
29
+ EditableCaret = (function() {
30
+ function EditableCaret($inputor) {
31
+ this.$inputor = $inputor;
32
+ this.domInputor = this.$inputor[0];
33
+ }
34
+
35
+ EditableCaret.prototype.setPos = function(pos) {
36
+ return this.domInputor;
37
+ };
38
+
39
+ EditableCaret.prototype.getIEPosition = function() {
40
+ return $.noop();
41
+ };
42
+
43
+ EditableCaret.prototype.getPosition = function() {
44
+ return $.noop();
45
+ };
46
+
47
+ EditableCaret.prototype.getOldIEPos = function() {
48
+ var preCaretTextRange, textRange;
49
+ textRange = oDocument.selection.createRange();
50
+ preCaretTextRange = oDocument.body.createTextRange();
51
+ preCaretTextRange.moveToElementText(this.domInputor);
52
+ preCaretTextRange.setEndPoint("EndToEnd", textRange);
53
+ return preCaretTextRange.text.length;
54
+ };
55
+
56
+ EditableCaret.prototype.getPos = function() {
57
+ var clonedRange, pos, range;
58
+ if (range = this.range()) {
59
+ clonedRange = range.cloneRange();
60
+ clonedRange.selectNodeContents(this.domInputor);
61
+ clonedRange.setEnd(range.endContainer, range.endOffset);
62
+ pos = clonedRange.toString().length;
63
+ clonedRange.detach();
64
+ return pos;
65
+ } else if (oDocument.selection) {
66
+ return this.getOldIEPos();
67
+ }
68
+ };
69
+
70
+ EditableCaret.prototype.getOldIEOffset = function() {
71
+ var range, rect;
72
+ range = oDocument.selection.createRange().duplicate();
73
+ range.moveStart("character", -1);
74
+ rect = range.getBoundingClientRect();
75
+ return {
76
+ height: rect.bottom - rect.top,
77
+ left: rect.left,
78
+ top: rect.top
79
+ };
80
+ };
81
+
82
+ EditableCaret.prototype.getOffset = function(pos) {
83
+ var clonedRange, offset, range, rect;
84
+ if (oWindow.getSelection && (range = this.range())) {
85
+ if (range.endOffset - 1 < 0) {
86
+ return null;
87
+ }
88
+ clonedRange = range.cloneRange();
89
+ clonedRange.setStart(range.endContainer, range.endOffset - 1);
90
+ clonedRange.setEnd(range.endContainer, range.endOffset);
91
+ rect = clonedRange.getBoundingClientRect();
92
+ offset = {
93
+ height: rect.height,
94
+ left: rect.left + rect.width,
95
+ top: rect.top
96
+ };
97
+ clonedRange.detach();
98
+ } else if (oDocument.selection) {
99
+ offset = this.getOldIEOffset();
100
+ }
101
+ if (offset && !oFrame) {
102
+ offset.top += $(oWindow).scrollTop();
103
+ offset.left += $(oWindow).scrollLeft();
104
+ }
105
+ return offset;
106
+ };
107
+
108
+ EditableCaret.prototype.range = function() {
109
+ var sel;
110
+ if (!oWindow.getSelection) {
111
+ return;
112
+ }
113
+ sel = oWindow.getSelection();
114
+ if (sel.rangeCount > 0) {
115
+ return sel.getRangeAt(0);
116
+ } else {
117
+ return null;
118
+ }
119
+ };
120
+
121
+ return EditableCaret;
122
+
123
+ })();
124
+ InputCaret = (function() {
125
+ function InputCaret($inputor) {
126
+ this.$inputor = $inputor;
127
+ this.domInputor = this.$inputor[0];
128
+ }
129
+
130
+ InputCaret.prototype.getIEPos = function() {
131
+ var endRange, inputor, len, normalizedValue, pos, range, textInputRange;
132
+ inputor = this.domInputor;
133
+ range = oDocument.selection.createRange();
134
+ pos = 0;
135
+ if (range && range.parentElement() === inputor) {
136
+ normalizedValue = inputor.value.replace(/\r\n/g, "\n");
137
+ len = normalizedValue.length;
138
+ textInputRange = inputor.createTextRange();
139
+ textInputRange.moveToBookmark(range.getBookmark());
140
+ endRange = inputor.createTextRange();
141
+ endRange.collapse(false);
142
+ if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
143
+ pos = len;
144
+ } else {
145
+ pos = -textInputRange.moveStart("character", -len);
146
+ }
147
+ }
148
+ return pos;
149
+ };
150
+
151
+ InputCaret.prototype.getPos = function() {
152
+ if (oDocument.selection) {
153
+ return this.getIEPos();
154
+ } else {
155
+ return this.domInputor.selectionStart;
156
+ }
157
+ };
158
+
159
+ InputCaret.prototype.setPos = function(pos) {
160
+ var inputor, range;
161
+ inputor = this.domInputor;
162
+ if (oDocument.selection) {
163
+ range = inputor.createTextRange();
164
+ range.move("character", pos);
165
+ range.select();
166
+ } else if (inputor.setSelectionRange) {
167
+ inputor.setSelectionRange(pos, pos);
168
+ }
169
+ return inputor;
170
+ };
171
+
172
+ InputCaret.prototype.getIEOffset = function(pos) {
173
+ var h, textRange, x, y;
174
+ textRange = this.domInputor.createTextRange();
175
+ pos || (pos = this.getPos());
176
+ textRange.move('character', pos);
177
+ x = textRange.boundingLeft;
178
+ y = textRange.boundingTop;
179
+ h = textRange.boundingHeight;
180
+ return {
181
+ left: x,
182
+ top: y,
183
+ height: h
184
+ };
185
+ };
186
+
187
+ InputCaret.prototype.getOffset = function(pos) {
188
+ var $inputor, offset, position;
189
+ $inputor = this.$inputor;
190
+ if (oDocument.selection) {
191
+ offset = this.getIEOffset(pos);
192
+ offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
193
+ offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
194
+ return offset;
195
+ } else {
196
+ offset = $inputor.offset();
197
+ position = this.getPosition(pos);
198
+ return offset = {
199
+ left: offset.left + position.left - $inputor.scrollLeft(),
200
+ top: offset.top + position.top - $inputor.scrollTop(),
201
+ height: position.height
202
+ };
203
+ }
204
+ };
205
+
206
+ InputCaret.prototype.getPosition = function(pos) {
207
+ var $inputor, at_rect, format, html, mirror, start_range;
208
+ $inputor = this.$inputor;
209
+ format = function(value) {
210
+ return value.replace(/</g, '&lt').replace(/>/g, '&gt').replace(/`/g, '&#96').replace(/"/g, '&quot').replace(/\r\n|\r|\n/g, "<br />");
211
+ };
212
+ if (pos === void 0) {
213
+ pos = this.getPos();
214
+ }
215
+ start_range = $inputor.val().slice(0, pos);
216
+ html = "<span>" + format(start_range) + "</span>";
217
+ html += "<span id='caret'>|</span>";
218
+ mirror = new Mirror($inputor);
219
+ return at_rect = mirror.create(html).rect();
220
+ };
221
+
222
+ InputCaret.prototype.getIEPosition = function(pos) {
223
+ var h, inputorOffset, offset, x, y;
224
+ offset = this.getIEOffset(pos);
225
+ inputorOffset = this.$inputor.offset();
226
+ x = offset.left - inputorOffset.left;
227
+ y = offset.top - inputorOffset.top;
228
+ h = offset.height;
229
+ return {
230
+ left: x,
231
+ top: y,
232
+ height: h
233
+ };
234
+ };
235
+
236
+ return InputCaret;
237
+
238
+ })();
239
+ Mirror = (function() {
240
+ Mirror.prototype.css_attr = ["overflowY", "height", "width", "paddingTop", "paddingLeft", "paddingRight", "paddingBottom", "marginTop", "marginLeft", "marginRight", "marginBottom", "fontFamily", "borderStyle", "borderWidth", "wordWrap", "fontSize", "lineHeight", "overflowX", "text-align"];
241
+
242
+ function Mirror($inputor) {
243
+ this.$inputor = $inputor;
244
+ }
245
+
246
+ Mirror.prototype.mirrorCss = function() {
247
+ var css,
248
+ _this = this;
249
+ css = {
250
+ position: 'absolute',
251
+ left: -9999,
252
+ top: 0,
253
+ zIndex: -20000,
254
+ 'white-space': 'pre-wrap'
255
+ };
256
+ $.each(this.css_attr, function(i, p) {
257
+ return css[p] = _this.$inputor.css(p);
258
+ });
259
+ return css;
260
+ };
261
+
262
+ Mirror.prototype.create = function(html) {
263
+ this.$mirror = $('<div></div>');
264
+ this.$mirror.css(this.mirrorCss());
265
+ this.$mirror.html(html);
266
+ this.$inputor.after(this.$mirror);
267
+ return this;
268
+ };
269
+
270
+ Mirror.prototype.rect = function() {
271
+ var $flag, pos, rect;
272
+ $flag = this.$mirror.find("#caret");
273
+ pos = $flag.position();
274
+ rect = {
275
+ left: pos.left,
276
+ top: pos.top,
277
+ height: $flag.height()
278
+ };
279
+ this.$mirror.remove();
280
+ return rect;
281
+ };
282
+
283
+ return Mirror;
284
+
285
+ })();
286
+ Utils = {
287
+ contentEditable: function($inputor) {
288
+ return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true');
289
+ }
290
+ };
291
+ methods = {
292
+ pos: function(pos) {
293
+ if (pos) {
294
+ return this.setPos(pos);
295
+ } else {
296
+ return this.getPos();
297
+ }
298
+ },
299
+ position: function(pos) {
300
+ if (oDocument.selection) {
301
+ return this.getIEPosition(pos);
302
+ } else {
303
+ return this.getPosition(pos);
304
+ }
305
+ },
306
+ offset: function(pos) {
307
+ var iOffset, offset;
308
+ offset = this.getOffset(pos);
309
+ if (oFrame) {
310
+ iOffset = $(oFrame).offset();
311
+ offset.top += iOffset.top;
312
+ offset.left += iOffset.left;
313
+ }
314
+ return offset;
315
+ }
316
+ };
317
+ oDocument = null;
318
+ oWindow = null;
319
+ oFrame = null;
320
+ $.fn.caret = function(method) {
321
+ var caret;
322
+ oDocument = this[0].ownerDocument;
323
+ oWindow = oDocument.defaultView || oDocument.parentWindow;
324
+ oFrame = oWindow.frameElement;
325
+ caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this);
326
+ if (methods[method]) {
327
+ return methods[method].apply(caret, Array.prototype.slice.call(arguments, 1));
328
+ } else {
329
+ return $.error("Method " + method + " does not exist on jQuery.caret");
330
+ }
331
+ };
332
+ $.fn.caret.EditableCaret = EditableCaret;
333
+ $.fn.caret.InputCaret = InputCaret;
334
+ $.fn.caret.Utils = Utils;
335
+ return $.fn.caret.apis = methods;
336
+ });
337
+
338
+ }).call(this);
@@ -1 +1,46 @@
1
- .atwho-view{position:absolute;top:0;left:0;display:none;margin-top:18px;background:#fff;border:1px solid #DDD;border-radius:3px;box-shadow:0 0 5px rgba(0,0,0,.1);min-width:120px;z-index:10}.atwho-view .cur{background:#36F;color:#fff}.atwho-view .cur small{color:#fff}.atwho-view strong{color:#36F}.atwho-view .cur strong{color:#fff;font:bold}.atwho-view ul{list-style:none;padding:0;margin:auto}.atwho-view ul li{display:block;padding:5px 10px;border-bottom:1px solid #DDD;cursor:pointer}.atwho-view small{font-size:smaller;color:#777;font-weight:400}
1
+ .atwho-view {
2
+ position:absolute;
3
+ top: 0;
4
+ left: 0;
5
+ display: none;
6
+ margin-top: 18px;
7
+ background: white;
8
+ border: 1px solid #DDD;
9
+ border-radius: 3px;
10
+ box-shadow: 0 0 5px rgba(0,0,0,0.1);
11
+ min-width: 120px;
12
+ z-index: 10;
13
+ }
14
+
15
+ .atwho-view .cur {
16
+ background: #3366FF;
17
+ color: white;
18
+ }
19
+ .atwho-view .cur small {
20
+ color: white;
21
+ }
22
+ .atwho-view strong {
23
+ color: #3366FF;
24
+ }
25
+ .atwho-view .cur strong {
26
+ color: white;
27
+ font:bold;
28
+ }
29
+ .atwho-view ul {
30
+ /* width: 100px; */
31
+ list-style:none;
32
+ padding:0;
33
+ margin:auto;
34
+ }
35
+ .atwho-view ul li {
36
+ display: block;
37
+ padding: 5px 10px;
38
+ border-bottom: 1px solid #DDD;
39
+ cursor: pointer;
40
+ /* border-top: 1px solid #C8C8C8; */
41
+ }
42
+ .atwho-view small {
43
+ font-size: smaller;
44
+ color: #777;
45
+ font-weight: normal;
46
+ }
@@ -1,7 +1,7 @@
1
1
  module Jquery
2
2
  module Atwho
3
3
  module Rails
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.7"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-atwho-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichord
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -54,7 +54,9 @@ files:
54
54
  - Rakefile
55
55
  - changelog.md
56
56
  - jquery-atwho-rails.gemspec
57
- - lib/assets/javascripts/jquery.atwho.js
57
+ - lib/assets/javascripts/jquery.atwho/index.js
58
+ - lib/assets/javascripts/jquery.atwho/jquery.atwho.js
59
+ - lib/assets/javascripts/jquery.atwho/jquery.caret.js
58
60
  - lib/assets/stylesheets/jquery.atwho.css
59
61
  - lib/generators/atwho/install_generator.rb
60
62
  - lib/jquery-atwho-rails.rb
@@ -1,1048 +0,0 @@
1
- //@ sourceMappingURL=jquery.caret.map
2
- /*
3
- Implement Github like autocomplete mentions
4
- http://ichord.github.com/At.js
5
-
6
- Copyright (c) 2013 chord.luo@gmail.com
7
- Licensed under the MIT license.
8
- */
9
-
10
-
11
- /*
12
- 本插件操作 textarea 或者 input 内的插入符
13
- 只实现了获得插入符在文本框中的位置,我设置
14
- 插入符的位置.
15
- */
16
-
17
-
18
- (function() {
19
- (function(factory) {
20
- if (typeof define === 'function' && define.amd) {
21
- return define(['jquery'], factory);
22
- } else {
23
- return factory(window.jQuery);
24
- }
25
- })(function($) {
26
- "use strict";
27
- var EditableCaret, InputCaret, Mirror, Utils, methods, oDocument, oFrame, oWindow, pluginName;
28
- pluginName = 'caret';
29
- EditableCaret = (function() {
30
- function EditableCaret($inputor) {
31
- this.$inputor = $inputor;
32
- this.domInputor = this.$inputor[0];
33
- }
34
-
35
- EditableCaret.prototype.setPos = function(pos) {
36
- return this.domInputor;
37
- };
38
-
39
- EditableCaret.prototype.getIEPosition = function() {
40
- return $.noop();
41
- };
42
-
43
- EditableCaret.prototype.getPosition = function() {
44
- return $.noop();
45
- };
46
-
47
- EditableCaret.prototype.getOldIEPos = function() {
48
- var preCaretTextRange, textRange;
49
- textRange = oDocument.selection.createRange();
50
- preCaretTextRange = oDocument.body.createTextRange();
51
- preCaretTextRange.moveToElementText(this.domInputor);
52
- preCaretTextRange.setEndPoint("EndToEnd", textRange);
53
- return preCaretTextRange.text.length;
54
- };
55
-
56
- EditableCaret.prototype.getPos = function() {
57
- var clonedRange, pos, range;
58
- if (range = this.range()) {
59
- clonedRange = range.cloneRange();
60
- clonedRange.selectNodeContents(this.domInputor);
61
- clonedRange.setEnd(range.endContainer, range.endOffset);
62
- pos = clonedRange.toString().length;
63
- clonedRange.detach();
64
- return pos;
65
- } else if (oDocument.selection) {
66
- return this.getOldIEPos();
67
- }
68
- };
69
-
70
- EditableCaret.prototype.getOldIEOffset = function() {
71
- var range, rect;
72
- range = oDocument.selection.createRange().duplicate();
73
- range.moveStart("character", -1);
74
- rect = range.getBoundingClientRect();
75
- return {
76
- height: rect.bottom - rect.top,
77
- left: rect.left,
78
- top: rect.top
79
- };
80
- };
81
-
82
- EditableCaret.prototype.getOffset = function(pos) {
83
- var clonedRange, offset, range, rect;
84
- if (oWindow.getSelection && (range = this.range())) {
85
- if (range.endOffset - 1 < 0) {
86
- return null;
87
- }
88
- clonedRange = range.cloneRange();
89
- clonedRange.setStart(range.endContainer, range.endOffset - 1);
90
- clonedRange.setEnd(range.endContainer, range.endOffset);
91
- rect = clonedRange.getBoundingClientRect();
92
- offset = {
93
- height: rect.height,
94
- left: rect.left + rect.width,
95
- top: rect.top
96
- };
97
- clonedRange.detach();
98
- } else if (oDocument.selection) {
99
- offset = this.getOldIEOffset();
100
- }
101
- if (offset && !oFrame) {
102
- offset.top += $(oWindow).scrollTop();
103
- offset.left += $(oWindow).scrollLeft();
104
- }
105
- return offset;
106
- };
107
-
108
- EditableCaret.prototype.range = function() {
109
- var sel;
110
- if (!oWindow.getSelection) {
111
- return;
112
- }
113
- sel = oWindow.getSelection();
114
- if (sel.rangeCount > 0) {
115
- return sel.getRangeAt(0);
116
- } else {
117
- return null;
118
- }
119
- };
120
-
121
- return EditableCaret;
122
-
123
- })();
124
- InputCaret = (function() {
125
- function InputCaret($inputor) {
126
- this.$inputor = $inputor;
127
- this.domInputor = this.$inputor[0];
128
- }
129
-
130
- InputCaret.prototype.getIEPos = function() {
131
- var endRange, inputor, len, normalizedValue, pos, range, textInputRange;
132
- inputor = this.domInputor;
133
- range = oDocument.selection.createRange();
134
- pos = 0;
135
- if (range && range.parentElement() === inputor) {
136
- normalizedValue = inputor.value.replace(/\r\n/g, "\n");
137
- len = normalizedValue.length;
138
- textInputRange = inputor.createTextRange();
139
- textInputRange.moveToBookmark(range.getBookmark());
140
- endRange = inputor.createTextRange();
141
- endRange.collapse(false);
142
- if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
143
- pos = len;
144
- } else {
145
- pos = -textInputRange.moveStart("character", -len);
146
- }
147
- }
148
- return pos;
149
- };
150
-
151
- InputCaret.prototype.getPos = function() {
152
- if (oDocument.selection) {
153
- return this.getIEPos();
154
- } else {
155
- return this.domInputor.selectionStart;
156
- }
157
- };
158
-
159
- InputCaret.prototype.setPos = function(pos) {
160
- var inputor, range;
161
- inputor = this.domInputor;
162
- if (oDocument.selection) {
163
- range = inputor.createTextRange();
164
- range.move("character", pos);
165
- range.select();
166
- } else if (inputor.setSelectionRange) {
167
- inputor.setSelectionRange(pos, pos);
168
- }
169
- return inputor;
170
- };
171
-
172
- InputCaret.prototype.getIEOffset = function(pos) {
173
- var h, textRange, x, y;
174
- textRange = this.domInputor.createTextRange();
175
- pos || (pos = this.getPos());
176
- textRange.move('character', pos);
177
- x = textRange.boundingLeft;
178
- y = textRange.boundingTop;
179
- h = textRange.boundingHeight;
180
- return {
181
- left: x,
182
- top: y,
183
- height: h
184
- };
185
- };
186
-
187
- InputCaret.prototype.getOffset = function(pos) {
188
- var $inputor, offset, position;
189
- $inputor = this.$inputor;
190
- if (oDocument.selection) {
191
- offset = this.getIEOffset(pos);
192
- offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
193
- offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
194
- return offset;
195
- } else {
196
- offset = $inputor.offset();
197
- position = this.getPosition(pos);
198
- return offset = {
199
- left: offset.left + position.left - $inputor.scrollLeft(),
200
- top: offset.top + position.top - $inputor.scrollTop(),
201
- height: position.height
202
- };
203
- }
204
- };
205
-
206
- InputCaret.prototype.getPosition = function(pos) {
207
- var $inputor, at_rect, format, html, mirror, start_range;
208
- $inputor = this.$inputor;
209
- format = function(value) {
210
- return value.replace(/</g, '&lt').replace(/>/g, '&gt').replace(/`/g, '&#96').replace(/"/g, '&quot').replace(/\r\n|\r|\n/g, "<br />");
211
- };
212
- if (pos === void 0) {
213
- pos = this.getPos();
214
- }
215
- start_range = $inputor.val().slice(0, pos);
216
- html = "<span>" + format(start_range) + "</span>";
217
- html += "<span id='caret'>|</span>";
218
- mirror = new Mirror($inputor);
219
- return at_rect = mirror.create(html).rect();
220
- };
221
-
222
- InputCaret.prototype.getIEPosition = function(pos) {
223
- var h, inputorOffset, offset, x, y;
224
- offset = this.getIEOffset(pos);
225
- inputorOffset = this.$inputor.offset();
226
- x = offset.left - inputorOffset.left;
227
- y = offset.top - inputorOffset.top;
228
- h = offset.height;
229
- return {
230
- left: x,
231
- top: y,
232
- height: h
233
- };
234
- };
235
-
236
- return InputCaret;
237
-
238
- })();
239
- Mirror = (function() {
240
- Mirror.prototype.css_attr = ["overflowY", "height", "width", "paddingTop", "paddingLeft", "paddingRight", "paddingBottom", "marginTop", "marginLeft", "marginRight", "marginBottom", "fontFamily", "borderStyle", "borderWidth", "wordWrap", "fontSize", "lineHeight", "overflowX", "text-align"];
241
-
242
- function Mirror($inputor) {
243
- this.$inputor = $inputor;
244
- }
245
-
246
- Mirror.prototype.mirrorCss = function() {
247
- var css,
248
- _this = this;
249
- css = {
250
- position: 'absolute',
251
- left: -9999,
252
- top: 0,
253
- zIndex: -20000,
254
- 'white-space': 'pre-wrap'
255
- };
256
- $.each(this.css_attr, function(i, p) {
257
- return css[p] = _this.$inputor.css(p);
258
- });
259
- return css;
260
- };
261
-
262
- Mirror.prototype.create = function(html) {
263
- this.$mirror = $('<div></div>');
264
- this.$mirror.css(this.mirrorCss());
265
- this.$mirror.html(html);
266
- this.$inputor.after(this.$mirror);
267
- return this;
268
- };
269
-
270
- Mirror.prototype.rect = function() {
271
- var $flag, pos, rect;
272
- $flag = this.$mirror.find("#caret");
273
- pos = $flag.position();
274
- rect = {
275
- left: pos.left,
276
- top: pos.top,
277
- height: $flag.height()
278
- };
279
- this.$mirror.remove();
280
- return rect;
281
- };
282
-
283
- return Mirror;
284
-
285
- })();
286
- Utils = {
287
- contentEditable: function($inputor) {
288
- return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true');
289
- }
290
- };
291
- methods = {
292
- pos: function(pos) {
293
- if (pos) {
294
- return this.setPos(pos);
295
- } else {
296
- return this.getPos();
297
- }
298
- },
299
- position: function(pos) {
300
- if (oDocument.selection) {
301
- return this.getIEPosition(pos);
302
- } else {
303
- return this.getPosition(pos);
304
- }
305
- },
306
- offset: function(pos) {
307
- var iOffset, offset;
308
- offset = this.getOffset(pos);
309
- if (oFrame) {
310
- iOffset = $(oFrame).offset();
311
- offset.top += iOffset.top;
312
- offset.left += iOffset.left;
313
- }
314
- return offset;
315
- }
316
- };
317
- oDocument = null;
318
- oWindow = null;
319
- oFrame = null;
320
- $.fn.caret = function(method) {
321
- var caret;
322
- oDocument = this[0].ownerDocument;
323
- oWindow = oDocument.defaultView || oDocument.parentWindow;
324
- oFrame = oWindow.frameElement;
325
- caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this);
326
- if (methods[method]) {
327
- return methods[method].apply(caret, Array.prototype.slice.call(arguments, 1));
328
- } else {
329
- return $.error("Method " + method + " does not exist on jQuery.caret");
330
- }
331
- };
332
- $.fn.caret.EditableCaret = EditableCaret;
333
- $.fn.caret.InputCaret = InputCaret;
334
- $.fn.caret.Utils = Utils;
335
- return $.fn.caret.apis = methods;
336
- });
337
-
338
- }).call(this);
339
-
340
-
341
- /*
342
- Implement Github like autocomplete mentions
343
- http://ichord.github.com/At.js
344
-
345
- Copyright (c) 2013 chord.luo@gmail.com
346
- Licensed under the MIT license.
347
- */
348
-
349
-
350
- (function() {
351
- var __slice = [].slice;
352
-
353
- (function(factory) {
354
- if (typeof define === 'function' && define.amd) {
355
- return define(['jquery'], factory);
356
- } else {
357
- return factory(window.jQuery);
358
- }
359
- })(function($) {
360
- var $CONTAINER, Api, App, Atwho, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View;
361
- App = (function() {
362
-
363
- function App(inputor) {
364
- this.current_flag = null;
365
- this.controllers = {};
366
- this.alias_maps = {};
367
- this.$inputor = $(inputor);
368
- this.listen();
369
- }
370
-
371
- App.prototype.controller = function(at) {
372
- return this.controllers[this.alias_maps[at] || at || this.current_flag];
373
- };
374
-
375
- App.prototype.set_context_for = function(at) {
376
- this.current_flag = at;
377
- return this;
378
- };
379
-
380
- App.prototype.reg = function(flag, setting) {
381
- var controller, _base;
382
- controller = (_base = this.controllers)[flag] || (_base[flag] = new Controller(this, flag));
383
- if (setting.alias) {
384
- this.alias_maps[setting.alias] = flag;
385
- }
386
- controller.init(setting);
387
- return this;
388
- };
389
-
390
- App.prototype.listen = function() {
391
- var _this = this;
392
- return this.$inputor.on('keyup.atwho', function(e) {
393
- return _this.on_keyup(e);
394
- }).on('keydown.atwho', function(e) {
395
- return _this.on_keydown(e);
396
- }).on('scroll.atwho', function(e) {
397
- var _ref;
398
- return (_ref = _this.controller()) != null ? _ref.view.hide() : void 0;
399
- }).on('blur.atwho', function(e) {
400
- var c;
401
- if (c = _this.controller()) {
402
- return c.view.hide(c.get_opt("display_timeout"));
403
- }
404
- });
405
- };
406
-
407
- App.prototype.dispatch = function() {
408
- var _this = this;
409
- return $.map(this.controllers, function(c) {
410
- if (c.look_up()) {
411
- return _this.set_context_for(c.at);
412
- }
413
- });
414
- };
415
-
416
- App.prototype.on_keyup = function(e) {
417
- var _ref;
418
- switch (e.keyCode) {
419
- case KEY_CODE.ESC:
420
- e.preventDefault();
421
- if ((_ref = this.controller()) != null) {
422
- _ref.view.hide();
423
- }
424
- break;
425
- case KEY_CODE.DOWN:
426
- case KEY_CODE.UP:
427
- $.noop();
428
- break;
429
- default:
430
- this.dispatch();
431
- }
432
- };
433
-
434
- App.prototype.on_keydown = function(e) {
435
- var view, _ref;
436
- view = (_ref = this.controller()) != null ? _ref.view : void 0;
437
- if (!(view && view.visible())) {
438
- return;
439
- }
440
- switch (e.keyCode) {
441
- case KEY_CODE.ESC:
442
- e.preventDefault();
443
- view.hide();
444
- break;
445
- case KEY_CODE.UP:
446
- e.preventDefault();
447
- view.prev();
448
- break;
449
- case KEY_CODE.DOWN:
450
- e.preventDefault();
451
- view.next();
452
- break;
453
- case KEY_CODE.TAB:
454
- case KEY_CODE.ENTER:
455
- if (!view.visible()) {
456
- return;
457
- }
458
- e.preventDefault();
459
- view.choose();
460
- break;
461
- default:
462
- $.noop();
463
- }
464
- };
465
-
466
- return App;
467
-
468
- })();
469
- Controller = (function() {
470
- var uuid, _uuid;
471
-
472
- _uuid = 0;
473
-
474
- uuid = function() {
475
- return _uuid += 1;
476
- };
477
-
478
- function Controller(app, at) {
479
- this.app = app;
480
- this.at = at;
481
- this.$inputor = this.app.$inputor;
482
- this.oDocument = this.$inputor[0].ownerDocument;
483
- this.oWindow = this.oDocument.defaultView || this.oDocument.parentWindow;
484
- this.id = this.$inputor[0].id || uuid();
485
- this.setting = null;
486
- this.query = null;
487
- this.pos = 0;
488
- this.cur_rect = null;
489
- this.range = null;
490
- $CONTAINER.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>"));
491
- this.model = new Model(this);
492
- this.view = new View(this);
493
- }
494
-
495
- Controller.prototype.init = function(setting) {
496
- this.setting = $.extend({}, this.setting || $.fn.atwho["default"], setting);
497
- this.view.init();
498
- return this.model.reload(this.setting.data);
499
- };
500
-
501
- Controller.prototype.call_default = function() {
502
- var args, func_name;
503
- func_name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
504
- try {
505
- return DEFAULT_CALLBACKS[func_name].apply(this, args);
506
- } catch (error) {
507
- return $.error("" + error + " Or maybe At.js doesn't have function " + func_name);
508
- }
509
- };
510
-
511
- Controller.prototype.trigger = function(name, data) {
512
- var alias, event_name;
513
- data.push(this);
514
- alias = this.get_opt('alias');
515
- event_name = alias ? "" + name + "-" + alias + ".atwho" : "" + name + ".atwho";
516
- return this.$inputor.trigger(event_name, data);
517
- };
518
-
519
- Controller.prototype.callbacks = function(func_name) {
520
- return this.get_opt("callbacks")[func_name] || DEFAULT_CALLBACKS[func_name];
521
- };
522
-
523
- Controller.prototype.get_opt = function(at, default_value) {
524
- try {
525
- return this.setting[at];
526
- } catch (e) {
527
- return null;
528
- }
529
- };
530
-
531
- Controller.prototype.content = function() {
532
- if (this.$inputor.is('textarea, input')) {
533
- return this.$inputor.val();
534
- } else {
535
- return this.$inputor.text();
536
- }
537
- };
538
-
539
- Controller.prototype.catch_query = function() {
540
- var caret_pos, content, end, query, start, subtext;
541
- content = this.content();
542
- caret_pos = this.$inputor.caret('pos');
543
- subtext = content.slice(0, caret_pos);
544
- query = this.callbacks("matcher").call(this, this.at, subtext, this.get_opt('start_with_space'));
545
- if (typeof query === "string" && query.length <= this.get_opt('max_len', 20)) {
546
- start = caret_pos - query.length;
547
- end = start + query.length;
548
- this.pos = start;
549
- query = {
550
- 'text': query.toLowerCase(),
551
- 'head_pos': start,
552
- 'end_pos': end
553
- };
554
- this.trigger("matched", [this.at, query.text]);
555
- } else {
556
- this.view.hide();
557
- }
558
- return this.query = query;
559
- };
560
-
561
- Controller.prototype.rect = function() {
562
- var c, scale_bottom;
563
- if (!(c = this.$inputor.caret('offset', this.pos - 1))) {
564
- return;
565
- }
566
- if (this.$inputor.attr('contentEditable') === 'true') {
567
- c = (this.cur_rect || (this.cur_rect = c)) || c;
568
- }
569
- scale_bottom = document.selection ? 0 : 2;
570
- return {
571
- left: c.left,
572
- top: c.top,
573
- bottom: c.top + c.height + scale_bottom
574
- };
575
- };
576
-
577
- Controller.prototype.reset_rect = function() {
578
- if (this.$inputor.attr('contentEditable') === 'true') {
579
- return this.cur_rect = null;
580
- }
581
- };
582
-
583
- Controller.prototype.mark_range = function() {
584
- this.range = this.get_range();
585
- return this.ie_range = this.get_ie_range();
586
- };
587
-
588
- Controller.prototype.clear_range = function() {
589
- return this.range = null;
590
- };
591
-
592
- Controller.prototype.get_range = function() {
593
- return this.range || (this.oWindow.getSelection ? this.oWindow.getSelection().getRangeAt(0) : void 0);
594
- };
595
-
596
- Controller.prototype.get_ie_range = function() {
597
- return this.ie_range || (this.oDocument.selection ? this.oDocument.selection.createRange() : void 0);
598
- };
599
-
600
- Controller.prototype.insert_content_for = function($li) {
601
- var data, data_value, tpl;
602
- data_value = $li.data('value');
603
- tpl = this.get_opt('insert_tpl');
604
- if (this.$inputor.is('textarea, input') || !tpl) {
605
- return data_value;
606
- }
607
- data = $.extend({}, $li.data('item-data'), {
608
- 'atwho-data-value': data_value,
609
- 'atwho-at': this.at
610
- });
611
- return this.callbacks("tpl_eval").call(this, tpl, data);
612
- };
613
-
614
- Controller.prototype.insert = function(content, $li) {
615
- var $inputor, $insert_node, class_name, content_node, insert_node, pos, range, sel, source, start_str, text;
616
- $inputor = this.$inputor;
617
- if ($inputor.attr('contentEditable') === 'true') {
618
- class_name = "atwho-view-flag atwho-view-flag-" + (this.get_opt('alias') || this.at);
619
- content_node = "" + content + "<span contenteditable='false'>&nbsp;<span>";
620
- insert_node = "<span contenteditable='false' class='" + class_name + "'>" + content_node + "</span>";
621
- $insert_node = $(insert_node).data('atwho-data-item', $li.data('item-data'));
622
- if (this.oDocument.selection) {
623
- $insert_node = $("<span contenteditable='true'></span>").html($insert_node);
624
- }
625
- }
626
- if ($inputor.is('textarea, input')) {
627
- content = '' + content;
628
- source = $inputor.val();
629
- start_str = source.slice(0, Math.max(this.query.head_pos - this.at.length, 0));
630
- text = "" + start_str + content + " " + (source.slice(this.query['end_pos'] || 0));
631
- $inputor.val(text);
632
- $inputor.caret('pos', start_str.length + content.length + 1);
633
- } else if (range = this.get_range()) {
634
- pos = range.startOffset - (this.query.end_pos - this.query.head_pos) - this.at.length;
635
- range.setStart(range.endContainer, Math.max(pos, 0));
636
- range.setEnd(range.endContainer, range.endOffset);
637
- range.deleteContents();
638
- range.insertNode($insert_node[0]);
639
- range.collapse(false);
640
- sel = this.oWindow.getSelection();
641
- sel.removeAllRanges();
642
- sel.addRange(range);
643
- } else if (range = this.get_ie_range()) {
644
- range.moveStart('character', this.query.end_pos - this.query.head_pos - this.at.length);
645
- range.pasteHTML(content_node);
646
- range.collapse(false);
647
- range.select();
648
- }
649
- $inputor.focus();
650
- return $inputor.change();
651
- };
652
-
653
- Controller.prototype.render_view = function(data) {
654
- var search_key;
655
- search_key = this.get_opt("search_key");
656
- data = this.callbacks("sorter").call(this, this.query.text, data.slice(0, 1001), search_key);
657
- return this.view.render(data.slice(0, this.get_opt('limit')));
658
- };
659
-
660
- Controller.prototype.look_up = function() {
661
- var query, _callback;
662
- if (!(query = this.catch_query())) {
663
- return;
664
- }
665
- _callback = function(data) {
666
- if (data && data.length > 0) {
667
- return this.render_view(data);
668
- } else {
669
- return this.view.hide();
670
- }
671
- };
672
- this.model.query(query.text, $.proxy(_callback, this));
673
- return query;
674
- };
675
-
676
- return Controller;
677
-
678
- })();
679
- Model = (function() {
680
-
681
- function Model(context) {
682
- this.context = context;
683
- this.at = this.context.at;
684
- this.storage = this.context.$inputor;
685
- }
686
-
687
- Model.prototype.saved = function() {
688
- return this.fetch() > 0;
689
- };
690
-
691
- Model.prototype.query = function(query, callback) {
692
- var data, search_key, _remote_filter;
693
- data = this.fetch();
694
- search_key = this.context.get_opt("search_key");
695
- data = this.context.callbacks('filter').call(this.context, query, data, search_key) || [];
696
- _remote_filter = this.context.callbacks('remote_filter');
697
- if (data.length > 0 || (!_remote_filter && data.length === 0)) {
698
- return callback(data);
699
- } else {
700
- return _remote_filter.call(this.context, query, callback);
701
- }
702
- };
703
-
704
- Model.prototype.fetch = function() {
705
- return this.storage.data(this.at) || [];
706
- };
707
-
708
- Model.prototype.save = function(data) {
709
- return this.storage.data(this.at, this.context.callbacks("before_save").call(this.context, data || []));
710
- };
711
-
712
- Model.prototype.load = function(data) {
713
- if (!(this.saved() || !data)) {
714
- return this._load(data);
715
- }
716
- };
717
-
718
- Model.prototype.reload = function(data) {
719
- return this._load(data);
720
- };
721
-
722
- Model.prototype._load = function(data) {
723
- var _this = this;
724
- if (typeof data === "string") {
725
- return $.ajax(data, {
726
- dataType: "json"
727
- }).done(function(data) {
728
- return _this.save(data);
729
- });
730
- } else {
731
- return this.save(data);
732
- }
733
- };
734
-
735
- return Model;
736
-
737
- })();
738
- View = (function() {
739
-
740
- function View(context) {
741
- this.context = context;
742
- this.$el = $("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>");
743
- this.timeout_id = null;
744
- this.context.$el.append(this.$el);
745
- this.bind_event();
746
- }
747
-
748
- View.prototype.init = function() {
749
- var id;
750
- id = this.context.get_opt("alias") || this.context.at.charCodeAt(0);
751
- return this.$el.attr({
752
- 'id': "at-view-" + id
753
- });
754
- };
755
-
756
- View.prototype.bind_event = function() {
757
- var $menu,
758
- _this = this;
759
- $menu = this.$el.find('ul');
760
- $menu.on('mouseenter.atwho-view', 'li', function(e) {
761
- $menu.find('.cur').removeClass('cur');
762
- return $(e.currentTarget).addClass('cur');
763
- }).on('click', function(e) {
764
- _this.choose();
765
- return e.preventDefault();
766
- });
767
- return this.$el.on('mouseenter.atwho-view', 'ul', function(e) {
768
- return _this.context.mark_range();
769
- }).on('mouseleave.atwho-view', 'ul', function(e) {
770
- return _this.context.clear_range();
771
- });
772
- };
773
-
774
- View.prototype.visible = function() {
775
- return this.$el.is(":visible");
776
- };
777
-
778
- View.prototype.choose = function() {
779
- var $li, content;
780
- $li = this.$el.find(".cur");
781
- content = this.context.insert_content_for($li);
782
- this.context.insert(this.context.callbacks("before_insert").call(this.context, content, $li), $li);
783
- this.context.trigger("inserted", [$li]);
784
- return this.hide();
785
- };
786
-
787
- View.prototype.reposition = function(rect) {
788
- var offset;
789
- if (rect.bottom + this.$el.height() - $(window).scrollTop() > $(window).height()) {
790
- rect.bottom = rect.top - this.$el.height();
791
- }
792
- offset = {
793
- left: rect.left,
794
- top: rect.bottom
795
- };
796
- this.$el.offset(offset);
797
- return this.context.trigger("reposition", [offset]);
798
- };
799
-
800
- View.prototype.next = function() {
801
- var cur, next;
802
- cur = this.$el.find('.cur').removeClass('cur');
803
- next = cur.next();
804
- if (!next.length) {
805
- next = this.$el.find('li:first');
806
- }
807
- return next.addClass('cur');
808
- };
809
-
810
- View.prototype.prev = function() {
811
- var cur, prev;
812
- cur = this.$el.find('.cur').removeClass('cur');
813
- prev = cur.prev();
814
- if (!prev.length) {
815
- prev = this.$el.find('li:last');
816
- }
817
- return prev.addClass('cur');
818
- };
819
-
820
- View.prototype.show = function() {
821
- var rect;
822
- if (!this.visible()) {
823
- this.$el.show();
824
- }
825
- if (rect = this.context.rect()) {
826
- return this.reposition(rect);
827
- }
828
- };
829
-
830
- View.prototype.hide = function(time) {
831
- var callback,
832
- _this = this;
833
- if (isNaN(time && this.visible())) {
834
- this.context.reset_rect();
835
- return this.$el.hide();
836
- } else {
837
- callback = function() {
838
- return _this.hide();
839
- };
840
- clearTimeout(this.timeout_id);
841
- return this.timeout_id = setTimeout(callback, time);
842
- }
843
- };
844
-
845
- View.prototype.render = function(list) {
846
- var $li, $ul, item, li, tpl, _i, _len;
847
- if (!($.isArray(list) && list.length > 0)) {
848
- this.hide();
849
- return;
850
- }
851
- this.$el.find('ul').empty();
852
- $ul = this.$el.find('ul');
853
- tpl = this.context.get_opt('tpl');
854
- for (_i = 0, _len = list.length; _i < _len; _i++) {
855
- item = list[_i];
856
- item = $.extend({}, item, {
857
- 'atwho-at': this.context.at
858
- });
859
- li = this.context.callbacks("tpl_eval").call(this.context, tpl, item);
860
- $li = $(this.context.callbacks("highlighter").call(this.context, li, this.context.query.text));
861
- $li.data("item-data", item);
862
- $ul.append($li);
863
- }
864
- this.show();
865
- return $ul.find("li:first").addClass("cur");
866
- };
867
-
868
- return View;
869
-
870
- })();
871
- KEY_CODE = {
872
- DOWN: 40,
873
- UP: 38,
874
- ESC: 27,
875
- TAB: 9,
876
- ENTER: 13
877
- };
878
- DEFAULT_CALLBACKS = {
879
- before_save: function(data) {
880
- var item, _i, _len, _results;
881
- if (!$.isArray(data)) {
882
- return data;
883
- }
884
- _results = [];
885
- for (_i = 0, _len = data.length; _i < _len; _i++) {
886
- item = data[_i];
887
- if ($.isPlainObject(item)) {
888
- _results.push(item);
889
- } else {
890
- _results.push({
891
- name: item
892
- });
893
- }
894
- }
895
- return _results;
896
- },
897
- matcher: function(flag, subtext, should_start_with_space) {
898
- var match, regexp;
899
- flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
900
- if (should_start_with_space) {
901
- flag = '(?:^|\\s)' + flag;
902
- }
903
- regexp = new RegExp(flag + '([A-Za-z0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');
904
- match = regexp.exec(subtext);
905
- if (match) {
906
- return match[2] || match[1];
907
- } else {
908
- return null;
909
- }
910
- },
911
- filter: function(query, data, search_key) {
912
- var item, _i, _len, _results;
913
- _results = [];
914
- for (_i = 0, _len = data.length; _i < _len; _i++) {
915
- item = data[_i];
916
- if (~item[search_key].toLowerCase().indexOf(query)) {
917
- _results.push(item);
918
- }
919
- }
920
- return _results;
921
- },
922
- remote_filter: null,
923
- sorter: function(query, items, search_key) {
924
- var item, _i, _len, _results;
925
- if (!query) {
926
- return items;
927
- }
928
- _results = [];
929
- for (_i = 0, _len = items.length; _i < _len; _i++) {
930
- item = items[_i];
931
- item.atwho_order = item[search_key].toLowerCase().indexOf(query);
932
- if (item.atwho_order > -1) {
933
- _results.push(item);
934
- }
935
- }
936
- return _results.sort(function(a, b) {
937
- return a.atwho_order - b.atwho_order;
938
- });
939
- },
940
- tpl_eval: function(tpl, map) {
941
- try {
942
- return tpl.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
943
- return map[key];
944
- });
945
- } catch (error) {
946
- return "";
947
- }
948
- },
949
- highlighter: function(li, query) {
950
- var regexp;
951
- if (!query) {
952
- return li;
953
- }
954
- regexp = new RegExp(">\\s*(\\w*)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig');
955
- return li.replace(regexp, function(str, $1, $2, $3) {
956
- return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
957
- });
958
- },
959
- before_insert: function(value, $li) {
960
- return value;
961
- }
962
- };
963
- Api = {
964
- load: function(at, data) {
965
- var c;
966
- if (c = this.controller(at)) {
967
- return c.model.load(data);
968
- }
969
- },
970
- getInsertedItemsWithIDs: function(at) {
971
- var c, ids, items;
972
- if (!(c = this.controller(at))) {
973
- return [null, null];
974
- }
975
- if (at) {
976
- at = "-" + (c.get_opt('alias') || c.at);
977
- }
978
- ids = [];
979
- items = $.map(this.$inputor.find("span.atwho-view-flag" + (at || "")), function(item) {
980
- var data;
981
- data = $(item).data('atwho-data-item');
982
- if (ids.indexOf(data.id) > -1) {
983
- return;
984
- }
985
- if (data.id) {
986
- ids.push = data.id;
987
- }
988
- return data;
989
- });
990
- return [ids, items];
991
- },
992
- getInsertedItems: function(at) {
993
- return Api.getInsertedItemsWithIDs.apply(this, [at])[1];
994
- },
995
- getInsertedIDs: function(at) {
996
- return Api.getInsertedItemsWithIDs.apply(this, [at])[0];
997
- },
998
- run: function() {
999
- return this.dispatch();
1000
- }
1001
- };
1002
- Atwho = {
1003
- init: function(options) {
1004
- var $this, app;
1005
- app = ($this = $(this)).data("atwho");
1006
- if (!app) {
1007
- $this.data('atwho', (app = new App(this)));
1008
- }
1009
- app.reg(options.at, options);
1010
- return this;
1011
- }
1012
- };
1013
- $CONTAINER = $("<div id='atwho-container'></div>");
1014
- $.fn.atwho = function(method) {
1015
- var result, _args;
1016
- _args = arguments;
1017
- $('body').append($CONTAINER);
1018
- result = null;
1019
- this.filter('textarea, input, [contenteditable=true]').each(function() {
1020
- var app;
1021
- if (typeof method === 'object' || !method) {
1022
- return Atwho.init.apply(this, _args);
1023
- } else if (Api[method]) {
1024
- if (app = $(this).data('atwho')) {
1025
- return result = Api[method].apply(app, Array.prototype.slice.call(_args, 1));
1026
- }
1027
- } else {
1028
- return $.error("Method " + method + " does not exist on jQuery.caret");
1029
- }
1030
- });
1031
- return result || this;
1032
- };
1033
- return $.fn.atwho["default"] = {
1034
- at: void 0,
1035
- alias: void 0,
1036
- data: null,
1037
- tpl: "<li data-value='${atwho-at}${name}'>${name}</li>",
1038
- insert_tpl: "<span>${atwho-data-value}</span>",
1039
- callbacks: DEFAULT_CALLBACKS,
1040
- search_key: "name",
1041
- start_with_space: true,
1042
- limit: 5,
1043
- max_len: 20,
1044
- display_timeout: 300
1045
- };
1046
- });
1047
-
1048
- }).call(this);