Skip to content

Commit 8965ef7

Browse files
committed
reuse options' code for notes
+ increase messagebox x icon to avoid misclicks + use identical x/y padding for content
1 parent 7394e4f commit 8965ef7

File tree

5 files changed

+29
-38
lines changed

5 files changed

+29
-38
lines changed

src/js/dlg/message-box.css

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
#message-box-title {
6767
font-weight: bold;
6868
background-color: var(--accent-3);
69-
padding: .75rem 24px .75rem 52px;
69+
padding: .75rem 2.5rem .75rem 52px;
7070
font-size: 1rem;
7171
position: relative;
7272
min-height: 42px;
@@ -107,19 +107,33 @@
107107
}
108108
}
109109

110+
#message-box.note {
111+
align-items: center;
112+
justify-content: center;
113+
white-space: pre-wrap;
114+
> div {
115+
max-width: 40em;
116+
top: unset;
117+
right: unset;
118+
position: relative;
119+
}
120+
}
121+
110122
#message-box-close-icon {
111123
cursor: pointer;
112124
position: absolute;
113-
right: 3px;
114-
top: 4px;
125+
right: 0;
126+
top: 0;
115127
& i {
116128
font-size: 16px;
129+
padding: .75rem;
130+
display: block;
117131
}
118132
}
119133

120134
#message-box-contents {
121135
overflow: auto;
122-
padding: 1.5rem .75rem;
136+
padding: 1rem;
123137
position: relative;
124138
flex-grow: 9;
125139
overflow-wrap: break-word;

src/js/dom-on-load.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,15 @@ function suppressFocusRingOnClick({target}) {
193193
}
194194

195195
function interceptClick(event) {
196-
const el = event.target.closest('[data-cmd=note]');
197-
if (el) {
196+
let note = event.target.closest('[data-cmd=note]');
197+
if (note) {
198198
event.preventDefault();
199+
note = tooltips.get(note) || note.title;
199200
messageBox.show({
200201
className: 'note center-dialog',
201-
contents: tHTML(tooltips.get(el) || el.title),
202+
contents: note.includes('<') ? tHTML(note) :
203+
note.includes('\n') ? $create('div', note.split('\n').map(line => $create('p', line))) :
204+
note,
202205
buttons: [t('confirmClose')],
203206
});
204207
}
@@ -210,15 +213,16 @@ function interceptClick(event) {
210213
function splitLongTooltips() {
211214
for (const el of $$('[title]')) {
212215
tooltips.set(el, el.title);
213-
el.title = el.title.replace(/\s*<\/?[^>]+>\s*/g, ' '); // strip html tags
216+
// Strip html tags but allow <invalid-html-tags> which we use to emphasize stuff
217+
el.title = el.title.replace(/(\n\s*)?<\/?[a-z]+[^>]*>(\n\s*)?/g, ' ');
214218
if (el.title.length < 50) {
215219
continue;
216220
}
217221
const newTitle = el.title
218222
.split('\n')
219223
.map(s => s.replace(/([.?!]\s+|[]\s*|.{50,60},)\s+/gu, '$1\n'))
220224
.map(s => s.replace(/(.{50,80}(?=.{40,}))\s+/gu, '$1\n'))
221-
.join('\n');
225+
.join('\n\n');
222226
if (newTitle !== el.title) el.title = newTitle;
223227
}
224228
}

src/manage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ <h2 i18n="manageFilters">:
235235
<option i18n="searchStylesAll" value="all"></option>
236236
</select>
237237
</div>
238-
<a id="search-help" tabindex="0" class="icon">
238+
<a id="search-help" tabindex="0" class="icon" i18n="title:searchStylesHelp">
239239
<i class=i-info></i>
240240
</a>
241241
</div>
@@ -246,7 +246,7 @@ <h2 i18n="manageFilters">:
246246
<div class="select-wrapper" i18n="title:sortLabel">
247247
<select id="manage.newUI.sort"></select>
248248
</div>
249-
<a id="sorter-help" tabindex="0" class="icon">
249+
<a id="sorter-help" tabindex="0" class="icon" data-cmd="note" i18n="title:sortStylesHelp">
250250
<i class=i-info></i>
251251
</a>
252252
</div>

src/manage/sorter.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {UCD} from '@/js/consts';
22
import {$, $create, dom} from '@/js/dom';
3-
import {messageBox} from '@/js/dom-util';
43
import {t} from '@/js/localization';
54
import {installed} from '@/manage/util';
65
import * as prefs from '@/js/prefs';
@@ -78,7 +77,6 @@ let minWidth;
7877

7978
export function init() {
8079
prefs.subscribe(ID, update);
81-
$('#sorter-help').onclick = showHelp;
8280
addOptions();
8381
prefs.subscribe('manage.minColumnWidth', updateColumnWidth, true);
8482
}
@@ -203,16 +201,3 @@ function onResize(evt) {
203201
}
204202
return c;
205203
}
206-
207-
async function showHelp(event) {
208-
event.preventDefault();
209-
messageBox.show({
210-
className: 'help-text center-dialog',
211-
title: t('sortStylesHelpTitle'),
212-
contents:
213-
$create('div',
214-
t('sortStylesHelp').split('\n').map(line =>
215-
$create('p', line))),
216-
buttons: [t('confirmOK')],
217-
});
218-
}

src/options/options.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,6 @@ a.icon {
203203
}
204204
}
205205

206-
#message-box.note {
207-
align-items: center;
208-
justify-content: center;
209-
white-space: pre-wrap;
210-
> div {
211-
max-width: 40em;
212-
top: unset;
213-
right: unset;
214-
position: relative;
215-
}
216-
}
217-
218206
.sync-status {
219207
padding-left: 1em;
220208
box-sizing: border-box;

0 commit comments

Comments
 (0)