EmoteList live reconfig support

This commit is contained in:
Xaekai 2022-01-20 20:23:26 -08:00 committed by Calvin Montgomery
parent 9f9bbfa022
commit de1f37735b
1 changed files with 34 additions and 15 deletions

View File

@ -2891,17 +2891,36 @@ function formatScriptAccessPrefs() {
}); });
} }
function EmoteList(selector, emoteClickCallback) {
this.elem = $(selector); class EmoteList {
this.initSearch(); constructor(selector, emoteClickCallback){
this.initSortOption(); this._cols = 5;
this.table = this.elem.find(".emotelist-table")[0]; this._itemsPerPage = 25;
this.paginatorContainer = this.elem.find(".emotelist-paginator-container"); this.elem = $(selector);
this.cols = 5; this.initSearch();
this.itemsPerPage = 25; this.initSortOption();
this.emotes = []; this.table = this.elem.find(".emotelist-table")[0];
this.page = 0; this.paginatorContainer = this.elem.find(".emotelist-paginator-container");
this.emoteClickCallback = emoteClickCallback || function(){}; this.emotes = [];
this.page = 0;
this.emoteClickCallback = emoteClickCallback || function(){};
}
set itemsPerPage(val) {
this.page = 0;
this._itemsPerPage = val;
this.handleChange();
}
get itemsPerPage() {
return this._itemsPerPage;
}
set cols(val) {
this.page = 0;
this._cols = val;
this.handleChange();
}
get cols() {
return this._cols;
}
} }
EmoteList.prototype.initSearch = function () { EmoteList.prototype.initSearch = function () {
@ -3019,12 +3038,12 @@ function onEmoteClicked(emote) {
window.EMOTELIST = new EmoteList("#emotelist", onEmoteClicked); window.EMOTELIST = new EmoteList("#emotelist", onEmoteClicked);
window.EMOTELIST.sortAlphabetical = USEROPTS.emotelist_sort; window.EMOTELIST.sortAlphabetical = USEROPTS.emotelist_sort;
function CSEmoteList(selector) { class CSEmoteList extends EmoteList {
EmoteList.call(this, selector); constructor(selector) {
super(selector);
}
} }
CSEmoteList.prototype = Object.create(EmoteList.prototype);
CSEmoteList.prototype.loadPage = function (page) { CSEmoteList.prototype.loadPage = function (page) {
var tbody = this.table.children[1]; var tbody = this.table.children[1];
tbody.innerHTML = ""; tbody.innerHTML = "";