From b1034114d72f395e8c1731937852be80cd55c6bc Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Thu, 29 Nov 2018 06:35:05 -0600 Subject: [PATCH] Disable input & hide icon --- install-usercss/install-usercss.css | 1 + install-usercss/install-usercss.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/install-usercss/install-usercss.css b/install-usercss/install-usercss.css index 71b6ebf5..a86ef582 100644 --- a/install-usercss/install-usercss.css +++ b/install-usercss/install-usercss.css @@ -248,6 +248,7 @@ h2.installed.active { .unavailable-message, .unavailable .available-message, +.unavailable .svg-icon, .live-reload.unavailable input, .set-update-url.unavailable input { display: none; diff --git a/install-usercss/install-usercss.js b/install-usercss/install-usercss.js index 8eeefbe9..47194fce 100644 --- a/install-usercss/install-usercss.js +++ b/install-usercss/install-usercss.js @@ -16,7 +16,7 @@ let port; if (params.has('direct')) { - $('.live-reload').classList.add('unavailable'); + setUnavailable('.live-reload'); getCodeDirectly(); } else { port = chrome.tabs.connect(tabId); @@ -315,7 +315,7 @@ checker.disabled = true; } else if (updateUrl.href === DUMMY_URL) { // drag'n'dropped on the manage page and the style doesn't have @updateURL - $('.set-update-url').classList.add('unavailable'); + setUnavailable('.set-update-url'); return; } else if (updateUrl.protocol !== 'file:') { checker.checked = true; @@ -354,6 +354,14 @@ } } + function setUnavailable(label) { + const el = $(label); + el.classList.add('unavailable'); + const input = $('input', el); + input.disabled = true; + input.checked = false; + } + function getAppliesTo(style) { function *_gen() { for (const section of style.sections) {