Created
July 9, 2020 15:17
-
-
Save pcperini/ae956a8844df35eb2f34fd7b541021e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (e, f) { | |
var b = {}; | |
var g = function (a) { | |
if(b[a]) { | |
f.clearInterval(b[a]); | |
b[a] = null; | |
}; | |
}; | |
e.fn.waitUntilExists = function (s, h, o, c) { | |
if(o == null || o == undefined) o = 0; | |
var d = e(s) | |
var k = d.not(function () { | |
return e(this).data("waitUntilExists.found"); | |
}); | |
if (h === "remove") { | |
g(s); | |
} else { | |
k.each(h).data("waitUntilExists.found", !0); | |
if (o && d.length) { | |
g(s); | |
} | |
else if (!c) { | |
b[s] = f.setInterval(function () { | |
console.log(s + " handler is running"); | |
d.waitUntilExists(s, h, o, !0); | |
}, 500); | |
} | |
} | |
return d | |
} | |
})(jQuery, window); | |
jQuery.expr[':'].regex = function(elem, index, match) { | |
var matchParams = match[3].split(','), | |
validLabels = /^(data|css):/, | |
attr = { | |
method: matchParams[0].match(validLabels) ? | |
matchParams[0].split(':')[0] : 'attr', | |
property: matchParams.shift().replace(validLabels,'') | |
}, | |
regexFlags = 'ig', | |
regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags); | |
return regex.test(jQuery(elem)[attr.method](attr.property)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment