Skip to content

Instantly share code, notes, and snippets.

@TCotton
Created January 18, 2013 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TCotton/4564346 to your computer and use it in GitHub Desktop.
Save TCotton/4564346 to your computer and use it in GitHub Desktop.
MOBILE = window.MOBILE || {};
MOBILE.QUERIES = (function() {
'use strict';
// declare document and windows in variables for performace
var doc = document,
win = window;
var _private = {
set: function(args) {
// use the HTML5 API matchMedia to target phones and tablets
var matches = win.matchMedia("(max-width: 1024px)").matches;
if (matches) {
this.run();
}
},
run: function() {
doc.body.onclick = this.event;
},
event: function(event) {
// on clicking links run script
if (event.target.tagName.toLowerCase().toString() === 'a') {
var slider, x, l, animationOne, element;
// add blur class to the body tag
doc.body.classList.add('blur');
setTimeout(function() {
// display ajax loading symbol
doc.getElementById('ajaxLoader').style.display = 'block';
}, 100);
setTimeout(function() {
doc.getElementById('ajaxLoader').style.display = 'none';
}, 5000);
}
}
};
return {
init: function(args) {
if (typeof args.matchMedia !== 'undefined') {
_private.set(args);
}
}
};
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment