edit buttons
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 13 Sep 2022 13:59:39 +0000 (15:59 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 13 Sep 2022 13:59:39 +0000 (15:59 +0200)
src/chunks/static/chunks/edit.js [new file with mode: 0644]
src/chunks/static/chunks/edit.scss [new file with mode: 0644]

diff --git a/src/chunks/static/chunks/edit.js b/src/chunks/static/chunks/edit.js
new file mode 100644 (file)
index 0000000..e5f9ce8
--- /dev/null
@@ -0,0 +1,21 @@
+(function() {
+
+    // is we admin?
+    function showEditLinks() {
+        $("a.admin-link").remove();
+
+        $('span[data-edit]').each(function() {
+            e = $(this).offset();
+            a = $('<a class="admin-link" target="admin">\u270e</a>');
+            a.attr('href', '/admin/' + $(this).attr('data-edit') + '/change/');
+            a.offset(e);
+            a.appendTo(document.body)
+        });
+    }
+
+    $('.edit-links-toggle').on('click', function() {
+        showEditLinks();
+        return false;
+    })
+    
+})()
diff --git a/src/chunks/static/chunks/edit.scss b/src/chunks/static/chunks/edit.scss
new file mode 100644 (file)
index 0000000..0c18caf
--- /dev/null
@@ -0,0 +1,19 @@
+.admin-link {
+    position: absolute;
+    background: #083F4D;
+    color: white;
+    border-radius: 100%;
+    font-size: 26px;
+    line-height: 32px;
+    width: 32px;
+    text-align: center;
+    box-shadow: 0 0 10px #083F4D;
+
+    transition: color, background 150ms;
+    z-index: 9999;
+
+    &:hover {
+        color: black;
+        background: #FBC40F;
+    }
+}