Skip to content

API: JS: Classification

Trott edited this page Apr 3, 2012 · 4 revisions
Clone this wiki locally

Description

The mwf.classification object uses device telemetry to define the classification scheme for a device. To do this, it leverages other mwf libraries including mwf.capability and mwf.screen. The mwf.classification object may also be modified by mwf.override if the client has specified an override.

This object is defined in assets/js/core/classification.js and is automatically loaded by the JS handler.

Current (MWF 1.2)

The following functions are available through mwf.classification:

  • mwf.classification.isMobile() If the device has a screen size smaller than the mobile dimensions set in the framework config (default maximum mobile screen size of 799 x 599). This is determined by comparing this value to the one in mwf.screen, and it should be noted that it represents the screen dimensions, not the browser.innerWindow dimensions, as the latter may change dynamically while on a page.

  • mwf.classification.isBasic() All devices are of the basic classification.

  • mwf.classification.isStandard() Returns true for a device that supports cookies, live DOM writes and addEventListener.

  • mwf.classification.isFull() Returns true for a device that has all standard capabilities, plus AJAX and at least limited CSS 3 support.

  • mwf.classification.isPreview() Returns true for a non-mobile device with an override set.

  • mwf.classification.get() The string value of the most capable classification of the device.

The following attribute is also available through mwf.classification:

  • mwf.classification.cookieName The name of the cookie that assets/js/core/server.js writes.

When an override is enabled, mwf.override adds the following functions:

  • mwf.classiciation.wasFull() If the device's actual classification is full.

  • mwf.classiciation.wasStandard() If the device's actual classification is at least standard.

  • mwf.classiciation.wasBasic() Always true as all device were at least basic.

If an override is enabled, mwf.override also modifies the behavior of the following:

  • mwf.classiciation.isFull() If "override"="full" and mwf.classification.wasFull() is true.

  • mwf.classiciation.isStandard() If "override"={"standard","full"} and mwf.classificiation.wasStandard() is true.

  • mwf.classiciation.isBasic() Always true as an override cannot be to less than basic.

See mwf.override for more information about override functionality.

Previous (MWF 1.0-1.1)

Before MWF 1.2, this functionality was encapsulated under the now-deprecated mwf.user_agent object, coupled tightly with other information now available through mwf.userAgent. For backwards compatibility, this object is still available, though its methods alias those of mwf.userAgent and mwf.classification. See the mwf.userAgent documentation for a detailed description of the mwf.user_agent

Something went wrong with that request. Please try again.