Browse Source

allow font resize with keyboard +- and 0.

Thomas Buck 3 years ago
parent
commit
cbe153b05b
1 changed files with 24 additions and 4 deletions
  1. 24
    4
      page.html

+ 24
- 4
page.html View File

143
             print '</script>'
143
             print '</script>'
144
     %-->
144
     %-->
145
     <script type="text/javascript">
145
     <script type="text/javascript">
146
-        jQuery(window).resize(function() {
147
-            $('#wrap').css('height', $('#nav').css('height'));
148
-        });
149
-        $(document).ready(function(){
146
+        $(document).ready(function() {
147
+            jQuery(window).resize(function() {
148
+                $('#wrap').css('height', $('#nav').css('height'));
149
+            });
150
             $('#wrap').css('height', $('#nav').css('height'));
150
             $('#wrap').css('height', $('#nav').css('height'));
151
 
151
 
152
             var fontSize = parseInt($('body').css('font-size'), 10);
152
             var fontSize = parseInt($('body').css('font-size'), 10);
153
             var initialFontSize = fontSize;
153
             var initialFontSize = fontSize;
154
+
154
             $('.inc').on('click', function() {
155
             $('.inc').on('click', function() {
155
                 fontSize += 1;
156
                 fontSize += 1;
156
                 $('#content').css('font-size', fontSize + 'px');
157
                 $('#content').css('font-size', fontSize + 'px');
167
                     $('#content').css('font-size', initialFontSize + 'px');
168
                     $('#content').css('font-size', initialFontSize + 'px');
168
                 }
169
                 }
169
             })
170
             })
171
+
172
+            $(document).keypress(function(event) {
173
+                if (event.charCode == '+'.charCodeAt(0)) {
174
+                    fontSize += 1;
175
+                    $('#content').css('font-size', fontSize + 'px');
176
+                }
177
+                if (event.charCode == '-'.charCodeAt(0)) {
178
+                    if (fontSize > 1) {
179
+                        fontSize -= 1;
180
+                        $('#content').css('font-size', fontSize + 'px');
181
+                    }
182
+                }
183
+                if (event.charCode == '0'.charCodeAt(0)) {
184
+                    if (fontSize != initialFontSize) {
185
+                        fontSize = initialFontSize;
186
+                        $('#content').css('font-size', initialFontSize + 'px');
187
+                    }
188
+                }
189
+            });
170
         })
190
         })
171
     </script>
191
     </script>
172
     <script type="text/javascript" src="js/jquery.mousewheel.min.js"></script>
192
     <script type="text/javascript" src="js/jquery.mousewheel.min.js"></script>

Loading…
Cancel
Save