aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/default/js/base.js48
-rw-r--r--assets/default/scss/shaarli.scss47
-rw-r--r--assets/vintage/css/shaarli.css2
3 files changed, 61 insertions, 36 deletions
diff --git a/assets/default/js/base.js b/assets/default/js/base.js
index 0f29799d..be986ae0 100644
--- a/assets/default/js/base.js
+++ b/assets/default/js/base.js
@@ -10,7 +10,7 @@ import Awesomplete from 'awesomplete';
10 * @returns Found element or null. 10 * @returns Found element or null.
11 */ 11 */
12function findParent(element, tagName, attributes) { 12function findParent(element, tagName, attributes) {
13 const parentMatch = key => attributes[key] !== '' && element.getAttribute(key).indexOf(attributes[key]) !== -1; 13 const parentMatch = (key) => attributes[key] !== '' && element.getAttribute(key).indexOf(attributes[key]) !== -1;
14 while (element) { 14 while (element) {
15 if (element.tagName.toLowerCase() === tagName) { 15 if (element.tagName.toLowerCase() === tagName) {
16 if (Object.keys(attributes).find(parentMatch)) { 16 if (Object.keys(attributes).find(parentMatch)) {
@@ -25,16 +25,18 @@ function findParent(element, tagName, attributes) {
25/** 25/**
26 * Ajax request to refresh the CSRF token. 26 * Ajax request to refresh the CSRF token.
27 */ 27 */
28function refreshToken(basePath) { 28function refreshToken(basePath, callback) {
29 console.log('refresh');
30 const xhr = new XMLHttpRequest(); 29 const xhr = new XMLHttpRequest();
31 xhr.open('GET', `${basePath}/admin/token`); 30 xhr.open('GET', `${basePath}/admin/token`);
32 xhr.onload = () => { 31 xhr.onload = () => {
33 const elements = document.querySelectorAll('input[name="token"]'); 32 const elements = document.querySelectorAll('input[name="token"]');
34 [...elements].forEach((element) => { 33 [...elements].forEach((element) => {
35 console.log(element);
36 element.setAttribute('value', xhr.responseText); 34 element.setAttribute('value', xhr.responseText);
37 }); 35 });
36
37 if (callback) {
38 callback(xhr.response);
39 }
38 }; 40 };
39 xhr.send(); 41 xhr.send();
40} 42}
@@ -99,7 +101,7 @@ function updateAwesompleteList(selector, tags, instances) {
99 * @see http://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript 101 * @see http://stackoverflow.com/questions/18749591/encode-html-entities-in-javascript
100 */ 102 */
101function htmlEntities(str) { 103function htmlEntities(str) {
102 return str.replace(/[\u00A0-\u9999<>&]/gim, i => `&#${i.charCodeAt(0)};`); 104 return str.replace(/[\u00A0-\u9999<>&]/gim, (i) => `&#${i.charCodeAt(0)};`);
103} 105}
104 106
105/** 107/**
@@ -192,8 +194,8 @@ function removeClass(element, classname) {
192function init(description) { 194function init(description) {
193 function resize() { 195 function resize() {
194 /* Fix jumpy resizing: https://stackoverflow.com/a/18262927/1484919 */ 196 /* Fix jumpy resizing: https://stackoverflow.com/a/18262927/1484919 */
195 const scrollTop = window.pageYOffset || 197 const scrollTop = window.pageYOffset
196 (document.documentElement || document.body.parentNode || document.body).scrollTop; 198 || (document.documentElement || document.body.parentNode || document.body).scrollTop;
197 199
198 description.style.height = 'auto'; 200 description.style.height = 'auto';
199 description.style.height = `${description.scrollHeight + 10}px`; 201 description.style.height = `${description.scrollHeight + 10}px`;
@@ -488,9 +490,10 @@ function init(description) {
488 }); 490 });
489 }); 491 });
490 492
491 const ids = links.map(item => item.id); 493 const ids = links.map((item) => item.id);
492 window.location = 494 window.location = (
493 `${basePath}/admin/shaare/visibility?token=${token.value}&newVisibility=${visibility}&id=${ids.join('+')}`; 495 `${basePath}/admin/shaare/visibility?token=${token.value}&newVisibility=${visibility}&id=${ids.join('+')}`
496 );
494 }); 497 });
495 }); 498 });
496 } 499 }
@@ -552,6 +555,7 @@ function init(description) {
552 } 555 }
553 const refreshedToken = document.getElementById('token').value; 556 const refreshedToken = document.getElementById('token').value;
554 const fromtag = block.getAttribute('data-tag'); 557 const fromtag = block.getAttribute('data-tag');
558 const fromtagUrl = block.getAttribute('data-tag-url');
555 const xhr = new XMLHttpRequest(); 559 const xhr = new XMLHttpRequest();
556 xhr.open('POST', `${basePath}/admin/tags`); 560 xhr.open('POST', `${basePath}/admin/tags`);
557 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 561 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
@@ -561,6 +565,7 @@ function init(description) {
561 location.reload(); 565 location.reload();
562 } else { 566 } else {
563 block.setAttribute('data-tag', totag); 567 block.setAttribute('data-tag', totag);
568 block.setAttribute('data-tag-url', encodeURIComponent(totag));
564 input.setAttribute('name', totag); 569 input.setAttribute('name', totag);
565 input.setAttribute('value', totag); 570 input.setAttribute('value', totag);
566 findParent(input, 'div', { class: 'rename-tag-form' }).style.display = 'none'; 571 findParent(input, 'div', { class: 'rename-tag-form' }).style.display = 'none';
@@ -569,15 +574,18 @@ function init(description) {
569 .querySelector('a.tag-link') 574 .querySelector('a.tag-link')
570 .setAttribute('href', `${basePath}/?searchtags=${encodeURIComponent(totag)}`); 575 .setAttribute('href', `${basePath}/?searchtags=${encodeURIComponent(totag)}`);
571 block 576 block
577 .querySelector('a.count')
578 .setAttribute('href', `${basePath}/add-tag/${encodeURIComponent(totag)}`);
579 block
572 .querySelector('a.rename-tag') 580 .querySelector('a.rename-tag')
573 .setAttribute('href', `${basePath}/admin/tags?fromtag=${encodeURIComponent(totag)}`); 581 .setAttribute('href', `${basePath}/admin/tags?fromtag=${encodeURIComponent(totag)}`);
574 582
575 // Refresh awesomplete values 583 // Refresh awesomplete values
576 existingTags = existingTags.map(tag => (tag === fromtag ? totag : tag)); 584 existingTags = existingTags.map((tag) => (tag === fromtag ? totag : tag));
577 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes); 585 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes);
578 } 586 }
579 }; 587 };
580 xhr.send(`renametag=1&fromtag=${encodeURIComponent(fromtag)}&totag=${encodeURIComponent(totag)}&token=${refreshedToken}`); 588 xhr.send(`renametag=1&fromtag=${fromtagUrl}&totag=${encodeURIComponent(totag)}&token=${refreshedToken}`);
581 refreshToken(basePath); 589 refreshToken(basePath);
582 }); 590 });
583 }); 591 });
@@ -600,6 +608,7 @@ function init(description) {
600 event.preventDefault(); 608 event.preventDefault();
601 const block = findParent(event.target, 'div', { class: 'tag-list-item' }); 609 const block = findParent(event.target, 'div', { class: 'tag-list-item' });
602 const tag = block.getAttribute('data-tag'); 610 const tag = block.getAttribute('data-tag');
611 const tagUrl = block.getAttribute('data-tag-url');
603 const refreshedToken = document.getElementById('token').value; 612 const refreshedToken = document.getElementById('token').value;
604 613
605 if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) { 614 if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) {
@@ -609,10 +618,10 @@ function init(description) {
609 xhr.onload = () => { 618 xhr.onload = () => {
610 block.remove(); 619 block.remove();
611 }; 620 };
612 xhr.send(encodeURI(`deletetag=1&fromtag=${tag}&token=${refreshedToken}`)); 621 xhr.send(`deletetag=1&fromtag=${tagUrl}&token=${refreshedToken}`);
613 refreshToken(basePath); 622 refreshToken(basePath);
614 623
615 existingTags = existingTags.filter(tagItem => tagItem !== tag); 624 existingTags = existingTags.filter((tagItem) => tagItem !== tag);
616 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes); 625 awesomepletes = updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes);
617 } 626 }
618 }); 627 });
@@ -622,4 +631,15 @@ function init(description) {
622 [...autocompleteFields].forEach((autocompleteField) => { 631 [...autocompleteFields].forEach((autocompleteField) => {
623 awesomepletes.push(createAwesompleteInstance(autocompleteField)); 632 awesomepletes.push(createAwesompleteInstance(autocompleteField));
624 }); 633 });
634
635 const exportForm = document.querySelector('#exportform');
636 if (exportForm != null) {
637 exportForm.addEventListener('submit', (event) => {
638 event.preventDefault();
639
640 refreshToken(basePath, () => {
641 event.target.submit();
642 });
643 });
644 }
625})(); 645})();
diff --git a/assets/default/scss/shaarli.scss b/assets/default/scss/shaarli.scss
index 759dff29..a528adb0 100644
--- a/assets/default/scss/shaarli.scss
+++ b/assets/default/scss/shaarli.scss
@@ -69,20 +69,22 @@ pre {
69 font-family: 'Roboto'; 69 font-family: 'Roboto';
70 font-weight: 400; 70 font-weight: 400;
71 font-style: normal; 71 font-style: normal;
72 src: local('Roboto'), 72 src:
73 local('Roboto-Regular'), 73 local('Roboto'),
74 url('../fonts/Roboto-Regular.woff2') format('woff2'), 74 local('Roboto-Regular'),
75 url('../fonts/Roboto-Regular.woff') format('woff'); 75 url('../fonts/Roboto-Regular.woff2') format('woff2'),
76 url('../fonts/Roboto-Regular.woff') format('woff');
76} 77}
77 78
78@font-face { 79@font-face {
79 font-family: 'Roboto'; 80 font-family: 'Roboto';
80 font-weight: 700; 81 font-weight: 700;
81 font-style: normal; 82 font-style: normal;
82 src: local('Roboto'), 83 src:
83 local('Roboto-Bold'), 84 local('Roboto'),
84 url('../fonts/Roboto-Bold.woff2') format('woff2'), 85 local('Roboto-Bold'),
85 url('../fonts/Roboto-Bold.woff') format('woff'); 86 url('../fonts/Roboto-Bold.woff2') format('woff2'),
87 url('../fonts/Roboto-Bold.woff') format('woff');
86} 88}
87 89
88body, 90body,
@@ -375,7 +377,7 @@ body,
375} 377}
376 378
377@media screen and (max-width: 64em) { 379@media screen and (max-width: 64em) {
378 .header-search , 380 .header-search,
379 .header-search * { 381 .header-search * {
380 visibility: hidden; 382 visibility: hidden;
381 } 383 }
@@ -554,7 +556,6 @@ body,
554 color: $dark-grey; 556 color: $dark-grey;
555 font-size: .9em; 557 font-size: .9em;
556 558
557
558 a { 559 a {
559 display: inline-block; 560 display: inline-block;
560 margin: 3px 0; 561 margin: 3px 0;
@@ -616,6 +617,11 @@ body,
616 padding: 5px; 617 padding: 5px;
617 text-decoration: none; 618 text-decoration: none;
618 color: $dark-grey; 619 color: $dark-grey;
620
621 &.selected {
622 background: var(--main-color);
623 color: $white;
624 }
619 } 625 }
620 626
621 input { 627 input {
@@ -1552,11 +1558,11 @@ form {
1552 text-align: center; 1558 text-align: center;
1553 1559
1554 a { 1560 a {
1561 background: $almost-white;
1555 display: inline-block; 1562 display: inline-block;
1556 margin: 0 15px; 1563 padding: 5px;
1557 text-decoration: none; 1564 text-decoration: none;
1558 color: $white; 1565 color: $dark-grey;
1559 font-weight: bold;
1560 } 1566 }
1561} 1567}
1562 1568
@@ -1604,13 +1610,14 @@ form {
1604 1610
1605 > div { 1611 > div {
1606 border-radius: 10px; 1612 border-radius: 10px;
1607 background: repeating-linear-gradient( 1613 background:
1608 -45deg, 1614 repeating-linear-gradient(
1609 $almost-white, 1615 -45deg,
1610 $almost-white 6px, 1616 $almost-white,
1611 var(--background-color) 6px, 1617 $almost-white 6px,
1612 var(--background-color) 12px 1618 var(--background-color) 6px,
1613 ); 1619 var(--background-color) 12px
1620 );
1614 width: 0%; 1621 width: 0%;
1615 height: 10px; 1622 height: 10px;
1616 } 1623 }
diff --git a/assets/vintage/css/shaarli.css b/assets/vintage/css/shaarli.css
index 87c440c8..1688dce0 100644
--- a/assets/vintage/css/shaarli.css
+++ b/assets/vintage/css/shaarli.css
@@ -746,8 +746,6 @@ a.bigbutton, #pageheader a.bigbutton {
746 text-align: left; 746 text-align: left;
747 background-color: transparent; 747 background-color: transparent;
748 background-color: rgba(0, 0, 0, 0.4); 748 background-color: rgba(0, 0, 0, 0.4);
749 /* FF3+, Saf3+, Opera 10.10+, Chrome, IE9 */
750 filter: progid: DXImageTransform.Microsoft.gradient(startColorstr=#66000000, endColorstr=#66000000);
751 /* IE6–IE9 */ 749 /* IE6–IE9 */
752 text-shadow: 2px 2px 1px #000000; 750 text-shadow: 2px 2px 1px #000000;
753} 751}