Really simple trick to get the current viewport in javascript.
HTML (somewhere in your grid)
<div class="viewport-width-id"></div>
CSS:
.viewport-width-id { width: 1px; }
@media (max-width: 1030px) { .viewport-width-id { width: 5px } }
@media (max-width: 768px) { .viewport-width-id { width: 10px; } }
Javascript
site = {
getPlatform : function() {
var winWidth = $(".viewport-width-id").width();
if(winWidth == 1) return 'desktop';
if(winWidth == 5) return 'tablet';
return 'mobile';
}
}
site.getPlatform() // desktop | tablet | mobile