1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-18 15:15:48 +02:00

Fix broken column names again and make getColumnName accessible to plugins

This commit is contained in:
chylex 2018-04-29 13:17:00 +02:00
parent 12525ac386
commit eac300627f
2 changed files with 16 additions and 16 deletions
Resources/Scripts

View File

@ -96,20 +96,24 @@
}; };
// //
// Function: Attempts to retrieve the column icon class. Returns undefined on failure. // Block: Fix columns missing any identifiable attributes to allow individual styles.
// //
const getColumnIconClass = function(column){ $(document).on("uiColumnRendered", function(e, data){
if (ensurePropertyExists(column, "ui", "_$chirpContainer")){ let icon = data.$column.find(".column-type-icon").first();
return column.ui._$chirpContainer.closest(".js-column").attr("data-td-icon"); return if icon.length !== 1;
}
}; let name = Array.prototype.find.call(icon[0].classList, cls => cls.startsWith("icon-"));
return if !name;
data.$column.attr("data-td-icon", name);
data.column._tduck_icon = name;
});
// //
// Function: Retrieves column name and caches it. // Block: Setup global function to retrieve the column name.
// //
const getColumnName = function(column){ window.TDGF_getColumnName = function(column){
let cached = column._tduck_icon || (column._tduck_icon = getColumnIconClass(column)); return columnTitles[column._tduck_icon] || "";
return columnTitles[cached] || "";
}; };
// //
@ -234,7 +238,7 @@
let tweetUrl = source ? source.getChirpURL() : ""; let tweetUrl = source ? source.getChirpURL() : "";
let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : ""; let quoteUrl = source && source.quotedTweet ? source.quotedTweet.getChirpURL() : "";
$TD.onTweetPopup(column.model.privateState.apiid, chirpId, getColumnName(column), html.html(), duration, tweetUrl, quoteUrl); $TD.onTweetPopup(column.model.privateState.apiid, chirpId, window.TDGF_getColumnName(column), html.html(), duration, tweetUrl, quoteUrl);
} }
if (column.model.getHasSound()){ if (column.model.getHasSound()){
@ -1324,11 +1328,6 @@
}; };
} }
//
// Block: Fix columns missing any identifiable attributes to allow individual styles.
//
TD.mustaches["column.mustache"] = TD.mustaches["column.mustache"].replace("{{columnclass}}\"", "{{columnclass}}\" data-td-icon=\"{{columniconclass}}\"");
// //
// Block: Remove column mouse wheel handler, which allows smooth scrolling inside columns, and horizontally scrolling column container when holding Shift. // Block: Remove column mouse wheel handler, which allows smooth scrolling inside columns, and horizontally scrolling column container when holding Shift.
// //

View File

@ -117,6 +117,7 @@
// //
// Block: Setup bridges to global functions. // Block: Setup bridges to global functions.
// //
window.TDPF_getColumnName = window.TDGF_getColumnName;
window.TDPF_playVideo = window.TDGF_playVideo; window.TDPF_playVideo = window.TDGF_playVideo;
window.TDPF_reloadColumns = window.TDGF_reloadColumns; window.TDPF_reloadColumns = window.TDGF_reloadColumns;
window.TDPF_prioritizeNewestEvent = window.TDGF_prioritizeNewestEvent; window.TDPF_prioritizeNewestEvent = window.TDGF_prioritizeNewestEvent;