@@ -6,19 +6,14 @@ let lhDefault;
6
6
let widthDefault ;
7
7
let columnDefault ;
8
8
9
- const textOptionsContainer = document . querySelector ( "#text-options-container" ) ;
10
- const textButton = document . querySelector ( "#text-options-btn" ) ;
11
9
const fontPlusButton = document . querySelector ( ".font-plus" ) ;
12
10
const fontMinusButton = document . querySelector ( ".font-minus" ) ;
13
- const fontField = document . querySelector ( ".text-options-size input" ) ;
14
11
15
12
const lhPlusButton = document . querySelector ( ".lh-plus" ) ;
16
13
const lhMinusButton = document . querySelector ( ".lh-minus" ) ;
17
- const lhField = document . querySelector ( ".text-options-lh input" ) ;
18
14
19
15
const widthPlusButton = document . querySelector ( ".width-plus" ) ;
20
16
const widthMinusButton = document . querySelector ( ".width-minus" ) ;
21
- const widthField = document . querySelector ( ".text-options-width input" ) ;
22
17
23
18
const oneColButton = document . querySelector ( ".column-one" ) ;
24
19
const twoColButton = document . querySelector ( ".column-two" ) ;
@@ -41,10 +36,6 @@ const domObserver = new MutationObserver((mutationList, observer) => {
41
36
const width = getFromLocalStorage ( "textWidth" , widthDefault ) ;
42
37
const columnCount = getFromLocalStorage ( "columnCount" , columnDefault ) ;
43
38
44
- fontField . value = `${ fontSize } px` ;
45
- lhField . value = `${ lhSize . toFixed ( 1 ) } ` ;
46
- widthField . value = `${ Math . round ( width ) } %` ;
47
-
48
39
textItems . forEach ( ( item ) => {
49
40
setFontSize ( item , `${ convertPixelsToRem ( fontSize ) } rem` ) ;
50
41
setLineHeight ( item , Number ( lhSize . toPrecision ( 2 ) ) ) ;
@@ -59,23 +50,6 @@ const domObserver = new MutationObserver((mutationList, observer) => {
59
50
60
51
domObserver . observe ( theText , { childList : true , subtree : true } ) ;
61
52
62
- textButton . addEventListener ( "click" , ( ) => {
63
- textOptionsContainer . classList . toggle ( "hide-text-options" ) ;
64
- } ) ;
65
-
66
- // stop propagation so clicking anything inside the popup
67
- // doesn't trigger text button click event
68
- textOptionsContainer . addEventListener ( "click" , ( e ) => {
69
- e . stopPropagation ( ) ;
70
- } ) ;
71
-
72
- // clicking away closes the popup
73
- document . addEventListener ( "click" , ( e ) => {
74
- if ( ! e . target . closest ( "#text-options-btn" ) ) {
75
- textOptionsContainer . classList . add ( "hide-text-options" ) ;
76
- }
77
- } ) ;
78
-
79
53
fontPlusButton . addEventListener ( "click" , ( ) => {
80
54
resizeFont ( "+" ) ;
81
55
} ) ;
@@ -117,41 +91,6 @@ function changeColumnCount(num) {
117
91
localStorage . setItem ( "columnCount" , num ) ;
118
92
}
119
93
120
- fontField . addEventListener ( "change" , ( e ) => {
121
- let size = parseFloat ( e . target . value ) ;
122
- size = clamp ( size , 1 , 50 ) ;
123
- e . target . value = `${ size } px` ;
124
-
125
- textItems . forEach ( ( item ) => {
126
- setFontSize ( item , `${ convertPixelsToRem ( size ) } rem` ) ;
127
- } ) ;
128
-
129
- localStorage . setItem ( "fontSize" , size ) ;
130
- } ) ;
131
-
132
- lhField . addEventListener ( "change" , ( e ) => {
133
- let size = parseFloat ( e . target . value ) ;
134
- size = clamp ( size , 1 , 5 ) ;
135
- e . target . value = size ;
136
-
137
- textItems . forEach ( ( item ) => {
138
- setLineHeight ( item , size ) ;
139
- } ) ;
140
-
141
- localStorage . setItem ( "lineHeight" , size . toPrecision ( 2 ) ) ;
142
- } ) ;
143
-
144
- widthField . addEventListener ( "change" , ( e ) => {
145
- let size = parseFloat ( e . target . value ) ;
146
- size = clamp ( size , 25 , 75 ) ;
147
- e . target . value = `${ size } %` ;
148
-
149
- readPaneLeft . style . width = `${ size } %` ;
150
- readPaneRight . style . width = `${ ( 100 - size ) * getReadPaneWidthRatio ( ) } %` ;
151
-
152
- localStorage . setItem ( "textWidth" , size ) ;
153
- } ) ;
154
-
155
94
function getFontSize ( element ) {
156
95
const elementComputedStyle = window . getComputedStyle ( element ) ;
157
96
return parseFloat ( elementComputedStyle . fontSize ) ;
@@ -194,7 +133,6 @@ function resizeLineHeight(operation) {
194
133
setLineHeight ( item , Number ( newSize . toPrecision ( 2 ) ) ) ;
195
134
} ) ;
196
135
197
- lhField . value = Number ( newSize . toPrecision ( 2 ) ) . toFixed ( 1 ) ;
198
136
localStorage . setItem ( "lineHeight" , newSize . toPrecision ( 2 ) ) ;
199
137
}
200
138
@@ -210,7 +148,6 @@ function resizeFont(operation) {
210
148
setFontSize ( item , `${ convertPixelsToRem ( newSize ) } rem` ) ;
211
149
} ) ;
212
150
213
- fontField . value = `${ newSize } px` ;
214
151
localStorage . setItem ( "fontSize" , newSize ) ;
215
152
}
216
153
@@ -225,7 +162,6 @@ function changeTextWidth(operation) {
225
162
readPaneLeft . style . width = `${ newWidth } %` ;
226
163
readPaneRight . style . width = `${ ( 100 - newWidth ) * getReadPaneWidthRatio ( ) } %` ;
227
164
228
- widthField . value = `${ Math . round ( newWidth ) } %` ;
229
165
localStorage . setItem ( "textWidth" , newWidth ) ;
230
166
}
231
167
@@ -255,4 +191,4 @@ function clamp (num, min, max) {
255
191
// viewport width. it can be less than that. but for the right side it's an absolute percentage value
256
192
function getReadPaneWidthRatio ( ) {
257
193
return parseFloat ( window . getComputedStyle ( readPaneContainer ) . getPropertyValue ( "width" ) ) / parseFloat ( document . documentElement . clientWidth ) ;
258
- }
194
+ }
0 commit comments