Remove injection order code (for now)

This commit is contained in:
Rob Garrison 2019-01-27 19:25:17 -06:00
parent 7d7e7e9f72
commit 71baf445e0
7 changed files with 9 additions and 140 deletions

View File

@ -1271,10 +1271,6 @@
"shortcutsNote": { "shortcutsNote": {
"message": "Define keyboard shortcuts" "message": "Define keyboard shortcuts"
}, },
"sortColumnInjection": {
"message": "injection order",
"description": "Column name seen in the tooltip when hovering over the header; used to replace the 'sortLabel` placeholder"
},
"sortColumnEnabled": { "sortColumnEnabled": {
"message": "enabled styles", "message": "enabled styles",
"description": "Column name seen in the tooltip when hovering over the header; used to replace the 'sortLabel` placeholder" "description": "Column name seen in the tooltip when hovering over the header; used to replace the 'sortLabel` placeholder"
@ -1304,10 +1300,6 @@
}, },
"description": "Title added to links in the manager page header to inform the user on how to sort the columns" "description": "Title added to links in the manager page header to inform the user on how to sort the columns"
}, },
"sortHeaderOrderLabel": {
"message": "Click and drag the icon to\nchange the style injection order",
"description": "Tooltip shown on manage page while hovering over the sort column header"
},
"styleBadRegexp": { "styleBadRegexp": {
"message": "Regexp is invalid.", "message": "Regexp is invalid.",
"description": "Validation message for a bad regexp in a style" "description": "Validation message for a bad regexp in a style"

View File

@ -40,12 +40,6 @@
</svg> </svg>
</label> </label>
</div> </div>
<div class="entry-col entry-id"></div>
<div class="entry-col entry-sort" draggable="true">
<svg class="svg-icon sort" viewBox="0 0 24 24">
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
</svg>
</div>
<div class="entry-col entry-state"> <div class="entry-col entry-state">
<label class="checkmate" tabindex="0"> <label class="checkmate" tabindex="0">
<input class="entry-state-toggle" type="checkbox"> <input class="entry-state-toggle" type="checkbox">
@ -182,7 +176,6 @@
<script src="manage/manage-ui.js"></script> <script src="manage/manage-ui.js"></script>
<script src="manage/manage-actions.js"></script> <script src="manage/manage-actions.js"></script>
<script src="manage/bulk-actions.js"></script> <script src="manage/bulk-actions.js"></script>
<script data-src="manage/draggable.js"></script>
<script data-src="vendor-overwrites/colorpicker/colorconverter.js"></script> <script data-src="vendor-overwrites/colorpicker/colorconverter.js"></script>
<script data-src="vendor-overwrites/colorpicker/colorpicker.js"></script> <script data-src="vendor-overwrites/colorpicker/colorpicker.js"></script>
@ -492,10 +485,6 @@
<path d="M6.42 7.58L2.92 3.5h8.75l-3.5 4.08v4.09c-1 0-1.75-.76-1.75-1.75V7.58z"/> <path d="M6.42 7.58L2.92 3.5h8.75l-3.5 4.08v4.09c-1 0-1.75-.76-1.75-1.75V7.58z"/>
</svg> </svg>
</div> </div>
<div class="entry-col header-id">
<a href="#" class="sortable tt-se" data-type="order" i18n-data-title="sortLabel;sortColumnInjection">#<span></span></a>
</div>
<div class="entry-col header-sort center-text tt-se" i18n-text="sortHeader" i18n-data-title="sortHeaderOrderLabel"></div>
<a href="#" class="entry-col sortable header-state center-text tt-se" i18n-text="genericEnabledLabel" i18n-data-title="sortLabel;sortColumnEnabled" data-type="enabled"><span></span></a> <a href="#" class="entry-col sortable header-state center-text tt-se" i18n-text="genericEnabledLabel" i18n-data-title="sortLabel;sortColumnEnabled" data-type="enabled"><span></span></a>
<div class="entry-col header-name"> <div class="entry-col header-name">
<a href="#" class="sortable tt-se" i18n-text="genericName" i18n-data-title="sortLabel;sortColumnName" data-type="title"><span></span></a> <a href="#" class="sortable tt-se" i18n-text="genericName" i18n-data-title="sortLabel;sortColumnName" data-type="title"><span></span></a>

View File

@ -1,58 +0,0 @@
/* global $$ installed updateInjectionOrder */
'use strict';
// Polyfill for mobile? - https://caniuse.com/#feat=dragndrop
(() => {
let dragged = null;
function isEnabled() {
return installed.dataset.sort === 'order';
}
function cleanup() {
$$('.entry.dragging').forEach(el => {
el.classList.remove('dragging');
});
if (isEnabled() && $('body').classList.contains('dragging')) {
updateInjectionOrder();
}
$('body').classList.remove('dragging');
}
document.addEventListener('dragstart', event => {
if (isEnabled()) {
const el = event.target && event.target.closest('.entry');
if (el) {
dragged = el;
el.classList.add('dragging');
$('body').classList.add('dragging');
}
} else {
cleanup();
return false;
}
}, false);
document.addEventListener('dragend', () => {
cleanup();
});
document.addEventListener('dragenter', event => {
if (isEnabled()) {
const el = event.target && event.target.closest('.entry, .entry-header');
if (el && dragged) {
// Insert after the target; keeps header at top
el.after(dragged);
}
}
}, false);
document.addEventListener('drop', event => {
event.preventDefault();
cleanup();
if (dragged) {
dragged = null;
}
}, false);
})();

View File

@ -10,7 +10,6 @@ global messageBox getStyleWithNoCode
scrollElementIntoView FIREFOX scrollElementIntoView FIREFOX
UI bulk UI bulk
*/ */
/* exported updateInjectionOrder */
'use strict'; 'use strict';
let installed; let installed;
@ -56,8 +55,7 @@ function onRuntimeMessage(msg) {
} }
setTimeout(() => { setTimeout(() => {
sorter.updateStripes({onlyWhenColumnsChanged: true}); sorter.updateStripes({onlyWhenColumnsChanged: true});
updateInjectionOrder(); }, 0);
}, 0, );
} }
@ -408,7 +406,6 @@ function handleDelete(id) {
btnApply.dataset.value = Number(btnApply.dataset.value) - 1; btnApply.dataset.value = Number(btnApply.dataset.value) - 1;
} }
showFiltersStats(); showFiltersStats();
updateInjectionOrder();
} }
} }
@ -442,10 +439,13 @@ function switchUI({styleOnly} = {}) {
const missingFavicons = UI.favicons && !$('.entry-applies-to img[src]'); const missingFavicons = UI.favicons && !$('.entry-applies-to img[src]');
if (changed.targets) { if (changed.targets) {
for (const targets of $$('.entry .targets')) { for (const targetWrapper of $$('.entry .targets')) {
$$('.target', targets).forEach((el, indx) => { const targets = $$('.target', targetWrapper);
el.classList.toggle('extra', indx >= UI.targets); targets.forEach((target, indx) => {
target.classList.toggle('extra', indx >= UI.targets);
}); });
$('.applies-to-extra-expander', targetWrapper)
.classList.toggle('hidden', targets.length <= UI.targets);
} }
return; return;
} }
@ -488,20 +488,6 @@ function removeSelection() {
} }
} }
function updateInjectionOrder() {
if (installed.dataset.sort === 'order') {
const entries = [...installed.children];
entries.shift(); // remove header
entries.forEach((entry, index) => {
entry.styleMeta.injectionOrder = index + 1;
$('.entry-id', entry).textContent = index + 1;
UI.injectionXref[entry.styleMeta.id] = index + 1;
});
sorter.update();
// TODO: Update database
}
}
function lazyLoad() { function lazyLoad() {
setTimeout(() => { setTimeout(() => {
$$('link[data-href]').forEach(link => { $$('link[data-href]').forEach(link => {

View File

@ -17,8 +17,6 @@ const UI = {
faviconsGray: prefs.get('manage.newUI.faviconsGray'), faviconsGray: prefs.get('manage.newUI.faviconsGray'),
targets: prefs.get('manage.newUI.targets'), targets: prefs.get('manage.newUI.targets'),
injectionXref: {},
labels: { labels: {
'usercss': { 'usercss': {
is: ({style}) => typeof style.usercssData !== 'undefined', is: ({style}) => typeof style.usercssData !== 'undefined',
@ -47,17 +45,6 @@ const UI = {
showStyles: (styles = [], matchUrlIds) => { showStyles: (styles = [], matchUrlIds) => {
UI.addHeaderLabels(); UI.addHeaderLabels();
// map injection order of styles
if (styles && styles.length && !styles.every(s => s.injectionOrder)) {
UI.injectionXref = styles
.sort((a, b) => ((a.injectionOrder || a.id) - (b.injectionOrder || b.id)))
.map((s, index) => (s.injectionOrder = index + 1))
.reduce((acc, s) => {
acc[s.id] = s.injectionOrder;
return acc;
}, {});
}
const sorted = sorter.sort({ const sorted = sorter.sort({
styles: styles.map(style => ({ styles: styles.map(style => ({
style, style,
@ -152,7 +139,6 @@ const UI = {
(style.updateUrl ? ' updatable' : '') + (style.updateUrl ? ' updatable' : '') +
(style.usercssData ? ' usercss' : ''); (style.usercssData ? ' usercss' : '');
$('.entry-id', entry).textContent = style.injectionOrder || UI.injectionXref[style.id];
let el = $('.entry-homepage', entry); let el = $('.entry-homepage', entry);
el.classList.toggle('invisible', !style.url); el.classList.toggle('invisible', !style.url);
el.href = style.url || ''; el.href = style.url || '';

View File

@ -2,7 +2,7 @@
--header-icon-size: 20px; --header-icon-size: 20px;
--entry-icon-size: 20px; --entry-icon-size: 20px;
--favicon-size: 16px; --favicon-size: 16px;
--narrow-column: 75px; --narrow-column: 60px;
--header-height: 40px; --header-height: 40px;
--toolbar-height: 60px; --toolbar-height: 60px;
--entry-height: 30px; --entry-height: 30px;
@ -186,7 +186,7 @@ a:hover {
#installed .entry, #installed .entry,
#installed .entry-header { #installed .entry-header {
width: 100%; width: 100%;
height: var(--entry-height); line-height: var(--entry-height);
display: flex; display: flex;
flex: 0 0 var(--narrow-column); flex: 0 0 var(--narrow-column);
flex-flow: row nowrap; flex-flow: row nowrap;
@ -227,7 +227,6 @@ body.all-styles-hidden-by-filters #installed:after {
.center-text, .center-text,
.entry-filter, .entry-filter,
.entry-state, .entry-state,
.entry-sort,
.entry-last-update { .entry-last-update {
text-align: center; text-align: center;
justify-content: center; justify-content: center;
@ -331,10 +330,6 @@ body.all-styles-hidden-by-filters #installed:after {
color: #000; color: #000;
} }
.entry-sort {
cursor: move;
}
.targets { .targets {
flex-wrap: wrap; flex-wrap: wrap;
} }
@ -361,8 +356,6 @@ body.all-styles-hidden-by-filters #installed:after {
width: var(--favicon-size); width: var(--favicon-size);
} }
.header-sort,
.entry-sort,
#installed:not(.has-favicons) .targets img, #installed:not(.has-favicons) .targets img,
#installed.has-favicons .targets img:not([src]), #installed.has-favicons .targets img:not([src]),
#installed.has-favicons .targets img[src] + svg { #installed.has-favicons .targets img[src] + svg {
@ -389,15 +382,6 @@ body.all-styles-hidden-by-filters #installed:after {
pointer-events: none; pointer-events: none;
} }
body.dragging .entry:not(.dragging) .entry-name:before {
/* hide the sustained hover */
background-image: none !important;
}
.entry.dragging {
background: linear-gradient(to right, hsla(255, 50%, 30%, 0.2), hsla(180, 20%, 10%, 0.05) 50%, transparent);
}
.entry.enabled .entry-name:hover .style-name { .entry.enabled .entry-name:hover .style-name {
color: hsla(180, 100%, 15%, 1); color: hsla(180, 100%, 15%, 1);
} }
@ -435,7 +419,6 @@ body.dragging .entry:not(.dragging) .entry-name:before {
.disabled .entry-name, .disabled .entry-name,
.disabled .entry-actions, .disabled .entry-actions,
.disabled .entry-sort,
.disabled .entry-version, .disabled .entry-version,
.disabled .entry-last-update { .disabled .entry-last-update {
opacity: 0.6; opacity: 0.6;
@ -480,7 +463,6 @@ a svg, .svg-icon.sort {
} }
#installed[data-sort="order"] .header-sort, #installed[data-sort="order"] .header-sort,
#installed[data-sort="order"] .entry-sort,
/* Update icons */ /* Update icons */
.can-update .update, .can-update .update,
.no-update:not(.update-problem):not(.update-done) .up-to-date, .no-update:not(.update-problem):not(.update-done) .up-to-date,
@ -583,9 +565,6 @@ a svg, .svg-icon.sort {
.entry.hide-extra .target.extra { .entry.hide-extra .target.extra {
display: none; display: none;
} }
.entry:not(.hide-extra) {
height: auto !important;
}
#faviconsHelp { #faviconsHelp {
overflow-y: auto; overflow-y: auto;

View File

@ -25,11 +25,6 @@ const sorter = (() => {
parse: ({name}) => name, parse: ({name}) => name,
sorter: sorterType.alpha sorter: sorterType.alpha
}, },
order: {
text: '#',
parse: ({style}) => style.injectionOrder || style.id,
sorter: sorterType.number,
},
usercss: { usercss: {
text: 'Usercss', text: 'Usercss',
parse: ({style}) => style.usercssData ? 0 : 1, parse: ({style}) => style.usercssData ? 0 : 1,