Skip to content

Commit 41d183b

Browse files
authored
[refactor] Improve global, link and group edit states
1 parent 73d2795 commit 41d183b

File tree

15 files changed

+285
-226
lines changed

15 files changed

+285
-226
lines changed

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nighttab",
3-
"version": "4.1.3",
3+
"version": "4.2.1",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
55
"main": "index.js",
66
"scripts":{

‎src/css/form.css‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ input[type="range"]:disabled::-moz-range-progress{
847847
display: inline-block;
848848
}
849849

850+
/* input button */
850851
.input-buttoninput[type="checkbox"]+label,
851852
.input-buttoninput[type="radio"]+label,
852853
.input-buttoninput[type="color"]+label,
@@ -998,6 +999,7 @@ input[type="range"]:disabled::-moz-range-progress{
998999
background-color:rgb(var(--button-border-disabled));
9991000
}
10001001

1002+
/* input button link */
10011003
.input-button-linkinput[type="checkbox"]+label,
10021004
.input-button-linkinput[type="radio"]+label,
10031005
.input-button-linkinput[type="color"]+label,
@@ -1032,7 +1034,6 @@ input[type="range"]:disabled::-moz-range-progress{
10321034
.input-button-linkinput:disabled[type="color"]+label,
10331035
.input-button-linkinput:disabled[type="file"]+label{
10341036
background-color: transparent;
1035-
color: transparent;
10361037
pointer-events: none;
10371038
}
10381039

‎src/css/group.css‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@
5555
}
5656

5757
.is-group-order-headerbody.is-group-name-show .group-header,
58-
.is-group-order-headerbody.is-link-edit .group-header{
58+
.is-group-order-headerbody.is-edit .group-header{
5959
padding-bottom:calc(var(--layout-space) *var(--layout-gutter));
6060
}
6161

6262
.is-group-order-bodyheader.is-group-name-show .group-header,
63-
.is-group-order-bodyheader.is-link-edit .group-header{
63+
.is-group-order-bodyheader.is-edit .group-header{
6464
padding-top:calc(var(--layout-space) *var(--layout-gutter));
6565
}
6666

@@ -101,7 +101,7 @@
101101
margin var(--layout-timing-extra-fast);
102102
}
103103

104-
.is-link-edit .group-control{
104+
.is-edit .group-control{
105105
height:2.5em;
106106
width:16em;
107107
transition:
@@ -110,12 +110,12 @@
110110
margin var(--layout-timing-extra-fast) var(--layout-duration-04);
111111
}
112112

113-
.is-link-edit.is-group-name-show.is-group-area-alignment-left .group-control,
114-
.is-link-edit.is-group-name-show.is-group-area-alignment-center .group-control{
113+
.is-edit.is-group-name-show.is-group-area-alignment-left .group-control,
114+
.is-edit.is-group-name-show.is-group-area-alignment-center .group-control{
115115
margin-right:1em;
116116
}
117117

118-
.is-link-edit.is-group-name-show.is-group-area-alignment-right .group-control{
118+
.is-edit.is-group-name-show.is-group-area-alignment-right .group-control{
119119
margin-left:1em;
120120
}
121121

‎src/css/link.css‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -239,29 +239,29 @@
239239
border-bottom-right-radius:calc(var(--theme-radius) /4);
240240
}
241241

242-
.is-link-edit .link-panel-front,
243-
.is-link-edit .link-item:hover .link-panel-front,
244-
.is-link-edit .link-item:focus .link-panel-front{
242+
.is-edit .link-panel-front,
243+
.is-edit .link-item:hover .link-panel-front,
244+
.is-edit .link-item:focus .link-panel-front{
245245
height:calc(100%-var(--link-item-edit-height));
246246
}
247247

248-
.is-theme-radius.is-link-edit.is-link-orientation-top .link-panel-front,
249-
.is-theme-radius.is-link-edit.is-link-orientation-top .link-item:hover .link-panel-front,
250-
.is-theme-radius.is-link-edit.is-link-orientation-top .link-item:focus .link-panel-front{
248+
.is-theme-radius.is-edit.is-link-orientation-top .link-panel-front,
249+
.is-theme-radius.is-edit.is-link-orientation-top .link-item:hover .link-panel-front,
250+
.is-theme-radius.is-edit.is-link-orientation-top .link-item:focus .link-panel-front{
251251
border-top-left-radius:calc(var(--theme-radius) /4);
252252
border-top-right-radius:calc(var(--theme-radius) /4);
253253
}
254254

255-
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-panel-front,
256-
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-item:hover .link-panel-front,
257-
.is-theme-radius.is-link-edit.is-link-orientation-bottom .link-item:focus .link-panel-front{
255+
.is-theme-radius.is-edit.is-link-orientation-bottom .link-panel-front,
256+
.is-theme-radius.is-edit.is-link-orientation-bottom .link-item:hover .link-panel-front,
257+
.is-theme-radius.is-edit.is-link-orientation-bottom .link-item:focus .link-panel-front{
258258
border-bottom-left-radius:calc(var(--theme-radius) /4);
259259
border-bottom-right-radius:calc(var(--theme-radius) /4);
260260
}
261261

262-
.is-link-item-shadow-show.is-link-edit .link-panel-front,
263-
.is-link-item-shadow-show.is-link-edit .link-item:hover .link-panel-front,
264-
.is-link-item-shadow-show.is-link-edit .link-item:focus .link-panel-front{
262+
.is-link-item-shadow-show.is-edit .link-panel-front,
263+
.is-link-item-shadow-show.is-edit .link-item:hover .link-panel-front,
264+
.is-link-item-shadow-show.is-edit .link-item:focus .link-panel-front{
265265
box-shadow:var(--layout-shadow-medium);
266266
}
267267

@@ -276,7 +276,7 @@
276276
transition: font-size var(--layout-timing-extra-fast), top var(--layout-timing-extra-fast), left var(--layout-timing-extra-fast);
277277
}
278278

279-
.is-link-edit .link-display{
279+
.is-edit .link-display{
280280
font-size:0.6em;
281281
}
282282

@@ -683,23 +683,23 @@
683683
clip-path:polygon(0calc(100%-calc(var(--link-item-url-height) +10%)),100%calc(100%-calc(var(--link-item-url-height) +10%)),100%100%,0100%);
684684
}
685685

686-
.is-link-edit.is-link-orientation-top .link-panel-back,
687-
.is-link-edit.is-link-orientation-top .link-panel-back,
688-
.is-link-edit.is-link-orientation-top .link-panel-back,
689-
.is-link-edit.is-link-orientation-top .link-item:focus .link-panel-back,
690-
.is-link-edit.is-link-orientation-top .link-item:focus-within .link-panel-back,
691-
.is-link-edit.is-link-orientation-top .link-item:hover .link-panel-back{
686+
.is-edit.is-link-orientation-top .link-panel-back,
687+
.is-edit.is-link-orientation-top .link-panel-back,
688+
.is-edit.is-link-orientation-top .link-panel-back,
689+
.is-edit.is-link-orientation-top .link-item:focus .link-panel-back,
690+
.is-edit.is-link-orientation-top .link-item:focus-within .link-panel-back,
691+
.is-edit.is-link-orientation-top .link-item:hover .link-panel-back{
692692
height:100%;
693693
top:0;
694694
clip-path:polygon(00,100%0,100%calc(100%-calc(var(--link-item-edit-height) -10%)),0calc(100%-calc(var(--link-item-edit-height) -10%)))
695695
}
696696

697-
.is-link-edit.is-link-orientation-bottom .link-panel-back,
698-
.is-link-edit.is-link-orientation-bottom .link-panel-back,
699-
.is-link-edit.is-link-orientation-bottom .link-panel-back,
700-
.is-link-edit.is-link-orientation-bottom .link-item:focus .link-panel-back,
701-
.is-link-edit.is-link-orientation-bottom .link-item:focus-within .link-panel-back,
702-
.is-link-edit.is-link-orientation-bottom .link-item:hover .link-panel-back{
697+
.is-edit.is-link-orientation-bottom .link-panel-back,
698+
.is-edit.is-link-orientation-bottom .link-panel-back,
699+
.is-edit.is-link-orientation-bottom .link-panel-back,
700+
.is-edit.is-link-orientation-bottom .link-item:focus .link-panel-back,
701+
.is-edit.is-link-orientation-bottom .link-item:focus-within .link-panel-back,
702+
.is-edit.is-link-orientation-bottom .link-item:hover .link-panel-back{
703703
height:100%;
704704
top:0;
705705
clip-path:polygon(0calc(100%-calc(var(--link-item-edit-height) +10%)),100%calc(100%-calc(var(--link-item-edit-height) +10%)),100%100%,0100%);
@@ -717,7 +717,7 @@
717717
transition: height var(--layout-timing-extra-fast);
718718
}
719719

720-
.is-link-edit .link-control{
720+
.is-edit .link-control{
721721
height:var(--link-item-edit-height);
722722
}
723723

@@ -850,9 +850,9 @@
850850
justify-content: flex-end;
851851
}
852852

853-
.is-link-item-url-show:not(.is-link-edit) .link-item:focus-within .link-url,
854-
.is-link-item-url-show:not(.is-link-edit) .link-item:focus .link-url,
855-
.is-link-item-url-show:not(.is-link-edit) .link-item:hover .link-url{
853+
.is-link-item-url-show:not(.is-edit) .link-item:focus-within .link-url,
854+
.is-link-item-url-show:not(.is-edit) .link-item:focus .link-url,
855+
.is-link-item-url-show:not(.is-edit) .link-item:hover .link-url{
856856
height:var(--link-item-url-height);
857857
}
858858

@@ -873,14 +873,14 @@
873873
color:rgb(var(--theme-white));
874874
}
875875

876-
.is-link-edit.is-link-item-url-show .link-item:focus .link-panel-front,
877-
.is-link-edit.is-link-item-url-show .link-item:focus-within .link-panel-front,
878-
.is-link-edit.is-link-item-url-show .link-item:hover .link-panel-front{
876+
.is-edit.is-link-item-url-show .link-item:focus .link-panel-front,
877+
.is-edit.is-link-item-url-show .link-item:focus-within .link-panel-front,
878+
.is-edit.is-link-item-url-show .link-item:hover .link-panel-front{
879879
height:calc(100%-var(--link-item-edit-height));
880880
}
881881

882-
.is-link-edit .link-item:hover .link-url,
883-
.is-link-edit .link-item:focus .link-url{
882+
.is-edit .link-item:hover .link-url,
883+
.is-edit .link-item:focus .link-url{
884884
height:0;
885885
}
886886

‎src/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
<divclass="header-button-body">
8989
<divclass="form-group nested-button mb-0">
9090
<divclass="input-wrap input-button input-hide py-0">
91-
<inputid="control-link-edit" class="control-link-edit" type="checkbox" tabindex="1">
92-
<labelfor="control-link-edit" class="mb-0"><spanclass="label-icon"></span> Edit</label>
91+
<inputid="control-edit" class="control-edit" type="checkbox" tabindex="1">
92+
<labelfor="control-edit" class="mb-0"><spanclass="label-icon"></span> Edit</label>
9393
</div>
9494
<divclass="input-wrap py-0">
9595
<divclass="form-dropdown">

‎src/js/control.js‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ var control = (function(){
7373
link.add.group.open();
7474
}
7575
},{
76-
element: helper.e(".control-link-edit"),
77-
path: "link.edit",
76+
element: helper.e(".control-edit"),
77+
path: "edit",
7878
type: "checkbox",
7979
func: function(){
8080
link.tabindex();
@@ -2876,6 +2876,12 @@ var control = (function(){
28762876

28772877
render.class=function(){
28782878
varhtml=helper.e("html");
2879+
var_edit=function(){
2880+
helper.removeClass(html,"is-edit");
2881+
if(state.get.current().edit){
2882+
helper.addClass(html,"is-edit");
2883+
};
2884+
};
28792885
var_menu=function(){
28802886
helper.addClass(html,"is-menu");
28812887
};
@@ -3044,7 +3050,6 @@ var control = (function(){
30443050
helper.removeClass(html,"is-link-style-block");
30453051
helper.removeClass(html,"is-link-orientation-top");
30463052
helper.removeClass(html,"is-link-orientation-bottom");
3047-
helper.removeClass(html,"is-link-edit");
30483053
if(state.get.current().link.show){
30493054
helper.addClass(html,"is-link-show");
30503055
helper.addClass(html,"is-link-area-alignment-"+state.get.current().link.area.alignment);
@@ -3074,9 +3079,6 @@ var control = (function(){
30743079
if(state.get.current().link.item.border>0){
30753080
helper.addClass(html,"is-link-item-border");
30763081
};
3077-
if(state.get.current().link.edit){
3078-
helper.addClass(html,"is-link-edit");
3079-
};
30803082
};
30813083
};
30823084
var_theme=function(){
@@ -3115,6 +3117,7 @@ var control = (function(){
31153117
helper.removeClass(html,"is-background-image-show");
31163118
};
31173119
};
3120+
_edit();
31183121
_menu();
31193122
_header();
31203123
_group();
@@ -3465,9 +3468,9 @@ var control = (function(){
34653468
};
34663469
var_edit=function(){
34673470
if(bookmarks.get().length>0){
3468-
_disable.input(".control-link-edit",false);
3471+
_disable.input(".control-edit",false);
34693472
}else{
3470-
_disable.input(".control-link-edit",false);
3473+
_disable.input(".control-edit",true);
34713474
};
34723475
};
34733476
var_group=function(){

‎src/js/header.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,24 +134,19 @@ var header = (function(){
134134
style: function(){
135135
varaction={
136136
box: function(){
137-
helper.removeClass(helper.getClosest(helper.e(".control-link-edit"),".input-wrap"),"input-button-link");
137+
helper.removeClass(helper.getClosest(helper.e(".control-edit"),".input-wrap"),"input-button-link");
138138
helper.removeClass(helper.e(".control-add-toggle"),"button-link");
139139
helper.removeClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"),".input-wrap"),"input-button-link");
140140
helper.removeClass(helper.e(".control-menu-open"),"button-link");
141141
},
142142
clear: function(){
143-
helper.addClass(helper.getClosest(helper.e(".control-link-edit"),".input-wrap"),"input-button-link");
143+
helper.addClass(helper.getClosest(helper.e(".control-edit"),".input-wrap"),"input-button-link");
144144
helper.addClass(helper.e(".control-add-toggle"),"button-link");
145145
helper.addClass(helper.getClosest(helper.e(".control-theme-accent-current-quick"),".input-wrap"),"input-button-link");
146146
helper.addClass(helper.e(".control-menu-open"),"button-link");
147147
}
148148
};
149149
action[state.get.current().header.button.style]();
150-
},
151-
edit: function(){
152-
if(!state.get.current().link.edit){
153-
helper.e(".control-link-edit").checked=false;
154-
};
155150
}
156151
};
157152

‎src/js/keyboard.js‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,28 @@ var keyboard = (function(){
1414
dropdown.close();
1515
}elseif(state.get.current().autoSuggest){
1616
autoSuggest.close();
17+
}elseif(state.get.current().link.edit){
18+
link.edit.item.close();
19+
shade.close();
20+
data.save();
1721
}elseif(state.get.current().link.add){
1822
link.add.item.close();
23+
shade.close();
24+
data.save();
25+
}elseif(state.get.current().group.edit){
26+
link.edit.group.close();
27+
shade.close();
28+
data.save();
1929
}elseif(state.get.current().group.add){
2030
link.add.group.close();
21-
}elseif(state.get.current().link.edit&&state.get.current().modal){
22-
link.add.item.close();
23-
}elseif(state.get.current().link.edit){
24-
link.edit.close();
31+
shade.close();
2532
data.save();
2633
}elseif(state.get.current().modal){
2734
modal.close();
2835
shade.close();
36+
}elseif(state.get.current().edit){
37+
link.edit.mode.close();
38+
data.save();
2939
};
3040
data.save();
3141
};
@@ -103,7 +113,11 @@ var keyboard = (function(){
103113
window.addEventListener("keydown",function(event){
104114
// ctrl+alt+e
105115
if(event.ctrlKey&&event.altKey&&event.keyCode==69){
106-
link.edit.toggle();
116+
if(bookmarks.get().length>0){
117+
link.edit.mode.toggle();
118+
}else{
119+
link.edit.mode.close();
120+
};
107121
data.save();
108122
};
109123
},false);

0 commit comments

Comments
(0)