From eaa5725c8f343823df30790d674cbf097ee29c9b Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Fri, 22 Dec 2017 18:11:46 -0600 Subject: [PATCH] Add manager sort block --- .eslintrc | 1 + _locales/en/messages.json | 52 ++++++++++++ global.css | 10 +-- js/localization.js | 11 +++ js/prefs.js | 1 + manage.html | 13 ++- manage/filters.js | 110 ++----------------------- manage/manage.css | 35 ++++++-- manage/manage.js | 52 +++++++++++- manage/sort.js | 169 ++++++++++++++++++++++++++++++++++++++ manage/updater-ui.js | 3 +- msgbox/msgbox.css | 8 ++ popup/search-results.js | 12 +-- 13 files changed, 343 insertions(+), 134 deletions(-) create mode 100644 manage/sort.js diff --git a/.eslintrc b/.eslintrc index bc0641d0..b4ebf99a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -49,6 +49,7 @@ globals: tNodeList: false tDocLoader: false tWordBreak: false + formatDate: false # dom.js onDOMready: false onDOMscriptReady: false diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 57d078bf..a8689abb 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -214,6 +214,10 @@ "message": "Disabled", "description": "Used in various lists/options to indicate that something is disabled" }, + "genericEnabledLabel": { + "message": "Enabled", + "description": "Used in various lists/options to indicate that something is enabled" + }, "genericHistoryLabel": { "message": "History", "description": "Used in various places to show a history log of something" @@ -234,6 +238,14 @@ "message": "Saved", "description": "Used in various parts of the UI to indicate that something was saved" }, + "genericTitle": { + "message": "Title", + "description": "Used in various parts of the UI to indicate the title of something" + }, + "genericUnknown": { + "message": "Unknown", + "description": "Used in various parts of the UI to indicate if something is unknown (e.g. an unknown date)" + }, "confirmNo": { "message": "No", "description": "'No' button in a confirm dialog" @@ -262,6 +274,14 @@ "message": "Close", "description": "'Close' button in a confirm dialog" }, + "dateInstalled": { + "message": "Date installed", + "description": "Option text for the user to sort the style by install date" + }, + "dateUpdated": { + "message": "Date updated", + "description": "Option text for the user to sort the style by last update date" + }, "dbError": { "message": "An error has occurred using the Stylus database. Would you like to visit a web page with possible solutions?", "description": "Prompt when a DB error is encountered" @@ -816,6 +836,38 @@ "shortcutsNote": { "message": "Define keyboard shortcuts" }, + "sortLabel": { + "message": "Select a sort to apply to the installed styles", + "description": "Title on the sort select to indicate it is used for sorting entries" + }, + "sortDescending": { + "message": "descending", + "description": "Text added to indicate that a sort is in the descending (Z to A) direction" + }, + "sortDateNewestFirst": { + "message": "newest first", + "description": "Text added to indicate that sorting a date would add the newest entries at the top" + }, + "sortDateOldestFirst": { + "message": "oldest first", + "description": "Text added to indicate that sorting a date would add the oldest entries at the top" + }, + "sortLabelFirst": { + "message": "first", + "description": "Text added to indicate that entry with a disabled or usercss label will be sorted first (at the top)" + }, + "sortLabelLast": { + "message": "last", + "description": "Text added to indicate that entry with a disabled or usercss label will be sorted last (at the bottom)" + }, + "sortStylesHelpTitle": { + "message": "Sort contents", + "description": "Label for the sort info popup on the Manage styles page" + }, + "sortStylesHelp": { + "message": "Choose the type of sort to apply to the installed entries from within the sort dropdown. The default setting applies an ascending sort (A to Z) to the entry titles. Sorts that include a \"(descending)\" label will apply a descending sort (Z to A) to the title.\nThere are other presets that will allow sorting the entries by multiple criteria. Think of this like sorting a table with multiple columns and each category in a select (between the plus signs) represents a column, or group.\nFor example, if the setting is \"Disabled (at bottom) + Title\", the entries would sort so that all the disabled entries are sorted to the bottom of the list and the entry titles are then applied to both disabled tags and the non-disabled tags separately.", + "description": "Text in the minihelp displayed when clicking (i) icon to the right of the sort input field on the Manage styles page" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/global.css b/global.css index a39c97e9..3351d0ac 100644 --- a/global.css +++ b/global.css @@ -41,7 +41,7 @@ input:not([type]) { padding: 0 3px; font: 400 13.3333px Arial; border: 1px solid hsl(0, 0%, 66%); -} +} .svg-icon.checked { position: absolute; @@ -115,7 +115,7 @@ select { } .select-resizer { - display: inline-flex!important; + display: inline-flex !important; cursor: default; position: relative; } @@ -196,7 +196,7 @@ select[disabled] > option { .moz-appearance-bug input[type="radio"] { -moz-appearance: radio !important; } - + .firefox select { font-size: 13px; padding: 0 20px 0 2px; @@ -228,8 +228,8 @@ select[disabled] > option { .firefox.non-windows .style-name { font-family: Arial, sans-serif; - } - + } + /* Firefox cannot handle fractions in font-size */ .firefox button:not(.install) { font-size: 13px; diff --git a/js/localization.js b/js/localization.js index 7c53cda1..8f1b4ebe 100644 --- a/js/localization.js +++ b/js/localization.js @@ -197,3 +197,14 @@ function tWordBreak(text) { return text.length <= 10 ? text : text.replace(/([\d\w\u007B-\uFFFF]{10}|[\d\w\u007B-\uFFFF]{5,10}[!-/]|((?!\s)\W){10})(?!\b|\s)/g, '$&\u00AD'); } + +function formatDate(date) { + return tryCatch(lang => { + const newDate = new Date(parseInt(date)); + return newDate.toLocaleDateString(lang, { + day: '2-digit', + month: 'short', + year: newDate.getYear() === new Date().getYear() ? undefined : '2-digit', + }); + }, [chrome.i18n.getUILanguage(), 'en']) || ''; +} diff --git a/js/prefs.js b/js/prefs.js index e2ac97eb..27a43531 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -36,6 +36,7 @@ var prefs = new function Prefs() { 'manage.newUI.favicons': false, // show favicons for the sites in applies-to 'manage.newUI.faviconsGray': true, // gray out favicons 'manage.newUI.targets': 3, // max number of applies-to targets visible: 0 = none + 'manage.newUI.sort': 'title,asc', // current applied sort 'editor.options': {}, // CodeMirror.defaults.* 'editor.options.expanded': true, // UI element state: expanded/collapsed diff --git a/manage.html b/manage.html index 0b3d029d..b6408040 100644 --- a/manage.html +++ b/manage.html @@ -155,6 +155,7 @@ + @@ -245,7 +246,6 @@ -

@@ -285,6 +285,16 @@

+
+
+ + +
+ + + +
+