mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-19 00:15:50 +02:00
Refactor some JS
This commit is contained in:
parent
dbade7f854
commit
9f0997be1a
Resources
@ -108,7 +108,7 @@ enabled(){
|
|||||||
let menu = $(".js-dropdown-content").children("ul").first();
|
let menu = $(".js-dropdown-content").children("ul").first();
|
||||||
return if menu.length === 0;
|
return if menu.length === 0;
|
||||||
|
|
||||||
let itemTD = menu.children("[data-std]").first();
|
let itemTD = menu.children("[data-tweetduck]").first();
|
||||||
return if itemTD.length === 0;
|
return if itemTD.length === 0;
|
||||||
|
|
||||||
if (!itemTD.prev().hasClass("drp-h-divider")){
|
if (!itemTD.prev().hasClass("drp-h-divider")){
|
||||||
@ -116,7 +116,7 @@ enabled(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
let itemEditDesign = $('<li class="is-selectable"><a href="#" data-action>Edit layout & design</a></li>');
|
let itemEditDesign = $('<li class="is-selectable"><a href="#" data-action>Edit layout & design</a></li>');
|
||||||
itemTD.after(itemEditDesign);
|
itemEditDesign.insertAfter(itemTD);
|
||||||
|
|
||||||
itemEditDesign.on("click", "a", this.openEditDesignDialog);
|
itemEditDesign.on("click", "a", this.openEditDesignDialog);
|
||||||
|
|
||||||
|
@ -328,9 +328,8 @@
|
|||||||
let menu = $(".js-dropdown-content").children("ul").first();
|
let menu = $(".js-dropdown-content").children("ul").first();
|
||||||
return if menu.length === 0;
|
return if menu.length === 0;
|
||||||
|
|
||||||
menu.children(".drp-h-divider").last().before('<li class="is-selectable" data-std><a href="#" data-action="tweetduck">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());
|
||||||
let button = menu.children("[data-std]");
|
|
||||||
|
|
||||||
button.on("click", "a", function(){
|
button.on("click", "a", function(){
|
||||||
$TD.openContextMenu();
|
$TD.openContextMenu();
|
||||||
@ -349,10 +348,6 @@
|
|||||||
// Block: Expand shortened links on hover or display tooltip.
|
// Block: Expand shortened links on hover or display tooltip.
|
||||||
//
|
//
|
||||||
(function(){
|
(function(){
|
||||||
var cutStart = function(str, search){
|
|
||||||
return str.startsWith(search) ? str.substr(search.length) : str;
|
|
||||||
};
|
|
||||||
|
|
||||||
var prevMouseX = -1, prevMouseY = -1;
|
var prevMouseX = -1, prevMouseY = -1;
|
||||||
var tooltipTimer, tooltipDisplayed;
|
var tooltipTimer, tooltipDisplayed;
|
||||||
|
|
||||||
@ -364,13 +359,8 @@
|
|||||||
|
|
||||||
if ($TDX.expandLinksOnHover){
|
if ($TDX.expandLinksOnHover){
|
||||||
tooltipTimer = window.setTimeout(function(){
|
tooltipTimer = window.setTimeout(function(){
|
||||||
let expanded = me.attr("data-full-url");
|
|
||||||
expanded = cutStart(expanded, "https://");
|
|
||||||
expanded = cutStart(expanded, "http://");
|
|
||||||
expanded = cutStart(expanded, "www.");
|
|
||||||
|
|
||||||
me.attr("td-prev-text", text);
|
me.attr("td-prev-text", text);
|
||||||
me.text(expanded);
|
me.text(me.attr("data-full-url").replace(/^https?:\/\/(www\.)?/, ""));
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -1128,18 +1118,10 @@
|
|||||||
return false if $("section.js-column").is(".is-shifted-1,.is-shifted-2");
|
return false if $("section.js-column").is(".is-shifted-1,.is-shifted-2");
|
||||||
|
|
||||||
// all textareas are empty
|
// all textareas are empty
|
||||||
if ($("textarea").is(function(){
|
return false if Array.prototype.some.call(document.getElementsByTagName("textarea"), ele => ele.value.length > 0);
|
||||||
return $(this).val().length > 0;
|
|
||||||
})){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// all columns are scrolled to top
|
// all columns are scrolled to top
|
||||||
if ($(".js-column-scroller").is(function(){
|
return false if Array.prototype.some.call(document.getElementsByClassName("js-column-scroller"), ele => ele.scrollTop > 0);
|
||||||
return $(this).scrollTop() > 0;
|
|
||||||
})){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
window.TDGF_reload();
|
window.TDGF_reload();
|
||||||
|
@ -42,10 +42,6 @@
|
|||||||
// Block: Expand shortened links on hover or display tooltip.
|
// Block: Expand shortened links on hover or display tooltip.
|
||||||
//
|
//
|
||||||
(function(){
|
(function(){
|
||||||
var cutStart = function(str, search){
|
|
||||||
return str.startsWith(search) ? str.substr(search.length) : str;
|
|
||||||
};
|
|
||||||
|
|
||||||
var prevMouseX = -1, prevMouseY = -1;
|
var prevMouseX = -1, prevMouseY = -1;
|
||||||
var tooltipTimer, tooltipDisplayed;
|
var tooltipTimer, tooltipDisplayed;
|
||||||
|
|
||||||
@ -60,13 +56,8 @@
|
|||||||
|
|
||||||
if ($TDX.expandLinksOnHover){
|
if ($TDX.expandLinksOnHover){
|
||||||
tooltipTimer = window.setTimeout(function(){
|
tooltipTimer = window.setTimeout(function(){
|
||||||
var expanded = url;
|
|
||||||
expanded = cutStart(expanded, "https://");
|
|
||||||
expanded = cutStart(expanded, "http://");
|
|
||||||
expanded = cutStart(expanded, "www.");
|
|
||||||
|
|
||||||
me.setAttribute("td-prev-text", text);
|
me.setAttribute("td-prev-text", text);
|
||||||
me.innerHTML = expanded;
|
me.innerHTML = url.replace(/^https?:\/\/(www\.)?/, "");
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
Loading…
Reference in New Issue
Block a user