Home > iDetector

iDetector

IDetector is a project mainly written in JavaScript, it's free.

A javascript to detect apple devices like iPhone, iPod and iPad and apply a different style for each device, if needed.

Allowed Options:

  • verticalStyles: an Object that contain each allowed device name and an Array with all css required for this device on vertical position.
  • horizontalStyles: an Object that contain each allowed device name and an Array with all css required for this device on vertical position.
  • standardStyles: an Array with all css required for not allowed devices, like common browsers.
  • cssPath: an string with correct path to css.
  • allowedDevices: an Array with allowed devices.
  • linksClassName: a class name for all css added dinamically.

Example:

var options = {
    verticalStyles: {
        ipad: ['ipad.css'],
    iphone: ['iphone.css'],
        ipod: ['ipod.css']
    },
    horizontalStyles: {
        ipad: ['hor_ipad.css'],
        iphone: ['hor_iphone.css'],
        ipod: ['hor_ipod.css']
    },
    standardStyles: ['common.css'],
    cssPath: '../_css/',
    allowedDevices: ['ipad', 'ipod', 'iphone'],
    linksClassName: 'iDetector'
}

var detector = new iDetector(options);

Methods:

  • getAgent(); //return a string that contain your user agent
  • getDeviceName(); //name of your device
  • getOrientation(); //get orientation of your deviceName
  • detectAgent(); //detect if this device is an allowed device
  • defineStyles(); //apply all defined styles in your options
  • addRotationEvent(); //apply rotation event for applications that need 1 css for each position (vertical, horizontal)
  • removeLinkTags(); // remove all css added dinamically
Previous:Test