Advertisement
Guest User

Untitled

a guest
Aug 14th, 2012
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Event Handler
  2. var bindEvt = (function () {
  3.     "use strict";
  4.     if (document.addEventListener) {
  5.         return function (element, event, handler) {
  6.             element.addEventListener(event, handler, false);
  7.         };
  8.     }
  9.     return function (element, event, handler) {
  10.         element.attachEvent('on' + event, handler);
  11.     };
  12. }());
  13.  
  14. // CSS calc() replacement
  15. function calcFailback() {
  16.     "use strict";
  17.     var d = document.createElement('div'),
  18.         host = document.getElementsByTagName('body')[0],
  19.         content = document.getElementsByTagName('article')[0],
  20.         menu = document.getElementsByTagName('nav')[0],
  21.         comments = document.getElementsByTagName('aside')[0],
  22.         newWidth;
  23.  
  24.     function resize() {
  25.         if (window.innerWidth > 1616) {
  26.             comments.style.width = window.innerWidth - 1366 + 'px';
  27.             content.style.width = "";
  28.         }
  29.         if (window.innerWidth < 1615) {content.style.width = window.innerWidth - 300 + 'px'; }
  30.  
  31.         content.style.height = window.innerHeight - 40 + 'px';
  32.         menu.style.height = window.innerHeight - 40 + 'px';
  33.         comments.style.height = window.innerHeight - 40 + 'px';
  34.     }
  35.  
  36.     host.appendChild(d);
  37.  
  38.     d.style.visibility = 'hidden';
  39.     d.style.width = "-webkit-calc(10px)";
  40.     d.style.width = "-o-calc(10px)";
  41.     d.style.width = "-moz-calc(10px)";
  42.     d.style.width = "calc(10px)";
  43.  
  44.     newWidth = d.offsetWidth;
  45.  
  46.     if (newWidth !== 10) {
  47.  
  48.         resize();
  49.         bindEvt(window, "resize", resize);
  50.         bindEvt(window, "orientationchange", resize);
  51.  
  52.     }
  53.  
  54.     host.removeChild(d);
  55. }
  56.  
  57. bindEvt(window, "load", calcFailback);
  58.  
  59. // Ajax article loading
  60. var menuitem = document.getElementsByTagName('nav').childNodes;
  61. alert(menuitem)
  62.  
  63. function loadajax (elem, evt) {
  64.     evt.preventDefault();
  65.     alert('yo');
  66. }
  67.  
  68. bindEvt(menuitem, "click", loadajax);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement