The template is designed from the start to be as responsive as possible. It will format, hide an move the various interface elements according to available space, with the following built-in layouts (and corresponding stylesheets):
To achieve this, the template uses a set of files designed for each layout, which are loaded accordingly to viewport size by media queries. For older browsers, a polyfill (respond.js) is used.
The template use the principle behind 320 and up developed by Andy Clarke (@malarkey): as mobile device are the least powerful devices, they need to have as few styles to parse as possible, so the base styles are designed for them. Then, for each larger layout, an additional stylesheet is loaded and will override some styles to give the expected layout.
So if you are changing some style and can't get the right result, check if one of the mediaqueries files don't overwrite your changes - sound obvious, but it may happen more often than you think!
In an admin skin, many elements are resolution and layout dependant, so the template provides several ways to work with media queries:
At any moment, you can get the current mode name:
if ($.template.mediaQuery.name === 'desktop') { // Do something only for widescreens }
Need to know if the current media query is smaller than a given one?
if ($.template.mediaQuery.isSmallerThan('tablet-portrait')) { // Do something only for smaller screens }
Need to check if a given media query is on?
if ($.template.mediaQuery.has('tablet-portrait')) { // Fire if this media query is on, even if it is not the current one }
Knowing the current mode is great, but what is more interesting is to track media queries changes. Several events are triggered to help your scripts:
Note that you can also listen for event relative to media queries groups: for instance, mobile-portrait and mobile-landscape belong to the group mobile, so you can track them both by using enter-query-mobile and quit-query-mobile. Note that these events only fire when changing group, not when changing between children modes.
To use these events, just listen on document:
$(document).on('init-queries', function() { console.log('media queries ready'); });
For instance, if you want an element to be visible only on desktop mode:
var element = $('#only-desktop'); $(document).on('init-queries', function() { if ($.template.mediaQuery.isSmallerThan('desktop')) { element.hide(); } }).on('enter-query-desktop', function() { element.show(); }).on('quit-query-desktop', function() { element.hide(); });