Skip to content

Commit 959c510

Browse files
committed
dump version
1 parent d3d17b5 commit 959c510

File tree

6 files changed

+53
-152
lines changed

6 files changed

+53
-152
lines changed

Gruntfile.coffee

-135
This file was deleted.

bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "At.js",
3+
"version": "1.4.0",
34
"main": [
45
"dist/js/jquery.atwho.js",
56
"dist/css/jquery.atwho.css"
@@ -28,4 +29,4 @@
2829
"atjs",
2930
"at.js"
3031
]
31-
}
32+
}

dist/js/jquery.atwho.js

+41-14
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,18 @@ EditableController = (function(superClass) {
685685
return e.type === 'click' || ((ref = e.which) === KEY_CODE.RIGHT || ref === KEY_CODE.LEFT || ref === KEY_CODE.UP || ref === KEY_CODE.DOWN);
686686
};
687687

688+
EditableController.prototype._unwrap = function(node) {
689+
var next;
690+
node = $(node).unwrap().get(0);
691+
if ((next = node.nextSibling) && next.nodeValue) {
692+
node.nodeValue += next.nodeValue;
693+
$(next).remove();
694+
}
695+
return node;
696+
};
697+
688698
EditableController.prototype.catchQuery = function(e) {
689-
var $inserted, $query, _range, index, inserted, isString, lastNode, matched, offset, parentNode, query, query_content, range;
699+
var $inserted, $query, _range, index, inserted, isString, lastNode, matched, offset, query, query_content, range;
690700
if (!(range = this._getRange())) {
691701
return;
692702
}
@@ -780,9 +790,7 @@ EditableController = (function(superClass) {
780790
if (this._movingEvent(e) && $query.hasClass('atwho-inserted')) {
781791
$query.removeClass('atwho-query');
782792
} else if (false !== this.callbacks('afterMatchFailed').call(this, this.at, $query)) {
783-
parentNode = $query[0].parentNode;
784-
this._setRange("after", $query.text($query.text()).contents().first().unwrap());
785-
parentNode.normalize();
793+
this._setRange("after", this._unwrap($query.text($query.text()).contents().first()));
786794
}
787795
}
788796
return null;
@@ -894,14 +902,19 @@ View = (function() {
894902
function View(context) {
895903
this.context = context;
896904
this.$el = $("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>");
905+
this.$elUl = this.$el.children();
897906
this.timeoutID = null;
898907
this.context.$el.append(this.$el);
899908
this.bindEvent();
900909
}
901910

902911
View.prototype.init = function() {
903-
var id;
912+
var header_tpl, id;
904913
id = this.context.getOpt("alias") || this.context.at.charCodeAt(0);
914+
header_tpl = this.context.getOpt("headerTpl");
915+
if (header_tpl && this.$el.children().length === 1) {
916+
this.$el.prepend(header_tpl);
917+
}
905918
return this.$el.attr({
906919
'id': "at-view-" + id
907920
});
@@ -912,12 +925,26 @@ View = (function() {
912925
};
913926

914927
View.prototype.bindEvent = function() {
915-
var $menu;
928+
var $menu, lastCoordX, lastCoordY;
916929
$menu = this.$el.find('ul');
917-
return $menu.on('mouseenter.atwho-view', 'li', function(e) {
918-
$menu.find('.cur').removeClass('cur');
919-
return $(e.currentTarget).addClass('cur');
920-
}).on('click.atwho-view', 'li', (function(_this) {
930+
lastCoordX = 0;
931+
lastCoordY = 0;
932+
return $menu.on('mousemove.atwho-view', 'li', (function(_this) {
933+
return function(e) {
934+
var $cur;
935+
if (lastCoordX === e.clientX && lastCoordY === e.clientY) {
936+
return;
937+
}
938+
lastCoordX = e.clientX;
939+
lastCoordY = e.clientY;
940+
$cur = $(e.currentTarget);
941+
if ($cur.hasClass('cur')) {
942+
return;
943+
}
944+
$menu.find('.cur').removeClass('cur');
945+
return $cur.addClass('cur');
946+
};
947+
})(this)).on('click.atwho-view', 'li', (function(_this) {
921948
return function(e) {
922949
$menu.find('.cur').removeClass('cur');
923950
$(e.currentTarget).addClass('cur');
@@ -977,7 +1004,7 @@ View = (function() {
9771004
next = this.$el.find('li:first');
9781005
}
9791006
next.addClass('cur');
980-
return this.scrollTop(Math.max(0, cur.innerHeight() * (next.index() + 2) - this.$el.height()));
1007+
return this.scrollTop(Math.max(0, cur.outerHeight(true) * (next.index() + 2) - this.$el.height()));
9811008
};
9821009

9831010
View.prototype.prev = function() {
@@ -988,18 +1015,18 @@ View = (function() {
9881015
prev = this.$el.find('li:last');
9891016
}
9901017
prev.addClass('cur');
991-
return this.scrollTop(Math.max(0, cur.innerHeight() * (prev.index() + 2) - this.$el.height()));
1018+
return this.scrollTop(Math.max(0, cur.outerHeight(true) * (prev.index() + 2) - this.$el.height()));
9921019
};
9931020

9941021
View.prototype.scrollTop = function(scrollTop) {
9951022
var scrollDuration;
9961023
scrollDuration = this.context.getOpt('scrollDuration');
9971024
if (scrollDuration) {
998-
return this.$el.animate({
1025+
return this.$elUl.animate({
9991026
scrollTop: scrollTop
10001027
}, scrollDuration);
10011028
} else {
1002-
return this.$el.scrollTop(scrollTop);
1029+
return this.$elUl.scrollTop(scrollTop);
10031030
}
10041031
};
10051032

0 commit comments

Comments
 (0)