Skip to content

Commit 90049b0

Browse files
authored
Merge pull request #147 from Fideow2/master
Improve settings readability, fix theme sync bugs, and enhance timer interactions; with unwanted changes reverted
2 parents 9c1546f + 1718468 commit 90049b0

14 files changed

Lines changed: 177 additions & 20 deletions

.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
approvedGitRepositories:
2+
- "**"
3+
14
compressionLevel: mixed
25

36
enableGlobalCache: false
47

8+
enableScripts: true
9+
510
nodeLinker: node-modules

custom-dialog.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,28 @@
1717
<body>
1818
<script src="supporter.js"></script>
1919
<style>
20+
html, body {
21+
width: 100%;
22+
margin: 0;
23+
}
24+
2025
#main {
26+
width: 100%;
27+
box-sizing: border-box;
2128
padding: 10px 12px;
2229
}
2330

2431
#timer {
32+
flex: 1 1 auto;
2533
width: 100% !important;
2634
max-width: 100%;
35+
min-width: 0;
36+
}
37+
38+
#dialog-msg,
39+
#dialog-detail {
40+
width: 100%;
41+
margin-bottom: 12px;
2742
}
2843

2944
#dialog-buttons {

floating.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</div>
2626
</div>
2727
<div id="floating-hover" onmouseover="hover()" onmouseleave="unhover()" ontouchstart="semihover()">
28-
<div class="small" id="floating-stopper" style="margin-top: 8px;">
28+
<div class="small" id="floating-stopper">
2929
<a id="stopper" href="#" role="button" class="text-muted" draggable="false">
3030
<i class="iconfont icon-pause"></i>
3131
</a>
@@ -102,6 +102,16 @@
102102
}
103103
}
104104

105+
function renderSkipperIcon(isReset) {
106+
if (isReset) {
107+
$("#floating-skipper a").html('<span class="reset-icon" id="skipper" aria-hidden="true">&#8634;</span>');
108+
$('#skipper').attr('title', i18n.__('positive-reset-tip'));
109+
} else {
110+
$("#floating-skipper a").html("<i class='iconfont icon-fastforward' id='skipper'></i>");
111+
$('#skipper').attr('title', i18n.__('skipper'));
112+
}
113+
}
114+
105115
const STOPPER_DEBOUNCE_MS = 320;
106116
function stopper(ev) {
107117
if (ev && ev.preventDefault) ev.preventDefault();
@@ -222,6 +232,7 @@
222232
.addClass("work")
223233
.removeClass("positive rest onlyRest");
224234
$("#time-left-msg").text(i18n.__('min-left'));
235+
renderSkipperIcon(false);
225236
$('#floating-bottom-bar').css("background-color", newWorkColor + "19");
226237
$('#floating-bottom-bar').css("display", "block");
227238
method = 1;
@@ -233,6 +244,7 @@
233244
$(".work").removeClass("onlyRest");
234245
$('#floating-bottom-bar').css("display", "none");
235246
$("#time-left-msg").text(i18n.__('min-already'));
247+
renderSkipperIcon(true);
236248
method = 3;
237249
}
238250

@@ -282,4 +294,4 @@
282294
<script src="theme.js"></script>
283295
</body>
284296

285-
</html>
297+
</html>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,4 +722,4 @@ <h6 id="new-feature-title" class="rest align-content-center small text-left"></h
722722
<script src="theme.js"></script>
723723
</body>
724724

725-
</html>
725+
</html>

locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"tip": "Press Enter to submit",
4343
"back-index": "Give up the schedule & Back",
4444
"skipper": "Skip current timer",
45+
"positive-reset": "Reset",
46+
"positive-reset-tip": "Reset the current stopwatch to zero and start again; saved statistics will not be cleared.",
4547
"not-enough": "Some items weren't set or the time is less than 5s, so the timer cannot start.",
4648
"too-long": "The time is too long. Please make it less than a day.",
4749
"back": "Back",

locales/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"tip": "输入各个项目,然后按 Enter 键开始计时",
4141
"back-index": "结束当前计时返回首页",
4242
"skipper": "提前跳过当前的时间",
43+
"positive-reset": "重置",
44+
"positive-reset-tip": "将当前正计时归零并重新开始;已记录的统计不会被清空。",
4345
"not-enough": "请合法输入工作时间、休息时间和循环次数。暂时不支持 5 秒以下的时间。",
4446
"too-long": "长度超过一天的计划暂时不能添加。",
4547
"back": "返回",

locales/zh-TW.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"tip": "輸入各個項目,然後按 Enter 鍵開始計時",
4141
"back-index": "結束當前計時返回首頁",
4242
"skipper": "提前跳過當前的時間",
43+
"positive-reset": "重置",
44+
"positive-reset-tip": "將當前正計時歸零並重新開始;已記錄的統計不會被清空。",
4345
"not-enough": "請合法輸入工作時間、休息時間和循環次數。暫時不支持 5 秒以下的時間。",
4446
"too-long": "長度超過一天的計劃暫時不能添加。",
4547
"back": "返回",

preferences-renderer.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,36 @@ function preferenceCreator(items, container, inner) {
1818
break;
1919
}
2020
}
21+
initializeSettingsTipToggles(container);
22+
}
23+
24+
function initializeSettingsTipToggles(container) {
25+
$(container).find('p.settings-msg').each(function () {
26+
let tip = $(this);
27+
if (tip.data('settings-tip-ready') || tip.hasClass('d-none')) return;
28+
if ($.trim(tip.text()) === '' && tip.find('a').length === 0) return;
29+
30+
let button = $(`
31+
<button type="button" class="settings-tip-toggle" aria-expanded="false" title="${ i18n.__('helper') }">
32+
?
33+
</button>
34+
`);
35+
36+
tip.data('settings-tip-ready', true);
37+
tip.addClass('settings-tip-content settings-tip-collapsed');
38+
tip.attr('aria-hidden', 'true');
39+
40+
let label = tip.prevAll('label:first');
41+
if (label.length > 0) label.after(button);
42+
else tip.before(button);
43+
44+
button.on('click', function () {
45+
let expanded = button.attr('aria-expanded') === 'true';
46+
button.attr('aria-expanded', expanded ? 'false' : 'true');
47+
tip.toggleClass('settings-tip-collapsed', expanded);
48+
tip.attr('aria-hidden', expanded ? 'true' : 'false');
49+
});
50+
});
2151
}
2252

2353
function titleSolution(obj, parent) {
@@ -708,9 +738,9 @@ function domString(type) {
708738
onkeydown="if(event.keyCode === 13) lock($('#passcode-locker').val(), $('#passcode-locker-again').val());"
709739
type="password" />
710740
<br /><br/>
711-
<div class="text-muted small">
741+
<small class="text-grey settings-title">
712742
${ store.get('islocked') ? i18n.__('locker-settings-input-tip-lock-mode-on') : i18n.__('locker-settings-input-tip-lock-mode-off') }
713-
</div></div></div>
743+
</small></div></div>
714744
<br/>`
715745
;
716746
break;
@@ -1091,6 +1121,7 @@ function colorSet(id) {
10911121
ipc.send("logger", $("#color-" + id).val());
10921122
themeColorList[id] = $("#color-" + id).val();
10931123
store.set("theme-color", themeColorList);
1124+
ipc.send("theme-color-changed");
10941125
}
10951126

10961127
function colorInitializer() {

renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ ipc.on('zoom-ratio-feedback', () => zoomRatioChange());
123123

124124
ipc.on('alert', (event, message) => {
125125
alert(message);
126-
})
126+
})

statistics.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,16 @@ <h2 class="text-muted">
478478
topPadding: 19,
479479
bottomPadding: 39,
480480
datasets: [{
481-
fillColor: '#5490eacc',
481+
fillColor: newWorkColor + 'cc',
482482
data: thisWeekWorkTimesInHour
483483
}, {
484-
fillColor: '#ea5454cc',
484+
fillColor: newRestColor + 'cc',
485485
data: thisWeekRestTimesInHour
486486
}, {
487-
fillColor: '#a26ae5cc',
487+
fillColor: newOnlyRestColor + 'cc',
488488
data: thisWeekOnlyRestTimesInHour
489489
}, {
490-
fillColor: '#17a2b8cc',
490+
fillColor: newPositiveColor + 'cc',
491491
data: thisWeekPositiveTimesInHour
492492
}]
493493
}
@@ -527,16 +527,16 @@ <h2 class="text-muted">
527527
bottomPadding: 59,
528528
showValue: false,
529529
datasets: [{
530-
fillColor: '#5490eacc',
530+
fillColor: newWorkColor + 'cc',
531531
data: thisYearWorkTimesInHour
532532
}, {
533-
fillColor: '#ea5454cc',
533+
fillColor: newRestColor + 'cc',
534534
data: thisYearRestTimesInHour
535535
}, {
536-
fillColor: '#a26ae5cc',
536+
fillColor: newOnlyRestColor + 'cc',
537537
data: thisYearOnlyRestTimesInHour
538538
}, {
539-
fillColor: '#17a2b8cc',
539+
fillColor: newPositiveColor + 'cc',
540540
data: thisYearPositiveTimesInHour
541541
}]
542542
}
@@ -586,6 +586,7 @@ <h2 class="text-muted">
586586

587587
</script>
588588
<script src="renderer.js"></script>
589+
<script src="theme.js"></script>
589590
</body>
590591

591-
</html>
592+
</html>

0 commit comments

Comments
 (0)