Advertisement
saadimran

Untitled

Oct 14th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.67 KB | None | 0 0
  1. function fixContentSize() {
  2.     var w = $("section.body > section.middle").outerWidth();
  3.     w = ($(document).width() - w) / 2;
  4.     $("section.body > section.left").width(Math.ceil(w));
  5.     $("section.body > section.right").width(Math.floor(w));
  6.    
  7.     var contentSectionsInner = $("section.body > section.middle > section > section.content.bare > section.content");
  8.     fixContentHeight(contentSectionsInner, 11);
  9.    
  10.     var contentSections = $("section.body > section.middle > section > section.content");
  11.     fixContentHeight(contentSections, (contentSectionsInner.length == 0 ? 11 : 1));
  12. }
  13.  
  14. function fixContentHeight(contentElems, margin) {
  15.     contentElems.each(function(index){
  16.         var contentSection = $(this);
  17.         var h = contentSection.outerHeight();
  18.         h = Math.max(1, Math.round((h / 28))) * 28 - margin;
  19.         contentSection.height(h);
  20.     });
  21. }
  22.  
  23. $(window).ready(function(){
  24.     setTimeout(fixContentSize, 50);
  25. });
  26.  
  27. $(document).ready(function(){
  28.     var region_picker = $("#region-picker");
  29.    
  30.     var page_intro = $("div.page-intro");
  31.     var region_intros = $("div.region-intro");
  32.     var current_intro = page_intro;
  33.    
  34.     region_picker.on('change', function(e, old_selection, new_selection){
  35.         current_intro.fadeOut(function() {
  36.             if(new_selection != null) {
  37.                 var region_id = new_selection.data('region-id');
  38.                 var region_intro = region_intros.filter('[data-region-id=' + region_id + ']');
  39.                 current_intro = region_intro;
  40.             } else {
  41.                 current_intro = page_intro;
  42.             }
  43.            
  44.             current_intro.fadeIn();
  45.         });
  46.        
  47.         var curScroll = $(document).scrollTop();
  48.         var maxScroll = $(".begin").offset().top;
  49.         if(curScroll > maxScroll)
  50.             $("html, body").animate({scrollTop: maxScroll + "px"});
  51.        
  52.     });
  53. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement