Skip to content

Commit 7c261b3

Browse files
committed
[feature] add clock and date separator text controls
1 parent a360b8a commit 7c261b3

File tree

7 files changed

+90
-6
lines changed

7 files changed

+90
-6
lines changed

‎src/html/menu/content/header/clock.html‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ <h1 class="menu-item-header-text">Clock</h1>
5858
<inputid="control-header-clock-separator-show" class="control-header-clock-separator-show" type="checkbox" tabindex="-1">
5959
<labelfor="control-header-clock-separator-show"><spanclass="label-icon"></span> Separators</label>
6060
</div>
61+
<divclass="form-indent">
62+
<divclass="form-wrap">
63+
<inputid="control-header-clock-separator-text" class="control-header-clock-separator-text" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder=":" tabindex="-1">
64+
</div>
65+
</div>
6166
<hr>
6267
<divclass="form-wrap">
6368
<inputid="control-header-clock-hour24-show" class="control-header-clock-hour24-show" type="checkbox" tabindex="-1">

‎src/html/menu/content/header/date.html‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ <h1 class="menu-item-header-text">Date</h1>
141141
<inputid="control-header-date-separator-show" class="control-header-date-separator-show" type="checkbox" tabindex="-1">
142142
<labelfor="control-header-date-separator-show"><spanclass="label-icon"></span> Separators</label>
143143
</div>
144+
<divclass="form-indent">
145+
<divclass="form-wrap">
146+
<inputid="control-header-date-separator-text" class="control-header-date-separator-text" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" placeholder="/" tabindex="-1">
147+
</div>
148+
</div>
144149
<hr>
145150
<divclass="form-wrap">
146151
<labelclass="control-header-date-format-label">Format</label>

‎src/js/clock.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ var clock = (function(){
111111
clock.appendChild(elementMeridiem);
112112
};
113113
if(state.get.current().header.clock.separator.show){
114-
varseparatorCharacter=":";
114+
if(state.get.current().header.clock.separator.text.trim().replace(/\s\s+/g," ")!=""){
115+
varseparatorCharacter=state.get.current().header.clock.separator.text.trim().replace(/\s\s+/g," ");
116+
}else{
117+
varseparatorCharacter=state.get.default().header.clock.separator.text;
118+
};
115119
varparts=clock.querySelectorAll("span");
116120
if(parts.length>1){
117121
parts.forEach(function(arrayItem,index){

‎src/js/control.js‎

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,15 @@ var control = (function(){
13151315
element: ".control-header-clock-separator-show",
13161316
path: "header.clock.separator.show",
13171317
type: "checkbox",
1318+
func: function(){
1319+
clock.render.clear();
1320+
clock.render.all();
1321+
render.dependents();
1322+
}
1323+
},{
1324+
element: ".control-header-clock-separator-text",
1325+
path: "header.clock.separator.text",
1326+
type: "text",
13181327
func: function(){
13191328
clock.render.clear();
13201329
clock.render.all();
@@ -1732,6 +1741,19 @@ var control = (function(){
17321741
element: ".control-header-date-separator-show",
17331742
path: "header.date.separator.show",
17341743
type: "checkbox",
1744+
func: function(){
1745+
date.render.clear();
1746+
date.render.all();
1747+
greeting.render.clear();
1748+
greeting.render.all();
1749+
transitional.render.clear();
1750+
transitional.render.all();
1751+
render.dependents();
1752+
}
1753+
},{
1754+
element: ".control-header-date-separator-text",
1755+
path: "header.date.separator.text",
1756+
type: "text",
17351757
func: function(){
17361758
date.render.clear();
17371759
date.render.all();
@@ -6876,7 +6898,24 @@ var control = (function(){
68766898
},
68776899
dependents: function(){
68786900
return[
6879-
".control-header-clock-separator-show"
6901+
".control-header-clock-separator-show",
6902+
".control-header-clock-separator-text"
6903+
];
6904+
}
6905+
},{
6906+
condition: function(){
6907+
varactiveCount=0;
6908+
vartoCheck=[state.get.current().header.clock.seconds.show,state.get.current().header.clock.minutes.show,state.get.current().header.clock.hours.show];
6909+
toCheck.forEach(function(arrayItem,index){
6910+
if(arrayItem==true){
6911+
activeCount++;
6912+
};
6913+
});
6914+
return(state.get.current().header.clock.separator.show&&activeCount>=2&&(state.get.current().header.clock.seconds.show||state.get.current().header.clock.minutes.show||state.get.current().header.clock.hours.show));
6915+
},
6916+
dependents: function(){
6917+
return[
6918+
".control-header-clock-separator-text"
68806919
];
68816920
}
68826921
},{
@@ -6984,7 +7023,24 @@ var control = (function(){
69847023
},
69857024
dependents: function(){
69867025
return[
6987-
".control-header-date-separator-show"
7026+
".control-header-date-separator-show",
7027+
".control-header-date-separator-text"
7028+
];
7029+
}
7030+
},{
7031+
condition: function(){
7032+
varactiveCount=0;
7033+
vartoCheck=[state.get.current().header.date.day.show,state.get.current().header.date.date.show,state.get.current().header.date.month.show,state.get.current().header.date.year.show];
7034+
toCheck.forEach(function(arrayItem,index){
7035+
if(arrayItem==true){
7036+
activeCount++;
7037+
};
7038+
});
7039+
return(state.get.current().header.date.separator.show&&activeCount>=2&&(state.get.current().header.date.day.show||state.get.current().header.date.date.show||state.get.current().header.date.month.show||state.get.current().header.date.year.show));
7040+
},
7041+
dependents: function(){
7042+
return[
7043+
".control-header-date-separator-text"
69887044
];
69897045
}
69907046
},{

‎src/js/date.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ var date = (function(){
128128
date.appendChild(elementYear);
129129
};
130130
if(state.get.current().header.date.separator.show){
131-
varseparatorCharacter="/";
131+
if(state.get.current().header.date.separator.text.trim().replace(/\s\s+/g," ")!=""){
132+
varseparatorCharacter=state.get.current().header.date.separator.text.trim().replace(/\s\s+/g," ");
133+
}else{
134+
varseparatorCharacter=state.get.default().header.date.separator.text;
135+
};
132136
varparts=date.querySelectorAll("span");
133137
if(parts.length>1){
134138
parts.forEach(function(arrayItem,index){

‎src/js/state.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var state = (function(){
3333
display: "number"
3434
},
3535
separator: {
36-
show: true
36+
show: true,
37+
text: ":"
3738
},
3839
meridiem: {
3940
show: true
@@ -73,7 +74,8 @@ var state = (function(){
7374
display: "number"
7475
},
7576
separator: {
76-
show: true
77+
show: true,
78+
text: "/"
7779
},
7880
format: "datemonth",
7981
size: 1,
@@ -351,9 +353,15 @@ var state = (function(){
351353
width: 100
352354
},
353355
clock: {
356+
separator: {
357+
text: ":"
358+
},
354359
size: 1
355360
},
356361
date: {
362+
separator: {
363+
text: "/"
364+
},
357365
size: 1
358366
},
359367
search: {

‎src/js/update.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,8 @@ var update = (function(){
900900
speed: 200,
901901
step: 10
902902
};
903+
data.state.header.clock.separator.text=":";
904+
data.state.header.date.separator.text="/";
903905
returndata;
904906
}
905907
};

0 commit comments

Comments
(0)