Defines static class UFBrowser, an utilities library with static methods related to the browser environment.

UFBrowser is a singleton class instance; its methods can be accessed directly.

Mobile browser detection: http://stackoverflow.com/questions/12606245/detect-if-browser-is-running-on-an-android-or-ios-device http://stackoverflow.com/questions/3007480/determine-if-user-navigated-from-mobile-safari

Constructors

Accessors

  • get ClickEvent(): "touchstart" | "click"

    Defines the event to listen for clicks on elements. Its value is either click or touchstart.

    Returns "touchstart" | "click"

  • get DownEvent(): "touchstart" | "mousedown"

    Defines the event to listen for down events on elements. Its value is either mousedown or touchstart.

    Returns "touchstart" | "mousedown"

  • get hasLocalStorage(): boolean

    Checks if browser supports the localStorage object.

    Returns boolean

  • get isInternetExplorer(): boolean

    Checks if the browser is Internet Explorer (does not include Edge).

    Returns boolean

  • get isIOS(): boolean

    Checks if browser is running within on iPad, iPhone or iPod

    Returns boolean

  • get isMobileSafari(): boolean

    Checks if browser is mobile safari by scanning the user-agent specific values.

    Returns boolean

  • get MoveEvent(): "touchmove" | "mousemove"

    Defines the event to listen for moves events on elements. Its value is either mousemove or touchmove.

    Returns "touchmove" | "mousemove"

  • get UpEvent(): "touchend" | "mouseup"

    Defines the event to listen for up events on elements. Its value is either mouseup or touchend.

    Returns "touchend" | "mouseup"

Methods

  • Animates an element using css animation and calls a callback at the end. Assumes the css class contains animate definitions that will start the animation.

    The method will install an event listener for 'animationend', add the classes to the element. When the event is fired, the method will remove the event listener, the css classes and call the callback if any.

    The event listener will also check if the event was fired from the specified element (in case there are more animations taking place)

    Parameters

    • element: string | Element

      Element to animate

    • classes: string

      One or more css classes to add (separated by a space)

    • Optionalcallback: UFCallback

      Callback to call

    Returns void

  • Checks if an element is scrolled to the bottom.

    Parameters

    • element: string | Element

      Element to check

    Returns boolean

    True if scrolled at the bottom

  • Finds a parent or (greater) grandparent that matches a test function.

    Parameters

    • element: string | Element

      Element to process

    • testCallback: (element: HTMLElement) => boolean

      A function expecting one parameter and returning a boolean

    Returns null | HTMLElement

    The parent or null if none passed the test

  • Returns Android version obtained from UA string.

    Returns string | false

    Version (x.x.x) or false if no version could be determined

  • Gets the url to the background image (if any).

    Based on answer: https://stackoverflow.com/a/12784180/968451

    Parameters

    • element: string | HTMLElement

      Element to get background image url for

    Returns null | string

    Background image or null if no image is used

  • Gets a css rule.

    Parameters

    • selector: string

      Name of rule (must match definition exactly)

    Returns false | CSSRule

    Either false if no rule could be found or an object with rules.

  • Returns location from an event. It supports both touch and mouse events.

    Parameters

    • event: Event

      jQuery event object

    Returns object

    object with position properties.

  • Return value of a query parameter

    Parameters

    • name: string

      Parameter name

    Returns string

    part behind the = (till the next & or # character) or empty string if aName parameter is not found

  • Checks if an element is clicked upon or one of the children is clicked upon.

    Parameters

    • element: Element

      Element to check

    • event: Event

      Event object from click event

    Returns boolean

    true: element is clicked upon, false: element is not clicked upon

  • Loads a new image.

    Parameters

    • url: string

      Url to image

    • OptionalsuccessCallback: (image: HTMLImageElement) => void

      Callback method when successful, will be passed the Image as parameter.

    • OptionalerrorCallback: (image: HTMLImageElement) => void

      Callback method when error occurred, will be passed the Image as parameter.

    Returns HTMLImageElement

    Image dom object

  • Scrolls an element to the bottom.

    Parameters

    • element: string | Element

      Element to scroll

    Returns void

  • Adds a class to or removes a class from an element (using toggleClass), assuming this results in a transition animation.

    The method will install an event listener for 'transitionend'. When the event is fired, the method will remove the event listener and call the callback if any.

    The event listener will also check if the event was fired from the specified element (in case there are more transitions taking place)

    Parameters

    • element: string | Element

      Element to add class to or remove from

    • classes: string

      One or more css classes to add or remove

    • Optionalcallback: UFCallback

      Callback to call

    Returns void