Kaynağa Gözat

integrated pending saves in the side panel

Former-commit-id: a8a2f017f220cd42b37fc2771070821fc5d0d976
Gildas 6 yıl önce
ebeveyn
işleme
83d7f7aed7

+ 43 - 0
extension/ui/bg/ui-panel.js

@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010-2019 Gildas Lormeau
+ * contact : gildas.lormeau <at> gmail.com
+ * 
+ * This file is part of SingleFile.
+ *
+ *   The code in this file is free software: you can redistribute it and/or 
+ *   modify it under the terms of the GNU Affero General Public License 
+ *   (GNU AGPL) as published by the Free Software Foundation, either version 3
+ *   of the License, or (at your option) any later version.
+ * 
+ *   The code in this file is distributed in the hope that it will be useful, 
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero 
+ *   General Public License for more details.
+ *
+ *   As additional permission under GNU AGPL version 3 section 7, you may 
+ *   distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU 
+ *   AGPL normally required by section 4, provided you include this license 
+ *   notice and a URL through which recipients can access the Corresponding 
+ *   Source.
+ */
+
+/* global document */
+
+(async () => {
+
+	const optionsTab = document.getElementById("tab-options");
+	const pendingsTab = document.getElementById("tab-pendings");
+	const viewPanel = document.getElementById("view-panel");	
+
+	optionsTab.onclick = () => {
+		optionsTab.classList.add("tab-selected");
+		pendingsTab.classList.remove("tab-selected");
+		viewPanel.src = "options.html#side-panel";
+	};
+	pendingsTab.onclick = () => {
+		optionsTab.classList.remove("tab-selected");
+		pendingsTab.classList.add("tab-selected");
+		viewPanel.src = "pendings.html#side-panel";
+	};
+
+})();

+ 4 - 1
extension/ui/bg/ui-pendings.js

@@ -21,7 +21,7 @@
  *   Source.
  */
 
-/* global browser, document, setInterval */
+/* global browser, document, setInterval, location */
 
 (async () => {
 
@@ -44,6 +44,9 @@
 		await browser.runtime.sendMessage({ method: "downloads.cancelAll" });
 		await refresh();
 	};
+	if (location.href.endsWith("#side-panel")) {
+		document.documentElement.classList.add("side-panel");
+	}
 	let URLDisplayed = true;
 	document.getElementById("URLTitleLabel").onclick = () => {
 		URLDisplayed = !URLDisplayed;

+ 50 - 0
extension/ui/pages/panel.css

@@ -0,0 +1,50 @@
+html,
+body {
+    height: 100%;
+    font-family: sans-serif;
+    font-size: 12px;
+}
+
+body {
+    display: flex;
+    flex-direction: column;
+    margin: 0;
+    height: 100%;
+    overflow: hidden;
+    background-color: #fbfbfb;
+}
+
+header {
+    display: flex;
+    flex-direction: row;
+}
+
+.tab {
+    height: 30px;
+    padding-top: 8px;
+    padding-left: 8px;
+    padding-right: 16px;
+	opacity: .5;
+	cursor: pointer;
+}
+
+.tab-selected {
+    opacity: 1;
+}
+
+main {
+    flex: 1;
+}
+
+iframe {
+    height: 100%;
+    width: 100%;
+    border-width: 0;
+}
+
+@media (prefers-color-scheme: dark) {
+    body {
+		background-color: #38383d;
+		color: #fdfdfd;
+    }
+}

+ 26 - 0
extension/ui/pages/panel.html

@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+	<title>Panel</title>
+	<link rel="stylesheet" href="panel.css">
+	<meta name="viewport" content="width=device-width,initial-scale=1">
+</head>
+
+<body>
+	<header>
+		<span id="tab-options" class="tab tab-selected">
+			options
+		</span>
+		<span id="tab-pendings" class="tab">
+			pending saves
+		</span>
+	</header>
+	<main>
+		<iframe id="view-panel" src="options.html#side-panel"></iframe>
+	</main>
+	<script type="text/javascript" src="../bg/ui-panel.js"></script>
+</body>
+
+</html>

+ 35 - 0
extension/ui/pages/pendings.css

@@ -110,6 +110,26 @@ header button {
     color: #888;
 }
 
+html.side-panel, .side-panel .result-head , .side-panel main {
+    background-color: #fbfbfb;
+}
+
+.side-panel header button {
+    position: absolute;
+    top: 4px;
+    right: 8px;
+}
+
+.side-panel main {
+    border: 0;
+    margin-left: 8px;
+    margin-right: 8px;
+}
+
+.side-panel .result-status {
+    display: none;
+}
+
 @media (prefers-color-scheme: dark) {
     html {
         background-color: #373737;
@@ -150,4 +170,19 @@ header button {
     button:hover {
         color: #2A2A2E;
     }
+
+    html.side-panel,
+    .side-panel .result-head,
+    .side-panel main,
+    .side-panel button {
+        background-color: #38383d;
+    }
+
+    .side-panel .result-head {
+        border-bottom: dashed 1px rgb(191, 191, 191);
+    }
+
+    .side-panel .result-cancel button {
+        color: #fdfdfd;        
+    }
 }

+ 2 - 2
manifest.json

@@ -101,8 +101,8 @@
 	"options_page": "extension/ui/pages/options.html",
 	"sidebar_action": {
 		"browser_style": true,
-		"default_title": "SingleFile options",
-		"default_panel": "extension/ui/pages/options.html#side-panel",
+		"default_title": "SingleFile",
+		"default_panel": "extension/ui/pages/panel.html",
 		"default_icon": "extension/ui/resources/icon_128.png",
 		"open_at_install": false
 	},