Skip to content

Instantly share code, notes, and snippets.

@bamboo-c
Created September 19, 2014 02:09
Show Gist options
  • Save bamboo-c/2fda7c3fc00de16bced2 to your computer and use it in GitHub Desktop.
Save bamboo-c/2fda7c3fc00de16bced2 to your computer and use it in GitHub Desktop.
/*-----------------------------------------------------
* ▼ Viewport ▼
-----------------------------------------------------*/
var Viewport = function() {
this._ua;
this._init.apply( this );
}
Viewport.prototype = {
//-------------------------------------------------
// initialize
//-------------------------------------------------
_init : function() {
var _ua = {};
_ua.name = window.navigator.userAgent.toLowerCase();
_ua.isiPad = _ua.name.indexOf('ipad') >= 0;
_ua.isAndroid = _ua.name.indexOf('android') >= 0;
_ua.isTablet = (_ua.isiPad || (_ua.isAndroid && _ua.name.indexOf('mobile') < 0));
this.update( _ua.isTablet );
},
//-------------------------------------------------
// update
//-------------------------------------------------
update : function( i_data ) {
if ( i_data ) {
var metalist = document.getElementsByTagName('meta');
for(var i = 0; i < metalist.length; i++) {
var name = metalist[i].getAttribute('name');
if(name && name.toLowerCase() === 'viewport') {
metalist[i].setAttribute('content', 'width=1000');
break;
}
}
}
}
}
/*-----------------------------------------------------
* ▲ Viewport ▲
-----------------------------------------------------*/
var viewport = new Viewport();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment