Last active
August 29, 2015 14:08
-
-
Save yanyaoer/ee04fb583085dfbb95a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source: http://www.sogoke.com/static/cache/js/35771f476692.js | |
a("." + d.inputClass).keydown(function(u) { | |
a("#" + d.tooManyInputsID).hide(); | |
a("#" + d.inputWrongID).hide(); | |
h = a(this).val(); | |
p = g(j); | |
// 回车停止事件没有处理tag | |
if (u.keyCode === 13) { | |
u.preventDefault() | |
} else { | |
if (u.keyCode === 8) { | |
if (a(this).val().length === 0) { | |
u.preventDefault(); | |
a("." + d.tagClass + ":last").remove(); | |
f(a(this).parent().attr("data-for")) | |
} else {} | |
} else { | |
if (u.keyCode === 32) { | |
if (d.emaily) { | |
k = b(h) | |
} else { | |
k = e(h) | |
} | |
if (!d.emaily && p.length >= d.max_length_of_tags) { | |
u.preventDefault(); | |
a("#" + d.tooManyInputsID).show() | |
} else { | |
if (d.emaily && p.length >= d.left_invitations) { | |
u.preventDefault(); | |
a("#" + d.tooManyInputsID).show() | |
} else { | |
if (!k.isValid) { | |
u.preventDefault(); | |
a("#" + d.inputWrongID + " span").text(k.msg); | |
a("#" + d.inputWrongID).show() | |
} else { | |
// 空格到这里才处理tag | |
u.preventDefault(); | |
q = a("<a/>", { | |
href: "#", | |
title: "删除", | |
"class": "delete" | |
}).append("x"); | |
r = a("<span/>").addClass(d.tagClass).append(this.value.substr(0, this.value.length)); | |
a(this).before(r.append(q)); | |
f(a(this).parent("." + d.containerClass).attr("data-for")); | |
a(this).val("").focus() | |
} | |
} | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment