1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-01 08:34:11 +02:00

Fix formatting in JavaScript files

This commit is contained in:
chylex 2016-09-02 17:35:21 +02:00
parent ca4eb17308
commit a3666a7ab2
5 changed files with 77 additions and 77 deletions

View File

@ -5,19 +5,19 @@ enabled(){
document.head.appendChild(style); document.head.appendChild(style);
var sheet = style.sheet; var sheet = style.sheet;
sheet.insertRule(".tweet-actions { float: right !important; width: auto !important; }",0); sheet.insertRule(".tweet-actions { float: right !important; width: auto !important; }", 0);
sheet.insertRule(".tweet-action { opacity: 0; }",0); sheet.insertRule(".tweet-action { opacity: 0; }", 0);
sheet.insertRule(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important; }",0); sheet.insertRule(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important; }", 0);
sheet.insertRule(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important; }",0); sheet.insertRule(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important; }", 0);
sheet.insertRule(".tweet-actions > li:nth-child(4) { margin-right: 2px !important; }",0); sheet.insertRule(".tweet-actions > li:nth-child(4) { margin-right: 2px !important; }", 0);
// revert small links around the tweet // revert small links around the tweet
this.prevFooterMustache = TD.mustaches["status/tweet_single_footer.mustache"]; this.prevFooterMustache = TD.mustaches["status/tweet_single_footer.mustache"];
var footerLayout = TD.mustaches["status/tweet_single_footer.mustache"]; var footerLayout = TD.mustaches["status/tweet_single_footer.mustache"];
footerLayout = footerLayout.replace('txt-mute txt-size--12','txt-mute txt-small'); footerLayout = footerLayout.replace('txt-mute txt-size--12', 'txt-mute txt-small');
footerLayout = footerLayout.replace('{{#inReplyToID}}','{{^inReplyToID}} <a class="pull-left margin-txs txt-mute txt-small is-vishidden-narrow" href="#" rel="viewDetails">{{_i}}Details{{/i}}</a> <a class="pull-left margin-txs txt-mute txt-small is-vishidden is-visshown-narrow" href="#" rel="viewDetails">{{_i}}Open{{/i}}</a> {{/inReplyToID}} {{#inReplyToID}}'); footerLayout = footerLayout.replace('{{#inReplyToID}}', '{{^inReplyToID}} <a class="pull-left margin-txs txt-mute txt-small is-vishidden-narrow" href="#" rel="viewDetails">{{_i}}Details{{/i}}</a> <a class="pull-left margin-txs txt-mute txt-small is-vishidden is-visshown-narrow" href="#" rel="viewDetails">{{_i}}Open{{/i}}</a> {{/inReplyToID}} {{#inReplyToID}}');
footerLayout = footerLayout.replace('<span class="link-complex-target"> {{_i}}View Conversation{{/i}}','<i class="icon icon-conversation icon-small-context"></i> <span class="link-complex-target"> <span class="is-vishidden-wide is-vishidden-narrow">{{_i}}View{{/i}}</span> <span class="is-vishidden is-visshown-wide">{{_i}}Conversation{{/i}}</span>'); footerLayout = footerLayout.replace('<span class="link-complex-target"> {{_i}}View Conversation{{/i}}', '<i class="icon icon-conversation icon-small-context"></i> <span class="link-complex-target"> <span class="is-vishidden-wide is-vishidden-narrow">{{_i}}View{{/i}}</span> <span class="is-vishidden is-visshown-wide">{{_i}}Conversation{{/i}}</span>');
TD.mustaches["status/tweet_single_footer.mustache"] = footerLayout; TD.mustaches["status/tweet_single_footer.mustache"] = footerLayout;
// fix layout for right-aligned actions menu // fix layout for right-aligned actions menu
@ -27,11 +27,11 @@ enabled(){
} }
ready(){ ready(){
$(document).on("uiShowActionsMenu",this.uiShowActionsMenuEvent); $(document).on("uiShowActionsMenu", this.uiShowActionsMenuEvent);
} }
disabled(){ disabled(){
$("#design-revert").remove(); $("#design-revert").remove();
$(document).off("uiShowActionsMenu",this.uiShowActionsMenuEvent); $(document).off("uiShowActionsMenu", this.uiShowActionsMenuEvent);
TD.mustaches["status/tweet_single_footer.mustache"] = this.prevFooterMustache; TD.mustaches["status/tweet_single_footer.mustache"] = this.prevFooterMustache;
} }

View File

@ -1,4 +1,4 @@
(function($,$TD,TD){ (function($, $TD, TD){
// //
// Variable: Current highlighted column jQuery object. // Variable: Current highlighted column jQuery object.
// //
@ -27,7 +27,7 @@
var buttons = menu.children("[data-std]"); var buttons = menu.children("[data-std]");
buttons.on("click","a",function(){ buttons.on("click", "a", function(){
var action = $(this).attr("data-action"); var action = $(this).attr("data-action");
if (action === "td-settings"){ if (action === "td-settings"){
@ -40,16 +40,16 @@
buttons.hover(function(){ buttons.hover(function(){
$(this).addClass("is-selected"); $(this).addClass("is-selected");
},function(){ }, function(){
$(this).removeClass("is-selected"); $(this).removeClass("is-selected");
}); });
},0); }, 0);
}); });
// Notification handling // Notification handling
$.subscribe("/notifications/new",function(obj){ $.subscribe("/notifications/new", function(obj){
for(let index = obj.items.length-1; index >= 0; index--){ for(let index = obj.items.length-1; index >= 0; index--){
onNewTweet(obj.column,obj.items[index]); onNewTweet(obj.column, obj.items[index]);
} }
}); });
@ -59,8 +59,8 @@
$(this).parent().replaceWith("<a href='"+$(this).attr("src")+"' rel='url' target='_blank' style='display:block; border:1px solid #555; padding:3px 6px'>&#9658; Open video in browser</a>"); $(this).parent().replaceWith("<a href='"+$(this).attr("src")+"' rel='url' target='_blank' style='display:block; border:1px solid #555; padding:3px 6px'>&#9658; Open video in browser</a>");
}); });
$("a[rel='user']").attr("target","_blank"); $("a[rel='user']").attr("target", "_blank");
}).observe($(".js-app-columns")[0],{ }).observe($(".js-app-columns")[0], {
childList: true, childList: true,
subtree: true subtree: true
}); });
@ -81,7 +81,7 @@
// //
var prependToFunction = function(func, extension){ var prependToFunction = function(func, extension){
return function(){ return function(){
return extension.apply(this,arguments) === true ? undefined : func.apply(this,arguments); return extension.apply(this, arguments) === true ? undefined : func.apply(this, arguments);
}; };
}; };
@ -90,8 +90,8 @@
// //
var appendToFunction = function(func, extension){ var appendToFunction = function(func, extension){
return function(){ return function(){
var res = func.apply(this,arguments); var res = func.apply(this, arguments);
extension.apply(this,arguments); extension.apply(this, arguments);
return res; return res;
}; };
}; };
@ -107,12 +107,12 @@
withMediaPreview: false withMediaPreview: false
})); }));
html.css("border","0"); html.css("border", "0");
html.find(".tweet-body").first().children("footer").remove(); html.find(".tweet-body").first().children("footer").remove();
var url = html.find("time").first().children("a").first().attr("href") || ""; var url = html.find("time").first().children("a").first().attr("href") || "";
$TD.onTweetPopup(html.html(),url,tweet.text.length); // TODO column $TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column
} }
else if (column.model.getHasSound()){ else if (column.model.getHasSound()){
$TD.onTweetSound(); // TODO disable original $TD.onTweetSound(); // TODO disable original
@ -144,7 +144,7 @@
else if (!window.TD_APP_READY && !app.hasClass("is-hidden")){ else if (!window.TD_APP_READY && !app.hasClass("is-hidden")){
initializeTweetDck(); initializeTweetDck();
} }
}).observe(app[0],{ }).observe(app[0], {
attributes: true, attributes: true,
attributeFilter: [ "class" ] attributeFilter: [ "class" ]
}); });
@ -152,14 +152,14 @@
// //
// Block: Hook into settings object to detect when the settings change. // Block: Hook into settings object to detect when the settings change.
// //
TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize,function(name){ TD.settings.setFontSize = appendToFunction(TD.settings.setFontSize, function(name){
$TD.loadFontSizeClass(name); $TD.loadFontSizeClass(name);
}); });
TD.settings.setTheme = appendToFunction(TD.settings.setTheme,function(){ TD.settings.setTheme = appendToFunction(TD.settings.setTheme, function(){
setTimeout(function(){ setTimeout(function(){
$TD.loadNotificationHeadContents(getNotificationHeadContents()); $TD.loadNotificationHeadContents(getNotificationHeadContents());
},0); }, 0);
}); });
// //
@ -184,7 +184,7 @@
var prevMouseX = -1, prevMouseY = -1; var prevMouseX = -1, prevMouseY = -1;
var tooltipTimer, tooltipDisplayed; var tooltipTimer, tooltipDisplayed;
$(document.body).delegate("a[data-full-url]","mouseenter mouseleave mousemove",function(e){ $(document.body).delegate("a[data-full-url]", "mouseenter mouseleave mousemove", function(e){
var me = $(this); var me = $(this);
if (e.type === "mouseenter"){ if (e.type === "mouseenter"){
@ -197,19 +197,19 @@
if ($TD.expandLinksOnHover){ if ($TD.expandLinksOnHover){
tooltipTimer = window.setTimeout(function(){ tooltipTimer = window.setTimeout(function(){
var expanded = me.attr("data-full-url"); var expanded = me.attr("data-full-url");
expanded = cutStart(expanded,"https://"); expanded = cutStart(expanded, "https://");
expanded = cutStart(expanded,"http://"); expanded = cutStart(expanded, "http://");
expanded = cutStart(expanded,"www."); expanded = cutStart(expanded, "www.");
me.attr("td-prev-text",text); me.attr("td-prev-text", text);
me.text(expanded); me.text(expanded);
},200); }, 200);
} }
else{ else{
tooltipTimer = window.setTimeout(function(){ tooltipTimer = window.setTimeout(function(){
$TD.displayTooltip(me.attr("data-full-url"),false); $TD.displayTooltip(me.attr("data-full-url"), false);
tooltipDisplayed = true; tooltipDisplayed = true;
},400); }, 400);
} }
} }
else if (e.type === "mouseleave"){ else if (e.type === "mouseleave"){
@ -225,12 +225,12 @@
if (tooltipDisplayed){ if (tooltipDisplayed){
tooltipDisplayed = false; tooltipDisplayed = false;
$TD.displayTooltip(null,false); $TD.displayTooltip(null, false);
} }
} }
else if (e.type === "mousemove"){ else if (e.type === "mousemove"){
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){ if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
$TD.displayTooltip(me.attr("data-full-url"),false); $TD.displayTooltip(me.attr("data-full-url"), false);
prevMouseX = e.clientX; prevMouseX = e.clientX;
prevMouseY = e.clientY; prevMouseY = e.clientY;
} }
@ -241,7 +241,7 @@
// //
// Block: Allow bypassing of t.co in context menus. // Block: Allow bypassing of t.co in context menus.
// //
$(document.body).delegate("a","contextmenu",function(){ $(document.body).delegate("a", "contextmenu", function(){
$TD.setLastRightClickedLink($(this).attr("data-full-url") || ""); $TD.setLastRightClickedLink($(this).attr("data-full-url") || "");
}); });
@ -251,7 +251,7 @@
(function(){ (function(){
var soundEle = document.getElementById("update-sound"); var soundEle = document.getElementById("update-sound");
soundEle.play = prependToFunction(soundEle.play,function(){ soundEle.play = prependToFunction(soundEle.play, function(){
return $TD.muteNotifications; return $TD.muteNotifications;
}); });
})(); })();
@ -263,7 +263,7 @@
// //
// Block: Update highlighted column. // Block: Update highlighted column.
// //
app.delegate("section","mouseenter mouseleave",function(e){ app.delegate("section", "mouseenter mouseleave", function(e){
if (e.type === "mouseenter"){ if (e.type === "mouseenter"){
highlightedColumnEle = $(this); highlightedColumnEle = $(this);
} }
@ -280,23 +280,23 @@
var updateHighlightedTweet = function(link, embeddedLink){ var updateHighlightedTweet = function(link, embeddedLink){
if (lastTweet !== link){ if (lastTweet !== link){
$TD.setLastHighlightedTweet(link,embeddedLink); $TD.setLastHighlightedTweet(link, embeddedLink);
lastTweet = link; lastTweet = link;
} }
}; };
app.delegate("article.js-stream-item","mouseenter mouseleave",function(e){ app.delegate("article.js-stream-item", "mouseenter mouseleave", function(e){
if (e.type === "mouseenter"){ if (e.type === "mouseenter"){
highlightedTweetEle = $(this); highlightedTweetEle = $(this);
var link = $(this).find("time").first().children("a").first(); var link = $(this).find("time").first().children("a").first();
var embedded = $(this).find(".quoted-tweet[data-tweet-id]").first(); var embedded = $(this).find(".quoted-tweet[data-tweet-id]").first();
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "",embedded.length > 0 ? embedded.find(".account-link").first().attr("href")+"/status/"+embedded.attr("data-tweet-id") : ""); updateHighlightedTweet(link.length > 0 ? link.attr("href") : "", embedded.length > 0 ? embedded.find(".account-link").first().attr("href")+"/status/"+embedded.attr("data-tweet-id") : "");
} }
else if (e.type === "mouseleave"){ else if (e.type === "mouseleave"){
highlightedTweetEle = null; highlightedTweetEle = null;
updateHighlightedTweet("",""); updateHighlightedTweet("", "");
} }
}); });
})(); })();
@ -322,10 +322,10 @@
scroller.scrollTop(button.offset().top); // scrolls the button into view scroller.scrollTop(button.offset().top); // scrolls the button into view
var buttonPos = button.children().first().offset(); // finds the camera icon offset var buttonPos = button.children().first().offset(); // finds the camera icon offset
$TD.clickUploadImage(Math.floor(buttonPos.left),Math.floor(buttonPos.top)); $TD.clickUploadImage(Math.floor(buttonPos.left), Math.floor(buttonPos.top));
}; };
$(".js-app").delegate(".js-compose-text,.js-reply-tweetbox","paste",function(){ $(".js-app").delegate(".js-compose-text,.js-reply-tweetbox", "paste", function(){
lastPasteElement = $(this); lastPasteElement = $(this);
$TD.tryPasteImage(); $TD.tryPasteImage();
}); });
@ -355,7 +355,7 @@
else if (++counter >= 10){ else if (++counter >= 10){
clearInterval(interval); clearInterval(interval);
} }
},51); }, 51);
} }
else{ else{
clickUpload(); clickUpload();
@ -369,7 +369,7 @@
setTimeout(function(){ setTimeout(function(){
getScroller().scrollTop(prevScrollTop); getScroller().scrollTop(prevScrollTop);
$(".js-drawer").find(".js-compose-text").first()[0].focus(); $(".js-drawer").find(".js-compose-text").first()[0].focus();
},10); }, 10);
}; };
})(); })();
@ -404,10 +404,10 @@
var styleOfficial = document.createElement("style"); var styleOfficial = document.createElement("style");
document.head.appendChild(styleOfficial); document.head.appendChild(styleOfficial);
styleOfficial.sheet.insertRule("a[data-full-url] { word-break: break-all; }",0); // break long urls styleOfficial.sheet.insertRule("a[data-full-url] { word-break: break-all; }", 0); // break long urls
styleOfficial.sheet.insertRule(".column-nav-link .attribution { position: absolute; }",0); // fix cut off account names styleOfficial.sheet.insertRule(".column-nav-link .attribution { position: absolute; }", 0); // fix cut off account names
styleOfficial.sheet.insertRule(".txt-base-smallest .badge-verified:before { height: 13px !important; }",0); // fix cut off badge icon styleOfficial.sheet.insertRule(".txt-base-smallest .badge-verified:before { height: 13px !important; }", 0); // fix cut off badge icon
styleOfficial.sheet.insertRule(".keyboard-shortcut-list { vertical-align: top; }",0); // fix keyboard navigation alignment styleOfficial.sheet.insertRule(".keyboard-shortcut-list { vertical-align: top; }", 0); // fix keyboard navigation alignment
if ($TD.hasCustomBrowserCSS){ if ($TD.hasCustomBrowserCSS){
var styleCustom = document.createElement("style"); var styleCustom = document.createElement("style");
@ -415,4 +415,4 @@
document.head.appendChild(styleCustom); document.head.appendChild(styleCustom);
} }
})(); })();
})($,$TD,TD); })($, $TD, TD);

View File

@ -9,14 +9,14 @@
// //
var addEventListener = function(collection, type, listener){ var addEventListener = function(collection, type, listener){
for(let index = 0; index < collection.length; index++){ for(let index = 0; index < collection.length; index++){
collection[index].addEventListener(type,listener); collection[index].addEventListener(type, listener);
} }
}; };
// //
// Block: Hook into links to bypass default open function. // Block: Hook into links to bypass default open function.
// //
addEventListener(links,"click",function(e){ addEventListener(links, "click", function(e){
$TD.openBrowser(e.currentTarget.getAttribute("href")); $TD.openBrowser(e.currentTarget.getAttribute("href"));
e.preventDefault(); e.preventDefault();
}); });
@ -24,7 +24,7 @@
// //
// Block: Allow bypassing of t.co in context menus. // Block: Allow bypassing of t.co in context menus.
// //
addEventListener(links,"contextmenu",function(e){ addEventListener(links, "contextmenu", function(e){
$TD.setLastRightClickedLink(e.currentTarget.getAttribute("data-full-url") || ""); $TD.setLastRightClickedLink(e.currentTarget.getAttribute("data-full-url") || "");
}); });
@ -39,7 +39,7 @@
var prevMouseX = -1, prevMouseY = -1; var prevMouseX = -1, prevMouseY = -1;
var tooltipTimer, tooltipDisplayed; var tooltipTimer, tooltipDisplayed;
addEventListener(links,"mouseenter",function(e){ addEventListener(links, "mouseenter", function(e){
var me = e.currentTarget; var me = e.currentTarget;
var url = me.getAttribute("data-full-url"); var url = me.getAttribute("data-full-url");
@ -54,23 +54,23 @@
if ($TD.expandLinksOnHover){ if ($TD.expandLinksOnHover){
tooltipTimer = window.setTimeout(function(){ tooltipTimer = window.setTimeout(function(){
var expanded = url; var expanded = url;
expanded = cutStart(expanded,"https://"); expanded = cutStart(expanded, "https://");
expanded = cutStart(expanded,"http://"); expanded = cutStart(expanded, "http://");
expanded = cutStart(expanded,"www."); expanded = cutStart(expanded, "www.");
me.setAttribute("td-prev-text",text); me.setAttribute("td-prev-text", text);
me.innerHTML = expanded; me.innerHTML = expanded;
},200); }, 200);
} }
else{ else{
tooltipTimer = window.setTimeout(function(){ tooltipTimer = window.setTimeout(function(){
$TD.displayTooltip(url,true); $TD.displayTooltip(url, true);
tooltipDisplayed = true; tooltipDisplayed = true;
},400); }, 400);
} }
}); });
addEventListener(links,"mouseleave",function(e){ addEventListener(links, "mouseleave", function(e){
if (!e.currentTarget.hasAttribute("data-full-url"))return; if (!e.currentTarget.hasAttribute("data-full-url"))return;
if ($TD.expandLinksOnHover){ if ($TD.expandLinksOnHover){
@ -85,16 +85,16 @@
if (tooltipDisplayed){ if (tooltipDisplayed){
tooltipDisplayed = false; tooltipDisplayed = false;
$TD.displayTooltip(null,true); $TD.displayTooltip(null, true);
} }
}); });
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"); var url = e.currentTarget.getAttribute("data-full-url");
if (!url)return; if (!url)return;
$TD.displayTooltip(url,true); $TD.displayTooltip(url, true);
prevMouseX = e.clientX; prevMouseX = e.clientX;
prevMouseY = e.clientY; prevMouseY = e.clientY;
} }

View File

@ -50,7 +50,7 @@
setState(plugin, enable){ setState(plugin, enable){
if (enable && this.isDisabled(plugin)){ if (enable && this.isDisabled(plugin)){
this.disabled.splice(this.disabled.indexOf(plugin.id),1); this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
plugin.obj.enabled(); plugin.obj.enabled();
this.runWhenReady(plugin); this.runWhenReady(plugin);
} }
@ -75,6 +75,6 @@
// Block: Setup global function to change plugin state. // Block: Setup global function to change plugin state.
// //
window.TDPF_setPluginState = function(identifier, enable){ window.TDPF_setPluginState = function(identifier, enable){
window.TD_PLUGINS.setState(window.TD_PLUGINS.findObject(identifier),enable); window.TD_PLUGINS.setState(window.TD_PLUGINS.findObject(identifier), enable);
}; };
})(); })();

View File

@ -1,4 +1,4 @@
(function($,$TDU){ (function($, $TDU){
// //
// Variable: Current timeout ID for update checking. // Variable: Current timeout ID for update checking.
// //
@ -90,7 +90,7 @@
buttonDiv.children(".tdu-btn-download").click(function(){ buttonDiv.children(".tdu-btn-download").click(function(){
ele.remove(); ele.remove();
$TDU.onUpdateAccepted(version,download); $TDU.onUpdateAccepted(version, download);
}); });
buttonDiv.children(".tdu-btn-dismiss").click(function(){ buttonDiv.children(".tdu-btn-dismiss").click(function(){
@ -110,21 +110,21 @@
// //
var runUpdateCheck = function(force, eventID){ var runUpdateCheck = function(force, eventID){
clearTimeout(updateCheckTimeoutID); clearTimeout(updateCheckTimeoutID);
updateCheckTimeoutID = setTimeout(runUpdateCheck,1000*60*60); // 1 hour updateCheckTimeoutID = setTimeout(runUpdateCheck, 1000*60*60); // 1 hour
if (!$TDU.updateCheckEnabled && !force)return; if (!$TDU.updateCheckEnabled && !force)return;
$.getJSON(updateCheckUrl,function(response){ $.getJSON(updateCheckUrl, function(response){
var tagName = response.tag_name; var tagName = response.tag_name;
var hasUpdate = tagName !== $TDU.versionTag && tagName !== $TDU.dismissedVersionTag && response.assets.length > 0; var hasUpdate = tagName !== $TDU.versionTag && tagName !== $TDU.dismissedVersionTag && response.assets.length > 0;
if (hasUpdate){ if (hasUpdate){
var obj = response.assets.find(asset => asset.name === updateFileName) || response.assets[0]; var obj = response.assets.find(asset => asset.name === updateFileName) || response.assets[0];
createUpdateNotificationElement(tagName,obj.browser_download_url); createUpdateNotificationElement(tagName, obj.browser_download_url);
} }
if (eventID !== 0){ if (eventID !== 0){
$TDU.onUpdateCheckFinished(eventID,hasUpdate,tagName); $TDU.onUpdateCheckFinished(eventID, hasUpdate, tagName);
} }
}); });
}; };
@ -134,4 +134,4 @@
// //
window.TDUF_runUpdateCheck = runUpdateCheck; window.TDUF_runUpdateCheck = runUpdateCheck;
runUpdateCheck(); runUpdateCheck();
})($,$TDU); })($, $TDU);