mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-13 09:15:47 +02:00
Massive JS formatting refactoring
This commit is contained in:
parent
937c8e22c4
commit
6d6bb79199
Resources
Plugins
.debug
clear-columns
edit-design
emoji-keyboard
reply-account
templates
timeline-polls
Scripts
@ -2,6 +2,7 @@ enabled(){
|
|||||||
this.isDebugging = false;
|
this.isDebugging = false;
|
||||||
|
|
||||||
this.onKeyDown = (e) => {
|
this.onKeyDown = (e) => {
|
||||||
|
|
||||||
// ==========================
|
// ==========================
|
||||||
// F4 key - toggle debug mode
|
// F4 key - toggle debug mode
|
||||||
// ==========================
|
// ==========================
|
||||||
@ -11,8 +12,6 @@ enabled(){
|
|||||||
$(".nav-user-info").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33");
|
$(".nav-user-info").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug mode handling
|
|
||||||
|
|
||||||
else if (this.isDebugging){
|
else if (this.isDebugging){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -22,15 +21,16 @@ enabled(){
|
|||||||
// ===================================
|
// ===================================
|
||||||
|
|
||||||
if (e.keyCode === 78 || e.keyCode === 83){
|
if (e.keyCode === 78 || e.keyCode === 83){
|
||||||
var col = TD.controller.columnManager.getAllOrdered()[0];
|
let col = TD.controller.columnManager.getAllOrdered()[0];
|
||||||
|
let model = col.model;
|
||||||
|
|
||||||
var prevPopup = col.model.getHasNotification();
|
let prevPopup = model.getHasNotification();
|
||||||
var prevSound = col.model.getHasSound();
|
let prevSound = model.getHasSound();
|
||||||
|
|
||||||
col.model.setHasNotification(e.keyCode === 78);
|
model.setHasNotification(e.keyCode === 78);
|
||||||
col.model.setHasSound(e.keyCode === 83);
|
model.setHasSound(e.keyCode === 83);
|
||||||
|
|
||||||
$.publish("/notifications/new",[{
|
$.publish("/notifications/new", [{
|
||||||
column: col,
|
column: col,
|
||||||
items: [
|
items: [
|
||||||
col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
|
col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
|
||||||
@ -38,8 +38,8 @@ enabled(){
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
col.model.setHasNotification(prevPopup);
|
model.setHasNotification(prevPopup);
|
||||||
col.model.setHasSound(prevSound);
|
model.setHasSound(prevSound);
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,24 +6,24 @@ constructor(){
|
|||||||
|
|
||||||
enabled(){
|
enabled(){
|
||||||
// prepare variables and functions
|
// prepare variables and functions
|
||||||
var clearColumn = (columnName) => {
|
const clearColumn = (columnName) => {
|
||||||
TD.controller.columnManager.get(columnName).clear();
|
TD.controller.columnManager.get(columnName).clear();
|
||||||
TD.controller.stats.columnActionClick("clear");
|
TD.controller.stats.columnActionClick("clear");
|
||||||
};
|
};
|
||||||
|
|
||||||
var resetColumn = (columnName) => {
|
const resetColumn = (columnName) => {
|
||||||
let col = TD.controller.columnManager.get(columnName);
|
let col = TD.controller.columnManager.get(columnName);
|
||||||
col.model.setClearedTimestamp(0);
|
col.model.setClearedTimestamp(0);
|
||||||
col.reloadTweets();
|
col.reloadTweets();
|
||||||
};
|
};
|
||||||
|
|
||||||
var forEachColumn = (func) => {
|
const forEachColumn = (func) => {
|
||||||
Object.keys(TD.controller.columnManager.getAll()).forEach(func);
|
Object.keys(TD.controller.columnManager.getAll()).forEach(func);
|
||||||
};
|
};
|
||||||
|
|
||||||
var wasShiftPressed = false;
|
let wasShiftPressed = false;
|
||||||
|
|
||||||
var updateShiftState = (pressed) => {
|
const updateShiftState = (pressed) => {
|
||||||
if (pressed != wasShiftPressed){
|
if (pressed != wasShiftPressed){
|
||||||
wasShiftPressed = pressed;
|
wasShiftPressed = pressed;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ enabled(){
|
|||||||
|
|
||||||
// prepare event handlers
|
// prepare event handlers
|
||||||
this.eventClickSingle = function(e){
|
this.eventClickSingle = function(e){
|
||||||
var name = $(this).closest(".js-column").attr("data-column");
|
let name = $(this).closest(".js-column").attr("data-column");
|
||||||
e.shiftKey ? resetColumn(name) : clearColumn(name);
|
e.shiftKey ? resetColumn(name) : clearColumn(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,10 +58,10 @@ enabled(){
|
|||||||
forEachColumn(e.shiftKey ? resetColumn : clearColumn);
|
forEachColumn(e.shiftKey ? resetColumn : clearColumn);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var focusedColumn = $(".js-column.is-focused");
|
let focusedColumn = $(".js-column.is-focused");
|
||||||
|
|
||||||
if (focusedColumn.length){
|
if (focusedColumn.length){
|
||||||
var name = focusedColumn.attr("data-column");
|
let name = focusedColumn.attr("data-column");
|
||||||
e.shiftKey ? resetColumn(name) : clearColumn(name);
|
e.shiftKey ? resetColumn(name) : clearColumn(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ enabled(){
|
|||||||
window.TDPF_injectMustache("menus/column_nav_menu.mustache", "replace", "{{_i}}Add column{{/i}}</div> </a> </div>", `{{_i}}Add column{{/i}}</div></a>${this.btnClearAllHTML}</div>`)
|
window.TDPF_injectMustache("menus/column_nav_menu.mustache", "replace", "{{_i}}Add column{{/i}}</div> </a> </div>", `{{_i}}Add column{{/i}}</div></a>${this.btnClearAllHTML}</div>`)
|
||||||
|
|
||||||
// load custom style
|
// load custom style
|
||||||
var css = window.TDPF_createCustomStyle(this);
|
let css = window.TDPF_createCustomStyle(this);
|
||||||
css.insert(".js-app-add-column.is-hidden + .clear-columns-btn-all-parent { display: none; }");
|
css.insert(".js-app-add-column.is-hidden + .clear-columns-btn-all-parent { display: none; }");
|
||||||
css.insert(".column-header-links { min-width: 51px !important; }");
|
css.insert(".column-header-links { min-width: 51px !important; }");
|
||||||
css.insert("[data-td-icon='icon-message'] .column-header-links { min-width: 110px !important; }");
|
css.insert("[data-td-icon='icon-message'] .column-header-links { min-width: 110px !important; }");
|
||||||
@ -120,7 +120,7 @@ ready(){
|
|||||||
$(".js-app-add-column").first().after(this.btnClearAllHTML);
|
$(".js-app-add-column").first().after(this.btnClearAllHTML);
|
||||||
|
|
||||||
// setup tooltip handling
|
// setup tooltip handling
|
||||||
var tooltipEvents = $._data($(".js-header-action")[0]).events;
|
let tooltipEvents = $._data($(".js-header-action")[0], "events");
|
||||||
|
|
||||||
if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){
|
if (tooltipEvents.mouseover && tooltipEvents.mouseover.length && tooltipEvents.mouseout && tooltipEvents.mouseout.length){
|
||||||
$(".clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);
|
$(".clear-columns-btn-all-parent").on("mouseover", tooltipEvents.mouseover[0].handler).on("mouseout", tooltipEvents.mouseout[0].handler);
|
||||||
|
@ -21,7 +21,7 @@ enabled(){
|
|||||||
avatarRadius: 2
|
avatarRadius: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var prepareDefaultConfig = () => {
|
const prepareDefaultConfig = () => {
|
||||||
this.defaultConfig._theme = TD.settings.getTheme();
|
this.defaultConfig._theme = TD.settings.getTheme();
|
||||||
|
|
||||||
switch(TD.settings.getColumnWidth()){
|
switch(TD.settings.getColumnWidth()){
|
||||||
@ -39,7 +39,7 @@ enabled(){
|
|||||||
|
|
||||||
this.firstTimeLoad = null;
|
this.firstTimeLoad = null;
|
||||||
|
|
||||||
var me = this;
|
const me = this;
|
||||||
|
|
||||||
// modal dialog loading
|
// modal dialog loading
|
||||||
$TDP.readFileRoot(this.$token, "modal.html").then(contents => {
|
$TDP.readFileRoot(this.$token, "modal.html").then(contents => {
|
||||||
@ -72,7 +72,7 @@ enabled(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadConfigObject = obj => {
|
const loadConfigObject = obj => {
|
||||||
this.tmpConfig = obj || {};
|
this.tmpConfig = obj || {};
|
||||||
this.firstTimeLoad = obj === null;
|
this.firstTimeLoad = obj === null;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
// modal dialog setup
|
// modal dialog setup
|
||||||
var updateKey = function(key, value){
|
const updateKey = function(key, value){
|
||||||
me.config[key] = value;
|
me.config[key] = value;
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
@ -228,7 +228,7 @@ enabled(){
|
|||||||
if (value == me.config[key]){
|
if (value == me.config[key]){
|
||||||
item.addClass("selected");
|
item.addClass("selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
item.click(function(){
|
item.click(function(){
|
||||||
modal.find("[data-td-key='"+key+"']").removeClass("selected");
|
modal.find("[data-td-key='"+key+"']").removeClass("selected");
|
||||||
item.addClass("selected");
|
item.addClass("selected");
|
||||||
@ -407,7 +407,7 @@ enabled(){
|
|||||||
case "dark":
|
case "dark":
|
||||||
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-track, .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-track { border-left-color: #14171A !important }");
|
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-track, .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-track { border-left-color: #14171A !important }");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "light":
|
case "light":
|
||||||
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover), .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover) { background-color: #d2d6da !important }");
|
this.css.insert(".scroll-styled-v:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover), .scroll-styled-h:not(.scroll-alt)::-webkit-scrollbar-thumb:not(:hover) { background-color: #d2d6da !important }");
|
||||||
this.css.insert(".app-columns-container.scroll-styled-h::-webkit-scrollbar-thumb:not(:hover) { background-color: #a5aeb5 !important }");
|
this.css.insert(".app-columns-container.scroll-styled-h::-webkit-scrollbar-thumb:not(:hover) { background-color: #a5aeb5 !important }");
|
||||||
@ -643,7 +643,7 @@ ready(){
|
|||||||
$(".js-app").append('<div id="td-design-plugin-modal" class="js-modal settings-modal ovl scroll-v scroll-styled-v"></div>');
|
$(".js-app").append('<div id="td-design-plugin-modal" class="js-modal settings-modal ovl scroll-v scroll-styled-v"></div>');
|
||||||
|
|
||||||
// global settings override
|
// global settings override
|
||||||
var me = this;
|
const me = this;
|
||||||
|
|
||||||
this.prevFuncSettingsGetInfo = TD.components.GlobalSettings.prototype.getInfo;
|
this.prevFuncSettingsGetInfo = TD.components.GlobalSettings.prototype.getInfo;
|
||||||
this.prevFuncSettingsSwitchTab = TD.components.GlobalSettings.prototype.switchTab;
|
this.prevFuncSettingsSwitchTab = TD.components.GlobalSettings.prototype.switchTab;
|
||||||
|
@ -26,7 +26,7 @@ enabled(){
|
|||||||
this.emojiData3 = []; // no skin tones, appended
|
this.emojiData3 = []; // no skin tones, appended
|
||||||
this.emojiNames = [];
|
this.emojiNames = [];
|
||||||
|
|
||||||
var me = this;
|
const me = this;
|
||||||
|
|
||||||
// styles
|
// styles
|
||||||
|
|
||||||
@ -51,12 +51,12 @@ enabled(){
|
|||||||
|
|
||||||
// layout
|
// layout
|
||||||
|
|
||||||
var buttonHTML = '<button class="needsclick btn btn-on-blue txt-left padding-v--6 padding-h--8 emoji-keyboard-popup-btn"><i class="icon icon-heart"></i></button>';
|
let buttonHTML = '<button class="needsclick btn btn-on-blue txt-left padding-v--6 padding-h--8 emoji-keyboard-popup-btn"><i class="icon icon-heart"></i></button>';
|
||||||
|
|
||||||
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
|
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
|
||||||
window.TDPF_injectMustache("compose/docked_compose.mustache", "append", '<div class="cf margin-t--12 margin-b--30">', buttonHTML);
|
window.TDPF_injectMustache("compose/docked_compose.mustache", "append", '<div class="cf margin-t--12 margin-b--30">', buttonHTML);
|
||||||
|
|
||||||
var maybeDockedComposePanel = $(".js-docked-compose");
|
let maybeDockedComposePanel = $(".js-docked-compose");
|
||||||
|
|
||||||
if (maybeDockedComposePanel.length){
|
if (maybeDockedComposePanel.length){
|
||||||
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
|
maybeDockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
|
||||||
@ -67,10 +67,10 @@ enabled(){
|
|||||||
this.currentKeyboard = null;
|
this.currentKeyboard = null;
|
||||||
this.currentSpanner = null;
|
this.currentSpanner = null;
|
||||||
|
|
||||||
var wasSearchFocused = false;
|
let wasSearchFocused = false;
|
||||||
var lastEmojiKeyword, lastEmojiPosition, lastEmojiLength;
|
let lastEmojiKeyword, lastEmojiPosition, lastEmojiLength;
|
||||||
|
|
||||||
var hideKeyboard = (refocus) => {
|
const hideKeyboard = (refocus) => {
|
||||||
$(this.currentKeyboard).remove();
|
$(this.currentKeyboard).remove();
|
||||||
this.currentKeyboard = null;
|
this.currentKeyboard = null;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ enabled(){
|
|||||||
lastEmojiKeyword = null;
|
lastEmojiKeyword = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
var generateEmojiHTML = skinTone => {
|
const generateEmojiHTML = skinTone => {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that some emoji may not show up correctly in the text box above, but they will display in the tweet.</p>" ];
|
let html = [ "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that some emoji may not show up correctly in the text box above, but they will display in the tweet.</p>" ];
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ enabled(){
|
|||||||
return html.join("");
|
return html.join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateFilters = () => {
|
const updateFilters = () => {
|
||||||
let keywords = this.currentKeywords;
|
let keywords = this.currentKeywords;
|
||||||
let container = $(this.currentKeyboard.children[1]);
|
let container = $(this.currentKeyboard.children[1]);
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ enabled(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var selectSkinTone = skinTone => {
|
const selectSkinTone = skinTone => {
|
||||||
let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']");
|
let selectedEle = this.currentKeyboard.children[2].querySelector("[data-tone='"+this.selectedSkinTone+"']");
|
||||||
selectedEle && selectedEle.classList.remove("sel");
|
selectedEle && selectedEle.classList.remove("sel");
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.generateKeyboard = (left, top) => {
|
this.generateKeyboard = (left, top) => {
|
||||||
var outer = document.createElement("div");
|
let outer = document.createElement("div");
|
||||||
outer.classList.add("emoji-keyboard");
|
outer.classList.add("emoji-keyboard");
|
||||||
outer.style.left = left+"px";
|
outer.style.left = left+"px";
|
||||||
outer.style.top = top+"px";
|
outer.style.top = top+"px";
|
||||||
|
|
||||||
var keyboard = document.createElement("div");
|
let keyboard = document.createElement("div");
|
||||||
keyboard.classList.add("emoji-keyboard-list");
|
keyboard.classList.add("emoji-keyboard-list");
|
||||||
|
|
||||||
keyboard.addEventListener("click", function(e){
|
keyboard.addEventListener("click", function(e){
|
||||||
@ -164,11 +164,11 @@ enabled(){
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
var search = document.createElement("div");
|
let search = document.createElement("div");
|
||||||
search.innerHTML = "<input type='text' placeholder='Search...'>";
|
search.innerHTML = "<input type='text' placeholder='Search...'>";
|
||||||
search.classList.add("emoji-keyboard-search");
|
search.classList.add("emoji-keyboard-search");
|
||||||
|
|
||||||
var skintones = document.createElement("div");
|
let skintones = document.createElement("div");
|
||||||
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
|
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
|
||||||
skintones.classList.add("emoji-keyboard-skintones");
|
skintones.classList.add("emoji-keyboard-skintones");
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ enabled(){
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
var searchInput = search.children[0];
|
let searchInput = search.children[0];
|
||||||
searchInput.focus();
|
searchInput.focus();
|
||||||
|
|
||||||
wasSearchFocused = false;
|
wasSearchFocused = false;
|
||||||
@ -232,21 +232,21 @@ enabled(){
|
|||||||
this.composePanelScroller.trigger("scroll");
|
this.composePanelScroller.trigger("scroll");
|
||||||
};
|
};
|
||||||
|
|
||||||
var getKeyboardTop = () => {
|
const getKeyboardTop = () => {
|
||||||
let button = $(".emoji-keyboard-popup-btn");
|
let button = $(".emoji-keyboard-popup-btn");
|
||||||
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
|
return button.offset().top+button.outerHeight()+me.composePanelScroller.scrollTop()+8;
|
||||||
};
|
};
|
||||||
|
|
||||||
var insertEmoji = (src, alt) => {
|
const insertEmoji = (src, alt) => {
|
||||||
let input = this.composeInput;
|
let input = this.composeInput;
|
||||||
|
|
||||||
let val = input.val();
|
let val = input.val();
|
||||||
let posStart = input[0].selectionStart;
|
let posStart = input[0].selectionStart;
|
||||||
let posEnd = input[0].selectionEnd;
|
let posEnd = input[0].selectionEnd;
|
||||||
|
|
||||||
input.val(val.slice(0, posStart)+alt+val.slice(posEnd));
|
input.val(val.slice(0, posStart)+alt+val.slice(posEnd));
|
||||||
input.trigger("change");
|
input.trigger("change");
|
||||||
|
|
||||||
input[0].selectionStart = posStart+alt.length;
|
input[0].selectionStart = posStart+alt.length;
|
||||||
input[0].selectionEnd = posStart+alt.length;
|
input[0].selectionEnd = posStart+alt.length;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ enabled(){
|
|||||||
if (ele.selectionStart === lastEmojiPosition){
|
if (ele.selectionStart === lastEmojiPosition){
|
||||||
ele.selectionStart -= lastEmojiLength; // selects the emoji
|
ele.selectionStart -= lastEmojiLength; // selects the emoji
|
||||||
document.execCommand("insertText", false, lastEmojiKeyword);
|
document.execCommand("insertText", false, lastEmojiKeyword);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ ready(){
|
|||||||
|
|
||||||
// HTML generation
|
// HTML generation
|
||||||
|
|
||||||
var convUnicode = function(codePt){
|
const convUnicode = function(codePt){
|
||||||
if (codePt > 0xFFFF){
|
if (codePt > 0xFFFF){
|
||||||
codePt -= 0x10000;
|
codePt -= 0x10000;
|
||||||
return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF));
|
return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF));
|
||||||
@ -489,7 +489,7 @@ ready(){
|
|||||||
|
|
||||||
if (skinToneState === 1){
|
if (skinToneState === 1){
|
||||||
let skinIndex = decl.indexOf('$');
|
let skinIndex = decl.indexOf('$');
|
||||||
|
|
||||||
if (skinIndex !== -1){
|
if (skinIndex !== -1){
|
||||||
let declPre = decl.slice(0, skinIndex);
|
let declPre = decl.slice(0, skinIndex);
|
||||||
let declPost = decl.slice(skinIndex+1);
|
let declPost = decl.slice(skinIndex+1);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
enabled(){
|
enabled(){
|
||||||
var configuration = { defaultAccount: "#preferred" };
|
let configuration = { defaultAccount: "#preferred" };
|
||||||
|
|
||||||
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => configuration = obj);
|
window.TDPF_loadConfigurationFile(this, "configuration.js", "configuration.default.js", obj => configuration = obj);
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ enabled(){
|
|||||||
this.uiComposeTweetEvent = (e, data) => {
|
this.uiComposeTweetEvent = (e, data) => {
|
||||||
return if !(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data);
|
return if !(data.type === "reply" || (data.type === "tweet" && "quotedTweet" in data)) || data.popFromInline || !("element" in data);
|
||||||
|
|
||||||
var query;
|
let query;
|
||||||
|
|
||||||
if (configuration.useAdvancedSelector){
|
if (configuration.useAdvancedSelector){
|
||||||
if (configuration.customSelector){
|
if (configuration.customSelector){
|
||||||
@ -88,7 +88,7 @@ enabled(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var identifier = null;
|
let identifier = null;
|
||||||
|
|
||||||
switch(query){
|
switch(query){
|
||||||
case "#preferred":
|
case "#preferred":
|
||||||
@ -106,7 +106,7 @@ enabled(){
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (query[0] === '@'){
|
if (query[0] === '@'){
|
||||||
var obj = TD.storage.accountController.getAccountFromUsername(query.substring(1));
|
let obj = TD.storage.accountController.getAccountFromUsername(query.substring(1));
|
||||||
|
|
||||||
if (obj.length === 0){
|
if (obj.length === 0){
|
||||||
$TD.alert("warning", "Plugin reply-account has invalid configuration: requested account not found: "+query);
|
$TD.alert("warning", "Plugin reply-account has invalid configuration: requested account not found: "+query);
|
||||||
@ -126,7 +126,7 @@ enabled(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.onSelectedAccountChanged = () => {
|
this.onSelectedAccountChanged = () => {
|
||||||
var selected = $(".js-account-item.is-selected", ".js-account-list");
|
let selected = $(".js-account-item.is-selected", ".js-account-list");
|
||||||
this.lastSelectedAccount = selected.length === 1 ? selected.attr("data-account-key") : null;
|
this.lastSelectedAccount = selected.length === 1 ? selected.attr("data-account-key") : null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,12 @@ enabled(){
|
|||||||
|
|
||||||
// button
|
// button
|
||||||
|
|
||||||
var buttonHTML = '<button class="manage-templates-btn needsclick btn btn-on-blue full-width txt-left margin-b--12 padding-v--6 padding-h--12"><i class="icon icon-bookmark"></i><span class="label padding-ls">Manage templates</span></button>';
|
let buttonHTML = '<button class="manage-templates-btn needsclick btn btn-on-blue full-width txt-left margin-b--12 padding-v--6 padding-h--12"><i class="icon icon-bookmark"></i><span class="label padding-ls">Manage templates</span></button>';
|
||||||
|
|
||||||
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
|
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
|
||||||
window.TDPF_injectMustache("compose/docked_compose.mustache", "prepend", '<div class="js-tweet-type-button">', buttonHTML);
|
window.TDPF_injectMustache("compose/docked_compose.mustache", "prepend", '<div class="js-tweet-type-button">', buttonHTML);
|
||||||
|
|
||||||
var dockedComposePanel = $(".js-docked-compose");
|
let dockedComposePanel = $(".js-docked-compose");
|
||||||
|
|
||||||
if (dockedComposePanel.length){
|
if (dockedComposePanel.length){
|
||||||
dockedComposePanel.find(".js-tweet-type-button").first().before(buttonHTML);
|
dockedComposePanel.find(".js-tweet-type-button").first().before(buttonHTML);
|
||||||
@ -57,7 +57,7 @@ enabled(){
|
|||||||
|
|
||||||
// template implementation
|
// template implementation
|
||||||
|
|
||||||
var readTemplateTokens = (contents, tokenData) => {
|
const readTemplateTokens = (contents, tokenData) => {
|
||||||
let startIndex = -1;
|
let startIndex = -1;
|
||||||
let endIndex = -1;
|
let endIndex = -1;
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ enabled(){
|
|||||||
return [ contents, data ];
|
return [ contents, data ];
|
||||||
};
|
};
|
||||||
|
|
||||||
var doAjaxRequest = (index, url, evaluator) => {
|
const doAjaxRequest = (index, url, evaluator) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!url){
|
if (!url){
|
||||||
resolve([ index, "{ajax}" ]);
|
resolve([ index, "{ajax}" ]);
|
||||||
@ -145,7 +145,7 @@ enabled(){
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var useTemplate = (contents, append) => {
|
const useTemplate = (contents, append) => {
|
||||||
let ele = $(".js-compose-text");
|
let ele = $(".js-compose-text");
|
||||||
return if ele.length === 0;
|
return if ele.length === 0;
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ enabled(){
|
|||||||
url = evaluator;
|
url = evaluator;
|
||||||
evaluator = null;
|
evaluator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(doAjaxRequest(index2, url, evaluator));
|
promises.push(doAjaxRequest(index2, url, evaluator));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ enabled(){
|
|||||||
|
|
||||||
this.editingTemplate = null;
|
this.editingTemplate = null;
|
||||||
|
|
||||||
var showTemplateModal = () => {
|
const showTemplateModal = () => {
|
||||||
$(".js-app-content").prepend(this.htmlModal);
|
$(".js-app-content").prepend(this.htmlModal);
|
||||||
|
|
||||||
/* TODO possibly implement this later
|
/* TODO possibly implement this later
|
||||||
@ -328,11 +328,11 @@ enabled(){
|
|||||||
onTemplatesUpdated(false);
|
onTemplatesUpdated(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
var hideTemplateModal = function(){
|
const hideTemplateModal = () => {
|
||||||
$("#templates-modal-wrap").remove();
|
$("#templates-modal-wrap").remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
var toggleEditor = function(){
|
const toggleEditor = () => {
|
||||||
let editor = $("#template-editor");
|
let editor = $("#template-editor");
|
||||||
$("[name]", editor).val("");
|
$("[name]", editor).val("");
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ enabled(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onTemplatesUpdated = (save) => {
|
const onTemplatesUpdated = (save) => {
|
||||||
let eles = [];
|
let eles = [];
|
||||||
|
|
||||||
for(let identifier of Object.keys(this.config.templates)){
|
for(let identifier of Object.keys(this.config.templates)){
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<button data-action="new-template" class="Button--primary"><i class="icon icon-plus icon-small padding-rs"></i><span class="label">New Template</span></button>
|
<button data-action="new-template" class="Button--primary"><i class="icon icon-plus icon-small padding-rs"></i><span class="label">New Template</span></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="template-editor" class="invisible">
|
<div id="template-editor" class="invisible">
|
||||||
<div class="template-editor-form">
|
<div class="template-editor-form">
|
||||||
<div class="compose-text-title">Template Name</div>
|
<div class="compose-text-title">Template Name</div>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="compose-text-title">Contents</div>
|
<div class="compose-text-title">Contents</div>
|
||||||
<textarea name="template-contents" class="compose-text scroll-v scroll-styled-v scroll-styled-h scroll-alt"></textarea>
|
<textarea name="template-contents" class="compose-text scroll-v scroll-styled-v scroll-styled-h scroll-alt"></textarea>
|
||||||
|
|
||||||
<div class="compose-text-title template-editor-tips-button">Advanced <i class="icon icon-arrow-d"></i></div>
|
<div class="compose-text-title template-editor-tips-button">Advanced <i class="icon icon-arrow-d"></i></div>
|
||||||
<div class="template-editor-tips">
|
<div class="template-editor-tips">
|
||||||
<p>You can use the following tokens. All tokens except for <span style="font-family: monospace">{ajax}</span> can only be used once.</p>
|
<p>You can use the following tokens. All tokens except for <span style="font-family: monospace">{ajax}</span> can only be used once.</p>
|
||||||
@ -69,7 +69,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.templates-modal-bottom {
|
.templates-modal-bottom {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
@ -92,7 +92,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Template list */
|
/* Template list */
|
||||||
|
|
||||||
#template-list {
|
#template-list {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
|
@ -38,7 +38,7 @@ enabled(){
|
|||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
|
|
||||||
var funcs = {
|
const funcs = {
|
||||||
TwitterStatus: TD.services.TwitterStatus.prototype.render,
|
TwitterStatus: TD.services.TwitterStatus.prototype.render,
|
||||||
TwitterActionOnTweet: TD.services.TwitterActionOnTweet.prototype.render,
|
TwitterActionOnTweet: TD.services.TwitterActionOnTweet.prototype.render,
|
||||||
TweetDetailView: TD.components.TweetDetailView.prototype._renderChirp
|
TweetDetailView: TD.components.TweetDetailView.prototype._renderChirp
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
//
|
//
|
||||||
// Variable: Current highlighted column jQuery & data objects.
|
// Variable: Current highlighted column jQuery & data objects.
|
||||||
//
|
//
|
||||||
var highlightedColumnEle, highlightedColumnObj;
|
let highlightedColumnEle, highlightedColumnObj;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variable: Currently highlighted tweet jQuery & data objects.
|
// Variable: Currently highlighted tweet jQuery & data objects.
|
||||||
//
|
//
|
||||||
var highlightedTweetEle, highlightedTweetObj;
|
let highlightedTweetEle, highlightedTweetObj;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variable: Array of functions called after the website app is loaded.
|
// Variable: Array of functions called after the website app is loaded.
|
||||||
//
|
//
|
||||||
var onAppReady = [];
|
let onAppReady = [];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variable: DOM HTML element.
|
// Variable: DOM HTML element.
|
||||||
@ -116,10 +116,10 @@
|
|||||||
$(document).on("uiColumnRendered", function(e, data){
|
$(document).on("uiColumnRendered", function(e, data){
|
||||||
let icon = data.$column.find(".column-type-icon").first();
|
let icon = data.$column.find(".column-type-icon").first();
|
||||||
return if icon.length !== 1;
|
return if icon.length !== 1;
|
||||||
|
|
||||||
let name = Array.prototype.find.call(icon[0].classList, cls => cls.startsWith("icon-"));
|
let name = Array.prototype.find.call(icon[0].classList, cls => cls.startsWith("icon-"));
|
||||||
return if !name;
|
return if !name;
|
||||||
|
|
||||||
data.$column.attr("data-td-icon", name);
|
data.$column.attr("data-td-icon", name);
|
||||||
data.column._tduck_icon = name;
|
data.column._tduck_icon = name;
|
||||||
});
|
});
|
||||||
@ -278,10 +278,10 @@
|
|||||||
let chirpId = source ? source.id : "";
|
let chirpId = source ? source.id : "";
|
||||||
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, window.TDGF_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()){
|
||||||
$TD.onTweetSound();
|
$TD.onTweetSound();
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@
|
|||||||
const showTweetDetailInternal = function(column, chirp){
|
const showTweetDetailInternal = function(column, chirp){
|
||||||
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
TD.ui.updates.showDetailView(column, chirp, column.findChirp(chirp) || chirp);
|
||||||
TD.controller.columnManager.showColumn(column.model.privateState.key);
|
TD.controller.columnManager.showColumn(column.model.privateState.key);
|
||||||
|
|
||||||
$(document).trigger("uiGridClearSelection");
|
$(document).trigger("uiGridClearSelection");
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -368,11 +368,11 @@
|
|||||||
TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize, function(name){
|
TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize, function(name){
|
||||||
setTimeout(refreshSettings, 0);
|
setTimeout(refreshSettings, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
TD.settings.setTheme = appendToFunction(TD.settings.setTheme, function(name){
|
TD.settings.setTheme = appendToFunction(TD.settings.setTheme, function(name){
|
||||||
setTimeout(refreshSettings, 0);
|
setTimeout(refreshSettings, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
onAppReady.push(refreshSettings);
|
onAppReady.push(refreshSettings);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -397,7 +397,7 @@
|
|||||||
TD.controller.notifications.hasNotifications = function(){
|
TD.controller.notifications.hasNotifications = function(){
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
TD.controller.notifications.isPermissionGranted = function(){
|
TD.controller.notifications.isPermissionGranted = function(){
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -420,11 +420,11 @@
|
|||||||
|
|
||||||
let button = $('<li class="is-selectable" data-tweetduck><a href="#" data-action>TweetDuck</a></li>');
|
let button = $('<li class="is-selectable" data-tweetduck><a href="#" data-action>TweetDuck</a></li>');
|
||||||
button.insertBefore(menu.children(".drp-h-divider").last());
|
button.insertBefore(menu.children(".drp-h-divider").last());
|
||||||
|
|
||||||
button.on("click", "a", function(){
|
button.on("click", "a", function(){
|
||||||
$TD.openContextMenu();
|
$TD.openContextMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
button.hover(function(){
|
button.hover(function(){
|
||||||
$(this).addClass("is-selected");
|
$(this).addClass("is-selected");
|
||||||
}, function(){
|
}, function(){
|
||||||
@ -438,8 +438,8 @@
|
|||||||
// Block: Expand shortened links on hover or display tooltip.
|
// Block: Expand shortened links on hover or display tooltip.
|
||||||
//
|
//
|
||||||
(function(){
|
(function(){
|
||||||
var prevMouseX = -1, prevMouseY = -1;
|
let prevMouseX = -1, prevMouseY = -1;
|
||||||
var tooltipTimer, tooltipDisplayed;
|
let tooltipTimer, tooltipDisplayed;
|
||||||
|
|
||||||
$(document.body).delegate("a[data-full-url]", {
|
$(document.body).delegate("a[data-full-url]", {
|
||||||
mouseenter: function(){
|
mouseenter: function(){
|
||||||
@ -906,7 +906,7 @@
|
|||||||
$(document).on("dataTweetSent", function(e, data){
|
$(document).on("dataTweetSent", function(e, data){
|
||||||
if (data.response.state && data.response.state === "scheduled"){
|
if (data.response.state && data.response.state === "scheduled"){
|
||||||
let column = Object.values(TD.controller.columnManager.getAll()).find(column => column.model.state.type === "scheduled");
|
let column = Object.values(TD.controller.columnManager.getAll()).find(column => column.model.state.type === "scheduled");
|
||||||
|
|
||||||
if (column){
|
if (column){
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
column.reloadTweets();
|
column.reloadTweets();
|
||||||
@ -922,7 +922,7 @@
|
|||||||
(function(){
|
(function(){
|
||||||
return if !ensurePropertyExists(TD, "vo", "Column", "prototype", "clear");
|
return if !ensurePropertyExists(TD, "vo", "Column", "prototype", "clear");
|
||||||
|
|
||||||
var holdingShift = false;
|
let holdingShift = false;
|
||||||
|
|
||||||
const updateShiftState = (pressed) => {
|
const updateShiftState = (pressed) => {
|
||||||
if (pressed != holdingShift){
|
if (pressed != holdingShift){
|
||||||
@ -1174,7 +1174,7 @@
|
|||||||
return if !ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer");
|
return if !ensurePropertyExists(TD, "components", "BaseModal", "prototype", "setAndShowContainer");
|
||||||
return if !ensurePropertyExists(TD, "ui", "Column", "prototype", "playGifIfNotManuallyPaused");
|
return if !ensurePropertyExists(TD, "ui", "Column", "prototype", "playGifIfNotManuallyPaused");
|
||||||
|
|
||||||
var cancelModal = false;
|
let cancelModal = false;
|
||||||
|
|
||||||
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
|
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
|
||||||
let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
let media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
||||||
@ -1184,7 +1184,7 @@
|
|||||||
cancelModal = true;
|
cancelModal = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TD.components.BaseModal.prototype.setAndShowContainer = prependToFunction(TD.components.BaseModal.prototype.setAndShowContainer, function(){
|
TD.components.BaseModal.prototype.setAndShowContainer = prependToFunction(TD.components.BaseModal.prototype.setAndShowContainer, function(){
|
||||||
if (cancelModal){
|
if (cancelModal){
|
||||||
cancelModal = false;
|
cancelModal = false;
|
||||||
@ -1215,12 +1215,13 @@
|
|||||||
// Block: Add a pin icon to make tweet compose drawer stay open.
|
// Block: Add a pin icon to make tweet compose drawer stay open.
|
||||||
//
|
//
|
||||||
onAppReady.push(function(){
|
onAppReady.push(function(){
|
||||||
let ele = $(`<svg id="td-compose-drawer-pin" viewBox="0 0 24 24" class="icon js-show-tip" data-original-title="Stay open" data-tooltip-position="left">
|
let ele = $(`
|
||||||
|
<svg id="td-compose-drawer-pin" viewBox="0 0 24 24" class="icon js-show-tip" data-original-title="Stay open" data-tooltip-position="left">
|
||||||
<path d="M9.884,16.959l3.272,0.001l-0.82,4.568l-1.635,0l-0.817,-4.569Z"/>
|
<path d="M9.884,16.959l3.272,0.001l-0.82,4.568l-1.635,0l-0.817,-4.569Z"/>
|
||||||
<rect x="8.694" y="7.208" width="5.652" height="7.445"/>
|
<rect x="8.694" y="7.208" width="5.652" height="7.445"/>
|
||||||
<path d="M16.877,17.448c0,-1.908 -1.549,-3.456 -3.456,-3.456l-3.802,0c-1.907,0 -3.456,1.548 -3.456,3.456l10.714,0Z"/>
|
<path d="M16.877,17.448c0,-1.908 -1.549,-3.456 -3.456,-3.456l-3.802,0c-1.907,0 -3.456,1.548 -3.456,3.456l10.714,0Z"/>
|
||||||
<path d="M6.572,5.676l2.182,2.183l5.532,0l2.182,-2.183l0,-1.455l-9.896,0l0,1.455Z"/>
|
<path d="M6.572,5.676l2.182,2.183l5.532,0l2.182,-2.183l0,-1.455l-9.896,0l0,1.455Z"/>
|
||||||
</svg>`).appendTo(".js-docked-compose .js-compose-header");
|
</svg>`).appendTo(".js-docked-compose .js-compose-header");
|
||||||
|
|
||||||
ele.click(function(){
|
ele.click(function(){
|
||||||
if (TD.settings.getComposeStayOpen()){
|
if (TD.settings.getComposeStayOpen()){
|
||||||
@ -1249,16 +1250,16 @@
|
|||||||
if (data.query && data.searchScope !== "users" && !data.columnKey){
|
if (data.query && data.searchScope !== "users" && !data.columnKey){
|
||||||
if ($TDX.openSearchInFirstColumn){
|
if ($TDX.openSearchInFirstColumn){
|
||||||
let order = TD.controller.columnManager._columnOrder;
|
let order = TD.controller.columnManager._columnOrder;
|
||||||
|
|
||||||
if (order.length > 1){
|
if (order.length > 1){
|
||||||
let columnKey = order[order.length-1];
|
let columnKey = order[order.length-1];
|
||||||
|
|
||||||
order.splice(order.length-1, 1);
|
order.splice(order.length-1, 1);
|
||||||
order.splice(1, 0, columnKey);
|
order.splice(1, 0, columnKey);
|
||||||
TD.controller.columnManager.move(columnKey, "left");
|
TD.controller.columnManager.move(columnKey, "left");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!("tweetduck" in data)){
|
if (!("tweetduck" in data)){
|
||||||
$(".js-app-search-input").val("");
|
$(".js-app-search-input").val("");
|
||||||
$(".js-perform-search").blur();
|
$(".js-perform-search").blur();
|
||||||
@ -1378,7 +1379,7 @@
|
|||||||
$(".js-btn-fav", ".js-modal-inner").each(function(){
|
$(".js-btn-fav", ".js-modal-inner").each(function(){
|
||||||
let event = $._data(this, "events").click[0];
|
let event = $._data(this, "events").click[0];
|
||||||
let handler = event.handler;
|
let handler = event.handler;
|
||||||
|
|
||||||
event.handler = function(){
|
event.handler = function(){
|
||||||
overrideState();
|
overrideState();
|
||||||
handler.apply(this, arguments);
|
handler.apply(this, arguments);
|
||||||
@ -1392,7 +1393,7 @@
|
|||||||
let event = $._data(this, "events").click[0];
|
let event = $._data(this, "events").click[0];
|
||||||
let handler = event.handler;
|
let handler = event.handler;
|
||||||
let context = handler.context;
|
let context = handler.context;
|
||||||
|
|
||||||
event.handler = function(){
|
event.handler = function(){
|
||||||
overrideState();
|
overrideState();
|
||||||
handler.apply(this, arguments);
|
handler.apply(this, arguments);
|
||||||
@ -1434,11 +1435,11 @@
|
|||||||
|
|
||||||
TD.services.TwitterConversation.prototype.renderThread = function(){
|
TD.services.TwitterConversation.prototype.renderThread = function(){
|
||||||
let prevMessages = this.messages;
|
let prevMessages = this.messages;
|
||||||
|
|
||||||
this.messages = prevMessages.slice(0, 100);
|
this.messages = prevMessages.slice(0, 100);
|
||||||
let result = prevFunc.apply(this, arguments);
|
let result = prevFunc.apply(this, arguments);
|
||||||
this.messages = prevMessages;
|
this.messages = prevMessages;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1479,9 +1480,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>`).appendTo(document.body);
|
||||||
`).appendTo(document.body);
|
|
||||||
|
|
||||||
ele.find("button").click(function(){
|
ele.find("button").click(function(){
|
||||||
ele.fadeOut(200);
|
ele.fadeOut(200);
|
||||||
});
|
});
|
||||||
@ -1521,7 +1521,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (window.TD_SESSION && window.TD_SESSION.gc){
|
if (window.TD_SESSION && window.TD_SESSION.gc){
|
||||||
var state;
|
let state;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
state = JSON.parse(window.TD_SESSION.gc);
|
state = JSON.parse(window.TD_SESSION.gc);
|
||||||
@ -1562,7 +1562,7 @@
|
|||||||
$(document).one("dataColumnsLoaded", function(){
|
$(document).one("dataColumnsLoaded", function(){
|
||||||
let columns = Object.values(TD.controller.columnManager.getAll());
|
let columns = Object.values(TD.controller.columnManager.getAll());
|
||||||
let remaining = columns.length;
|
let remaining = columns.length;
|
||||||
|
|
||||||
for(let column of columns){
|
for(let column of columns){
|
||||||
column.ui.getChirpContainer().one("dataColumnFeedUpdated", () => {
|
column.ui.getChirpContainer().one("dataColumnFeedUpdated", () => {
|
||||||
if (--remaining === 0){
|
if (--remaining === 0){
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
// Block: Setup a simple JavaScript object configuration loader.
|
// Block: Setup a simple JavaScript object configuration loader.
|
||||||
//
|
//
|
||||||
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
|
window.TDPF_loadConfigurationFile = function(pluginObject, fileNameUser, fileNameDefault, onSuccess, onFailure){
|
||||||
var identifier = pluginObject.$id;
|
let identifier = pluginObject.$id;
|
||||||
var token = pluginObject.$token;
|
let token = pluginObject.$token;
|
||||||
|
|
||||||
$TDP.checkFileExists(token, fileNameUser).then(exists => {
|
$TDP.checkFileExists(token, fileNameUser).then(exists => {
|
||||||
var fileName = exists ? fileNameUser : fileNameDefault;
|
let fileName = exists ? fileNameUser : fileNameDefault;
|
||||||
|
|
||||||
(exists ? $TDP.readFile(token, fileName, true) : $TDP.readFileRoot(token, fileName)).then(contents => {
|
(exists ? $TDP.readFile(token, fileName, true) : $TDP.readFileRoot(token, fileName)).then(contents => {
|
||||||
var obj;
|
let obj;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
obj = eval("("+contents+")");
|
obj = eval("("+contents+")");
|
||||||
@ -39,7 +39,7 @@
|
|||||||
// Block: Setup a function to add/remove custom CSS.
|
// Block: Setup a function to add/remove custom CSS.
|
||||||
//
|
//
|
||||||
window.TDPF_createCustomStyle = function(pluginObject){
|
window.TDPF_createCustomStyle = function(pluginObject){
|
||||||
var element = document.createElement("style");
|
let element = document.createElement("style");
|
||||||
element.id = "plugin-"+pluginObject.$id+"-"+Math.random().toString(36).substring(2, 7);
|
element.id = "plugin-"+pluginObject.$id+"-"+Math.random().toString(36).substring(2, 7);
|
||||||
document.head.appendChild(element);
|
document.head.appendChild(element);
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
//
|
//
|
||||||
// Variable: Collection of all <a> tags.
|
// Variable: Collection of all <a> tags.
|
||||||
//
|
//
|
||||||
var links = document.getElementsByTagName("A");
|
const links = document.getElementsByTagName("A");
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function: Adds an event listener to all elements in the array or collection.
|
// Function: Adds an event listener to all elements in the array or collection.
|
||||||
//
|
//
|
||||||
var addEventListener = function(collection, type, listener){
|
const addEventListener = function(collection, type, listener){
|
||||||
for(let index = 0; index < collection.length; index++){
|
for(let ele of collection){
|
||||||
collection[index].addEventListener(type, listener);
|
ele.addEventListener(type, listener);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -20,13 +20,13 @@
|
|||||||
const onLinkClick = function(e){
|
const onLinkClick = function(e){
|
||||||
if (e.button === 0 || e.button === 1){
|
if (e.button === 0 || e.button === 1){
|
||||||
let ele = e.currentTarget;
|
let ele = e.currentTarget;
|
||||||
|
|
||||||
$TD.openBrowser(ele.href);
|
$TD.openBrowser(ele.href);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if ($TDX.skipOnLinkClick){
|
if ($TDX.skipOnLinkClick){
|
||||||
let parentClasses = ele.parentNode.classList;
|
let parentClasses = ele.parentNode.classList;
|
||||||
|
|
||||||
if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
|
if (parentClasses.contains("js-tweet-text") || parentClasses.contains("js-quoted-tweet-text") || parentClasses.contains("js-timestamp")){
|
||||||
$TD.loadNextNotification();
|
$TD.loadNextNotification();
|
||||||
}
|
}
|
||||||
@ -42,18 +42,18 @@
|
|||||||
// Block: Expand shortened links on hover or display tooltip.
|
// Block: Expand shortened links on hover or display tooltip.
|
||||||
//
|
//
|
||||||
(function(){
|
(function(){
|
||||||
var prevMouseX = -1, prevMouseY = -1;
|
let prevMouseX = -1, prevMouseY = -1;
|
||||||
var tooltipTimer, tooltipDisplayed;
|
let tooltipTimer, tooltipDisplayed;
|
||||||
|
|
||||||
addEventListener(links, "mouseenter", function(e){
|
addEventListener(links, "mouseenter", function(e){
|
||||||
var me = e.currentTarget;
|
let me = e.currentTarget;
|
||||||
|
|
||||||
var url = me.getAttribute("data-full-url");
|
let url = me.getAttribute("data-full-url");
|
||||||
return if !url;
|
return if !url;
|
||||||
|
|
||||||
var text = me.textContent;
|
let text = me.textContent;
|
||||||
return if text.charCodeAt(text.length-1) !== 8230 && text.charCodeAt(0) !== 8230; // horizontal ellipsis
|
return if text.charCodeAt(text.length-1) !== 8230 && text.charCodeAt(0) !== 8230; // horizontal ellipsis
|
||||||
|
|
||||||
if ($TDX.expandLinksOnHover){
|
if ($TDX.expandLinksOnHover){
|
||||||
tooltipTimer = window.setTimeout(function(){
|
tooltipTimer = window.setTimeout(function(){
|
||||||
me.setAttribute("td-prev-text", text);
|
me.setAttribute("td-prev-text", text);
|
||||||
@ -72,8 +72,8 @@
|
|||||||
return if !e.currentTarget.hasAttribute("data-full-url");
|
return if !e.currentTarget.hasAttribute("data-full-url");
|
||||||
|
|
||||||
if ($TDX.expandLinksOnHover){
|
if ($TDX.expandLinksOnHover){
|
||||||
var prevText = e.currentTarget.getAttribute("td-prev-text");
|
let prevText = e.currentTarget.getAttribute("td-prev-text");
|
||||||
|
|
||||||
if (prevText){
|
if (prevText){
|
||||||
e.currentTarget.innerHTML = prevText;
|
e.currentTarget.innerHTML = prevText;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@
|
|||||||
|
|
||||||
addEventListener(links, "mousemove", function(e){
|
addEventListener(links, "mousemove", function(e){
|
||||||
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
|
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
|
||||||
var url = e.currentTarget.getAttribute("data-full-url");
|
let url = e.currentTarget.getAttribute("data-full-url");
|
||||||
return if !url;
|
return if !url;
|
||||||
|
|
||||||
$TD.displayTooltip(url);
|
$TD.displayTooltip(url);
|
||||||
@ -110,7 +110,7 @@
|
|||||||
// Block: Setup a handler for 'Show this thread'.
|
// Block: Setup a handler for 'Show this thread'.
|
||||||
//
|
//
|
||||||
(function(){
|
(function(){
|
||||||
var btn = document.getElementById("tduck-show-thread");
|
let btn = document.getElementById("tduck-show-thread");
|
||||||
return if !btn;
|
return if !btn;
|
||||||
|
|
||||||
btn.addEventListener("click", function(){
|
btn.addEventListener("click", function(){
|
||||||
@ -138,7 +138,7 @@
|
|||||||
document.body.addEventListener("mouseenter", function(){
|
document.body.addEventListener("mouseenter", function(){
|
||||||
document.body.classList.add("td-hover");
|
document.body.classList.add("td-hover");
|
||||||
});
|
});
|
||||||
|
|
||||||
document.body.addEventListener("mouseleave", function(){
|
document.body.addEventListener("mouseleave", function(){
|
||||||
document.body.classList.remove("td-hover");
|
document.body.classList.remove("td-hover");
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var isReloading = false;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Class: Abstract plugin base class.
|
// Class: Abstract plugin base class.
|
||||||
//
|
//
|
||||||
@ -107,12 +105,16 @@
|
|||||||
//
|
//
|
||||||
// Block: Setup a function to reload the page.
|
// Block: Setup a function to reload the page.
|
||||||
//
|
//
|
||||||
window.TDPF_requestReload = function(){
|
(function(){
|
||||||
if (!isReloading){
|
let isReloading = false;
|
||||||
window.setTimeout(window.TDGF_reload, 1);
|
|
||||||
isReloading = true;
|
window.TDPF_requestReload = function(){
|
||||||
}
|
if (!isReloading){
|
||||||
};
|
window.setTimeout(window.TDGF_reload, 1);
|
||||||
|
isReloading = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Setup bridges to global functions.
|
// Block: Setup bridges to global functions.
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
//
|
//
|
||||||
// Function: Inject custom CSS into the page.
|
// Function: Inject custom CSS into the page.
|
||||||
//
|
//
|
||||||
var injectCSS = function(){
|
const injectCSS = function(){
|
||||||
if (!document.head){
|
if (!document.head){
|
||||||
setTimeout(injectCSS, 5);
|
setTimeout(injectCSS, 5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var style = document.createElement("style");
|
let style = document.createElement("style");
|
||||||
|
|
||||||
style.innerText = `#import "styles/twitter.base.css"`;
|
style.innerText = `#import "styles/twitter.base.css"`;
|
||||||
|
|
||||||
@ -26,22 +26,20 @@
|
|||||||
//
|
//
|
||||||
if (location.pathname === "/login"){
|
if (location.pathname === "/login"){
|
||||||
document.addEventListener("DOMContentLoaded", function(){
|
document.addEventListener("DOMContentLoaded", function(){
|
||||||
let openLinkExternally = function(e){
|
const openLinkExternally = function(e){
|
||||||
let href = e.currentTarget.getAttribute("href");
|
let href = e.currentTarget.getAttribute("href");
|
||||||
$TD.openBrowser(href[0] === '/' ? location.origin+href : href);
|
$TD.openBrowser(href[0] === '/' ? location.origin+href : href);
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
|
|
||||||
let links = document.getElementsByTagName("A");
|
for(let link of document.getElementsByTagName("A")){
|
||||||
|
link.addEventListener("click", openLinkExternally);
|
||||||
for(let index = 0; index < links.length; index++){
|
|
||||||
links[index].addEventListener("click", openLinkExternally);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let texts = document.querySelector(".page-canvas > div:last-child");
|
let texts = document.querySelector(".page-canvas > div:last-child");
|
||||||
|
|
||||||
if (texts){
|
if (texts){
|
||||||
texts.insertAdjacentHTML("beforeend", `<p class="tweetduck-helper">Used the TweetDuck app before? <a href="#">Import your profile »</a></p>`);
|
texts.insertAdjacentHTML("beforeend", `<p class="tweetduck-helper">Used the TweetDuck app before? <a href="#">Import your profile »</a></p>`);
|
||||||
|
|
||||||
@ -57,7 +55,7 @@
|
|||||||
else if (location.pathname === "/logout"){
|
else if (location.pathname === "/logout"){
|
||||||
document.addEventListener("DOMContentLoaded", function(){
|
document.addEventListener("DOMContentLoaded", function(){
|
||||||
let cancel = document.querySelector(".buttons .cancel");
|
let cancel = document.querySelector(".buttons .cancel");
|
||||||
|
|
||||||
if (cancel && cancel.tagName === "A"){
|
if (cancel && cancel.tagName === "A"){
|
||||||
cancel.href = "https://tweetdeck.twitter.com/";
|
cancel.href = "https://tweetdeck.twitter.com/";
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Function: Creates the update notification element. Removes the old one if already exists.
|
// Function: Creates the update notification element. Removes the old one if already exists.
|
||||||
//
|
//
|
||||||
var displayNotification = function(version, changelog){
|
const displayNotification = function(version, changelog){
|
||||||
|
|
||||||
// styles
|
// styles
|
||||||
let css = document.getElementById("tweetduck-update-css");
|
let css = document.getElementById("tweetduck-update-css");
|
||||||
|
Loading…
Reference in New Issue
Block a user