1window.addEvent('domready', function() { 2 var prevHeight = 0; 3 var prevWidth = 0; 4 getData(); 5 Function.implement({ debounce: function(wait, immediate) { 6 var timeout, func = this; 7 return function() { 8 var context = this, 9 args = arguments; 10 var later = function() { timeout = null; 11 if (!immediate) func.apply(context, args); }; 12 var callNow = immediate && !timeout; 13 clearTimeout(timeout); 14 timeout = setTimeout(later, wait); 15 if (callNow) func.apply(context, args); }; } }); 16 window.addEvent("resize", navResize.debounce(500)); 17 window.addEvent("resize", moveBar.debounce(500)); 18 19 function navResize() { 20 var isMobile = { Android: function() { 21 return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { 22 return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { 23 return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { 24 return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { 25 return navigator.userAgent.match(/IEMobile/i); }, any: function() { 26 return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; 27 windowChange = prevHeight - window.getSize().y; 28 if (isMobile.any()) { 29 if (windowChange > 80) { getData(); } } else { getData(); } } 30 31 function getData() { 32 var menuContainer = $('menuContainer'); 33 menuContainer.setStyle('display', 'block'); 34 var request = new Request({ url: '/include/menu/menu-data-city.json', format: 'json', method: 'get', onRequest: function() {}, onFailure: function(xhr) { alert('Sorry, your request failed :(\n\n' + xhr); }, onComplete: function(strJson) { processData(strJson); } }).send(); } 35 36 function processData(strJSON) { 37 try { objJSON = JSON.decode(strJSON); } catch (e) { 38 return false; } 39 menuContainer.empty(); 40 generateList(objJSON.children, null, 1).inject(menuContainer); 41 prevWidth = window.getSize().x; 42 prevHeight = window.getSize().y; 43 if (window.getSize().x > 1099) { makeMenu(); } else { makeSlide(); } } 44 45 function generateList(children, depth, useTopId) { 46 if (!depth) depth = 0; 47 if (useTopId == 1) { 48 var ul = new Element('ul', { 'id': "topNav" }); } else { 49 var ul = new Element('ul'); } 50 if (depth) { ul.addClass('sub' + depth); } 51 for (var i = 0; i < children.length; ++i) { 52 var item = children[i]; 53 if (item.data.id) { 54 var li = new Element('li', { 'id': item.data.id + 'Item' }).inject(ul); } else { 55 var li = new Element('li').inject(ul); } 56 if (item.children) { 57 var a = new Element('a', { 'href': item.data.href, 'name': item.data.name, "id": item.data.id, 'html': item.data.name, 'target': item.data.target, 'class': item.data.htmlclass + ' dropArrow' }); 58 if (depth > 0) a.addClass('arrow'); 59 li.adopt(a); 60 if (depth == 0) { li.adopt(new Element('span', { 'class': 'accordionToggle', 'html': '' })); } 61 li.adopt(generateList(item.children, depth + 1, 0)); } else { li.adopt(new Element('a', { 'href': item.data.href, 'name': item.data.name, "id": item.data.id, 'html': item.data.name, 'target': item.data.target, 'class': item.data.htmlclass })); } } 62 return ul; } 63 64 function makeMenu() { 65 var menuToggle = $('menuToggleContainer'); 66 var menuContainer = $('menuContainer'); 67 menuToggle.setStyle('position', null); 68 menuContainer.setStyle('position', null); 69 $('topNav').MooDropMenu({ onOpen: function(el) { el.fade('in'); }, onClose: function(el) { el.fade('out'); }, onInitialize: function(el) { el.fade('hide').set('tween', { duration: 200 }); } }); } 70 71 function makeSlide() { new Fx.Accordion($('accordion'), '.accordionToggle', '.sub1', { start: 'all-close', opacity: false, alwaysHide: true, onActive: function(toggler) { toggler.setStyle('background-position', '0 -44px'); }
71, onBackground: function(toggler) { toggler.setStyle('background-position', '0 5px'); } }); 72 var myVerticalSlide = new Fx.Reveal('topNav', { mode: 'vertical', transitionOpacity: false, opacity: 0 }); 73 $('menuToggle').addEvent('click', function(e) { e.stop(); 74 myVerticalSlide.toggle(); }); } 75 76 function moveBar() { 77 var menuToggle = $('menuToggleContainer'); 78 var topDistance = nav.offsetTop; 79 var menuContainer = $('menuContainer'); 80 var menuToggleposition = menuToggle.offsetTop; 81 var menuToggleME = function() { 82 if (window.getSize().x < 1100) { menuToggle.setStyle('position', null); 83 menuContainer.setStyle('position', null); } }; 84 var menuToggleML = function() { 85 if (window.getSize().x < 1100) { menuToggle.setStyle('position', 'fixed'); 86 menuToggle.setStyle('top', 0); 87 menuToggle.setStyle('right', 0); 88 menuToggle.setStyle('left', 0); 89 menuContainer.setStyle('position', 'fixed'); 90 menuContainer.setStyle('top', '40px'); 91 menuContainer.setStyle('left', 0); 92 menuContainer.setStyle('right', 0); 93 menuContainer.setStyle('z-index', 64000); } }; 94 var events = { mouseenter: menuToggleME, mouseleave: menuToggleML }; 95 var ss = new ScrollSpy({ min: topDistance, max: window.innerHeight + 10000, onLeave: function() { menuToggleME(); }, onEnter: function() { menuToggleML(); } }); } });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.