Skip to content

Instantly share code, notes, and snippets.

@miloplacencia
Last active October 11, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miloplacencia/3802961 to your computer and use it in GitHub Desktop.
Save miloplacencia/3802961 to your computer and use it in GitHub Desktop.
objeto inicial encapsulado
(function(window,document,$,URL,undefined)
{
var i = {
android : navigator.userAgent.toLowerCase().indexOf('android')!=-1,
ipod : navigator.userAgent.toLowerCase().indexOf('ipod')!=-1,
ipad : navigator.userAgent.toLowerCase().indexOf('ipad')!=-1,
iphone : navigator.userAgent.toLowerCase().indexOf('iphone')!=-1,
isMobile: this.android || this.ipod || this.iphone,
cargaAjax : function(datos)
{
/*
data.url = url
data.cFunction(c) = callbackFunctions,
data.eFunction(e) = errorFunctions,
data.datos = all data
*/
$.ajax(datos.url,
{
dataType: 'json',
data: datos.datos,
type: 'post',
success: function(n) { datos.cFunction(n); },
error: function(e) { datos.eFunction(e); }
});
},
initRAF: function()
{
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
})();
},
init : function()
{
this.initRAF();
}
};
i.init();
})(window,document,jQuery,URL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment