Last active
December 26, 2015 12:59
Revisions
-
Robert Pataki revised this gist
Apr 28, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ function getDefaultFontSize() { var el = document.body.appendChild(document.createElement('p')); el.innerHTML = 'size matters'; el.style['font-size'] = '1em'; var fontSize = document.defaultView.getComputedStyle(el).fontSize; document.body.removeChild(el); return fontSize.substring(0, fontSize.indexOf('px')); }; -
Robert Pataki revised this gist
Apr 26, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ s = s.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' '); function getDefaultFontSize() { var el = document.body.appendChild(document.createElement('p')); el.innerHTML = 'size matters'; el.style['font-size'] = '1em'; var fontSize = document.defaultView.getComputedStyle(el)['font-size']; document.body.removeChild(el); return fontSize.substring(0, fontSize.indexOf('px')); -
Robert Pataki revised this gist
Apr 25, 2014 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,15 @@ // Replace extra spaces with single ones and get rid of any spaces at the end and beginning of the string. // http://stackoverflow.com/questions/6163169/replace-multiple-whitespaces-with-single-whitespace-in-javascript-string - Marku Uttula's answer var s = " too much trailing space " s = s.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' '); // Determining the base font size, so that we can use em and rem units in JS // TODO - make it foolproof and compatible with browsers, which handle `getComputedStyle()` function getDefaultFontSize() { var el = document.body.appendChild(document.createElement('p')); el.innerHTML = 'size matters'; el.style.fontSize = '1em'; var fontSize = document.defaultView.getComputedStyle(el)['font-size']; document.body.removeChild(el); return fontSize.substring(0, fontSize.indexOf('px')); }; -
heartcode revised this gist
Oct 25, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // Replace extra spaces with single ones and get rid of any spaces at the end and beginning of the string. // http://stackoverflow.com/questions/6163169/replace-multiple-whitespaces-with-single-whitespace-in-javascript-string - Marku Uttula's answer var s = " too much trailing space " s = s.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' '); -
heartcode created this gist
Oct 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ // Replace extra spaces with single ones and get rid of any spaces at the end and beginning of the string. var s = " too much trailing space " s = s.replace(/^(\s*)|(\s*)$/g, '').replace(/\s+/g, ' ');