Demo
Code:
http://www.hotrofm.net/post?f=1&mode=newtopic
Cách làm
Vào posting_body , thêm vào cuối templates posting_body code sau :
Code:
<script type="text/javascript">
//<![CDATA[
var dataTags = "comic, film, funny, cartoon, animation, music, vietnam, usuk, kpop, game, game mobile, ios game, android game, wp game, infographic, samsung, apple, microsoft, lg, blackberry, htc, oppo, sony, android, ios, windows phone, mobile, smartphone, tablet, phablet, smartwatch, computer, windows, os x, mac os, code, tutorial, skin, wallpaper, anime, design, guide tutorial, stock image, brushes, textures, fonts, software, firmware, update";
(function(a) {
var g = [],
h = dataTags.split(/\s?,\s?/),
b = a("#text_editor_textarea"),
d = a("#tagsInput"),
e = a("<select>", {
"class": "js-example-data-array",
multiple: "multiple",
css: {
width: "100%"
}
});
e.appendTo("#tagsSelect");
if (/\[hr\]\n?\[b\]Tags:\s\[\/b\]#/.test(b.val())) {
var f = b.val().split(/\[hr\]\n?\[b\]Tags:\s\[\/b\]/); - 1 === f[0].search(/\[quote="[^"]+"\]/) && -1 === f[1].indexOf("[/quote]") ? (b.val(f[0]), a.each(f[1].split(" "), function(c, k) {
a("<option>", {
value: k.replace("#", ""),
text: k.replace("#", "").replace(/-/g, " "),
selected: "selected"
}).appendTo(e)
}), d.val(f[1])) : b.val(b.val().replace(/\[hr\]\n?\[b\]Tags:\s\[\/b\](\#[^\[]+\s?)+/g, ""))
}
a.each(h, function(c, a) {
g[c] = {
id: a.replace(/\s/g, "-"),
text: a
}
});
e.select2({
data: g,
placeholder: "Th\u00eam nh\u00e3n cho b\u00e0i vi\u1ebft...",
tags: !0,
tokenSeparators: [","]
});
e.on("change", function() {
var c = e.val();
null !== c ? (a.each(c, function(a, b) {
-1 === h.indexOf(b.toLowerCase()) && (b = b.replace(/\s/g, "-").toLowerCase());
c[a] = "#" + b
}), d.val(c.join(" "))) : d.val("")
});
a('form[name="post"]').submit(function() {
var a = b.sceditor("instance");
"" !== d.val() && "" !== a.val() && a.val(a.val() + "[hr][b]Tags: [/b]" + d.val())
})
})(jQuery); //]]>
</script>
Rồi chèn code sau vào chỗ mình muốn :
Code:
<fieldset>
<dl><dt><label>Từ khóa </label></dt>
<dd id="tagsSelect">
<input id="tagsInput" type="hidden" />
</dd>
</dl>
</fieldset>
Xong , nhớ +1