jQuery.event.special.touchstart = { setup: function( _, ns, handle ) { this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.touchmove = { setup: function( _, ns, handle ) { this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); } }; jQuery.event.special.wheel = { setup: function( _, ns, handle ){ this.addEventListener("wheel", handle, { passive: true }); } }; jQuery.event.special.mousewheel = { setup: function( _, ns, handle ){ this.addEventListener("mousewheel", handle, { passive: true }); } }; jQuery.event.special.scroll = { setup: function( _, ns, handle ){ this.addEventListener("scroll", handle, { passive: true }); } }; $.fn.reverse = [].reverse; $.fn.exists = function(fn) { if (this.length > 0) { if (fn) { fn.call(this); } else { return true; } } return this; }; $.fn.prevNodes = function() { var el = this[0], current = el.previousSibling, list = [el]; while (current) { list.push(current); current = current.previousSibling; } return $(list); }; $.fn.nextNodes = function() { var el = this[0], current = el.nextSibling, list = [el]; while (current) { list.push(current); current = current.nextSibling; } return $(list); }; $.fn.changeElementType = function(newType) { var attrs = {}; $.each(this[0].attributes, function(idx, attr) { attrs[attr.nodeName] = attr.nodeValue; }); attrs['value'] = this[0].value; var $replace = $("<" + newType + "/>", attrs); this.replaceWith(function() { return $replace.append($(this).contents()); }); return $replace; };