From a2498edb76c6e20e1c7c6f9b8f3897d04ea034e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=AB=20=E3=82=A6=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=96?= Date: Wed, 20 Mar 2019 15:56:39 -0500 Subject: [PATCH] Closes #989 --- .gitmodules | 6 +- view/template/nav/_header.php | 8 +- web/components | 2 +- web/js/global.js | 121 +++++++++++++------------------ web/scss/components/_header.scss | 4 + 5 files changed, 62 insertions(+), 79 deletions(-) diff --git a/.gitmodules b/.gitmodules index 660f6763..502e5248 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "web/components"] - path = web/components - url = https://github.com/lbryio/components [submodule "web/scss/color"] path = web/scss/color url = https://github.com/lbryio/color +[submodule "web/components"] + path = web/components + url = https://github.com/lbryio/components diff --git a/view/template/nav/_header.php b/view/template/nav/_header.php index 6c40facd..b527d7ff 100644 --- a/view/template/nav/_header.php +++ b/view/template/nav/_header.php @@ -166,10 +166,10 @@ - - The Spec - Read a formal technical description of how LBRY works - + + The Spec + Read a formal technical description of how LBRY works + diff --git a/web/components b/web/components index bcde1c91..fac5d5c4 160000 --- a/web/components +++ b/web/components @@ -1 +1 @@ -Subproject commit bcde1c9131da7b3f9d71d9bff5d91f115b756efc +Subproject commit fac5d5c4461301bfbef4794e67123a050dd5d8fc diff --git a/web/js/global.js b/web/js/global.js index fc31931a..1e27b1ce 100644 --- a/web/js/global.js +++ b/web/js/global.js @@ -1,5 +1,4 @@ window.lbry = {}; -//document.domain = 'lbry.com'; jQuery.fn.extend({ jFor: function() { @@ -7,13 +6,11 @@ jQuery.fn.extend({ target = self.data('for') || self.attr('for'); if (!target) - { return $(); - } - if (target instanceof jQuery) //can be set in JS - { + + if (target instanceof jQuery) return target; - } + return $(target.toString()); } }); @@ -23,59 +20,52 @@ $(document).ready(function() { body.on('click', 'a', onAnchorClick); - if (window.twttr) - { + if (window.twttr) { twttr.events.bind('follow', onTwitterFollow); } - window.fbAsyncInit = function() - { + window.fbAsyncInit = function() { window.FB.Event.subscribe('edge.create', onFacebookLike); } - function onAnchorClick() - { + function onAnchorClick() { var anchor = $(this), action = anchor.data('action'); - if (action == 'toggle') - { + if (action == 'toggle') { anchor.jFor().toggle(); anchor.data('toggle-count', 1 + (anchor.data('toggle-count') ? anchor.data('toggle-count') : 0)); anchor.find('.toggle-even, .toggle-odd').hide(); anchor.find(anchor.data('toggle-count') % 2 == 1 ? '.toggle-odd' : '.toggle-even').show(); } - if (action == 'toggle-class') - { + + if (action == 'toggle-class') { anchor.jFor().toggleClass(anchor.data('class')); } - if (anchor.data('facebook-track') && window.fbq) - { + + if (anchor.data('facebook-track') && window.fbq) { fbq('track', "Lead"); } - if (anchor.data('twitter-track-id') && window.twttr) - { + + if (anchor.data('twitter-track-id') && window.twttr) { twttr.conversion.trackPid(anchor.data('twitter-track-id')); } - if (anchor.data('analytics-category') && anchor.data('analytics-action') && anchor.data('analytics-label') && window.ga) - { + + if (anchor.data('analytics-category') && anchor.data('analytics-action') && anchor.data('analytics-label') && window.ga) { ga('send', 'event', anchor.data('analytics-category'), anchor.data('analytics-action'), anchor.data('analytics-label')); } } - function resizeVideo(iframe) - { + function resizeVideo(iframe) { var maxWidth = Math.min(iframe.offsetParent().width(), iframe.data('maxWidth')), maxHeight = iframe.data('maxHeight'), ratio = iframe.data('aspectRatio'); - if (ratio && maxWidth && maxHeight) - { + if (ratio && maxWidth && maxHeight) { var height = maxWidth * ratio, width = maxWidth; - if (height > maxHeight) - { + if (height > maxHeight) { height = maxHeight; width = maxHeight * 1 / ratio; } @@ -86,36 +76,23 @@ $(document).ready(function() { } } - function onTwitterFollow (intentEvent) - { - if (!intentEvent || !ga) return; + function onTwitterFollow(intentEvent) { + if (!intentEvent || !ga) + return; + ga('send', 'social', 'Twitter', 'follow', window.location.href); } - function onFacebookLike() - { - if (!ga) return; + function onFacebookLike() { + if (!ga) + return; + ga('send', 'social', 'Facebook', 'like', window.location.href); } - // - // $('.video > video').each(function() { - // var iframe = $(this); - // iframe.data('maxWidth', iframe.attr('width')); - // iframe.data('maxHeight', iframe.attr('height')); - // iframe.data('aspectRatio', iframe.attr('height') / iframe.attr('width')) - // .removeAttr('height') - // .removeAttr('width'); - // - // resizeVideo(iframe); - // }); - // - // $(window).resize(function() { - // $('.video > video').each(function() { - // resizeVideo($(this)); - // }) - // }); }); + + // Automatically open external links in new tabs document.querySelectorAll("a[href]").forEach(link => { if (link.href.indexOf(location.hostname) === -1) { @@ -126,28 +103,30 @@ document.querySelectorAll("a[href]").forEach(link => { // Greet visitors from .tech document.addEventListener("DOMContentLoaded", () => { - if ( - document.referrer.includes("http://localhost:8080") || - document.referrer.includes("https://lbry.tech") - ) { - const html = ` -
-
-

Welcome to the consumer side of LBRY! You've had fun delving into the tech, we hope.

-

-

Here by accident? Come back to the techno scene.

+ switch(true) { + case document.referrer.includes("http://localhost:8080"): + case document.referrer.includes("https://lbry.tech"): + const html = ` +
+
+

Welcome to the consumer side of LBRY! You've had fun delving into the tech, we hope.

+

+

Here by accident? Come back to the techno scene.

- -
-
- `; + +
+
+ `; - document.querySelector("body").insertAdjacentHTML("afterend", html); + document.querySelector("body").insertAdjacentHTML("afterend", html); - document.getElementById("close-alert").onclick = () => { - document.getElementById("tech-greeting").style.display = "none"; - }; + document.getElementById("close-alert").onclick = () => { + document.getElementById("tech-greeting").style.display = "none"; + }; + + break; + + default: + break; } }); - - diff --git a/web/scss/components/_header.scss b/web/scss/components/_header.scss index 6d42385f..59078b11 100644 --- a/web/scss/components/_header.scss +++ b/web/scss/components/_header.scss @@ -99,6 +99,10 @@ drawer-children { } drawer-child { + > a { + display: block; + } + @media (min-width: 951px) { &.drawer--social { &:hover {