|
| 1 | +var isMobile = false; |
| 2 | + |
| 3 | +if(window.matchMedia && window.matchMedia("(max-device-width: 480px)").matches){ |
| 4 | + isMobile = true; |
| 5 | +} |
| 6 | + |
| 7 | + |
1 | 8 | var currentH2slug = "";
|
2 | 9 | var animationCount = 0;
|
3 | 10 |
|
@@ -210,15 +217,17 @@ can.Control('Menu', {
|
210 | 217 | }, 1);
|
211 | 218 | },
|
212 | 219 | resizeMenu : function(){
|
213 |
| - var menuWrapHeight = this.element.find('#menu-wrapper').height(), |
| 220 | + if(!isMobile){ |
| 221 | + var menuWrapHeight = this.element.find('#menu-wrapper').height(), |
214 | 222 | menuHeight = this._menu.height(),
|
215 | 223 | windowHeight = $(window).height();
|
216 |
| - this.element.find('#inner-menu-wrap').css('maxHeight', (windowHeight - (menuWrapHeight - menuHeight) - 40) + "px"); |
217 |
| - if(this.element.find('#inner-menu-wrap').innerHeight() - menuHeight > 2){ // top and bottom borders |
218 |
| - this._menuShouldScroll = true; |
219 |
| - } else { |
220 |
| - this._menuShouldScroll = false; |
221 |
| - this._menu.css('marginTop', 0); |
| 224 | + this.element.find('#inner-menu-wrap').css('maxHeight', (windowHeight - (menuWrapHeight - menuHeight) - 40) + "px"); |
| 225 | + if(this.element.find('#inner-menu-wrap').innerHeight() - menuHeight > 2){ // top and bottom borders |
| 226 | + this._menuShouldScroll = true; |
| 227 | + } else { |
| 228 | + this._menuShouldScroll = false; |
| 229 | + this._menu.css('marginTop', 0); |
| 230 | + } |
222 | 231 | }
|
223 | 232 | },
|
224 | 233 | "#inner-menu-wrap mousemove" : function(el, ev){
|
@@ -292,6 +301,38 @@ can.Control('Menu', {
|
292 | 301 | }
|
293 | 302 | });
|
294 | 303 |
|
| 304 | +can.Control('MobileMenu', {}, { |
| 305 | + "{document} swiperight" : function(el, ev){ |
| 306 | + $('#menu-wrapper').css({ |
| 307 | + top: $(window).scrollTop() + "px" |
| 308 | + }).animate({ |
| 309 | + marginLeft: 0 |
| 310 | + }, 150) |
| 311 | + }, |
| 312 | + " touchstart" : function(el, ev){ |
| 313 | + var target = $(ev.target); |
| 314 | + if(target.closest('#menu-wrapper').length > 0 && target.is('a')){ |
| 315 | + var cb = function(){ |
| 316 | + window.location = target.attr('href'); |
| 317 | + } |
| 318 | + this.hideMenu(cb); |
| 319 | + ev.preventDefault(); |
| 320 | + } |
| 321 | + }, |
| 322 | + "{document} swipeleft" : "hideMenu", |
| 323 | + "#inner-menu-wrapper li a swipeleft" : "hideMenu", |
| 324 | + hideMenu : function(cb){ |
| 325 | + if(arguments.length > 1){ |
| 326 | + cb = function(){}; |
| 327 | + } |
| 328 | + $('#menu-wrapper').animate({ |
| 329 | + marginLeft: "-100%" |
| 330 | + }, 150, cb) |
| 331 | + } |
| 332 | +}) |
| 333 | + |
| 334 | + |
| 335 | + |
295 | 336 | can.Control('Builder', {
|
296 | 337 | 'input[type="checkbox"] click' : function() {
|
297 | 338 | var button = this.element.find('button');
|
@@ -323,6 +364,22 @@ if($('.lt-ie7, .lt-ie8, .lt-ie9').length == 0){
|
323 | 364 | } else {
|
324 | 365 | new Menu($('#wrapper'), 'html,body');
|
325 | 366 | }
|
326 |
| - |
| 367 | +if(isMobile){ |
| 368 | + new MobileMenu(document.documentElement) |
| 369 | + var header = $('#logo-and-download').clone(); |
| 370 | + header.find('a').remove(); |
| 371 | + header.append("<img src='/images/swipe.png' id='swipe' />") |
| 372 | + $('#content-wrapper').prepend(header) |
| 373 | +} |
327 | 374 | $('a[href$=#dom_helpers], a[href$=#events]').prepend('<span class="special">★</span>');
|
328 | 375 |
|
| 376 | +// google analytics |
| 377 | +var _gaq = _gaq || []; |
| 378 | +_gaq.push(['_setAccount', 'UA-2302003-11']); |
| 379 | +_gaq.push(['_trackPageview']); |
| 380 | + |
| 381 | +(function() { |
| 382 | + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| 383 | + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| 384 | + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| 385 | +})(); |
0 commit comments