scroll.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
  3. *
  4. * Uses the built In easIng capabilities added In jQuery 1.1
  5. * to offer multiple easIng options
  6. *
  7. * Copyright (c) 2007 George Smith
  8. * Licensed under the MIT License:
  9. * http://www.opensource.org/licenses/mit-license.php
  10. */
  11. // t: current time, b: begInnIng value, c: change In value, d: duration
  12. jQuery.extend( jQuery.easing,
  13. {
  14. easeInQuad: function (x, t, b, c, d) {
  15. return c*(t/=d)*t + b;
  16. },
  17. easeOutQuad: function (x, t, b, c, d) {
  18. return -c *(t/=d)*(t-2) + b;
  19. },
  20. easeInOutQuad: function (x, t, b, c, d) {
  21. if ((t/=d/2) < 1) return c/2*t*t + b;
  22. return -c/2 * ((--t)*(t-2) - 1) + b;
  23. },
  24. easeInCubic: function (x, t, b, c, d) {
  25. return c*(t/=d)*t*t + b;
  26. },
  27. easeOutCubic: function (x, t, b, c, d) {
  28. return c*((t=t/d-1)*t*t + 1) + b;
  29. },
  30. easeInOutCubic: function (x, t, b, c, d) {
  31. if ((t/=d/2) < 1) return c/2*t*t*t + b;
  32. return c/2*((t-=2)*t*t + 2) + b;
  33. },
  34. easeInQuart: function (x, t, b, c, d) {
  35. return c*(t/=d)*t*t*t + b;
  36. },
  37. easeOutQuart: function (x, t, b, c, d) {
  38. return -c * ((t=t/d-1)*t*t*t - 1) + b;
  39. },
  40. easeInOutQuart: function (x, t, b, c, d) {
  41. if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  42. return -c/2 * ((t-=2)*t*t*t - 2) + b;
  43. },
  44. easeInQuint: function (x, t, b, c, d) {
  45. return c*(t/=d)*t*t*t*t + b;
  46. },
  47. easeOutQuint: function (x, t, b, c, d) {
  48. return c*((t=t/d-1)*t*t*t*t + 1) + b;
  49. },
  50. easeInOutQuint: function (x, t, b, c, d) {
  51. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  52. return c/2*((t-=2)*t*t*t*t + 2) + b;
  53. },
  54. easeInSine: function (x, t, b, c, d) {
  55. return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  56. },
  57. easeOutSine: function (x, t, b, c, d) {
  58. return c * Math.sin(t/d * (Math.PI/2)) + b;
  59. },
  60. easeInOutSine: function (x, t, b, c, d) {
  61. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  62. },
  63. easeInExpo: function (x, t, b, c, d) {
  64. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  65. },
  66. easeOutExpo: function (x, t, b, c, d) {
  67. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  68. },
  69. easeInOutExpo: function (x, t, b, c, d) {
  70. if (t==0) return b;
  71. if (t==d) return b+c;
  72. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  73. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  74. },
  75. easeInCirc: function (x, t, b, c, d) {
  76. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  77. },
  78. easeOutCirc: function (x, t, b, c, d) {
  79. return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  80. },
  81. easeInOutCirc: function (x, t, b, c, d) {
  82. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  83. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  84. },
  85. easeInElastic: function (x, t, b, c, d) {
  86. var s=1.70158;var p=0;var a=c;
  87. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  88. if (a < Math.abs(c)) { a=c; var s=p/4; }
  89. else var s = p/(2*Math.PI) * Math.asin (c/a);
  90. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  91. },
  92. easeOutElastic: function (x, t, b, c, d) {
  93. var s=1.70158;var p=0;var a=c;
  94. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
  95. if (a < Math.abs(c)) { a=c; var s=p/4; }
  96. else var s = p/(2*Math.PI) * Math.asin (c/a);
  97. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  98. },
  99. easeInOutElastic: function (x, t, b, c, d) {
  100. var s=1.70158;var p=0;var a=c;
  101. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
  102. if (a < Math.abs(c)) { a=c; var s=p/4; }
  103. else var s = p/(2*Math.PI) * Math.asin (c/a);
  104. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  105. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  106. },
  107. easeInBack: function (x, t, b, c, d, s) {
  108. if (s == undefined) s = 1.70158;
  109. return c*(t/=d)*t*((s+1)*t - s) + b;
  110. },
  111. easeOutBack: function (x, t, b, c, d, s) {
  112. if (s == undefined) s = 1.70158;
  113. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  114. },
  115. easeInOutBack: function (x, t, b, c, d, s) {
  116. if (s == undefined) s = 1.70158;
  117. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  118. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  119. },
  120. easeInBounce: function (x, t, b, c, d) {
  121. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
  122. },
  123. easeOutBounce: function (x, t, b, c, d) {
  124. if ((t/=d) < (1/2.75)) {
  125. return c*(7.5625*t*t) + b;
  126. } else if (t < (2/2.75)) {
  127. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  128. } else if (t < (2.5/2.75)) {
  129. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  130. } else {
  131. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  132. }
  133. },
  134. easeInOutBounce: function (x, t, b, c, d) {
  135. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
  136. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
  137. }
  138. });
  139. /*
  140. |--------------------------------------------------------------------------
  141. | UItoTop jQuery Plugin 1.1
  142. | http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
  143. |--------------------------------------------------------------------------
  144. */
  145. (function($){
  146. $.fn.UItoTop = function(options) {
  147. var defaults = {
  148. text: 'To Top',
  149. min: 200,
  150. inDelay:600,
  151. outDelay:400,
  152. containerID: 'toTop',
  153. containerHoverID: 'toTopHover',
  154. scrollSpeed: 1200,
  155. easingType: 'linear'
  156. };
  157. var settings = $.extend(defaults, options);
  158. var containerIDhash = '#' + settings.containerID;
  159. var containerHoverIDHash = '#'+settings.containerHoverID;
  160. $('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
  161. $(containerIDhash).hide().click(function(){
  162. $('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
  163. $('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
  164. return false;
  165. })
  166. .prepend('<span id="'+settings.containerHoverID+'"></span>')
  167. .hover(function() {
  168. $(containerHoverIDHash, this).stop().animate({
  169. 'opacity': 1
  170. }, 600, 'linear');
  171. }, function() {
  172. $(containerHoverIDHash, this).stop().animate({
  173. 'opacity': 0
  174. }, 700, 'linear');
  175. });
  176. $(window).scroll(function() {
  177. var sd = $(window).scrollTop();
  178. if(typeof document.body.style.maxHeight === "undefined") {
  179. $(containerIDhash).css({
  180. 'position': 'absolute',
  181. 'top': $(window).scrollTop() + $(window).height() - 50
  182. });
  183. }
  184. if ( sd > settings.min )
  185. $(containerIDhash).fadeIn(settings.inDelay);
  186. else
  187. $(containerIDhash).fadeOut(settings.Outdelay);
  188. });
  189. };
  190. })(jQuery);
  191. $(document).ready(function() {
  192. $().UItoTop({ easingType: 'easeOutQuart' });
  193. if ($('#docs-sidebar').length ) {
  194. $.get('/docs/sidebar', function(data) {
  195. $('.sidebar ul.toc').before(data);
  196. $('.sidebar ul.toc').hide();
  197. var url = document.location.href;
  198. // console.log(url);
  199. var parent_folder = url.substr(0, url.lastIndexOf('/'));
  200. var active = url.substr(0, url.length-document.location.hash.length);
  201. $('.docs.sidebar ul ul').hide();
  202. $('.docs.sidebar ul ul').each(function() {
  203. $(this).parent('li').addClass('nav-close');
  204. var anchor = $(this).prev('a').attr('href');
  205. if (anchor == active.replace('http://laravel.com', '')) {
  206. $(this).prev('a').addClass('active');
  207. $(this).parent('li').addClass('nav-open').removeClass('nav-close');
  208. $(this).show();
  209. } else if (anchor == parent_folder.replace('http://laravel.com', '')) {
  210. $(this).prev('a').addClass('active');
  211. $(this).parent('li').addClass('nav-open').removeClass('nav-close');
  212. $(this).show();
  213. }
  214. //console.log(anchor+' == '+parent_folder);
  215. $(this).prev('a').bind('click', function(e) {
  216. $(this).parent('li').toggleClass('nav-open').toggleClass('nav-close');
  217. $(this).next('ul').animate({opacity: 'toggle', height: 'toggle'}, "slow");
  218. return false;
  219. });
  220. });
  221. });
  222. } // end if
  223. });