Giter VIP home page Giter VIP logo

useragentfeaturedetection's Introduction

User Agent Feature Detection

  • Version: 1.0
  • Author: Brian Drum
  • Release Date: 1 February 2012
  • Requirements: Symphony 2.2.5

Description

The User Agent Feature Detection extension makes information about user agent features available in the param pool for the purposes of responsive web design.

How it works

On page load the extension checks for the presence of a cookie called feature_detection. If none is found (as on the first page request) the value of data/params/feature-detection is set to 0. In the XSL template if the value of data/params/feature-detection is 0 a script block is written to the head of the page which creates a cookie called feature_detection with a value of 1 to prevent the script block being inserted in subsequent pages during this session.

For each feature test that has been enabled on System » Preferences, a unique param node is created. In the XSL template if a test’s param node is present a corresponding JavaScript block is written to the page containing a test that creates a cookie for that feature. On subsequent page loads the extension checks for the presence of those cookies and adds the values to the param pool. After all test have been run the page is immediately reloaded.

Installation

  1. Upload the useragentfeaturedetection folder in this archive to your Symphony extensions folder
  2. Enable it by selecting “User Agent Feature Detection” on the System » Extensions page, choose “Enable/Install” from the “With Selected…” menu, then click “Apply”
  3. On System » Preferences enable the tests you want to use and verify that feature-detection and any other test params are being included in your page XML
  4. Add user-agent-feature-detection.xsl to Blueprints » Components » Utilities

Usage

  1. Import the feature detection utility into your stylesheet: <xsl:import href="../utilities/user-agent-feature-detection.xsl" />
  2. Call the feature detection utility early in the <head> of your HTML: <xsl:call-template name="user-agent-feature-detection" />
  3. Define your image breakpoints in user-agent-feature-detection.xsl (default [480, 600, 768, 1024, 1200]). The array value just larger than feature-screen-max will be returned for use with JIT images. This restricts the number of sizes of images that are created and cached on your server.
  4. Use the information contained in /data/params/feature-… to customize your layout or content. For example, you can use the value of /data/params/feature-breakpoint in your JIT image source attribute to create responsive images: <img src="{$root}/image/4/{data/params/feature-breakpoint}/0/1/path/to/image.jpg" />

Notes

With this release the screen dimensions (integer, in pixels) and orientation (landscape, portrait, or unknown) of the device is returned, along with a user defined breakpoint. Future versions may add additional feature detection.

Changelog

  • 1.0, 1 February 2012
    • Official release
  • 0.4, 18 December 2011
    • Added feature-breakpoint
  • 0.3, 1 December 2011
    • Changed feature-maxwidth to feature-screen-max
      • Added feature-screen-min
      • Added feature-screen-orientation
  • 0.2, 29 November 2011
    • Add preference for default maxwidth
    • Move feature detection JavaScript to utility
    • Add ability to enable or disable individual tests
  • 0.1, 28 November 2011
    • Initial release

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.