Created
September 19, 2014 02:09
-
-
Save bamboo-c/2fda7c3fc00de16bced2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*----------------------------------------------------- | |
* ▼ 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