From 19d0c1bedec6a3e195932110f27876a1c9be9fb7 Mon Sep 17 00:00:00 2001 From: Federico Zivolo Date: Fri, 5 Sep 2014 10:08:47 +0200 Subject: [PATCH] fixed ripples.js on old versions of browsers which not support element.matches --- scripts/ripples.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/ripples.js b/scripts/ripples.js index c31462bd..1be5f567 100644 --- a/scripts/ripples.js +++ b/scripts/ripples.js @@ -3,6 +3,12 @@ var ripples = { init : function(withRipple) { "use strict"; + // Cross browser matches function + function matchesSelector(dom_element, selector) { + var matches = dom_element.matches || dom_element.matchesSelector || dom_element.webkitMatchesSelector || dom_element.mozMatchesSelector || dom_element.msMatchesSelector || dom_element.oMatchesSelector; + return matches.call(dom_element, selector); + } + // animations time var rippleOutTime = 100, rippleStartTime = 500; @@ -12,7 +18,7 @@ var ripples = { document.addEventListener(event, function(e) { var target = (typeof e.detail !== "number") ? e.detail : e.target; - if (target.matches(selector)) { + if (matchesSelector(target, selector)) { callback(e, target); } }); @@ -21,7 +27,7 @@ var ripples = { var rippleStart = function(e, target) { // Init variables - var $rippleWrapper = (target.matches(".ripple-wrapper")) ? target : target.parentNode, + var $rippleWrapper = (matchesSelector(target, ".ripple-wrapper")) ? target : target.parentNode, $el = $rippleWrapper.parentNode, $ripple = document.createElement("div"), elPos = $el.getBoundingClientRect(),