Skip to content

Commit dd7dba7

Browse files
committed
Paste choosing improve
1 parent 81c0b8c commit dd7dba7

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

css/styles.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@
403403
margin: 5px 0;
404404
}
405405

406-
.ptro-selector-btn div {
406+
.ptro-paster-select .ptro-in div {
407407
font-family: "Open Sans", sans-serif;
408+
font-size: 14px;
408409
}
409410

410411
.ptro-selector-btn:hover {
@@ -426,7 +427,7 @@
426427

427428
.ptro-paster-select .ptro-in {
428429
display: inline-block;
429-
background-color: rgba(0,0,0,0.5);
430+
background-color: rgba(0,0,0,0.7);
430431
padding: 10px;
431432
}
432433
.ptro-paster-select-wrapper {
@@ -435,4 +436,9 @@
435436
left: 0;
436437
right: 0;
437438
bottom: 0;
439+
}
440+
441+
.ptro-paste-label {
442+
color: white;
443+
margin-bottom: 10px;
438444
}

js/inserter.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { tr } from './translation';
2-
import { genId } from './utils';
2+
import { genId, KEYS } from './utils';
33

44
export default class Inserter {
55
constructor() {
@@ -79,7 +79,7 @@ export default class Inserter {
7979
this.main = main;
8080
this.worklog = main.worklog;
8181
this.selector = main.wrapper.querySelector('.ptro-paster-select-wrapper');
82-
this.selector.setAttribute('hidden', '');
82+
this.cancelChoosing();
8383
this.img = null;
8484
Object.keys(this.pasteOptions).forEach((k) => {
8585
const o = this.pasteOptions[k];
@@ -89,7 +89,7 @@ export default class Inserter {
8989
} else {
9090
o.handle(this.img);
9191
}
92-
this.selector.setAttribute('hidden', '');
92+
this.cancelChoosing();
9393
};
9494
});
9595
this.loading = false;
@@ -101,6 +101,11 @@ export default class Inserter {
101101
this.main.worklog.reCaptureState();
102102
}
103103

104+
cancelChoosing() {
105+
this.selector.setAttribute('hidden', '');
106+
this.waitChoice = false;
107+
}
108+
104109
loaded(img) {
105110
this.img = img;
106111
this.loading = false;
@@ -125,6 +130,13 @@ export default class Inserter {
125130
img.src = source;
126131
if (!empty) {
127132
this.selector.removeAttribute('hidden');
133+
this.waitChoice = true;
134+
}
135+
}
136+
137+
handleKeyDown(evt) {
138+
if (this.waitChoice && evt.keyCode === KEYS.esc) {
139+
this.cancelChoosing();
128140
}
129141
}
130142

@@ -161,8 +173,8 @@ export default class Inserter {
161173
`<div>${tr(`pasteOptions.${k}`)}</div>` +
162174
'</button>';
163175
});
164-
return `<div class="ptro-paster-select-wrapper" hidden><div class="ptro-paster-select"><div class="ptro-in">${
165-
buttons
166-
}</div></div></div>`;
176+
return '<div class="ptro-paster-select-wrapper" hidden><div class="ptro-paster-select"><div class="ptro-in">' +
177+
`<div class="ptro-paste-label">${tr('pasteOptions.how_to_paste')}</div>${
178+
buttons}</div></div></div>`;
167179
}
168180
}

js/selecter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export default class PainterroSelecter {
156156
}
157157

158158
handleKeyDown(evt) {
159+
this.main.inserter.handleKeyDown(evt);
159160
if (this.shown && this.imagePlaced) {
160161
if (evt.keyCode === KEYS.enter) {
161162
this.finishPlacing();

js/translation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class Translation {
4747
extend_down: 'Extend down',
4848
extend_right: 'Extend right',
4949
over: 'Paste over',
50+
how_to_paste: 'How to paste?',
5051
},
5152
},
5253
};

0 commit comments

Comments
 (0)