r111075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111074‎ | r111075 | r111076 >
Date:19:39, 9 February 2012
Author:brion
Status:deferred
Tags:
Comment:

show/hide behavior
Modified paths:
  • /trunk/mockups/glaucus-quick/app.js (modified) (history)
  • /trunk/mockups/glaucus-quick/glaucus.css (modified) (history)

Diff [purge]

Index: trunk/mockups/glaucus-quick/glaucus.css
@@ -67,6 +67,7 @@
6868 overflow: hidden;
6969 font-size: 13px;
7070 padding: 1px 4px;
 71+ background: white;
7172 }
7273
7374 .langbar span {
Index: trunk/mockups/glaucus-quick/app.js
@@ -6,10 +6,11 @@
77 $active.removeClass('active');
88 $('.menu').hide();
99 }
10 - }
 10+ }
1111 function setupMenu(button, menu) {
1212 $(button).bind('click touchstart mousedown', function(e) {
1313 e.preventDefault();
 14+ e.stopPropagation();
1415
1516 hideMenus();
1617
@@ -21,6 +22,7 @@
2223
2324 $('#menu-pane').bind('click touchstart mousedown', function(e) {
2425 e.preventDefault();
 26+ e.stopPropagation();
2527 hideMenus();
2628 $('#menu-pane').hide();
2729 });
@@ -30,5 +32,54 @@
3133 setupMenu('#menu-contribute', '#contribute-menu');
3234 setupMenu('#menu-search', '#search-menu');
3335
 36+ function sendHeaderTo(y) {
 37+ $('header').css('top', y + 'px');
 38+ $('#menu-pane').css('top', (y + 44) + 'px');
 39+ }
 40+
 41+ function hideMenuBar() {
 42+ hideMenus();
 43+ $('#menu-pane').hide();
 44+ sendHeaderTo(0);
 45+ }
 46+
 47+ function showMenuThingy() {
 48+ var top = $(window).scrollTop(),
 49+ current = $('header').css('top');
 50+ if (current == '0px') {
 51+ sendHeaderTo(top);
 52+ } else {
 53+ hideMenuBar();
 54+ }
 55+ }
 56+
 57+ $(document).bind('click', function() {
 58+ showMenuThingy();
 59+ });
 60+ $(document).bind('scroll', function() {
 61+ hideMenuBar();
 62+ });
 63+
 64+ $(document).bind('touchstart', function() {
 65+ var current = $('header').css('top');
 66+ if (current == '0px') {
 67+ // simulate click handling for some reason it doesn't work
 68+ $(document).bind('touchend.menubar', function() {
 69+ $(document).unbind('touchmove.menubar');
 70+ $(document).unbind('touchend.menubar');
 71+ showMenuThingy();
 72+ });
 73+ $(document).bind('touchmove.menubar', function() {
 74+ // moved too much! cancel
 75+ $(document).unbind('touchmove.menubar');
 76+ $(document).unbind('touchend.menubar');
 77+ });
 78+ } else {
 79+ // for start of scrolling or touch
 80+ hideMenuBar();
 81+ }
 82+ });
 83+
 84+
3485 $(window).scrollTop(0);
3586 });