From 5cedb0970326eeeea9cffd2a208a49e690aad4bf Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Thu, 2 Jul 2015 21:27:16 +0100 Subject: [PATCH] Combined UI Fixes phone overlap bug fix + scroll-locker feature added --- public/js/main_0.0.3.js | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/public/js/main_0.0.3.js b/public/js/main_0.0.3.js index 20152c48f5..e17967c7b7 100644 --- a/public/js/main_0.0.3.js +++ b/public/js/main_0.0.3.js @@ -349,6 +349,48 @@ $(document).ready(function() { }); }; + //fakeiphone positioning hotfix + if($('.iphone-position').html() !==undefined || $('.iphone').html() !== undefined){ + var startIphonePosition = parseInt($('.iphone-position').css('top').replace('px', '')); + var startIphone = parseInt($('.iphone').css('top').replace('px', '')); + $(window).on('scroll', function(){ + if((($('.courseware-height').height() + $('.courseware-height').offset().top)-$(window).scrollTop()-$('.iphone-position').height()) <= 0){ + $('.iphone-position').css('top', startIphonePosition+(($('.courseware-height').height() + $('.courseware-height').offset().top)-$(window).scrollTop()-$('.iphone-position').height())); + $('.iphone').css('top', startIphonePosition+(($('.courseware-height').height() + $('.courseware-height').offset().top)-$(window).scrollTop()-$('.iphone-position').height())+120); + } + else{ + $('.iphone-position').css('top', startIphonePosition); + $('.iphone').css('top', startIphone); + } + }); + } + + if($('.scroll-locker') != undefined){ + function lockTop(initOff){ + $(window).scroll(function() { + if ($(window).width() >= 992) { + if ((($('.scroll-locker').offset().top - $(window).scrollTop()) + $('.scroll-locker').height()) >= ($('.fcc-footer').offset().top - $(window).scrollTop())) { + $('.scroll-locker').css('position', 'fixed').css('top', initOff).css('width', $($('.scroll-locker').parent()).width()).css('max-height', '75%').css('overflow-y', 'auto').css('overflow-x', 'hidden'); + $('.well').css('margin-right', '6px'); + } + else { + $('.scroll-locker').css('position', 'fixed').css('bottom', $('.fcc-footer') - (($('.scroll-locker').offset().top - $(window).scrollTop()) + $('.scroll-locker').height()) - ($('.fcc-footer').offset().top - $(window).scrollTop())).css('width', $($('.scroll-locker').parent()).width()).css('max-height', '75%').css('overflow-y', 'auto').css('overflow-x', 'hidden'); + $('.well').css('margin-right', '6px'); + } + } + else { + $('.scroll-locker').css('position', 'inherit').css('top', 'inherit').css('width', '100%').css('max-height', '').css('overflow-y', 'auto').css('overflow-x', 'hidden'); + $('.well').css('margin-right', ''); + } + }); + } + var initOff = ($('.scroll-locker').offset().top - $(window).scrollTop()); + lockTop(initOff); + $(window).on('resize', function(){ + lockTop(initOff); + }); + } + $('#comment-button').on('click', commentSubmitButtonHandler); });