Date Range Slider
by ravimallya
HTML
<div id="slider-date"></div>
<br /> <span class="example-val" id="event-start"></span>
<br /> <span class="example-val" id="event-end"></span>
<br />
<input type="text" name="dateFrom" id="dateFrom" />
<br />
<input type="text" name="dateTo" id="dateTo" />
<br />
<input type="button" id="setDate" onClick="doAlert()" value="Set" />
CSS
/* Functional styling;
* These styles are required for noUiSlider to function.
* You don't need to change these rules to apply your design.
*/
.noUi-target, .noUi-target * {
-webkit-touch-callout: none;
-webkit-user-select: none;
-ms-touch-action: none;
-ms-user-select: none;
-moz-user-select: none;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.noUi-target {
position: relative;
}
.noUi-base {
width: 100%;
height: 100%;
position: relative;
}
.noUi-origin {
position: absolute;
right: 0;
top: 0;
left: 0;
bottom: 0;
}
.noUi-handle {
position: relative;
z-index: 1;
}
.noUi-stacking .noUi-handle {
/* This class is applied to the lower origin when
its values is > 50%. */
z-index: 10;
}
.noUi-stacking + .noUi-origin {
/* Fix stacking order in IE7, which incorrectly
creates a new context for the origins. */
*z-index: -1;
}
.noUi-state-tap .noUi-origin {
-webkit-transition: left 0.3s, top 0.3s;
transition: left 0.3s, top 0.3s;
}
.noUi-state-drag * {
cursor: inherit !important;
}
/* Painting and performance;
* Browsers can paint handles in their own layer.
*/
.noUi-origin, .noUi-handle {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
/* Slider size and handle placement;
*/
.noUi-horizontal {
height: 18px;
}
.noUi-horizontal .noUi-handle {
width: 34px;
height: 28px;
left: -17px;
top: -6px;
}
.noUi-vertical {
width: 18px;
}
.noUi-vertical .noUi-handle {
width: 28px;
height: 34px;
left: -6px;
top: -17px;
}
/* Styling;
*/
.noUi-background {
background: #FAFAFA;
box-shadow: inset 0 1px 1px #f0f0f0;
}
.noUi-connect {
background: #3FB8AF;
box-shadow: inset 0 0 3px rgba(51, 51, 51, 0.45);
-webkit-transition: background 450ms;
transition: background 450ms;
}
.noUi-origin {
...
JavaScript
(function () {
function c(a) {
return a.split("").reverse().join("")
}
function l(a, b) {
return a.substring(0, b.length) === b
}
function q(a, b, d) {
if ((a[b] || a[d]) && a[b] === a[d]) throw Error(b);
}
function m(a, b, d, e, n, h, w, k, A, H, D, g) {
w = g;
var l, s = D = "";
h && (g = h(g));
if ("number" !== typeof g || !isFinite(g)) return !1;
a && 0 === parseFloat(g.toFixed(a)) && (g = 0);
0 > g && (l = !0, g = Math.abs(g));
!1 !== a && (h = g, g = Math.pow(10, a), g = (Math.round(h * g) / g).toFixed(a));
g = g.toString(); - 1 !== g.indexOf(".") ? (a = g.split("."), h = a[0], d && (D = d + a[1])) : h = g;
b && (h = c(h).match(/.{1,3}/g), h = c(h.join(c(b))));
l && k && (s += k);
e && (s += e);
l && A && (s += A);
s = s + h + D;
n && (s += n);
H && (s = H(s, w));
return s
}
function u(a, b, d, c, e, h, w, k, A, H, D, g) {
var m;
a = "";
D && (g = D(g));
if (!g || "string" !== typeof g) return !1;
k && l(g, k) && (g = g.replace(k, ""), m = !0);
c && l(g, c) && (g = g.replace(c, ""));
A && l(g, A) && (g = g.replace(A, ""), m = !0);
if (c = e) c = g.slice(-1 * e.length) === e;
c && (g = g.slice(0, -1 * e.length));
b && (g = g.split(b).join(""));
d && (g = g.replace(d, "."));
m && (a += "-");
a = (a + g).replace(/[^0-9\.\-.]/g, "");
if ("" === a) return !1;
a = Number(a);
w && (a = w(a));
return "number" === typeof a && isFinite(a) ? a : !1
}
function a(a) {
var b, d, c, n = {};
for (b = 0; b < e.length; b += 1) if (d = e[b], c = a[d], void 0 === c) n[d] = "negative" !== d || n.negativeBefore ? "mark" === d && "." !== n.thousand ? "." : !1 : "-";
else if ("decimals" === d) if (0 <= c && 8 > c) n[d] = c;
...