a zip code crypto-currency system good for red ONLY

script.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. (function($) {
  2. var $window = $(window);
  3. var $document = $(document);
  4. /*
  5. * Scrollspy.
  6. */
  7. $document.on('flatdoc:ready', function() {
  8. $("h2, h3").scrollagent(function(cid, pid, currentElement, previousElement) {
  9. if (pid) {
  10. $("[href='#"+pid+"']").removeClass('active');
  11. }
  12. if (cid) {
  13. $("[href='#"+cid+"']").addClass('active');
  14. }
  15. });
  16. });
  17. /*
  18. * Anchor jump links.
  19. */
  20. $document.on('flatdoc:ready', function() {
  21. $('.menu a').anchorjump();
  22. });
  23. /*
  24. * Title card.
  25. */
  26. $(function() {
  27. var $card = $('.title-card');
  28. if (!$card.length) return;
  29. var $header = $('.header');
  30. var headerHeight = $header.length ? $header.outerHeight() : 0;
  31. $window
  32. .on('resize.title-card', function() {
  33. var windowWidth = $window.width();
  34. if (windowWidth < 480) {
  35. $card.css('height', '');
  36. } else {
  37. var height = $window.height();
  38. $card.css('height', height - headerHeight);
  39. }
  40. })
  41. .trigger('resize.title-card');
  42. });
  43. /*
  44. * Sidebar stick.
  45. */
  46. $(function() {
  47. var $sidebar = $('.menubar');
  48. var elTop;
  49. $window
  50. .on('resize.sidestick', function() {
  51. $sidebar.removeClass('fixed');
  52. elTop = $sidebar.offset().top;
  53. $window.trigger('scroll.sidestick');
  54. })
  55. .on('scroll.sidestick', function() {
  56. var scrollY = $window.scrollTop();
  57. $sidebar.toggleClass('fixed', (scrollY >= elTop));
  58. })
  59. .trigger('resize.sidestick');
  60. });
  61. })(jQuery);
  62. /*! jQuery.scrollagent (c) 2012, Rico Sta. Cruz. MIT License.
  63. * https://github.com/rstacruz/jquery-stuff/tree/master/scrollagent */
  64. // Call $(...).scrollagent() with a callback function.
  65. //
  66. // The callback will be called everytime the focus changes.
  67. //
  68. // Example:
  69. //
  70. // $("h2").scrollagent(function(cid, pid, currentElement, previousElement) {
  71. // if (pid) {
  72. // $("[href='#"+pid+"']").removeClass('active');
  73. // }
  74. // if (cid) {
  75. // $("[href='#"+cid+"']").addClass('active');
  76. // }
  77. // });
  78. (function($) {
  79. $.fn.scrollagent = function(options, callback) {
  80. // Account for $.scrollspy(function)
  81. if (typeof callback === 'undefined') {
  82. callback = options;
  83. options = {};
  84. }
  85. var $sections = $(this);
  86. var $parent = options.parent || $(window);
  87. // Find the top offsets of each section
  88. var offsets = [];
  89. $sections.each(function(i) {
  90. var offset = $(this).attr('data-anchor-offset') ?
  91. parseInt($(this).attr('data-anchor-offset'), 10) :
  92. (options.offset || 0);
  93. offsets.push({
  94. id: $(this).attr('id'),
  95. index: i,
  96. el: this,
  97. offset: offset
  98. });
  99. });
  100. // State
  101. var current = null;
  102. var height = null;
  103. var range = null;
  104. // Save the height. Do this only whenever the window is resized so we don't
  105. // recalculate often.
  106. $(window).on('resize', function() {
  107. height = $parent.height();
  108. range = $(document).height();
  109. });
  110. // Find the current active section every scroll tick.
  111. $parent.on('scroll', function() {
  112. var y = $parent.scrollTop();
  113. y += height * (0.3 + 0.7 * Math.pow(y/range, 2));
  114. var latest = null;
  115. for (var i in offsets) {
  116. if (offsets.hasOwnProperty(i)) {
  117. var offset = offsets[i];
  118. if ($(offset.el).offset().top + offset.offset < y) latest = offset;
  119. }
  120. }
  121. if (latest && (!current || (latest.index !== current.index))) {
  122. callback.call($sections,
  123. latest ? latest.id : null,
  124. current ? current.id : null,
  125. latest ? latest.el : null,
  126. current ? current.el : null);
  127. current = latest;
  128. }
  129. });
  130. $(window).trigger('resize');
  131. $parent.trigger('scroll');
  132. return this;
  133. };
  134. })(jQuery);
  135. /*! Anchorjump (c) 2012, Rico Sta. Cruz. MIT License.
  136. * http://github.com/rstacruz/jquery-stuff/tree/master/anchorjump */
  137. // Makes anchor jumps happen with smooth scrolling.
  138. //
  139. // $("#menu a").anchorjump();
  140. // $("#menu a").anchorjump({ offset: -30 });
  141. //
  142. // // Via delegate:
  143. // $("#menu").anchorjump({ for: 'a', offset: -30 });
  144. //
  145. // You may specify a parent. This makes it scroll down to the parent.
  146. // Great for tabbed views.
  147. //
  148. // $('#menu a').anchorjump({ parent: '.anchor' });
  149. //
  150. // You can jump to a given area.
  151. //
  152. // $.anchorjump('#bank-deposit', options);
  153. (function($) {
  154. var defaults = {
  155. 'speed': 500,
  156. 'offset': 0,
  157. 'for': null,
  158. 'parent': null
  159. };
  160. $.fn.anchorjump = function(options) {
  161. options = $.extend({}, defaults, options);
  162. if (options['for']) {
  163. this.on('click', options['for'], onClick);
  164. } else {
  165. this.on('click', onClick);
  166. }
  167. function onClick(e) {
  168. var $a = $(e.target).closest('a');
  169. if (e.ctrlKey || e.metaKey || e.altKey || $a.attr('target')) return;
  170. e.preventDefault();
  171. var href = $a.attr('href');
  172. $.anchorjump(href, options);
  173. }
  174. };
  175. // Jump to a given area.
  176. $.anchorjump = function(href, options) {
  177. options = $.extend({}, defaults, options);
  178. var top = 0;
  179. if (href != '#') {
  180. var $area = $(href);
  181. // Find the parent
  182. if (options.parent) {
  183. var $parent = $area.closest(options.parent);
  184. if ($parent.length) { $area = $parent; }
  185. }
  186. if (!$area.length) { return; }
  187. // Determine the pixel offset; use the default if not available
  188. var offset =
  189. $area.attr('data-anchor-offset') ?
  190. parseInt($area.attr('data-anchor-offset'), 10) :
  191. options.offset;
  192. top = Math.max(0, $area.offset().top + offset);
  193. }
  194. $('html, body').animate({ scrollTop: top }, options.speed);
  195. $('body').trigger('anchor', href);
  196. // Add the location hash via pushState.
  197. if (window.history.pushState) {
  198. window.history.pushState({ href: href }, "", href);
  199. }
  200. };
  201. })(jQuery);