Fixed edit emotes
This commit is contained in:
parent
97daae9090
commit
63a8d60ee1
25
js/main.js
25
js/main.js
|
@ -375,8 +375,20 @@ EmoteModule.prototype.injectEmote = function(node) {
|
|||
if(!node.parentElement) return;
|
||||
|
||||
var parent = node.parentElement;
|
||||
|
||||
if(parent.tagName != "SPAN") return;
|
||||
if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return;
|
||||
|
||||
var edited = false;
|
||||
|
||||
if($(parent.parentElement).hasClass("edited")) {
|
||||
parent = parent.parentElement.parentElement.firstChild; //:D
|
||||
edited = true;
|
||||
}
|
||||
|
||||
//if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return;
|
||||
|
||||
function inject() {
|
||||
if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) { return; }
|
||||
|
||||
var parentInnerHTML = parent.innerHTML;
|
||||
var words = parentInnerHTML.split(/\s+/g);
|
||||
|
@ -388,9 +400,7 @@ EmoteModule.prototype.injectEmote = function(node) {
|
|||
if(word.slice(0, 4) == "[!s]" ) {
|
||||
|
||||
parentInnerHTML = parentInnerHTML.replace("[!s]", "");
|
||||
|
||||
var markup = $(parent).parent();
|
||||
|
||||
var reactId = markup.attr("data-reactid");
|
||||
|
||||
if(spoilered.indexOf(reactId) > -1) {
|
||||
|
@ -398,7 +408,6 @@ EmoteModule.prototype.injectEmote = function(node) {
|
|||
}
|
||||
|
||||
markup.addClass("spoiler");
|
||||
|
||||
markup.on("click", function() {
|
||||
$(this).removeClass("spoiler");
|
||||
spoilered.push($(this).attr("data-reactid"));
|
||||
|
@ -459,6 +468,14 @@ EmoteModule.prototype.injectEmote = function(node) {
|
|||
//Scrollfix
|
||||
var scrollPane = $(".scroller.messages").first();
|
||||
scrollPane.scrollTop(scrollPane.scrollTop() + (newHeight - oldHeight));
|
||||
}
|
||||
|
||||
if(edited) {
|
||||
setTimeout(inject, 250);
|
||||
} else {
|
||||
inject();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EmoteModule.prototype.autoCapitalize = function() {
|
||||
|
|
Loading…
Reference in New Issue