Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Event Handler
- var bindEvt = (function () {
- "use strict";
- if (document.addEventListener) {
- return function (element, event, handler) {
- element.addEventListener(event, handler, false);
- };
- }
- return function (element, event, handler) {
- element.attachEvent('on' + event, handler);
- };
- }());
- // CSS calc() replacement
- function calcFailback() {
- "use strict";
- var d = document.createElement('div'),
- host = document.getElementsByTagName('body')[0],
- content = document.getElementsByTagName('article')[0],
- menu = document.getElementsByTagName('nav')[0],
- comments = document.getElementsByTagName('aside')[0],
- newWidth;
- function resize() {
- if (window.innerWidth > 1616) {
- comments.style.width = window.innerWidth - 1366 + 'px';
- content.style.width = "";
- }
- if (window.innerWidth < 1615) {content.style.width = window.innerWidth - 300 + 'px'; }
- content.style.height = window.innerHeight - 40 + 'px';
- menu.style.height = window.innerHeight - 40 + 'px';
- comments.style.height = window.innerHeight - 40 + 'px';
- }
- host.appendChild(d);
- d.style.visibility = 'hidden';
- d.style.width = "-webkit-calc(10px)";
- d.style.width = "-o-calc(10px)";
- d.style.width = "-moz-calc(10px)";
- d.style.width = "calc(10px)";
- newWidth = d.offsetWidth;
- if (newWidth !== 10) {
- resize();
- bindEvt(window, "resize", resize);
- bindEvt(window, "orientationchange", resize);
- }
- host.removeChild(d);
- }
- bindEvt(window, "load", calcFailback);
- // Ajax article loading
- var menuitem = document.getElementsByTagName('nav').childNodes;
- alert(menuitem)
- function loadajax (elem, evt) {
- evt.preventDefault();
- alert('yo');
- }
- bindEvt(menuitem, "click", loadajax);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement