@@ -6,19 +6,14 @@ let lhDefault;
66let widthDefault ;
77let columnDefault ;
88
9- const textOptionsContainer = document . querySelector ( "#text-options-container" ) ;
10- const textButton = document . querySelector ( "#text-options-btn" ) ;
119const fontPlusButton = document . querySelector ( ".font-plus" ) ;
1210const fontMinusButton = document . querySelector ( ".font-minus" ) ;
13- const fontField = document . querySelector ( ".text-options-size input" ) ;
1411
1512const lhPlusButton = document . querySelector ( ".lh-plus" ) ;
1613const lhMinusButton = document . querySelector ( ".lh-minus" ) ;
17- const lhField = document . querySelector ( ".text-options-lh input" ) ;
1814
1915const widthPlusButton = document . querySelector ( ".width-plus" ) ;
2016const widthMinusButton = document . querySelector ( ".width-minus" ) ;
21- const widthField = document . querySelector ( ".text-options-width input" ) ;
2217
2318const oneColButton = document . querySelector ( ".column-one" ) ;
2419const twoColButton = document . querySelector ( ".column-two" ) ;
@@ -41,10 +36,6 @@ const domObserver = new MutationObserver((mutationList, observer) => {
4136 const width = getFromLocalStorage ( "textWidth" , widthDefault ) ;
4237 const columnCount = getFromLocalStorage ( "columnCount" , columnDefault ) ;
4338
44- fontField . value = `${ fontSize } px` ;
45- lhField . value = `${ lhSize . toFixed ( 1 ) } ` ;
46- widthField . value = `${ Math . round ( width ) } %` ;
47-
4839 textItems . forEach ( ( item ) => {
4940 setFontSize ( item , `${ convertPixelsToRem ( fontSize ) } rem` ) ;
5041 setLineHeight ( item , Number ( lhSize . toPrecision ( 2 ) ) ) ;
@@ -59,23 +50,6 @@ const domObserver = new MutationObserver((mutationList, observer) => {
5950
6051domObserver . observe ( theText , { childList : true , subtree : true } ) ;
6152
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-
7953fontPlusButton . addEventListener ( "click" , ( ) => {
8054 resizeFont ( "+" ) ;
8155} ) ;
@@ -117,41 +91,6 @@ function changeColumnCount(num) {
11791 localStorage . setItem ( "columnCount" , num ) ;
11892}
11993
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-
15594function getFontSize ( element ) {
15695 const elementComputedStyle = window . getComputedStyle ( element ) ;
15796 return parseFloat ( elementComputedStyle . fontSize ) ;
@@ -194,7 +133,6 @@ function resizeLineHeight(operation) {
194133 setLineHeight ( item , Number ( newSize . toPrecision ( 2 ) ) ) ;
195134 } ) ;
196135
197- lhField . value = Number ( newSize . toPrecision ( 2 ) ) . toFixed ( 1 ) ;
198136 localStorage . setItem ( "lineHeight" , newSize . toPrecision ( 2 ) ) ;
199137}
200138
@@ -210,7 +148,6 @@ function resizeFont(operation) {
210148 setFontSize ( item , `${ convertPixelsToRem ( newSize ) } rem` ) ;
211149 } ) ;
212150
213- fontField . value = `${ newSize } px` ;
214151 localStorage . setItem ( "fontSize" , newSize ) ;
215152}
216153
@@ -225,7 +162,6 @@ function changeTextWidth(operation) {
225162 readPaneLeft . style . width = `${ newWidth } %` ;
226163 readPaneRight . style . width = `${ ( 100 - newWidth ) * getReadPaneWidthRatio ( ) } %` ;
227164
228- widthField . value = `${ Math . round ( newWidth ) } %` ;
229165 localStorage . setItem ( "textWidth" , newWidth ) ;
230166}
231167
@@ -255,4 +191,4 @@ function clamp (num, min, max) {
255191// viewport width. it can be less than that. but for the right side it's an absolute percentage value
256192function getReadPaneWidthRatio ( ) {
257193 return parseFloat ( window . getComputedStyle ( readPaneContainer ) . getPropertyValue ( "width" ) ) / parseFloat ( document . documentElement . clientWidth ) ;
258- }
194+ }
0 commit comments