1/************************************************************************************************* 2 * Accessibility Font Resizer 3 * 4 * Project URL : https://github.com/SatelliteWP/accessibility-font-resizer 5 * 6 * By SatelliteWP - 2019 7 * https://www.SatelliteWP.som 8 * 9 ************************************************************************************************/ 10 11/** 12 * When document is ready 13 */ 14jQuery(document).ready(function($) { 15 16 // Direct call to normal size 17 $('#afr_normal, .afr_normal, #afr-normal, .arf-normal, .afr-normal').click(function(e) { 18 if (afr_debug) { console.log('AFR - Click normal size'); } 19 afr(afr_sizes['n']); 20 e.preventDefault(); 21 }); 22 23 // Direct call to large size 24 $('#afr_large, .afr_large, #afr-large, .afr-large').click(function(e) { 25 if (afr_debug) { console.log('AFR - Click large size'); } 26 afr(afr_sizes['l']); 27 e.preventDefault(); 28 }); 29 30 // Direct call to very large size 31 $('#afr_xlarge, .afr_xlarge, #afr-xlarge, .afr-xlarge').click(function(e) { 32 if (afr_debug) { console.log('AFR - Click very large size'); } 33 afr(afr_sizes['xl']); 34 e.preventDefault(); 35 }); 36 37 // setup 38 afr(afr_sizes['n'], true); 39 40 // Get previously set size 41 var s = afr_gc('afr_size'); 42 43 // Set size if previously set 44 if (s) afr(s); 45}); 46 47/** 48 * Change font size (or setup) 49 * 50 * @param {int} size Size in percentage 51 * @param {boolean} setup Setup time ? 52 */ 53function afr(size, setup) { 54 setup = (typeof setup == 'undefined') ? false : setup; 55 56 if (typeof size == 'undefined') return; 57 58 var el = jQuery('body'), tags; 59 60 for ( var i = 0 ; i < afr_elems.length ; i++ ) { 61 tags = el.find( afr_elems[ i ] ); 62 for ( var j = 0 ; j < tags.length ; j++ ) { 63 64 if (setup) { 65 var ofs = jQuery(tags[ j ]).css('font-size'); 66 jQuery(tags[ j ]).attr('data-swp-font-size', ofs); 67 if (afr_debug) console.log('Original font size: ' + ofs); 68 } 69 else { 70 var sfs = jQuery(tags[ j ]).attr('data-swp-font-size'); 71 var new_size = parseFloat(sfs) * size / 100; 72 var old_size = jQuery(tags[ j ]).css('font-size'); 73 jQuery(tags[ j ]).css('font-size', new_size + "px"); 74 75 if (afr_debug) console.log('change from: ' + old_size + '. To: ' + new_size); 76 77 afr_sc('afr_size', size , afr_days); 78 } 79 } 80 } 81 return 1; 82} 83 84/** 85 * Set cookie value 86 * 87 * @param {string} cname Cookie name 88 * @param {string} cvalue Cookie value 89 * @param {int} expdays Expiration in days 90 */ 91function afr_sc(cname, cvalue, expdays) { 92 var d = new Date(); 93 d.setTime(d.getTime() + (expdays*24*60*60*1000)); 94 var expires = "expires="+ d.toUTCString(); 95 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 96} 97 98/** 99 * Get cookie value 100 * 101 * @param {string} cname Cookie name 102 * 103 * @returns {string} Value 104 */ 105function afr_gc(cname) { 106 var name = cname + "="; 107 var decodedCookie = decodeURIComponent(document.cookie); 108 var ca = decodedCookie.split(';'); 109 for(var i = 0; i <ca.length; i++) { 110 var c = ca[i]; 111 while (c.charAt(0) == ' ') { 112 c = c.substring(1); 113 } 114 if (c.indexOf(name) == 0) { 115 return c.substring(name.length, c.length); 116 } 117 } 118 return null; 119}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.