/** * @author Scott O'Hara * @license https://github.com/scottaohara/select-to-datalist/blob/master/LICENSE * */ ;(function ( w, doc ) { //enable strict mode 'use strict'; // Local object for method references var ProgDatalist = {}; // Meta ProgDatalist.NS = "ProgDatalist"; ProgDatalist.AUTHOR = "Scott O'Hara"; ProgDatalist.VERION = "0.1.1"; ProgDatalist.LICENSE = "https://github.com/scottaohara/select-to-datalist/blob/master/LICENSE"; // Create accordion instances ProgDatalist.create = function () { var widget = doc.querySelectorAll('.progressive-datalist'); var widgetCount = widget.length; // setup / cache vars var self; var selfID; var cleanup = true; var i; // run a check to see if datalist is supported if ( 'options' in document.createElement('datalist') ) { // if supported, run through all instances of prog-datalist // and convert the select elements to inputs w/datalists for ( i = 0; i < widgetCount; i++ ) { self = widget[i]; // the generated datalist will need an ID var genID = 'datalist_' + Math.floor(Math.random() * 999) + 1; // now find the select element by pulling it's ID from // the 'for' attribute on the self container (label) selfID = self.getAttribute('id'); // set the ID, grab the options, and placeholder the a for looping var el = doc.getElementById(selfID); var grabOptions = el.innerHTML; var a; // create new input var newInput = doc.createElement('input'); // pull each of the attributes from the original