jquery-atwho-rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 726bba9a4b37da246176b51d74f556349d9dd42f
|
4
|
+
data.tar.gz: 6bc804d4df04719726219ac5892711c26a07cf4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bbe73676becc9c1d442e2625861af9a0743cd6a16e7cb54458de81a6ad3205b14e9646ceefcd8ac77d42ada47f28d38b0f8b4e06bbdf5a70d6e0727d52756a
|
7
|
+
data.tar.gz: a22a4418a9536ef532cc5d60c9420fbb3c3e12198ab203824b028677f798f8e82304dc5fe2a8f45f94ef81415d263456abd6f3e79fb345f77e98534b9b954718
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! jquery.atwho - v1.0.
|
1
|
+
/*! jquery.atwho - v1.0.1 %>
|
2
2
|
* Copyright (c) 2015 chord.luo <chord.luo@gmail.com>;
|
3
3
|
* homepage: http://ichord.github.com/At.js
|
4
4
|
* Licensed MIT
|
@@ -327,6 +327,25 @@ Controller = (function() {
|
|
327
327
|
return this.view.render(data.slice(0, this.getOpt('limit')));
|
328
328
|
};
|
329
329
|
|
330
|
+
Controller.arrayToDefaultHash = function(data) {
|
331
|
+
var item, _i, _len, _results;
|
332
|
+
if (!$.isArray(data)) {
|
333
|
+
return data;
|
334
|
+
}
|
335
|
+
_results = [];
|
336
|
+
for (_i = 0, _len = data.length; _i < _len; _i++) {
|
337
|
+
item = data[_i];
|
338
|
+
if ($.isPlainObject(item)) {
|
339
|
+
_results.push(item);
|
340
|
+
} else {
|
341
|
+
_results.push({
|
342
|
+
name: item
|
343
|
+
});
|
344
|
+
}
|
345
|
+
}
|
346
|
+
return _results;
|
347
|
+
};
|
348
|
+
|
330
349
|
Controller.prototype.lookUp = function(e) {
|
331
350
|
var query, _callback;
|
332
351
|
if (!(query = this.catchQuery(e))) {
|
@@ -334,7 +353,7 @@ Controller = (function() {
|
|
334
353
|
}
|
335
354
|
_callback = function(data) {
|
336
355
|
if (data && data.length > 0) {
|
337
|
-
return this.renderView(data);
|
356
|
+
return this.renderView(this.constructor.arrayToDefaultHash(data));
|
338
357
|
} else {
|
339
358
|
return this.view.hide();
|
340
359
|
}
|
@@ -833,22 +852,7 @@ KEY_CODE = {
|
|
833
852
|
|
834
853
|
DEFAULT_CALLBACKS = {
|
835
854
|
beforeSave: function(data) {
|
836
|
-
|
837
|
-
if (!$.isArray(data)) {
|
838
|
-
return data;
|
839
|
-
}
|
840
|
-
_results = [];
|
841
|
-
for (_i = 0, _len = data.length; _i < _len; _i++) {
|
842
|
-
item = data[_i];
|
843
|
-
if ($.isPlainObject(item)) {
|
844
|
-
_results.push(item);
|
845
|
-
} else {
|
846
|
-
_results.push({
|
847
|
-
name: item
|
848
|
-
});
|
849
|
-
}
|
850
|
-
}
|
851
|
-
return _results;
|
855
|
+
return Controller.arrayToDefaultHash(data);
|
852
856
|
},
|
853
857
|
matcher: function(flag, subtext, should_startWithSpace) {
|
854
858
|
var match, regexp, _a, _y;
|
@@ -934,7 +938,7 @@ Api = {
|
|
934
938
|
},
|
935
939
|
isSelecting: function() {
|
936
940
|
var _ref;
|
937
|
-
return (_ref = this.controller()) != null ? _ref.view.
|
941
|
+
return (_ref = this.controller()) != null ? _ref.view.visible() : void 0;
|
938
942
|
},
|
939
943
|
setIframe: function(iframe, asRoot) {
|
940
944
|
this.setupRootElement(iframe, asRoot);
|
@@ -1,3 +1,19 @@
|
|
1
|
+
(function (root, factory) {
|
2
|
+
if (typeof define === 'function' && define.amd) {
|
3
|
+
// AMD. Register as an anonymous module.
|
4
|
+
define(["jquery"], function ($) {
|
5
|
+
return (root.returnExportsGlobal = factory($));
|
6
|
+
});
|
7
|
+
} else if (typeof exports === 'object') {
|
8
|
+
// Node. Does not work with strict CommonJS, but
|
9
|
+
// only CommonJS-like enviroments that support module.exports,
|
10
|
+
// like Node.
|
11
|
+
module.exports = factory(require("jquery"));
|
12
|
+
} else {
|
13
|
+
factory(jQuery);
|
14
|
+
}
|
15
|
+
}(this, function ($) {
|
16
|
+
|
1
17
|
/*
|
2
18
|
Implement Github like autocomplete mentions
|
3
19
|
http://ichord.github.com/At.js
|
@@ -6,361 +22,384 @@
|
|
6
22
|
Licensed under the MIT license.
|
7
23
|
*/
|
8
24
|
|
9
|
-
|
10
25
|
/*
|
11
26
|
本插件操作 textarea 或者 input 内的插入符
|
12
27
|
只实现了获得插入符在文本框中的位置,我设置
|
13
28
|
插入符的位置.
|
14
29
|
*/
|
15
30
|
|
31
|
+
"use strict";
|
32
|
+
var EditableCaret, InputCaret, Mirror, Utils, discoveryIframeOf, methods, oDocument, oFrame, oWindow, pluginName, setContextBy;
|
16
33
|
|
17
|
-
|
18
|
-
(function(factory) {
|
19
|
-
if (typeof define === 'function' && define.amd) {
|
20
|
-
return define(['jquery'], factory);
|
21
|
-
} else {
|
22
|
-
return factory(window.jQuery);
|
23
|
-
}
|
24
|
-
})(function($) {
|
25
|
-
"use strict";
|
26
|
-
var EditableCaret, InputCaret, Mirror, Utils, discoveryIframeOf, methods, oDocument, oFrame, oWindow, pluginName, setContextBy;
|
27
|
-
pluginName = 'caret';
|
28
|
-
EditableCaret = (function() {
|
29
|
-
function EditableCaret($inputor) {
|
30
|
-
this.$inputor = $inputor;
|
31
|
-
this.domInputor = this.$inputor[0];
|
32
|
-
}
|
34
|
+
pluginName = 'caret';
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
EditableCaret = (function() {
|
37
|
+
function EditableCaret($inputor) {
|
38
|
+
this.$inputor = $inputor;
|
39
|
+
this.domInputor = this.$inputor[0];
|
40
|
+
}
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
42
|
+
EditableCaret.prototype.setPos = function(pos) {
|
43
|
+
return this.domInputor;
|
44
|
+
};
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
inputor_offset = this.$inputor.offset();
|
46
|
-
offset.left -= inputor_offset.left;
|
47
|
-
offset.top -= inputor_offset.top;
|
48
|
-
return offset;
|
49
|
-
};
|
46
|
+
EditableCaret.prototype.getIEPosition = function() {
|
47
|
+
return this.getPosition();
|
48
|
+
};
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
EditableCaret.prototype.getPosition = function() {
|
51
|
+
var inputor_offset, offset;
|
52
|
+
offset = this.getOffset();
|
53
|
+
inputor_offset = this.$inputor.offset();
|
54
|
+
offset.left -= inputor_offset.left;
|
55
|
+
offset.top -= inputor_offset.top;
|
56
|
+
return offset;
|
57
|
+
};
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
59
|
+
EditableCaret.prototype.getOldIEPos = function() {
|
60
|
+
var preCaretTextRange, textRange;
|
61
|
+
textRange = oDocument.selection.createRange();
|
62
|
+
preCaretTextRange = oDocument.body.createTextRange();
|
63
|
+
preCaretTextRange.moveToElementText(this.domInputor);
|
64
|
+
preCaretTextRange.setEndPoint("EndToEnd", textRange);
|
65
|
+
return preCaretTextRange.text.length;
|
66
|
+
};
|
67
|
+
|
68
|
+
EditableCaret.prototype.getPos = function() {
|
69
|
+
var clonedRange, pos, range;
|
70
|
+
if (range = this.range()) {
|
71
|
+
clonedRange = range.cloneRange();
|
72
|
+
clonedRange.selectNodeContents(this.domInputor);
|
73
|
+
clonedRange.setEnd(range.endContainer, range.endOffset);
|
74
|
+
pos = clonedRange.toString().length;
|
75
|
+
clonedRange.detach();
|
76
|
+
return pos;
|
77
|
+
} else if (oDocument.selection) {
|
78
|
+
return this.getOldIEPos();
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
EditableCaret.prototype.getOldIEOffset = function() {
|
83
|
+
var range, rect;
|
84
|
+
range = oDocument.selection.createRange().duplicate();
|
85
|
+
range.moveStart("character", -1);
|
86
|
+
rect = range.getBoundingClientRect();
|
87
|
+
return {
|
88
|
+
height: rect.bottom - rect.top,
|
89
|
+
left: rect.left,
|
90
|
+
top: rect.top
|
91
|
+
};
|
92
|
+
};
|
73
93
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
94
|
+
EditableCaret.prototype.getOffset = function(pos) {
|
95
|
+
var clonedRange, offset, range, rect, shadowCaret;
|
96
|
+
if (oWindow.getSelection && (range = this.range())) {
|
97
|
+
if (range.endOffset - 1 > 0 && range.endContainer === !this.domInputor) {
|
98
|
+
clonedRange = range.cloneRange();
|
99
|
+
clonedRange.setStart(range.endContainer, range.endOffset - 1);
|
100
|
+
clonedRange.setEnd(range.endContainer, range.endOffset);
|
101
|
+
rect = clonedRange.getBoundingClientRect();
|
102
|
+
offset = {
|
103
|
+
height: rect.height,
|
104
|
+
left: rect.left + rect.width,
|
105
|
+
top: rect.top
|
106
|
+
};
|
107
|
+
clonedRange.detach();
|
108
|
+
}
|
109
|
+
if (!offset || (offset != null ? offset.height : void 0) === 0) {
|
110
|
+
clonedRange = range.cloneRange();
|
111
|
+
shadowCaret = $(oDocument.createTextNode("|"));
|
112
|
+
clonedRange.insertNode(shadowCaret[0]);
|
113
|
+
clonedRange.selectNode(shadowCaret[0]);
|
114
|
+
rect = clonedRange.getBoundingClientRect();
|
115
|
+
offset = {
|
116
|
+
height: rect.height,
|
81
117
|
left: rect.left,
|
82
118
|
top: rect.top
|
83
119
|
};
|
84
|
-
|
120
|
+
shadowCaret.remove();
|
121
|
+
clonedRange.detach();
|
122
|
+
}
|
123
|
+
} else if (oDocument.selection) {
|
124
|
+
offset = this.getOldIEOffset();
|
125
|
+
}
|
126
|
+
if (offset) {
|
127
|
+
offset.top += $(oWindow).scrollTop();
|
128
|
+
offset.left += $(oWindow).scrollLeft();
|
129
|
+
}
|
130
|
+
return offset;
|
131
|
+
};
|
85
132
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
left: rect.left + rect.width,
|
99
|
-
top: rect.top
|
100
|
-
};
|
101
|
-
clonedRange.detach();
|
102
|
-
} else if (oDocument.selection) {
|
103
|
-
offset = this.getOldIEOffset();
|
104
|
-
}
|
105
|
-
if (offset) {
|
106
|
-
offset.top += $(oWindow).scrollTop();
|
107
|
-
offset.left += $(oWindow).scrollLeft();
|
108
|
-
}
|
109
|
-
return offset;
|
110
|
-
};
|
133
|
+
EditableCaret.prototype.range = function() {
|
134
|
+
var sel;
|
135
|
+
if (!oWindow.getSelection) {
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
sel = oWindow.getSelection();
|
139
|
+
if (sel.rangeCount > 0) {
|
140
|
+
return sel.getRangeAt(0);
|
141
|
+
} else {
|
142
|
+
return null;
|
143
|
+
}
|
144
|
+
};
|
111
145
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
return;
|
116
|
-
}
|
117
|
-
sel = oWindow.getSelection();
|
118
|
-
if (sel.rangeCount > 0) {
|
119
|
-
return sel.getRangeAt(0);
|
120
|
-
} else {
|
121
|
-
return null;
|
122
|
-
}
|
123
|
-
};
|
146
|
+
return EditableCaret;
|
147
|
+
|
148
|
+
})();
|
124
149
|
|
125
|
-
|
150
|
+
InputCaret = (function() {
|
151
|
+
function InputCaret($inputor) {
|
152
|
+
this.$inputor = $inputor;
|
153
|
+
this.domInputor = this.$inputor[0];
|
154
|
+
}
|
126
155
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
156
|
+
InputCaret.prototype.getIEPos = function() {
|
157
|
+
var endRange, inputor, len, normalizedValue, pos, range, textInputRange;
|
158
|
+
inputor = this.domInputor;
|
159
|
+
range = oDocument.selection.createRange();
|
160
|
+
pos = 0;
|
161
|
+
if (range && range.parentElement() === inputor) {
|
162
|
+
normalizedValue = inputor.value.replace(/\r\n/g, "\n");
|
163
|
+
len = normalizedValue.length;
|
164
|
+
textInputRange = inputor.createTextRange();
|
165
|
+
textInputRange.moveToBookmark(range.getBookmark());
|
166
|
+
endRange = inputor.createTextRange();
|
167
|
+
endRange.collapse(false);
|
168
|
+
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
|
169
|
+
pos = len;
|
170
|
+
} else {
|
171
|
+
pos = -textInputRange.moveStart("character", -len);
|
132
172
|
}
|
173
|
+
}
|
174
|
+
return pos;
|
175
|
+
};
|
133
176
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
len = normalizedValue.length;
|
142
|
-
textInputRange = inputor.createTextRange();
|
143
|
-
textInputRange.moveToBookmark(range.getBookmark());
|
144
|
-
endRange = inputor.createTextRange();
|
145
|
-
endRange.collapse(false);
|
146
|
-
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
|
147
|
-
pos = len;
|
148
|
-
} else {
|
149
|
-
pos = -textInputRange.moveStart("character", -len);
|
150
|
-
}
|
151
|
-
}
|
152
|
-
return pos;
|
153
|
-
};
|
177
|
+
InputCaret.prototype.getPos = function() {
|
178
|
+
if (oDocument.selection) {
|
179
|
+
return this.getIEPos();
|
180
|
+
} else {
|
181
|
+
return this.domInputor.selectionStart;
|
182
|
+
}
|
183
|
+
};
|
154
184
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
185
|
+
InputCaret.prototype.setPos = function(pos) {
|
186
|
+
var inputor, range;
|
187
|
+
inputor = this.domInputor;
|
188
|
+
if (oDocument.selection) {
|
189
|
+
range = inputor.createTextRange();
|
190
|
+
range.move("character", pos);
|
191
|
+
range.select();
|
192
|
+
} else if (inputor.setSelectionRange) {
|
193
|
+
inputor.setSelectionRange(pos, pos);
|
194
|
+
}
|
195
|
+
return inputor;
|
196
|
+
};
|
162
197
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
198
|
+
InputCaret.prototype.getIEOffset = function(pos) {
|
199
|
+
var h, textRange, x, y;
|
200
|
+
textRange = this.domInputor.createTextRange();
|
201
|
+
pos || (pos = this.getPos());
|
202
|
+
textRange.move('character', pos);
|
203
|
+
x = textRange.boundingLeft;
|
204
|
+
y = textRange.boundingTop;
|
205
|
+
h = textRange.boundingHeight;
|
206
|
+
return {
|
207
|
+
left: x,
|
208
|
+
top: y,
|
209
|
+
height: h
|
210
|
+
};
|
211
|
+
};
|
175
212
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
213
|
+
InputCaret.prototype.getOffset = function(pos) {
|
214
|
+
var $inputor, offset, position;
|
215
|
+
$inputor = this.$inputor;
|
216
|
+
if (oDocument.selection) {
|
217
|
+
offset = this.getIEOffset(pos);
|
218
|
+
offset.top += $(oWindow).scrollTop() + $inputor.scrollTop();
|
219
|
+
offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft();
|
220
|
+
return offset;
|
221
|
+
} else {
|
222
|
+
offset = $inputor.offset();
|
223
|
+
position = this.getPosition(pos);
|
224
|
+
return offset = {
|
225
|
+
left: offset.left + position.left - $inputor.scrollLeft(),
|
226
|
+
top: offset.top + position.top - $inputor.scrollTop(),
|
227
|
+
height: position.height
|
189
228
|
};
|
229
|
+
}
|
230
|
+
};
|
190
231
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
232
|
+
InputCaret.prototype.getPosition = function(pos) {
|
233
|
+
var $inputor, at_rect, end_range, format, html, mirror, start_range;
|
234
|
+
$inputor = this.$inputor;
|
235
|
+
format = function(value) {
|
236
|
+
value = value.replace(/<|>|`|"|&/g, '?').replace(/\r\n|\r|\n/g, "<br/>");
|
237
|
+
if (/firefox/i.test(navigator.userAgent)) {
|
238
|
+
value = value.replace(/\s/g, ' ');
|
239
|
+
}
|
240
|
+
return value;
|
241
|
+
};
|
242
|
+
if (pos === void 0) {
|
243
|
+
pos = this.getPos();
|
244
|
+
}
|
245
|
+
start_range = $inputor.val().slice(0, pos);
|
246
|
+
end_range = $inputor.val().slice(pos);
|
247
|
+
html = "<span style='position: relative; display: inline;'>" + format(start_range) + "</span>";
|
248
|
+
html += "<span id='caret' style='position: relative; display: inline;'>|</span>";
|
249
|
+
html += "<span style='position: relative; display: inline;'>" + format(end_range) + "</span>";
|
250
|
+
mirror = new Mirror($inputor);
|
251
|
+
return at_rect = mirror.create(html).rect();
|
252
|
+
};
|
209
253
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
html += "<span style='position: relative; display: inline;'>" + format(end_range) + "</span>";
|
224
|
-
mirror = new Mirror($inputor);
|
225
|
-
return at_rect = mirror.create(html).rect();
|
226
|
-
};
|
254
|
+
InputCaret.prototype.getIEPosition = function(pos) {
|
255
|
+
var h, inputorOffset, offset, x, y;
|
256
|
+
offset = this.getIEOffset(pos);
|
257
|
+
inputorOffset = this.$inputor.offset();
|
258
|
+
x = offset.left - inputorOffset.left;
|
259
|
+
y = offset.top - inputorOffset.top;
|
260
|
+
h = offset.height;
|
261
|
+
return {
|
262
|
+
left: x,
|
263
|
+
top: y,
|
264
|
+
height: h
|
265
|
+
};
|
266
|
+
};
|
227
267
|
|
228
|
-
|
229
|
-
var h, inputorOffset, offset, x, y;
|
230
|
-
offset = this.getIEOffset(pos);
|
231
|
-
inputorOffset = this.$inputor.offset();
|
232
|
-
x = offset.left - inputorOffset.left;
|
233
|
-
y = offset.top - inputorOffset.top;
|
234
|
-
h = offset.height;
|
235
|
-
return {
|
236
|
-
left: x,
|
237
|
-
top: y,
|
238
|
-
height: h
|
239
|
-
};
|
240
|
-
};
|
268
|
+
return InputCaret;
|
241
269
|
|
242
|
-
|
270
|
+
})();
|
243
271
|
|
244
|
-
|
245
|
-
|
246
|
-
Mirror.prototype.css_attr = ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle", "borderTopWidth", "boxSizing", "fontFamily", "fontSize", "fontWeight", "height", "letterSpacing", "lineHeight", "marginBottom", "marginLeft", "marginRight", "marginTop", "outlineWidth", "overflow", "overflowX", "overflowY", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign", "textOverflow", "textTransform", "whiteSpace", "wordBreak", "wordWrap"];
|
272
|
+
Mirror = (function() {
|
273
|
+
Mirror.prototype.css_attr = ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle", "borderTopWidth", "boxSizing", "fontFamily", "fontSize", "fontWeight", "height", "letterSpacing", "lineHeight", "marginBottom", "marginLeft", "marginRight", "marginTop", "outlineWidth", "overflow", "overflowX", "overflowY", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign", "textOverflow", "textTransform", "whiteSpace", "wordBreak", "wordWrap"];
|
247
274
|
|
248
|
-
|
249
|
-
|
250
|
-
|
275
|
+
function Mirror($inputor) {
|
276
|
+
this.$inputor = $inputor;
|
277
|
+
}
|
251
278
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
279
|
+
Mirror.prototype.mirrorCss = function() {
|
280
|
+
var css,
|
281
|
+
_this = this;
|
282
|
+
css = {
|
283
|
+
position: 'absolute',
|
284
|
+
left: -9999,
|
285
|
+
top: 0,
|
286
|
+
zIndex: -20000
|
287
|
+
};
|
288
|
+
if (this.$inputor.prop('tagName') === 'TEXTAREA') {
|
289
|
+
this.css_attr.push('width');
|
290
|
+
}
|
291
|
+
$.each(this.css_attr, function(i, p) {
|
292
|
+
return css[p] = _this.$inputor.css(p);
|
293
|
+
});
|
294
|
+
return css;
|
295
|
+
};
|
269
296
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
297
|
+
Mirror.prototype.create = function(html) {
|
298
|
+
this.$mirror = $('<div></div>');
|
299
|
+
this.$mirror.css(this.mirrorCss());
|
300
|
+
this.$mirror.html(html);
|
301
|
+
this.$inputor.after(this.$mirror);
|
302
|
+
return this;
|
303
|
+
};
|
277
304
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
305
|
+
Mirror.prototype.rect = function() {
|
306
|
+
var $flag, pos, rect;
|
307
|
+
$flag = this.$mirror.find("#caret");
|
308
|
+
pos = $flag.position();
|
309
|
+
rect = {
|
310
|
+
left: pos.left,
|
311
|
+
top: pos.top,
|
312
|
+
height: $flag.height()
|
313
|
+
};
|
314
|
+
this.$mirror.remove();
|
315
|
+
return rect;
|
316
|
+
};
|
290
317
|
|
291
|
-
|
318
|
+
return Mirror;
|
319
|
+
|
320
|
+
})();
|
321
|
+
|
322
|
+
Utils = {
|
323
|
+
contentEditable: function($inputor) {
|
324
|
+
return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true');
|
325
|
+
}
|
326
|
+
};
|
327
|
+
|
328
|
+
methods = {
|
329
|
+
pos: function(pos) {
|
330
|
+
if (pos || pos === 0) {
|
331
|
+
return this.setPos(pos);
|
332
|
+
} else {
|
333
|
+
return this.getPos();
|
334
|
+
}
|
335
|
+
},
|
336
|
+
position: function(pos) {
|
337
|
+
if (oDocument.selection) {
|
338
|
+
return this.getIEPosition(pos);
|
339
|
+
} else {
|
340
|
+
return this.getPosition(pos);
|
341
|
+
}
|
342
|
+
},
|
343
|
+
offset: function(pos) {
|
344
|
+
var offset;
|
345
|
+
offset = this.getOffset(pos);
|
346
|
+
return offset;
|
347
|
+
}
|
348
|
+
};
|
349
|
+
|
350
|
+
oDocument = null;
|
351
|
+
|
352
|
+
oWindow = null;
|
353
|
+
|
354
|
+
oFrame = null;
|
355
|
+
|
356
|
+
setContextBy = function(settings) {
|
357
|
+
var iframe;
|
358
|
+
if (iframe = settings != null ? settings.iframe : void 0) {
|
359
|
+
oFrame = iframe;
|
360
|
+
oWindow = iframe.contentWindow;
|
361
|
+
return oDocument = iframe.contentDocument || oWindow.document;
|
362
|
+
} else {
|
363
|
+
oFrame = void 0;
|
364
|
+
oWindow = window;
|
365
|
+
return oDocument = document;
|
366
|
+
}
|
367
|
+
};
|
368
|
+
|
369
|
+
discoveryIframeOf = function($dom) {
|
370
|
+
var error;
|
371
|
+
oDocument = $dom[0].ownerDocument;
|
372
|
+
oWindow = oDocument.defaultView || oDocument.parentWindow;
|
373
|
+
try {
|
374
|
+
return oFrame = oWindow.frameElement;
|
375
|
+
} catch (_error) {
|
376
|
+
error = _error;
|
377
|
+
}
|
378
|
+
};
|
379
|
+
|
380
|
+
$.fn.caret = function(method, value, settings) {
|
381
|
+
var caret;
|
382
|
+
if (methods[method]) {
|
383
|
+
if ($.isPlainObject(value)) {
|
384
|
+
setContextBy(value);
|
385
|
+
value = void 0;
|
386
|
+
} else {
|
387
|
+
setContextBy(settings);
|
388
|
+
}
|
389
|
+
caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this);
|
390
|
+
return methods[method].apply(caret, [value]);
|
391
|
+
} else {
|
392
|
+
return $.error("Method " + method + " does not exist on jQuery.caret");
|
393
|
+
}
|
394
|
+
};
|
395
|
+
|
396
|
+
$.fn.caret.EditableCaret = EditableCaret;
|
397
|
+
|
398
|
+
$.fn.caret.InputCaret = InputCaret;
|
399
|
+
|
400
|
+
$.fn.caret.Utils = Utils;
|
401
|
+
|
402
|
+
$.fn.caret.apis = methods;
|
292
403
|
|
293
|
-
})();
|
294
|
-
Utils = {
|
295
|
-
contentEditable: function($inputor) {
|
296
|
-
return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true');
|
297
|
-
}
|
298
|
-
};
|
299
|
-
methods = {
|
300
|
-
pos: function(pos) {
|
301
|
-
if (pos || pos === 0) {
|
302
|
-
return this.setPos(pos);
|
303
|
-
} else {
|
304
|
-
return this.getPos();
|
305
|
-
}
|
306
|
-
},
|
307
|
-
position: function(pos) {
|
308
|
-
if (oDocument.selection) {
|
309
|
-
return this.getIEPosition(pos);
|
310
|
-
} else {
|
311
|
-
return this.getPosition(pos);
|
312
|
-
}
|
313
|
-
},
|
314
|
-
offset: function(pos) {
|
315
|
-
var offset;
|
316
|
-
offset = this.getOffset(pos);
|
317
|
-
return offset;
|
318
|
-
}
|
319
|
-
};
|
320
|
-
oDocument = null;
|
321
|
-
oWindow = null;
|
322
|
-
oFrame = null;
|
323
|
-
setContextBy = function(settings) {
|
324
|
-
var iframe;
|
325
|
-
if (iframe = settings != null ? settings.iframe : void 0) {
|
326
|
-
oFrame = iframe;
|
327
|
-
oWindow = iframe.contentWindow;
|
328
|
-
return oDocument = iframe.contentDocument || oWindow.document;
|
329
|
-
} else {
|
330
|
-
oFrame = void 0;
|
331
|
-
oWindow = window;
|
332
|
-
return oDocument = document;
|
333
|
-
}
|
334
|
-
};
|
335
|
-
discoveryIframeOf = function($dom) {
|
336
|
-
var error;
|
337
|
-
oDocument = $dom[0].ownerDocument;
|
338
|
-
oWindow = oDocument.defaultView || oDocument.parentWindow;
|
339
|
-
try {
|
340
|
-
return oFrame = oWindow.frameElement;
|
341
|
-
} catch (_error) {
|
342
|
-
error = _error;
|
343
|
-
}
|
344
|
-
};
|
345
|
-
$.fn.caret = function(method, value, settings) {
|
346
|
-
var caret;
|
347
|
-
if (methods[method]) {
|
348
|
-
if ($.isPlainObject(value)) {
|
349
|
-
setContextBy(value);
|
350
|
-
value = void 0;
|
351
|
-
} else {
|
352
|
-
setContextBy(settings);
|
353
|
-
}
|
354
|
-
caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this);
|
355
|
-
return methods[method].apply(caret, [value]);
|
356
|
-
} else {
|
357
|
-
return $.error("Method " + method + " does not exist on jQuery.caret");
|
358
|
-
}
|
359
|
-
};
|
360
|
-
$.fn.caret.EditableCaret = EditableCaret;
|
361
|
-
$.fn.caret.InputCaret = InputCaret;
|
362
|
-
$.fn.caret.Utils = Utils;
|
363
|
-
return $.fn.caret.apis = methods;
|
364
|
-
});
|
365
404
|
|
366
|
-
})
|
405
|
+
}));
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ichord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|