/layouter

Lightweight JavaScript-based plugin for browser layout engine detection

Primary LanguageJavaScript

Layouter

Lightweight JavaScript-based plugin for browser layout engine detection. Written in vanilla Javascript, it doesn't depend on any other library

Build Status

Installation

###As jQuery plugin Include script after the jQuery library:

<script src="/path/to/layouter.js"></script>

###As standalone library Simply include this script to your page:

<script src="/path/to/layouter.js"></script>

###As node.js module:

npm install layouter
var Layouter = require('layouter');

##Usage ###As jQuery plugin

$.layout.name

Returns browser name determined from user agent string

$.layout.version

Returns layout engine version as string

###Without jQuery

window.layout.name

Returns browser name determined from user agent string

window.layout.version

Returns layout engine version as string

###As node.js module for parsing user agent string

var layouter = new Layouter();
var layout = layouter.parse(uaString);
layout.name

Returns browser name determined from user agent string

layout.version

Returns layout engine version as string

Development

Test

For running tests execute following command:

npm test

Tests are described in test/tests_description.json using following format:

{
    "name"    : "Gecko", //test name
    "ua"      : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre", //user agent string which will be passed as parameter to Layouter.parse()
    "expect"  : //result expected to be returned
    {
        "name"    : "Gecko", //layout engine name
        "version" : "2.0b9pre" //its version
    }
}