@@ -45,25 +45,41 @@ function loadProvisuToolbar(element, url, file, extra) {
4545 '<div class="tooltip-inner tooltip-wide"></div></div>' ,
4646 } ) ;
4747 $ ( '#toolbar-smaller' ) . click ( function ( ) {
48- setFontSize ( getFontSize ( ) - 4 ) ;
48+ setFontSize ( - 4 ) ;
4949 } ) ;
5050 $ ( '#toolbar-bigger' ) . click ( function ( ) {
51- setFontSize ( getFontSize ( ) + 4 ) ;
51+ setFontSize ( 4 ) ;
5252 } ) ;
5353 } ) ;
5454 }
5555}
5656
57- function getFontSize ( ) {
58- var el = document . body ;
59- var style = window . getComputedStyle ( el , null ) . getPropertyValue ( 'font-size' ) ;
60- return parseFloat ( style ) ;
61- }
62-
63- function setFontSize ( size ) {
64- var el = document . body ;
65- el . style . fontSize = size + 'px' ;
66- return size ;
57+ function setFontSize ( variant ) {
58+ var tags = [ 'span' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ] ;
59+ var elements = [ document . body ] ;
60+ var tmp ;
61+ var currentFontSize ;
62+ var currentLineHeight ;
63+ var newSize ;
64+ var newHeight ;
65+ for ( var i = 0 ; i < tags . length ; i ++ ) {
66+ tmp = Array . prototype . slice . call (
67+ document . body . getElementsByTagName ( tags [ i ] ) , 0
68+ ) ;
69+ elements = elements . concat ( tmp ) ;
70+ }
71+ for ( i = 0 ; i < elements . length ; i ++ ) {
72+ currentFontSize = parseFloat (
73+ window . getComputedStyle ( elements [ i ] , null ) . getPropertyValue ( 'font-size' )
74+ ) ;
75+ currentLineHeight = parseFloat (
76+ window . getComputedStyle ( elements [ i ] , null ) . getPropertyValue ( 'line-height' )
77+ ) ;
78+ newSize = currentFontSize + variant ;
79+ newHeight = currentLineHeight + variant ;
80+ elements [ i ] . style . fontSize = newSize + 'px' ;
81+ elements [ i ] . style . lineHeight = newHeight + 'px' ;
82+ }
6783}
6884
6985function generateHTML ( element , url , i18n , extra ) {
@@ -124,17 +140,16 @@ function generateHTML(element, url, i18n, extra) {
124140 'title="' + i18n . toolbarDescription . message + '">' +
125141 '<i class="fa fa-low-vision fa-2x" aria-hidden="true"></i>' +
126142 '</a>' +
127- // Remove font-size buttons
128- // '<button type="button" class="btn btn-default" id="toolbar-smaller" ' +
129- // 'data-toggle="tooltip" data-placement="bottom" ' +
130- // 'title="' + i18n.infoSmaller.message + '">' +
131- // '<i class="fa fa-minus fa-2x" aria-hidden="true"></i>' +
132- // '</button>' +
133- // '<button type="button" class="btn btn-default" id="toolbar-bigger" ' +
134- // 'data-toggle="tooltip" data-placement="bottom" ' +
135- // 'title="' + i18n.infoBigger.message + '">' +
136- // '<i class="fa fa-plus fa-2x" aria-hidden="true"></i>' +
137- // '</button>' +
143+ '<button type="button" class="btn btn-default" id="toolbar-smaller" ' +
144+ 'data-toggle="tooltip" data-placement="bottom" ' +
145+ 'title="' + i18n . infoSmaller . message + '">' +
146+ '<i class="fa fa-minus fa-2x" aria-hidden="true"></i>' +
147+ '</button>' +
148+ '<button type="button" class="btn btn-default" id="toolbar-bigger" ' +
149+ 'data-toggle="tooltip" data-placement="bottom" ' +
150+ 'title="' + i18n . infoBigger . message + '">' +
151+ '<i class="fa fa-plus fa-2x" aria-hidden="true"></i>' +
152+ '</button>' +
138153 '</div>' ;
139154 }
140155 document . getElementById ( element ) . innerHTML = html ;
0 commit comments