Created
October 8, 2009 21:16
-
-
Save jney/205433 to your computer and use it in GitHub Desktop.
This file contains 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 characters
// Zoom | |
// | |
// Proportionnaly update font size | |
// | |
// Usage : | |
// $(document).ready(function () { | |
// $("#zoom-in").zoom("#to-zoom", 1.25); | |
// $("#zoom-out").zoom("#to-zoom", 0.8); | |
// }); | |
// | |
(function($){ | |
$.fn.extend({ | |
zoom: function(e,sz){ | |
$(this).click(function(){ | |
var fs = $(e).css('font-size') || "1em"; | |
var lh = $(e).css('line-height') || "1"; | |
$(e).css('font-size', fs.replace(/(\d+\.*\d*)(\S*)/, ((parseFloat(fs) * sz) + "$2"))); | |
if(lh.match(/px/)) | |
$(e).css('line-height', lh.replace(/(\d+\.*\d*)(\S*)/, ((parseFloat(lh) * sz) + "$2"))); | |
}); | |
} | |
}); | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment