JefMari / week-polyfill

😎😎😎😎😎 A polyfill for implementing the HTML5 <input type="week"> element to make it cross-browser compatible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Week polyfill

                   _oo0oo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  0\  =  /0
                ___/`---'\___
              .' \\|     |// '.
             / \\|||  :  |||// \
            / _||||| -:- |||||- \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |_/ |
           \  .-\__  '-'  ___/-. /
         ___'. .'  /--.--\  `. .'___
      ."" '<  `.___\_<|>_/___.' >' "".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `_.   \_ __\ /__ _/   .-` /  /
 =====`-.____`.___ \_____/___.-`___.-'=====
                   `=---='

This is a polyfill for implementing the HTML5 <input type="week"> element in browsers that do not currently support it.

Usage

Using it is easy β€” simply include the week-polyfill.min.js file in the HEAD of the HTML page.
You can then use <input type="week"> elements normally.

If the script detects that the browser doesn't support <input type="week">, it will search for these elements and replace them with a jQuery UI datepicker to select the week. The week selection is stored in a hidden form field and submitted with the form in the standard format.

A default CSS file is provided. You may edit this file to style the input fields to make them look the way you want.

Manual usage

The script can also be called manually as a jQuery plugin for elements dynamically generated through script. Simply call the .inputWeek() method on any jQuery object containing one or more <input type="week"> elements.

Dependencies

This script requires jQuery, jQuery UI, and Modernizr.

Demo

https://jefmari.github.io/week-polyfill/demo.html

See also

Compatibility chart for input datetime elements

License (MIT)

About

😎😎😎😎😎 A polyfill for implementing the HTML5 <input type="week"> element to make it cross-browser compatible.


Languages

Language:CoffeeScript 66.8%Language:HTML 23.3%Language:CSS 9.9%