Created
May 2, 2014 16:46
-
-
Save demogar/bd866e1e77243e615ec6 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
| // Con esta función transformamos de pixeles (o la unidad por default) | |
| // a dp | |
| function pixelToDp(pixel) { | |
| var dpi = Ti.Platform.displayCaps.dpi; | |
| var dp = (pixel / dpi) * 160; | |
| dp = Math.ceil(dp); | |
| return dp; | |
| }; | |
| // Esta self-calling-function es la que utilizamos para sobreescribir la funcionalidad de Alloy. Como nuestro aplicativo sólo funciona para iOS y Android hacemos la verificación para esta dos. | |
| Alloy.isTablet = (function() { | |
| var width = Ti.Platform.displayCaps.platformWidth; | |
| var height = Ti.Platform.displayCaps.platformHeight; | |
| var min = Math.min(width, height); | |
| if (OS_IOS) { | |
| return Ti.Platform.osname === 'ipad'; | |
| } else { | |
| return pixelToDp(min) >= 500; | |
| } | |
| })(); | |
| // Y bueno, isHandheld sería el inverso de isTablet | |
| Alloy.isHandheld = !Alloy.isTablet; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment