Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Mark things you want to resize with class="resizeable"
- // The ratio between their sizes will be maintained.
- // works with jquery-1.4.2.min.js
- //
- // <script src=".../jquery-1.4.2.min.js"></script>
- // <script src=".../resize.js"></script>
- //
- function resizeNodes(nodes, startsizes, multiplier){
- var newsizes = startsizes.map(function(item, index){return item * multiplier;});
- nodes.each(function(index){$(this).css('font-size',newsizes[index]);});
- };
- function resize() {
- var multiplier = 1.0;
- var nodes = $(".resizeable");
- var startsizes = nodes.map(function(){return parseFloat($(this).css('font-size'),10);}).get();
- while ($(document).height()<=($(window).height()))
- {
- multiplier += 0.5;
- resizeNodes(nodes, startsizes, multiplier);
- };
- while ($(window).height()<$(document).height()&& multiplier > 0.5)
- {
- multiplier -= 0.01;
- resizeNodes(nodes, startsizes, multiplier);
- };
- while ($(window).width()<$(document).width() && multiplier > 0.5)
- {
- multiplier -= 0.05;
- resizeNodes(nodes, startsizes, multiplier);
- };
- };
- $(document).ready(resize);
Add Comment
Please, Sign In to add comment