jquery-atwho-rails 0.1.6 → 0.1.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.
- data/lib/assets/javascripts/jquery.atwho.js +214 -143
- data/lib/jquery-atwho-rails/version.rb +1 -1
- metadata +4 -3
@@ -1,3 +1,4 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
1
2
|
|
2
3
|
/*
|
3
4
|
Implement Twitter/Weibo @ mentions
|
@@ -24,132 +25,9 @@
|
|
24
25
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
26
|
*/
|
26
27
|
|
27
|
-
/*
|
28
|
-
本插件操作 textarea 或者 input 内的插入符
|
29
|
-
只实现了获得插入符在文本框中的位置,我设置
|
30
|
-
插入符的位置.
|
31
|
-
*/
|
32
28
|
|
33
29
|
(function() {
|
34
30
|
|
35
|
-
(function($) {
|
36
|
-
var getCaretPos, setCaretPos;
|
37
|
-
getCaretPos = function(inputor) {
|
38
|
-
var end, endRange, len, normalizedValue, pos, range, start, textInputRange;
|
39
|
-
if (document.selection) {
|
40
|
-
/*
|
41
|
-
#assume we select "HATE" in the inputor such as textarea -> { }.
|
42
|
-
* start end-point.
|
43
|
-
* /
|
44
|
-
* < I really [HATE] IE > between the brackets is the selection range.
|
45
|
-
* \
|
46
|
-
* end end-point.
|
47
|
-
*/
|
48
|
-
range = document.selection.createRange();
|
49
|
-
pos = 0;
|
50
|
-
if (range && range.parentElement() === inputor) {
|
51
|
-
normalizedValue = inputor.value.replace(/\r\n/g, "\n");
|
52
|
-
/* SOMETIME !!!
|
53
|
-
"/r/n" is counted as two char.
|
54
|
-
one line is two, two will be four. balalala.
|
55
|
-
so we have to using the normalized one's length.;
|
56
|
-
*/
|
57
|
-
len = normalizedValue.length;
|
58
|
-
/*
|
59
|
-
<[ I really HATE IE ]>:
|
60
|
-
the whole content in the inputor will be the textInputRange.
|
61
|
-
*/
|
62
|
-
textInputRange = inputor.createTextRange();
|
63
|
-
/* _here must be the position of bookmark.
|
64
|
-
/
|
65
|
-
<[ I really [HATE] IE ]>
|
66
|
-
[---------->[ ] : this is what moveToBookmark do.
|
67
|
-
< I really [[HATE] IE ]> : here is result.
|
68
|
-
\ two brackets in should be in line.
|
69
|
-
*/
|
70
|
-
textInputRange.moveToBookmark(range.getBookmark());
|
71
|
-
endRange = inputor.createTextRange();
|
72
|
-
/* [--------------------->[] : if set false all end-point goto end.
|
73
|
-
< I really [[HATE] IE []]>
|
74
|
-
*/
|
75
|
-
endRange.collapse(false);
|
76
|
-
/*
|
77
|
-
___VS____
|
78
|
-
/ \
|
79
|
-
< I really [[HATE] IE []]>
|
80
|
-
\_endRange end-point.
|
81
|
-
|
82
|
-
" > -1" mean the start end-point will be the same or right to the end end-point
|
83
|
-
* simplelly, all in the end.
|
84
|
-
*/
|
85
|
-
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
|
86
|
-
start = end = len;
|
87
|
-
} else {
|
88
|
-
/*
|
89
|
-
I really |HATE] IE ]>
|
90
|
-
<-|
|
91
|
-
I really[ [HATE] IE ]>
|
92
|
-
<-[
|
93
|
-
I reall[y [HATE] IE ]>
|
94
|
-
|
95
|
-
will return how many unit have moved.
|
96
|
-
*/
|
97
|
-
start = -textInputRange.moveStart("character", -len);
|
98
|
-
end = -textInputRange.moveEnd("character", -len);
|
99
|
-
}
|
100
|
-
}
|
101
|
-
} else {
|
102
|
-
start = inputor.selectionStart;
|
103
|
-
}
|
104
|
-
return start;
|
105
|
-
};
|
106
|
-
setCaretPos = function(inputor, pos) {
|
107
|
-
var range;
|
108
|
-
if (document.selection) {
|
109
|
-
range = inputor.createTextRange();
|
110
|
-
range.move("character", pos);
|
111
|
-
return range.select();
|
112
|
-
} else {
|
113
|
-
return inputor.setSelectionRange(pos, pos);
|
114
|
-
}
|
115
|
-
};
|
116
|
-
return $.fn.caretPos = function(pos) {
|
117
|
-
var inputor;
|
118
|
-
inputor = this[0];
|
119
|
-
inputor.focus();
|
120
|
-
if (pos) {
|
121
|
-
return setCaretPos(inputor, pos);
|
122
|
-
} else {
|
123
|
-
return getCaretPos(inputor);
|
124
|
-
}
|
125
|
-
};
|
126
|
-
})(window.jQuery);
|
127
|
-
|
128
|
-
/*
|
129
|
-
Implement Twitter/Weibo @ mentions
|
130
|
-
|
131
|
-
Copyright (c) 2012 chord.luo@gmail.com
|
132
|
-
|
133
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
134
|
-
a copy of this software and associated documentation files (the
|
135
|
-
"Software"), to deal in the Software without restriction, including
|
136
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
137
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
138
|
-
permit persons to whom the Software is furnished to do so, subject to
|
139
|
-
the following conditions:
|
140
|
-
|
141
|
-
The above copyright notice and this permission notice shall be
|
142
|
-
included in all copies or substantial portions of the Software.
|
143
|
-
|
144
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
145
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
146
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
147
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
148
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
149
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
150
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
151
|
-
*/
|
152
|
-
|
153
31
|
(function($) {
|
154
32
|
var At, AtView, Mirror, log, _DEFAULT_TPL, _evalTpl, _highlighter, _isNil, _objectify, _sorter, _unique;
|
155
33
|
Mirror = {
|
@@ -211,7 +89,9 @@
|
|
211
89
|
var lookup, stop;
|
212
90
|
stop = e.keyCode === 40 || e.keyCode === 38;
|
213
91
|
lookup = !(stop && _this.view.isShowing());
|
214
|
-
if (lookup)
|
92
|
+
if (lookup) {
|
93
|
+
return _this.lookup();
|
94
|
+
}
|
215
95
|
}).on("mouseup.inputor", function(e) {
|
216
96
|
return _this.lookup();
|
217
97
|
});
|
@@ -223,7 +103,9 @@
|
|
223
103
|
constructor: At,
|
224
104
|
init: function() {
|
225
105
|
var _this = this;
|
226
|
-
this.$inputor.on('
|
106
|
+
this.$inputor.on('keyup.inputor', function(e) {
|
107
|
+
return _this.onkeyup(e);
|
108
|
+
}).on('keydown.inputor', function(e) {
|
227
109
|
return _this.onkeydown(e);
|
228
110
|
}).on('scroll.inputor', function(e) {
|
229
111
|
return _this.view.hide();
|
@@ -247,7 +129,9 @@
|
|
247
129
|
dataValue: function() {
|
248
130
|
var match, search_word;
|
249
131
|
search_word = this.search_word[this.theflag];
|
250
|
-
if (search_word)
|
132
|
+
if (search_word) {
|
133
|
+
return search_word;
|
134
|
+
}
|
251
135
|
match = /data-value=["']?\$\{(\w+)\}/g.exec(this.getOpt('tpl'));
|
252
136
|
return this.search_word[this.theflag] = !_isNil(match) ? match[1] : null;
|
253
137
|
},
|
@@ -278,6 +162,7 @@
|
|
278
162
|
/* 克隆完inputor后将原来的文本内容根据
|
279
163
|
@的位置进行分块,以获取@块在inputor(输入框)里的position
|
280
164
|
*/
|
165
|
+
|
281
166
|
start_range = $inputor.val().slice(0, this.pos - 1);
|
282
167
|
html = "<span>" + format(start_range) + "</span>";
|
283
168
|
html += "<span id='flag'>@</span>";
|
@@ -287,6 +172,7 @@
|
|
287
172
|
就得到了@相对于document的offset.
|
288
173
|
当然,还要加上行高和滚动条的偏移量.
|
289
174
|
*/
|
175
|
+
|
290
176
|
offset = $inputor.offset();
|
291
177
|
at_rect = this.mirror.init($inputor).setContent(html).getFlagRect();
|
292
178
|
x = offset.left + at_rect.left - $inputor.scrollLeft();
|
@@ -302,7 +188,9 @@
|
|
302
188
|
cache: function(value) {
|
303
189
|
var key, _base;
|
304
190
|
key = this.query.text;
|
305
|
-
if (!this.getOpt("cache") || !key)
|
191
|
+
if (!this.getOpt("cache") || !key) {
|
192
|
+
return null;
|
193
|
+
}
|
306
194
|
return (_base = this._cache)[key] || (_base[key] = value);
|
307
195
|
},
|
308
196
|
getKeyname: function() {
|
@@ -314,6 +202,7 @@
|
|
314
202
|
/* 向在插入符前的的文本进行正则匹配
|
315
203
|
* 考虑会有多个 @ 的存在, 匹配离插入符最近的一个
|
316
204
|
*/
|
205
|
+
|
317
206
|
subtext = text.slice(0, caret_pos);
|
318
207
|
matched = null;
|
319
208
|
$.each(this.options, function(flag) {
|
@@ -321,7 +210,7 @@
|
|
321
210
|
regexp = new RegExp(flag + '([A-Za-z0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');
|
322
211
|
match = regexp.exec(subtext);
|
323
212
|
if (!_isNil(match)) {
|
324
|
-
matched = match[
|
213
|
+
matched = match[2] ? match[2] : match[1];
|
325
214
|
_this.theflag = flag;
|
326
215
|
return false;
|
327
216
|
}
|
@@ -342,22 +231,45 @@
|
|
342
231
|
return this.query = key;
|
343
232
|
},
|
344
233
|
replaceStr: function(str) {
|
345
|
-
var $inputor, key, source, start_str, text;
|
234
|
+
var $inputor, flag_len, key, source, start_str, text;
|
346
235
|
$inputor = this.$inputor;
|
347
236
|
key = this.query;
|
348
237
|
source = $inputor.val();
|
349
|
-
|
238
|
+
flag_len = this.getOpt("display_flag") ? 0 : this.theflag.length;
|
239
|
+
start_str = source.slice(0, key.start - flag_len);
|
350
240
|
text = start_str + str + source.slice(key.end);
|
351
241
|
$inputor.val(text);
|
352
242
|
$inputor.caretPos(start_str.length + str.length);
|
353
243
|
$inputor.change();
|
354
244
|
return log("At.replaceStr", text);
|
355
245
|
},
|
246
|
+
onkeyup: function(e) {
|
247
|
+
var view;
|
248
|
+
view = this.view;
|
249
|
+
if (!view.isShowing()) {
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
switch (e.keyCode) {
|
253
|
+
case 27:
|
254
|
+
e.preventDefault();
|
255
|
+
view.hide();
|
256
|
+
break;
|
257
|
+
default:
|
258
|
+
$.noop();
|
259
|
+
}
|
260
|
+
return e.stopPropagation();
|
261
|
+
},
|
356
262
|
onkeydown: function(e) {
|
357
263
|
var view;
|
358
264
|
view = this.view;
|
359
|
-
if (!view.isShowing())
|
265
|
+
if (!view.isShowing()) {
|
266
|
+
return;
|
267
|
+
}
|
360
268
|
switch (e.keyCode) {
|
269
|
+
case 27:
|
270
|
+
e.preventDefault();
|
271
|
+
view.hide();
|
272
|
+
break;
|
361
273
|
case 38:
|
362
274
|
e.preventDefault();
|
363
275
|
view.prev();
|
@@ -368,7 +280,9 @@
|
|
368
280
|
break;
|
369
281
|
case 9:
|
370
282
|
case 13:
|
371
|
-
if (!view.isShowing())
|
283
|
+
if (!view.isShowing()) {
|
284
|
+
return;
|
285
|
+
}
|
372
286
|
e.preventDefault();
|
373
287
|
view.choose();
|
374
288
|
break;
|
@@ -388,7 +302,9 @@
|
|
388
302
|
lookup: function() {
|
389
303
|
var callback, datas, key;
|
390
304
|
key = this.getKeyname();
|
391
|
-
if (!key)
|
305
|
+
if (!key) {
|
306
|
+
return false;
|
307
|
+
}
|
392
308
|
log("At.lookup.key", key);
|
393
309
|
if (!_isNil(datas = this.cache())) {
|
394
310
|
this.renderView(datas);
|
@@ -438,7 +354,9 @@
|
|
438
354
|
init: function() {
|
439
355
|
var $menu, tpl,
|
440
356
|
_this = this;
|
441
|
-
if (!_isNil(this.jqo()))
|
357
|
+
if (!_isNil(this.jqo())) {
|
358
|
+
return;
|
359
|
+
}
|
442
360
|
tpl = "<div id='" + this.id.slice(1) + "' class='at-view'><ul id='" + this.id.slice(1) + "-ul'></ul></div>";
|
443
361
|
$("body").append(tpl);
|
444
362
|
$menu = this.jqo().find('ul');
|
@@ -480,25 +398,33 @@
|
|
480
398
|
var cur, next;
|
481
399
|
cur = this.jqo().find('.cur').removeClass('cur');
|
482
400
|
next = cur.next();
|
483
|
-
if (!next.length)
|
401
|
+
if (!next.length) {
|
402
|
+
next = $(this.jqo().find('li')[0]);
|
403
|
+
}
|
484
404
|
return next.addClass('cur');
|
485
405
|
},
|
486
406
|
prev: function() {
|
487
407
|
var cur, prev;
|
488
408
|
cur = this.jqo().find('.cur').removeClass('cur');
|
489
409
|
prev = cur.prev();
|
490
|
-
if (!prev.length)
|
410
|
+
if (!prev.length) {
|
411
|
+
prev = this.jqo().find('li').last();
|
412
|
+
}
|
491
413
|
return prev.addClass('cur');
|
492
414
|
},
|
493
415
|
show: function() {
|
494
|
-
if (!this.isShowing())
|
416
|
+
if (!this.isShowing()) {
|
417
|
+
this.jqo().show();
|
418
|
+
}
|
495
419
|
return this.rePosition();
|
496
420
|
},
|
497
421
|
hide: function(time) {
|
498
422
|
var callback,
|
499
423
|
_this = this;
|
500
424
|
if (isNaN(time)) {
|
501
|
-
if (this.isShowing())
|
425
|
+
if (this.isShowing()) {
|
426
|
+
return this.jqo().hide();
|
427
|
+
}
|
502
428
|
} else {
|
503
429
|
callback = function() {
|
504
430
|
return _this.hide();
|
@@ -508,12 +434,16 @@
|
|
508
434
|
}
|
509
435
|
},
|
510
436
|
clear: function(clear_all) {
|
511
|
-
if (clear_all === true)
|
437
|
+
if (clear_all === true) {
|
438
|
+
this._cache = {};
|
439
|
+
}
|
512
440
|
return this.jqo().find('ul').empty();
|
513
441
|
},
|
514
442
|
render: function(holder, list) {
|
515
443
|
var $ul, tpl;
|
516
|
-
if (!$.isArray(list))
|
444
|
+
if (!$.isArray(list)) {
|
445
|
+
return false;
|
446
|
+
}
|
517
447
|
if (list.length <= 0) {
|
518
448
|
this.hide();
|
519
449
|
return true;
|
@@ -556,7 +486,9 @@
|
|
556
486
|
}
|
557
487
|
};
|
558
488
|
_highlighter = function(li, query) {
|
559
|
-
if (_isNil(query))
|
489
|
+
if (_isNil(query)) {
|
490
|
+
return li;
|
491
|
+
}
|
560
492
|
return li.replace(new RegExp(">\\s*(\\w*)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig'), function(str, $1, $2, $3) {
|
561
493
|
return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
|
562
494
|
});
|
@@ -569,7 +501,9 @@
|
|
569
501
|
for (_i = 0, _len = items.length; _i < _len; _i++) {
|
570
502
|
item = items[_i];
|
571
503
|
text = item[data_value];
|
572
|
-
if (text.toLowerCase().indexOf(query) === -1)
|
504
|
+
if (text.toLowerCase().indexOf(query) === -1) {
|
505
|
+
continue;
|
506
|
+
}
|
573
507
|
item.order = text.toLowerCase().indexOf(query);
|
574
508
|
results.push(item);
|
575
509
|
}
|
@@ -584,6 +518,7 @@
|
|
584
518
|
I think we should not change DOM element frequently.
|
585
519
|
more, It seems batter not to call evalTpl function too much times.
|
586
520
|
*/
|
521
|
+
|
587
522
|
_unique = function(list, query) {
|
588
523
|
var record;
|
589
524
|
record = [];
|
@@ -607,7 +542,9 @@
|
|
607
542
|
var $this, data;
|
608
543
|
$this = $(this);
|
609
544
|
data = $this.data("AtWho");
|
610
|
-
if (!data)
|
545
|
+
if (!data) {
|
546
|
+
$this.data('AtWho', (data = new At(this)));
|
547
|
+
}
|
611
548
|
return data.reg(flag, options);
|
612
549
|
});
|
613
550
|
};
|
@@ -617,8 +554,142 @@
|
|
617
554
|
callback: null,
|
618
555
|
cache: true,
|
619
556
|
limit: 5,
|
557
|
+
display_flag: true,
|
620
558
|
tpl: _DEFAULT_TPL
|
621
559
|
};
|
622
560
|
})(window.jQuery);
|
623
561
|
|
562
|
+
/*
|
563
|
+
Implement Twitter/Weibo @ mentions
|
564
|
+
|
565
|
+
Copyright (c) 2012 chord.luo@gmail.com
|
566
|
+
|
567
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
568
|
+
a copy of this software and associated documentation files (the
|
569
|
+
"Software"), to deal in the Software without restriction, including
|
570
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
571
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
572
|
+
permit persons to whom the Software is furnished to do so, subject to
|
573
|
+
the following conditions:
|
574
|
+
|
575
|
+
The above copyright notice and this permission notice shall be
|
576
|
+
included in all copies or substantial portions of the Software.
|
577
|
+
|
578
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
579
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
580
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
581
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
582
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
583
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
584
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
585
|
+
*/
|
586
|
+
|
587
|
+
|
588
|
+
/*
|
589
|
+
本插件操作 textarea 或者 input 内的插入符
|
590
|
+
只实现了获得插入符在文本框中的位置,我设置
|
591
|
+
插入符的位置.
|
592
|
+
*/
|
593
|
+
|
594
|
+
|
595
|
+
(function($) {
|
596
|
+
var getCaretPos, setCaretPos;
|
597
|
+
getCaretPos = function(inputor) {
|
598
|
+
var end, endRange, len, normalizedValue, pos, range, start, textInputRange;
|
599
|
+
if (document.selection) {
|
600
|
+
/*
|
601
|
+
#assume we select "HATE" in the inputor such as textarea -> { }.
|
602
|
+
* start end-point.
|
603
|
+
* /
|
604
|
+
* < I really [HATE] IE > between the brackets is the selection range.
|
605
|
+
* \
|
606
|
+
* end end-point.
|
607
|
+
*/
|
608
|
+
|
609
|
+
range = document.selection.createRange();
|
610
|
+
pos = 0;
|
611
|
+
if (range && range.parentElement() === inputor) {
|
612
|
+
normalizedValue = inputor.value.replace(/\r\n/g, "\n");
|
613
|
+
/* SOMETIME !!!
|
614
|
+
"/r/n" is counted as two char.
|
615
|
+
one line is two, two will be four. balalala.
|
616
|
+
so we have to using the normalized one's length.;
|
617
|
+
*/
|
618
|
+
|
619
|
+
len = normalizedValue.length;
|
620
|
+
/*
|
621
|
+
<[ I really HATE IE ]>:
|
622
|
+
the whole content in the inputor will be the textInputRange.
|
623
|
+
*/
|
624
|
+
|
625
|
+
textInputRange = inputor.createTextRange();
|
626
|
+
/* _here must be the position of bookmark.
|
627
|
+
/
|
628
|
+
<[ I really [HATE] IE ]>
|
629
|
+
[---------->[ ] : this is what moveToBookmark do.
|
630
|
+
< I really [[HATE] IE ]> : here is result.
|
631
|
+
\ two brackets in should be in line.
|
632
|
+
*/
|
633
|
+
|
634
|
+
textInputRange.moveToBookmark(range.getBookmark());
|
635
|
+
endRange = inputor.createTextRange();
|
636
|
+
/* [--------------------->[] : if set false all end-point goto end.
|
637
|
+
< I really [[HATE] IE []]>
|
638
|
+
*/
|
639
|
+
|
640
|
+
endRange.collapse(false);
|
641
|
+
/*
|
642
|
+
___VS____
|
643
|
+
/ \
|
644
|
+
< I really [[HATE] IE []]>
|
645
|
+
\_endRange end-point.
|
646
|
+
|
647
|
+
" > -1" mean the start end-point will be the same or right to the end end-point
|
648
|
+
* simplelly, all in the end.
|
649
|
+
*/
|
650
|
+
|
651
|
+
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
|
652
|
+
start = end = len;
|
653
|
+
} else {
|
654
|
+
/*
|
655
|
+
I really |HATE] IE ]>
|
656
|
+
<-|
|
657
|
+
I really[ [HATE] IE ]>
|
658
|
+
<-[
|
659
|
+
I reall[y [HATE] IE ]>
|
660
|
+
|
661
|
+
will return how many unit have moved.
|
662
|
+
*/
|
663
|
+
|
664
|
+
start = -textInputRange.moveStart("character", -len);
|
665
|
+
end = -textInputRange.moveEnd("character", -len);
|
666
|
+
}
|
667
|
+
}
|
668
|
+
} else {
|
669
|
+
start = inputor.selectionStart;
|
670
|
+
}
|
671
|
+
return start;
|
672
|
+
};
|
673
|
+
setCaretPos = function(inputor, pos) {
|
674
|
+
var range;
|
675
|
+
if (document.selection) {
|
676
|
+
range = inputor.createTextRange();
|
677
|
+
range.move("character", pos);
|
678
|
+
return range.select();
|
679
|
+
} else {
|
680
|
+
return inputor.setSelectionRange(pos, pos);
|
681
|
+
}
|
682
|
+
};
|
683
|
+
return $.fn.caretPos = function(pos) {
|
684
|
+
var inputor;
|
685
|
+
inputor = this[0];
|
686
|
+
inputor.focus();
|
687
|
+
if (pos) {
|
688
|
+
return setCaretPos(inputor, pos);
|
689
|
+
} else {
|
690
|
+
return getCaretPos(inputor);
|
691
|
+
}
|
692
|
+
};
|
693
|
+
})(window.jQuery);
|
694
|
+
|
624
695
|
}).call(this);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-atwho-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -84,10 +84,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project: jquery-atwho-rails
|
87
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.24
|
88
88
|
signing_key:
|
89
89
|
specification_version: 3
|
90
90
|
summary: ! 'jquery plugin: @mentions'
|
91
91
|
test_files:
|
92
92
|
- spec/generators/install_generator_spec.rb
|
93
93
|
- spec/spec_helper.rb
|
94
|
+
has_rdoc:
|