StructureJS

0.15.2

A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.

BrowserUtil Class

Module: util
Parent Module: StructureJS

A helper class to detect OS and browsers.

Index

Show:

Properties

Methods

Properties

_eventDispatcher EventDispatcher private static

A reference to the EventDispatcher object.

_onBreakpointChangeHandler Any private static

TODO: YUIDoc_comment

_styleDeclaration Any private static

A reference to the getComputedStyle method.

_window Window private static

A reference to the browser window object.

debounceDelay Number public static

The delay in milliseconds for the Util.debounce method that dispatches the BaseEvent.RESIZE event to get the your browser breakpoints. See getBreakpoint.

Default: 250

isEnabled Boolean public static

The isEnabled property is used to keep track of the enabled state of listening for Breakpoint changes.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

_onBreakpointChange () private static

Dispatches a breakpoint event.

addEventListener () public static

TODO: YUIDoc_comment

browserName () String public static

Returns the name of the browser.

Returns:

Example:

 BrowserUtil.browserName();
 // 'Chrome'

browserVersion
(
  • [majorVersion=true]
)
Number | String public static

Returns the version of the browser.

Parameters:

  • [majorVersion=true] Boolean optional

Returns:

Example:

 BrowserUtil.browserVersion();
 // 39

 BrowserUtil.browserVersion(false);
 // '39.0.2171.99'

dispatchEvent () public static

TODO: YUIDoc_comment

enable () public static

Dispatches a breakpoint event.

getBreakpoint () String public static

Get the current breakpoint from the style sheets. You must add a body:after property with a specific content in each of your style sheets for this functionality to work.

Returns:

String:

The string value of the current style sheet.

Example:

 // For each of your different style sheets add something like below:
 // screen_lg.css
 body:after {
     content: 'screen_lg';  width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; position: absolute; clip: rect(0 0 0 0); overflow: hidden;
 }
 // screen_sm.css
 body:after {
     content: 'screen_sm';  width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; position: absolute; clip: rect(0 0 0 0); overflow: hidden;
 }

 BrowserUtil.getBreakpoint();
 // 'screen_lg'

 // Add a listener to get notified when the browser is resized:
 BrowserUtil.addEventListener(BaseEvent.RESIZE, this._onBreakpointChange, this);
 ...
 _onBreakpointChange(baseEvent) {
     console.log(baseEvent.data);
     // 'screen_sm'
 }

getBrowser () Array. public static

Gets the browser name a user agent.

Returns:

Array.:

Example:

 BrowserUtil.getBrowser();
 // ["Chrome", "39.0.2171.99"]

hasBrowserHistory () Boolean public static

Determines if the browser can you Browser History push states.

Returns:

Example:

 BrowserUtil.hasBrowserHistory();
 // true

hasLocalStorage () Boolean public static

Determines if the browser can you Local Storage.

Returns:

Example:

 BrowserUtil.hasLocalStorage();
 // true

hasSessionStorage () Boolean public static

Determines if the browser can you Session Storage.

Returns:

Example:

 BrowserUtil.hasSessionStorage();
 // true

isAndroid () Boolean public static

Determines if the device OS is Android.

Returns:

Example:

 BrowserUtil.isAndroid();
 // false

isBlackBerry () Boolean public static

Determines if the device OS is Android.

Returns:

Example:

 BrowserUtil.isBlackBerry();
 // false

isIEMobile () Boolean public static

Determines if the device OS is IE Mobile.

Returns:

Example:

 BrowserUtil.isIEMobile();
 // false

isIOS () Boolean public static

Determines if the device OS is IOS.

Returns:

Example:

 BrowserUtil.isIOS();
 // false

isMobile () Boolean public static

Determines if the it is run on a mobile or desktop device.

Returns:

Example:

 BrowserUtil.isMobile();
 // false

isOperaMini () Boolean public static

Determines if the device OS is Opera Mini.

Returns:

Example:

 BrowserUtil.isOperaMini();
 // false

removeEventListener () public static

TODO: YUIDoc_comment

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index