2014-08-25 15:00:49 +04:00
|
|
|
/* globals ripples */
|
|
|
|
|
2014-08-18 18:25:33 +04:00
|
|
|
$(function (){
|
|
|
|
|
2014-08-25 15:00:49 +04:00
|
|
|
ripples.init(".btn:not(.btn-link), .navbar a, .nav-tabs a, .withripple");
|
2014-08-18 18:25:33 +04:00
|
|
|
|
|
|
|
// Add fake-checkbox to material checkboxes
|
2014-08-20 14:53:26 +04:00
|
|
|
$(".checkbox label input").after("<span class=ripple></span><span class=check></span><span class=box></span>");
|
2014-08-18 18:25:33 +04:00
|
|
|
|
|
|
|
// Add fake-radio to material radios
|
2014-08-20 14:53:26 +04:00
|
|
|
$(".radio label input").after("<span class=ripple></span><span class=circle></span><span class=check></span>");
|
2014-08-18 18:25:33 +04:00
|
|
|
|
|
|
|
// Add elements for material inputs
|
2014-08-19 12:11:29 +04:00
|
|
|
$("input.form-control, textarea.form-control, select.form-control").each( function() {
|
2014-08-18 18:25:33 +04:00
|
|
|
$(this).wrap("<div class=form-control-wrapper></div>");
|
|
|
|
$(this).after("<span class=material-input></span>");
|
|
|
|
if ($(this).hasClass("floating-label")) {
|
|
|
|
var placeholder = $(this).attr("placeholder");
|
|
|
|
$(this).attr("placeholder", null).removeClass("floating-label");
|
|
|
|
$(this).after("<div class=floating-label>" + placeholder + "</div>");
|
|
|
|
}
|
|
|
|
if ($(this).val() === "") {
|
|
|
|
$(this).addClass("empty");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-20 14:53:26 +04:00
|
|
|
// Material inputs engine (ripple effect)
|
2014-08-18 18:25:33 +04:00
|
|
|
$(document).on("click", ".checkbox label, .radio label", function() {
|
2014-08-20 14:53:26 +04:00
|
|
|
var $ripple = $(this).find(".ripple"),
|
2014-08-18 18:25:33 +04:00
|
|
|
timestamp = "t" + new Date().getTime();
|
2014-08-20 14:53:26 +04:00
|
|
|
$ripple.attr("class", "ripple");
|
|
|
|
$ripple.addClass("animate").addClass(timestamp);
|
2014-08-18 18:25:33 +04:00
|
|
|
setTimeout(function() {
|
2014-08-20 14:53:26 +04:00
|
|
|
if ($ripple.hasClass(timestamp)) {
|
|
|
|
$ripple.removeClass("animate").removeClass(timestamp);
|
2014-08-18 18:25:33 +04:00
|
|
|
}
|
2014-08-20 14:53:26 +04:00
|
|
|
}, 800);
|
2014-08-18 18:25:33 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on("change", ".form-control", function() {
|
|
|
|
if ($(this).val() !== "") {
|
|
|
|
$(this).removeClass("empty");
|
|
|
|
} else {
|
|
|
|
$(this).addClass("empty");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|