Demo
Phiên bản: Mọi phiên bản
Tạo Javascript mới:
Code:
$(function() {
var modButton = true, admButton = true,
modImage = 'http://i39.servimg.com/u/f39/18/21/41/30/bouton11.png',
admImage = 'http://i39.servimg.com/u/f39/18/21/41/30/bouton10.png';
if (_userdata.user_level != 0 && modButton === true) {
$("#text_editor_textarea").before("<img src='"+modImage+"' title='Moderator warning' id='mod-b'/>");
$('#mod-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('[mod]','[/mod]')});
}
if (_userdata.user_level === 1 && admButton === true) {
$("#text_editor_textarea").before("<img src='"+admImage+"' title='Admin warning' id='adm-b'/>");
$('#adm-b').click(function(){$('#text_editor_textarea').sceditor('instance').insertText('[adm]','[/adm]')});
}
$('div.postbody div').each(function () {
if ($(this).text().indexOf('[adm]') != -1) $(this).html($(this).html().replace(/\[adm\](.+?)\[\/adm\]/gi, '<div class="adm_mess"><div class="titl">Administrator Warning</div><div>$1 </div></div>'));
if ($(this).text().indexOf('[mod]') != -1) $(this).html($(this).html().replace(/\[mod\](.+?)\[\/mod\]/gi, '<div class="mod_mess"><div class="titl">Moderator Warning</div><div>$1 </div></div>'));
});
});
Hướng dẫn sử dụng:
modButton : Bật tắt BBcode cho Moderator, có 2 giá trị: true hoặc false
admButton : Bật tắt BBcode cho Administrator, có 2 giá trị: true hoặc false
true : Bật
false : Tắt
modImage : Đổi ảnh của thông báo Moderator. Tìm: https://i.servimg.com/u/f39/18/21/41/30/bouton11.png và đổi bằng ảnh của bạn
admImage : Đổi ảnh của thông báo Administrator https://i.servimg.com/u/f39/18/21/41/30/bouton10.png và đổi ảnh của bạn
Thêm tiếp vào CSS:
Code:
.mod_mess, .adm_mess {margin: 5px auto;width: 90%;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;} .mod_mess a.postlink, .adm_mess a.postlink {color: #FFF !important;text-decoration: underline !important;} .adm_mess {background: #e54858;background: -moz-linear-gradient(left, #e54858 0%, #f5b57a 100%);background: -webkit-gradient(linear, left top, right top, color-stop(0%, #e54858), color-stop(100%, #f5b57a));background: -webkit-linear-gradient(left, #e54858 0%, #f5b57a 100%);background: -o-linear-gradient(left, #e54858 0%, #f5b57a 100%);background: -ms-linear-gradient(left, #e54858 0%, #f5b57a 100%);background: linear-gradient(left, #e54858 0%, #f5b57a 100%);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#e54858",endColorstr="#f5b57a", GradientType=1);-webkit-box-shadow: 4px 4px 0px 0px #352727;-moz-box-shadow: 4px 4px 0px 0px #352727;box-shadow: 4px 4px 0px 0px #352727;} .adm_mess .titl {font-size: 15px;font-weight: bold;padding: 5px;border-bottom: 1px dashed #B60505; } .adm_mess .titl + div {display: block;margin-left: 10px;padding: 25px 5px 25px 80px;background: transparent url(http://i33.servimg.com/u/f33/17/37/83/89/gnome-10.png) no-repeat left center;} .mod_mess {background: #5c93f5;background: -moz-linear-gradient(left, #5c93f5 0%, #afcfda 100%);background: -webkit-gradient(linear, left top, right top, color-stop(0%, #5c93f5), color-stop(100%, #afcfda));background: -webkit-linear-gradient(left, #5c93f5 0%, #afcfda 100%);background: -o-linear-gradient(left, #5c93f5 0%, #afcfda 100%);background: -ms-linear-gradient(left, #5c93f5 0%, #afcfda 100%);background: linear-gradient(left, #5c93f5 0%, #afcfda 100%);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#5c93f5",endColorstr="#afcfda", GradientType=1);-webkit-box-shadow: 4px 4px 0px 0px #352727;-moz-box-shadow: 4px 4px 0px 0px #352727;box-shadow: 4px 4px 0px 0px #352727;} .mod_mess .titl {font-size: 15px;font-weight: bold;padding: 5px;border-bottom: 1px dashed #0D4DD3; } .mod_mess .titl + div {display: block;margin-left: 10px;padding: 25px 5px 25px 80px;background: transparent url(http://i33.servimg.com/u/f33/17/37/83/89/gnome610.png) no-repeat left center; }
Tùy chỉnh CSS của bạn như thế này:
Tags: #code #javascript