From eeade31592fc6093547f1d904210b01d37678cfc Mon Sep 17 00:00:00 2001 From: Fez Vrasta Date: Mon, 18 Aug 2014 16:27:39 +0200 Subject: [PATCH] updated to latest release. --- material/material.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/material/material.js b/material/material.js index a99fee22..d87aad27 100644 --- a/material/material.js +++ b/material/material.js @@ -1,29 +1,26 @@ /* Copyright 2014+, Federico Zivolo, LICENSE at https://github.com/FezVrasta/bootstrap-material-design/blob/master/LICENSE.md */ $(function (){ + // with ripple elements + var withRipple = ".btn:not('.btn-link'), .navbar a, .nav-tabs a"; + // Add ripple elements to material buttons - $(".btn:not('.btn-link'), .navbar a").each( function(){ - $(this).append(""); - }); + $(withRipple).append(""); // Add fake-checkbox to material checkboxes - $(".checkbox label input").each( function() { - $(this).after(""); - }); + $(".checkbox label input").after(""); // Add fake-radio to material radios - $(".radio label input").each( function() { - $(this).after(""); - }); + $(".radio label input").after(""); // Add elements for material inputs $("input.form-control, textarea.form-control").each( function() { - $(this).wrap("
"); - $(this).after(""); + $(this).wrap("
"); + $(this).after(""); if ($(this).hasClass("floating-label")) { - $(this) - .removeClass("floating-label") - .after("" + $(this).attr("placeholder") + "").attr("placeholder", null); + var placeholder = $(this).attr("placeholder"); + $(this).attr("placeholder", null).removeClass("floating-label"); + $(this).after("
" + placeholder + "
"); } if ($(this).val() === "") { $(this).addClass("empty"); @@ -39,7 +36,7 @@ $(function (){ }); // Material buttons engine - $(document).on("mousedown", ".btn:not('.btn-link'), .navbar a", function(e){ + $(document).on("mousedown", withRipple, function(e){ // Cache elements var $self = $(this), $rippleWrapper = $self.find(".ripple-wrapper"), @@ -64,7 +61,7 @@ $(function (){ $rippleWrapper.attr("class", "ripple-wrapper").data("animating", false).trigger("rippleEnd"); }, 500); }) - .on("rippleEnd", ".btn:not('.btn-link'), .navbar a", function() { + .on("rippleEnd", withRipple, function() { if (!mouseDown) { var $self = $(this), $rippleWrapper = $self.find(".ripple-wrapper"), @@ -73,7 +70,7 @@ $(function (){ rippleOut($ripple, $rippleWrapper); } }) - .on("mouseup", ".btn:not('.btn-link'), .navbar a", function() { + .on("mouseup", withRipple, function() { var $self = $(this), $rippleWrapper = $self.find(".ripple-wrapper"), $ripple = $self.find(".ripple");