jquery-atwho-rails 1.0.1 → 1.1.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +5 -15
- data/lib/assets/javascripts/jquery.atwho/jquery.atwho.js +50 -25
- data/lib/jquery-atwho-rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f147f6dc894847559d1f5c240cbdb7a46fe14409
|
4
|
+
data.tar.gz: eabd2f00d29fe2e8480e251848aea0a2041c00f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0bc1c81a508bab44cfbc9c927a504e61e7b3410918082b1512a72b0eb9c31b037f955d6cbe2e5f7e583354d5a2cdd7a94c3ef9e65d7af83e6f189dde49f5487
|
7
|
+
data.tar.gz: 820e7b345bb800961e39a45a6f6f8a877b3579e706758b928a9733b2b927f0bebbfd7f00ecffd93272466b5907c191602148702a2b0bf8025e6e2553e27432b6
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -2,28 +2,18 @@ require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
|
5
|
-
|
6
|
-
bower_dir = "#{at_dir}/bower_components/"
|
5
|
+
bower_dir = "bower_components/"
|
7
6
|
|
8
7
|
desc "sync from At.js"
|
9
8
|
task :sync do
|
10
|
-
puts "
|
11
|
-
|
12
|
-
unless Dir.exist? at_dir
|
13
|
-
system "git clone git://github.com/ichord/At.js.git #{at_dir}"
|
14
|
-
else
|
15
|
-
Dir.chdir(at_dir) { puts %x{git pull -X theirs} }
|
16
|
-
end
|
17
|
-
Dir.chdir(at_dir) {
|
18
|
-
puts "* bower install..."
|
19
|
-
puts %x{bower install}
|
20
|
-
}
|
9
|
+
puts "* bower install..."
|
10
|
+
puts %x{bower install}
|
21
11
|
end
|
22
12
|
|
23
13
|
desc "copy assets"
|
24
|
-
task
|
14
|
+
task refresh: :sync do
|
25
15
|
puts " * Copying..."
|
26
|
-
source_dir = "
|
16
|
+
source_dir = "bower_components/At.js/dist"
|
27
17
|
dist_dir = "lib/assets"
|
28
18
|
|
29
19
|
js_dist_dir = "#{dist_dir}/javascripts/jquery.atwho/"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! jquery.atwho - v1.0
|
1
|
+
/*! jquery.atwho - v1.1.0 %>
|
2
2
|
* Copyright (c) 2015 chord.luo <chord.luo@gmail.com>;
|
3
3
|
* homepage: http://ichord.github.com/At.js
|
4
4
|
* Licensed MIT
|
@@ -6,8 +6,8 @@
|
|
6
6
|
(function (root, factory) {
|
7
7
|
if (typeof define === 'function' && define.amd) {
|
8
8
|
// AMD. Register as an anonymous module.
|
9
|
-
define(["jquery"], function (
|
10
|
-
return (root.returnExportsGlobal = factory(
|
9
|
+
define(["jquery"], function (jquery) {
|
10
|
+
return (root.returnExportsGlobal = factory(jquery));
|
11
11
|
});
|
12
12
|
} else if (typeof exports === 'object') {
|
13
13
|
// Node. Does not work with strict CommonJS, but
|
@@ -17,7 +17,7 @@
|
|
17
17
|
} else {
|
18
18
|
factory(jQuery);
|
19
19
|
}
|
20
|
-
}(this, function (
|
20
|
+
}(this, function (jquery) {
|
21
21
|
|
22
22
|
var Api, App, Controller, DEFAULT_CALLBACKS, EditableController, KEY_CODE, Model, TextareaController, View,
|
23
23
|
__slice = [].slice,
|
@@ -35,13 +35,15 @@ App = (function() {
|
|
35
35
|
}
|
36
36
|
|
37
37
|
App.prototype.createContainer = function(doc) {
|
38
|
-
|
39
|
-
|
38
|
+
var _ref;
|
39
|
+
if ((_ref = this.$el) != null) {
|
40
|
+
_ref.remove();
|
40
41
|
}
|
42
|
+
return $(doc.body).append(this.$el = $("<div class='atwho-container'></div>"));
|
41
43
|
};
|
42
44
|
|
43
45
|
App.prototype.setupRootElement = function(iframe, asRoot) {
|
44
|
-
var error
|
46
|
+
var error;
|
45
47
|
if (asRoot == null) {
|
46
48
|
asRoot = false;
|
47
49
|
}
|
@@ -57,17 +59,10 @@ App = (function() {
|
|
57
59
|
} catch (_error) {
|
58
60
|
error = _error;
|
59
61
|
this.iframe = null;
|
60
|
-
throw new Error("iframe auto-discovery is failed.\nPlease use `
|
61
|
-
}
|
62
|
-
}
|
63
|
-
if (this.iframeAsRoot = asRoot) {
|
64
|
-
if ((_ref = this.$el) != null) {
|
65
|
-
_ref.remove();
|
62
|
+
throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.");
|
66
63
|
}
|
67
|
-
return this.createContainer(this.document);
|
68
|
-
} else {
|
69
|
-
return this.createContainer(document);
|
70
64
|
}
|
65
|
+
return this.createContainer((this.iframeAsRoot = asRoot) ? this.document : document);
|
71
66
|
};
|
72
67
|
|
73
68
|
App.prototype.controller = function(at) {
|
@@ -107,7 +102,19 @@ App = (function() {
|
|
107
102
|
};
|
108
103
|
|
109
104
|
App.prototype.listen = function() {
|
110
|
-
return this.$inputor.on('
|
105
|
+
return this.$inputor.on('compositionstart', (function(_this) {
|
106
|
+
return function(e) {
|
107
|
+
var _ref;
|
108
|
+
if ((_ref = _this.controller()) != null) {
|
109
|
+
_ref.view.hide();
|
110
|
+
}
|
111
|
+
return _this.isComposing = true;
|
112
|
+
};
|
113
|
+
})(this)).on('compositionend', (function(_this) {
|
114
|
+
return function(e) {
|
115
|
+
return _this.isComposing = false;
|
116
|
+
};
|
117
|
+
})(this)).on('keyup.atwhoInner', (function(_this) {
|
111
118
|
return function(e) {
|
112
119
|
return _this.onKeyup(e);
|
113
120
|
};
|
@@ -226,9 +233,13 @@ App = (function() {
|
|
226
233
|
break;
|
227
234
|
case KEY_CODE.TAB:
|
228
235
|
case KEY_CODE.ENTER:
|
236
|
+
case KEY_CODE.SPACE:
|
229
237
|
if (!view.visible()) {
|
230
238
|
return;
|
231
239
|
}
|
240
|
+
if (!this.controller().getOpt('spaceSelectsMatch') && e.keyCode === KEY_CODE.SPACE) {
|
241
|
+
return;
|
242
|
+
}
|
232
243
|
e.preventDefault();
|
233
244
|
view.choose(e);
|
234
245
|
break;
|
@@ -501,6 +512,9 @@ EditableController = (function(_super) {
|
|
501
512
|
|
502
513
|
EditableController.prototype.catchQuery = function(e) {
|
503
514
|
var $inserted, $query, index, inserted, lastNode, matched, offset, query, range, _range;
|
515
|
+
if (this.app.isComposing) {
|
516
|
+
return;
|
517
|
+
}
|
504
518
|
if (!(range = this._getRange())) {
|
505
519
|
return;
|
506
520
|
}
|
@@ -544,7 +558,8 @@ EditableController = (function(_super) {
|
|
544
558
|
matched = this.callbacks("matcher").call(this, this.at, _range.toString(), this.getOpt('startWithSpace'));
|
545
559
|
if ($query.length === 0 && typeof matched === 'string' && (index = range.startOffset - this.at.length - matched.length) >= 0) {
|
546
560
|
range.setStart(range.startContainer, index);
|
547
|
-
|
561
|
+
$query = $("<span/>", this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass('atwho-query');
|
562
|
+
range.surroundContents($query.get(0));
|
548
563
|
lastNode = $query.contents().last().get(0);
|
549
564
|
if (/firefox/i.test(navigator.userAgent)) {
|
550
565
|
range.setStart(lastNode, lastNode.length);
|
@@ -560,9 +575,12 @@ EditableController = (function(_super) {
|
|
560
575
|
el: $query
|
561
576
|
};
|
562
577
|
this.trigger("matched", [this.at, query.text]);
|
578
|
+
return this.query = query;
|
563
579
|
} else {
|
564
580
|
this.view.hide();
|
565
|
-
query =
|
581
|
+
this.query = {
|
582
|
+
el: $query
|
583
|
+
};
|
566
584
|
if ($query.text().indexOf(this.at) >= 0) {
|
567
585
|
if (this._movingEvent(e) && $query.hasClass('atwho-inserted')) {
|
568
586
|
$query.removeClass('atwho-query');
|
@@ -570,8 +588,8 @@ EditableController = (function(_super) {
|
|
570
588
|
this._setRange("after", this._unwrap($query.text($query.text()).contents().first()));
|
571
589
|
}
|
572
590
|
}
|
591
|
+
return null;
|
573
592
|
}
|
574
|
-
return this.query = query;
|
575
593
|
};
|
576
594
|
|
577
595
|
EditableController.prototype.rect = function() {
|
@@ -847,7 +865,8 @@ KEY_CODE = {
|
|
847
865
|
UP: 38,
|
848
866
|
RIGHT: 39,
|
849
867
|
DOWN: 40,
|
850
|
-
BACKSPACE: 8
|
868
|
+
BACKSPACE: 8,
|
869
|
+
SPACE: 32
|
851
870
|
};
|
852
871
|
|
853
872
|
DEFAULT_CALLBACKS = {
|
@@ -862,7 +881,7 @@ DEFAULT_CALLBACKS = {
|
|
862
881
|
}
|
863
882
|
_a = decodeURI("%C3%80");
|
864
883
|
_y = decodeURI("%C3%BF");
|
865
|
-
regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_
|
884
|
+
regexp = new RegExp("" + flag + "([A-Za-z" + _a + "-" + _y + "0-9_\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
|
866
885
|
match = regexp.exec(subtext);
|
867
886
|
if (match) {
|
868
887
|
return match[2] || match[1];
|
@@ -900,9 +919,13 @@ DEFAULT_CALLBACKS = {
|
|
900
919
|
});
|
901
920
|
},
|
902
921
|
tplEval: function(tpl, map) {
|
903
|
-
var error;
|
922
|
+
var error, template;
|
923
|
+
template = tpl;
|
904
924
|
try {
|
905
|
-
|
925
|
+
if (typeof tpl !== 'string') {
|
926
|
+
template = tpl(map);
|
927
|
+
}
|
928
|
+
return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) {
|
906
929
|
return map[key];
|
907
930
|
});
|
908
931
|
} catch (_error) {
|
@@ -988,7 +1011,9 @@ $.fn.atwho["default"] = {
|
|
988
1011
|
limit: 5,
|
989
1012
|
maxLen: 20,
|
990
1013
|
displayTimeout: 300,
|
991
|
-
delay: null
|
1014
|
+
delay: null,
|
1015
|
+
spaceSelectsMatch: false,
|
1016
|
+
editableAtwhoQueryAttrs: {}
|
992
1017
|
};
|
993
1018
|
|
994
1019
|
|
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.1.0
|
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-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project: jquery-atwho-rails
|
88
|
-
rubygems_version: 2.4.
|
88
|
+
rubygems_version: 2.4.6
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: 'jquery plugin: @mentions'
|