From db6df6ddb3448a28c56dff08e6442e4109e6fab2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 24 Sep 2016 13:47:51 +0200 Subject: [PATCH] Only load JS on homepage, no other page uses it --- app/assets/javascripts/application.js | 1 - app/assets/javascripts/mastodon-logo.coffee | 48 --------------------- app/views/home/index.html.haml | 3 ++ app/views/layouts/application.html.haml | 1 - 4 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 app/assets/javascripts/mastodon-logo.coffee diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b9d77b07fe..c442ded617 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,4 +14,3 @@ //= require jquery_ujs //= require components //= require cable -//= require mastodon-logo diff --git a/app/assets/javascripts/mastodon-logo.coffee b/app/assets/javascripts/mastodon-logo.coffee deleted file mode 100644 index 0b4e67e798..0000000000 --- a/app/assets/javascripts/mastodon-logo.coffee +++ /dev/null @@ -1,48 +0,0 @@ -defaultClass = 'mastodon-shape' -pieces = [ - 'path#mastodon-tusk-front, path#mastodon-tusk-back', - 'path#mastodon-nose', - 'path#mastodon-cheek', - 'path#mastodon-forehead', - 'path#mastodon-backhead', - 'path#mastodon-ear', -] -pieceIndex = 0 -firstPiece = pieces[0] - -currentTimer = null -delay = 100 -runs = 0 -stop_at_run = 1 - -clearHighlights = -> - $(".#{defaultClass}.highlight").attr('class', defaultClass) - -start = -> - clearHighlights() - pieceIndex = 0 - runs = 0 - pieces.reverse() unless pieces[0] == firstPiece - clearInterval(currentTimer) if currentTimer - currentTimer = setInterval(work, delay) - -stop = -> - clearInterval(currentTimer) - clearHighlights() - -work = -> - clearHighlights() - $(pieces[pieceIndex]).attr('class', "#{defaultClass} highlight") - - if pieceIndex == pieces.length - 1 - pieceIndex = 0 - pieces.reverse() - runs++ - else - pieceIndex++ - - if runs == stop_at_run - stop() - -$(document).on 'turbolinks:load', -> - setTimeout(start, 100) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index f06c26e9d2..498fae105c 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1 +1,4 @@ +- content_for :header_tags do + = javascript_include_tag 'application' + = react_component 'Mastodon', default_props, class: 'app-holder', prerender: false diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 1746d99640..8cb062cfbe 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,7 +6,6 @@ = "#{yield(:page_title)} - " if content_for?(:page_title) Mastodon = stylesheet_link_tag 'application', media: 'all' - = javascript_include_tag 'application' = csrf_meta_tags = yield :header_tags %body{ class: @body_classes }