/*
* The global eqjs object that contains all eq.js functionality.
*
* eqjs.nodes - List of all nodes to act upon when eqjs.states is called
* eqjs.nodesLength - Number of nodes in eqjs.nodes
*
* eqjs.refreshNodes - Call this function to refresh the list of nodes that eq.js should act on
* eqjs.sortObj - Sorts a key: value object based on value
* eqjs.query - Runs through all nodes and finds their widths and points
* eqjs.nodeWrites - Runs through all nodes and writes their eq status
*/
(function (eqjs) {
'use strict';
function EQjs() {
this.nodes = [];
this.eqsLength = 0;
this.widths = [];
this.points = [];
this.callback = undefined;
}
/*
* Add event (cross browser)
* From http://stackoverflow.com/a/10150042
*/
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent('on' + event, function () {
// set the this pointer same as addEventListener when fn is called
return (fn.call(elem, window.event));
});
}
}
/*
* Parse Before
*
* Reads `:before` content and splits it at the comma
* From http://jsbin.com/ramiguzefiji/1/edit?html,css,js,output
*/
function parseBefore(elem) {
return window.getComputedStyle(elem, ':before').getPropertyValue('content').slice(1, -1);
}
/*
* Merges two node lists together.
*
* From http://stackoverflow.com/questions/914783/javascript-nodelist/17262552#17262552
*/
var mergeNodes = function(a, b) {
return [].slice.call(a).concat([].slice.call(b));
};
/*
* Query
*
* Reads nodes and finds the widths/points
* nodes - optional, an array or NodeList of nodes to query
* callback - Either boolean (`true`/`false`) to force a normal callback, or a function to use as a callback once query and nodeWrites have finished.
*/
EQjs.prototype.query = function (nodes, callback) {
var proto =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.