\n/gi, "\n\n").replace(/<(?:[^>]+)?>/g, "").replace(new RegExp(l, "g"), "").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/`/g, "`").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"), b.saveEmojisAs) {
case "image":
a = A(a, b.emojiTemplate);
break;
case "shortname":
a = e.toShort(a)
}
return a
}
function D() {
var a = this,
b = a.editor[0].offsetWidth - a.editor[0].clientWidth,
c = parseInt(a.button.css("marginRight"));
c !== b && (a.button.css({
marginRight: b
}), a.floatingPicker && a.picker.css({
right: parseInt(a.picker.css("right")) - c + b
}))
}
function E() {
var b = this;
if (!b.sprite && b.lasyEmoji[0] && b.lasyEmoji.eq(0).is(".lazy-emoji")) {
var c = b.picker.offset().top,
d = c + b.picker.height() + 20;
b.lasyEmoji.each(function () {
var b = a(this),
e = b.offset().top;
if (e > c && e < d && b.attr("src", b.data("src")).removeClass("lazy-emoji"), e > d) return !1
}), b.lasyEmoji = b.lasyEmoji.filter(".lazy-emoji")
}
}
function F(a, b) {
return (b ? "" : ".") + j + (a ? "-" + a : "")
}
function G(b) {
var c = a("
", s(b) ? b : {
"class": F(b, !0)
});
return a.each(i.call(arguments).slice(1), function (b, d) {
a.isFunction(d) && (d = d.call(c)), d && a(d).appendTo(c)
}), c
}
function H() {
return localStorage.getItem("recent_emojis") || ""
}
function I(b, c) {
var d = H();
if (!b.recent || b.recent !== d || c) {
if (d.length) {
var e = b.scrollArea.is(".skinnable"),
f, g;
e || (f = b.scrollArea.scrollTop(), c && b.recentCategory.show(), g = b.recentCategory.is(":visible") ? b.recentCategory.height() : 0);
var h = p(d, b.emojiBtnTemplate, !0).split("|").join("");
if (b.recentCategory.children(".emojibtn").remove(), a(h).insertAfter(b.recentCategory.children(".emojionearea-category-title")), b.recentCategory.children(".emojibtn").on("click", function () {
b.trigger("emojibtn.click", a(this))
}), b.recentFilter.show(), !e) {
b.recentCategory.show();
var i = b.recentCategory.height();
g !== i && b.scrollArea.scrollTop(f + i - g)
}
} else b.recentFilter.hasClass("active") && b.recentFilter.removeClass("active").next().addClass("active"), b.recentCategory.hide(), b.recentFilter.hide();
b.recent = d
}
}
function J(a, b) {
var c = H(),
d = c.split("|"),
e = d.indexOf(b);
e !== -1 && d.splice(e, 1), d.unshift(b), d.length > 9 && d.pop(), localStorage.setItem("recent_emojis", d.join("|")), I(a)
}
function K() {
var a = "test";
try {
return localStorage.setItem(a, a), localStorage.removeItem(a), !0
} catch (b) {
return !1
}
}
function L(b, c, d) {
b.options = d = w(d), b.sprite = d.sprite && k < 3, b.inline = null === d.inline ? c.is("INPUT") : d.inline, b.shortnames = d.shortnames, b.saveEmojisAs = d.saveEmojisAs, b.standalone = d.standalone, b.emojiTemplate = '

' : 'emoji" src="{img}"/>'), b.emojiTemplateAlt = b.sprite ? '
' : '

', b.emojiBtnTemplate = '
' + b.emojiTemplateAlt + "", b.recentEmojis = d.recentEmojis && K();
var f = d.pickerPosition;
b.floatingPicker = "top" === f || "bottom" === f, b.source = c, (c.is(":disabled") || c.is(".disabled")) && b.disable();
var g = c.is("TEXTAREA") || c.is("INPUT") ? "val" : "text",
i, o, r, t, u, v, z, A, L, M, N = G("tones", d.tones ? function () {
this.addClass(F("tones-" + d.tonesStyle, !0));
for (var b = 0; b <= 5; b++) this.append(a("
", {
"class": "btn-tone btn-tone-" + b + (b ? "" : " active"),
"data-skin": b,
role: "button"
}))
} : null),
O = G({
"class": j + (b.standalone ? " " + j + "-standalone " : " ") + (c.attr("class") || ""),
role: "application"
}, i = b.editor = G("editor").attr({
contenteditable: !b.standalone,
placeholder: d.placeholder || c.data("placeholder") || c.attr("placeholder") || "",
tabindex: 0
}), o = b.button = G("button", G("button-open"), G("button-close")).attr("title", d.buttonTitle), r = b.picker = G("picker", G("wrapper", t = G("filters"), d.search ? v = G("search-panel", G("search", d.search ? function () {
b.search = a("
", {
placeholder: d.searchPlaceholder || "",
type: "text",
"class": "search"
}), this.append(b.search)
} : null), N) : null, M = G("scroll-area", d.tones && !d.search ? G("tones-panel", N) : null, z = G("emojis-list")))).addClass(F("picker-position-" + d.pickerPosition, !0)).addClass(F("filters-position-" + d.filtersPosition, !0)).addClass(F("search-position-" + d.searchPosition, !0)).addClass("hidden"));
d.search && v.addClass(F("with-search", !0)), b.searchSel = null, i.data(c.data()), a.each(d.attributes, function (a, b) {
i.attr(a, b)
});
var P = G("category-block").attr({
"data-tone": 0
}).prependTo(z);
if (a.each(d.filters, function (c, e) {
var f = 0;
if ("recent" !== c || b.recentEmojis) {
if ("tones" !== c) a("
", {
"class": F("filter", !0) + " " + F("filter-" + c, !0),
"data-filter": c,
title: e.title
}).wrapInner(p(e.icon, b.emojiTemplateAlt)).appendTo(t);
else {
if (!d.tones) return;
f = 5
}
do {
var g, h = e.emoji.replace(/[\s,;]+/g, "|");
g = 0 === f ? G("category").attr({
name: c,
"data-tone": f
}).appendTo(P) : G("category-block").attr({
name: c,
"data-tone": f
}).appendTo(z), f > 0 && (g.hide(), h = h.split("|").join("_tone" + f + "|") + "_tone" + f), "recent" === c && (h = H()), h = p(h, b.sprite ? '
' : '
![]()
', !0).split("|").join(""), g.html(h), a('
').text(e.title).prependTo(g)
} while (--f > 0)
}
}), d.filters = null, b.sprite || (b.lasyEmoji = z.find(".lazy-emoji")), u = t.find(F("filter")), u.eq(0).addClass("active"), L = z.find(F("category-block")), A = z.find(F("category")), b.recentFilter = u.filter('[data-filter="recent"]'), b.recentCategory = A.filter("[name=recent]"), b.scrollArea = M, d.container ? a(d.container).wrapInner(O) : O.insertAfter(c), d.hideSource && c.hide(), b.setText(c[g]()), c[g](b.getText()), D.apply(b), b.standalone && !b.getText().length) {
var Q = a(c).data("emoji-placeholder") || d.emojiPlaceholder;
b.setText(Q), i.addClass("has-placeholder")
}
n(b, z.find(".emojibtn"), {
click: "emojibtn.click"
}), n(b, window, {
resize: "!resize"
}), n(b, N.children(), {
click: "tone.click"
}), n(b, [r, o], {
mousedown: "!mousedown"
}, i), n(b, o, {
click: "button.click"
}), n(b, i, {
paste: "!paste"
}, i), n(b, i, ["focus", "blur"], function () {
return !b.stayFocused && i
}), n(b, r, {
mousedown: "picker.mousedown",
mouseup: "picker.mouseup",
click: "picker.click",
keyup: "picker.keyup",
keydown: "picker.keydown",
keypress: "picker.keypress"
}), n(b, i, ["mousedown", "mouseup", "click", "keyup", "keydown", "keypress"]), n(b, r.find(".emojionearea-filter"), {
click: "filter.click"
}), n(b, c, {
change: "source.change"
}), d.search && n(b, b.search, {
keyup: "search.keypress",
focus: "search.focus",
blur: "search.blur"
});
var R = !1;
if (M.on("scroll", function () {
if (!R && (E.call(b), M.is(":not(.skinnable)"))) {
var c = A.eq(0),
d = M.offset().top;
A.each(function (b, e) {
return !(a(e).offset().top - d >= 10) && void(c = a(e))
});
var e = u.filter('[data-filter="' + c.attr("name") + '"]');
e[0] && !e.is(".active") && (u.removeClass("active"), e.addClass("active"))
}
}), b.on("@filter.click", function (a) {
var c = a.is(".active");
if (M.is(".skinnable")) {
if (c) return;
N.children().eq(0).click()
}
R = !0, c || (u.filter(".active").removeClass("active"), a.addClass("active"));
var d = A.filter('[name="' + a.data("filter") + '"]').offset().top,
e = M.scrollTop(),
f = M.offset().top;
M.stop().animate({
scrollTop: d + e - f - 2
}, 200, "swing", function () {
E.call(b), R = !1
})
}).on("@picker.show", function () {
b.recentEmojis && I(b), E.call(b)
}).on("@tone.click", function (a) {
N.children().removeClass("active");
var c = a.addClass("active").data("skin");
c ? (M.addClass("skinnable"), L.hide().filter("[data-tone=" + c + "]").show(), u.removeClass("active")) : (M.removeClass("skinnable"), L.hide().filter("[data-tone=0]").show(), u.eq(0).click()), E.call(b), d.search && b.trigger("search.keypress")
}).on("@button.click", function (a) {
a.is(".active") ? b.hidePicker() : (b.showPicker(), b.searchSel = null)
}).on("@!paste", function (c, d) {
var e = function (d) {
var e = "caret-" + (new Date).getTime(),
f = B(d, b);
q(f), q('
'), c.scrollTop(h);
var g = a("#" + e),
i = g.offset().top - c.offset().top,
j = c.height();
(h + i >= j || h > i) && c.scrollTop(h + i - 2 * j / 3), g.remove(), b.stayFocused = !1, D.apply(b), m(b, "paste", [c, d, f])
};
if (d.originalEvent.clipboardData) {
var f = d.originalEvent.clipboardData.getData("text/plain");
return e(f), d.preventDefault ? d.preventDefault() : d.stop(), d.returnValue = !1, d.stopPropagation(), !1
}
b.stayFocused = !0, q("
" + l + "");
var g = x(c[0]),
h = c.scrollTop(),
i = a("
", {
contenteditable: !0
}).css({
position: "fixed",
left: "-999px",
width: "1px",
height: "1px",
top: "20px",
overflow: "hidden"
}).appendTo(a("BODY")).focus();
window.setTimeout(function () {
c.focus(), y(c[0], g);
var a = C(i.html().replace(/\r\n|\n|\r/g, "
"), b);
i.remove(), e(a)
}, 200)
}).on("@emojibtn.click", function (a) {
i.removeClass("has-placeholder"), null !== b.searchSel && (i.focus(), y(i[0], b.searchSel), b.searchSel = null), b.standalone ? (i.html(p(a.data("name"), b.emojiTemplate)), b.trigger("blur")) : (x(i[0]), q(p(a.data("name"), b.emojiTemplate))), b.recentEmojis && J(b, a.data("name")), b.trigger("search.keypress")
}).on("@!resize @keyup @emojibtn.click", D).on("@!mousedown", function (c, d) {
return a(d.target).hasClass("search") ? (b.stayFocused = !0, null === b.searchSel && (b.searchSel = x(c[0]))) : (O.is(".focused") || c.trigger("focus"), d.preventDefault()), !1
}).on("@change", function () {
var a = b.editor.html().replace(/<\/?(?:div|span|p)[^>]*>/gi, "");
a.length && !/^
]*>$/i.test(a) || b.editor.html(b.content = ""), c[g](b.getText())
}).on("@source.change", function () {
b.setText(c[g]()), m("change")
}).on("@focus", function () {
O.addClass("focused")
}).on("@blur", function () {
O.removeClass("focused"), d.hidePickerOnBlur && b.hidePicker();
var a = b.editor.html();
b.content !== a ? (b.content = a, m(b, "change", [b.editor]), c.trigger("blur").trigger("change")) : c.trigger("blur"), d.search && (b.search.val(""), b.trigger("search.keypress", !0))
}), d.search && b.on("@search.focus", function () {
b.stayFocused = !0, b.search.addClass("focused")
}).on("@search.keypress", function (c) {
var e = r.find(".emojionearea-filter"),
f = d.tones ? N.find("i.active").data("skin") : 0,
g = b.search.val().replace(/ /g, "_").replace(/"/g, '\\"');
g && g.length ? (b.recentFilter.hasClass("active") && b.recentFilter.removeClass("active").next().addClass("active"), b.recentCategory.hide(), b.recentFilter.hide(), L.each(function () {
var b = function (a, b) {
var c = a.find('.emojibtn[data-name*="' + g + '"]');
if (0 === c.length) a.data("tone") === b && a.hide(), e.filter('[data-filter="' + a.attr("name") + '"]').hide();
else {
var d = a.find('.emojibtn:not([data-name*="' + g + '"])');
d.hide(), c.show(), a.data("tone") === b && a.show(), e.filter('[data-filter="' + a.attr("name") + '"]').show()
}
},
c = a(this);
0 === c.data("tone") ? A.filter(':not([name="recent"])').each(function () {
b(a(this), 0)
}) : b(c, f)
}), R ? E.call(b) : M.trigger("scroll")) : (I(b, !0), L.filter('[data-tone="' + N.find("i.active").data("skin") + '"]:not([name="recent"])').show(), a(".emojibtn", L).show(), e.show(), E.call(b))
}).on("@search.blur", function () {
b.stayFocused = !1, b.search.removeClass("focused"), b.trigger("blur")
}), d.shortcuts && b.on("@keydown", function (a, c) {
c.ctrlKey || (9 == c.which ? (c.preventDefault(), o.click()) : 27 == c.which && (c.preventDefault(), o.is(".active") && b.hidePicker()))
}), s(d.events) && !a.isEmptyObject(d.events) && a.each(d.events, function (a, c) {
b.on(a.replace(/_/g, "."), c)
}), d.autocomplete) {
var S = function () {
var c = {
maxCount: d.textcomplete.maxCount,
placement: d.textcomplete.placement
};
d.shortcuts && (c.onKeydown = function (a, b) {
if (!a.ctrlKey && 13 == a.which) return b.KEY_ENTER
});
var f = a.map(e.emojioneList, function (a, b) {
return d.autocompleteTones ? b : /_tone[12345]/.test(b) ? null : b
});
f.sort(), i.textcomplete([{
id: j,
match: /\B(:[\-+\w]*)$/,
search: function (b, c) {
c(a.map(f, function (a) {
return 0 === a.indexOf(b) ? a : null
}))
},
template: function (a) {
return p(a, b.emojiTemplate) + " " + a.replace(/:/g, "")
},
replace: function (a) {
return p(a, b.emojiTemplate)
},
cache: !0,
index: 1
}], c), d.textcomplete.placement && "static" == a(i.data("textComplete").option.appendTo).css("position") && a(i.data("textComplete").option.appendTo).css("position", "relative")
},
T = function () {
if (b.disabled) {
var a = function () {
b.off("enabled", a), S()
};
b.on("enabled", a)
} else S()
};
a.fn.textcomplete ? T() : a.ajax({
url: "https://cdn.rawgit.com/yuku-t/jquery-textcomplete/v1.3.4/dist/jquery.textcomplete.js",
dataType: "script",
cache: !0,
success: T
})
}
b.inline && (O.addClass(F("inline", !0)), b.on("@keydown", function (a, b) {
13 == b.which && b.preventDefault()
})), /firefox/i.test(navigator.userAgent) && document.execCommand("enableObjectResizing", !1, !1), b.isReady = !0, b.trigger("onLoad", i), b.trigger("ready", i)
}
var M = {
defaultBase: "https://cdnjs.cloudflare.com/ajax/libs/emojione/",
defaultBase3: "https://cdn.jsdelivr.net/",
base: null,
isLoading: !1
};
function N(b) {
var c = r();
if (b = w(b), !M.isLoading)
if (!e || u(t(e)) < 2) {
M.isLoading = !0;
var d;
d = u(c) > 5 ? M.defaultBase3 + "npm/emojione@" + c : u(c) > 4 ? M.defaultBase3 + "emojione/" + c : M.defaultBase + "/" + c, a.ajax({
url: d + "/lib/js/emojione.min.js",
dataType: "script",
cache: !0,
success: function () {
e = window.emojione, c = t(e), k = u(c);
var d;
k > 4 ? (M.base = M.defaultBase3 + "emojione/assets/" + c, d = M.base + "/sprites/emojione-sprite-" + e.emojiSize + ".css") : (M.base = M.defaultBase + c + "/assets", d = M.base + "/sprites/emojione.sprites.css"), b.sprite && (document.createStyleSheet ? document.createStyleSheet(d) : a("
", {
rel: "stylesheet",
href: d
}).appendTo("head"));
while (f.length) f.shift().call();
M.isLoading = !1
}
})
} else c = t(e), k = u(c), k > 4 ? M.base = M.defaultBase3 + "emojione/assets/" + c : M.base = M.defaultBase + c + "/assets";
g(function () {
var a = "";
b.useInternalCDN && (k > 4 && (a = e.emojiSize + "/"), e.imagePathPNG = M.base + "/png/" + a, e.imagePathSVG = M.base + "/svg/" + a, e.imagePathSVGSprites = M.base + "/sprites/emojione.sprites.svg", e.imageType = b.imageType), u(c) > 4 ? (z = e.regUnicode, e.imageType = b.imageType || "png") : z = new RegExp("
|
]*>.*?|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(" + e.unicodeRegexp + ")", "gi")
})
}
var O = function (a, e) {
var f = this;
N(e), c[f.id = ++b] = {}, d[f.id] = {}, g(function () {
L(f, a, e)
})
};
function P(b, c) {
c = c.replace(/^@/, "");
var e = b.id;
d[e][c] && (a.each(d[e][c], function (d, e) {
a.each(a.isArray(e[0]) ? e[0] : [e[0]], function (d, f) {
a(f).on(e[1], function () {
var d = i.call(arguments),
f = a.isFunction(e[2]) ? e[2].apply(b, [c].concat(d)) : e[2];
f && m(b, c, [f].concat(d))
})
})
}), d[e][c] = null)
}
O.prototype.on = function (b, d) {
if (b && a.isFunction(d)) {
var e = this;
a.each(b.toLowerCase().split(" "), function (a, b) {
P(e, b), (c[e.id][b] || (c[e.id][b] = [])).push(d)
})
}
return this
}, O.prototype.off = function (b, d) {
if (b) {
var e = this.id;
a.each(b.toLowerCase().replace(/_/g, ".").split(" "), function (b, f) {
c[e][f] && !/^@/.test(f) && (d ? a.each(c[e][f], function (a, b) {
b === d && (c[e][f] = c[e][f].splice(a, 1))
}) : c[e][f] = [])
})
}
return this
}, O.prototype.trigger = function () {
var a = i.call(arguments),
b = [this].concat(a.slice(0, 1));
return b.push(a.slice(1)), m.apply(this, b)
}, O.prototype.setFocus = function () {
var a = this;
return g(function () {
a.editor.focus()
}), a
}, O.prototype.setText = function (a) {
var b = this;
return g(function () {
b.editor.html(B(a, b)), b.content = b.editor.html(), m(b, "change", [b.editor]), D.apply(b)
}), b
}, O.prototype.getText = function () {
return C(this.editor.html(), this)
}, O.prototype.showPicker = function () {
var a = this;
return a._sh_timer && window.clearTimeout(a._sh_timer), a.picker.removeClass("hidden"), a._sh_timer = window.setTimeout(function () {
a.button.addClass("active")
}, 50), m(a, "picker.show", [a.picker]), a
}, O.prototype.hidePicker = function () {
var a = this;
return a._sh_timer && window.clearTimeout(a._sh_timer), a.button.removeClass("active"), a._sh_timer = window.setTimeout(function () {
a.picker.addClass("hidden")
}, 500), m(a, "picker.hide", [a.picker]), a
}, O.prototype.enable = function () {
var a = this,
b = function () {
a.disabled = !1, a.editor.prop("contenteditable", !0), a.button.show();
var b = a[a.standalone ? "button" : "editor"];
b.parent().removeClass("emojionearea-disable"), m(a, "enabled", [b])
};
return a.isReady ? b() : a.on("ready", b), a
}, O.prototype.disable = function () {
var a = this;
a.disabled = !0;
var b = function () {
a.editor.prop("contenteditable", !1), a.hidePicker(), a.button.hide();
var b = a[a.standalone ? "button" : "editor"];
b.parent().addClass("emojionearea-disable"), m(a, "disabled", [b])
};
return a.isReady ? b() : a.on("ready", b), a
}, a.fn.emojioneArea = function (b) {
return this.each(function () {
return this.emojioneArea ? this.emojioneArea : (a.data(this, "emojioneArea", this.emojioneArea = new O(a(this), b)), this.emojioneArea)
})
}, a.fn.emojioneArea.defaults = v(), a.fn.emojioneAreaText = function (b) {
b = w(b);
var c = this,
d = {
shortnames: !b || "undefined" == typeof b.shortnames || b.shortnames,
emojiTemplate: '

'
};
return N(b), g(function () {
c.each(function () {
var b = a(this);
return b.hasClass("emojionearea-text") || b.addClass("emojionearea-text").html(B(b.is("TEXTAREA") || b.is("INPUT") ? b.val() : b.text(), d)), b
})
}), this
}
}, window);
//# sourceMappingURL=emojionearea.min.map