diff --git a/js/script.js b/js/script.js index 5ca286999c..809ebbe82e 100755 --- a/js/script.js +++ b/js/script.js @@ -415,6 +415,28 @@ var π, π1, πd; return immediateParent.parent(selector); }; + HTMLElement.prototype.parents = Node.prototype.parents = function (selector) { + var parents = []; + var immediateParent = this.parentNode; + + while(immediateParent !== π1('html')) { + parents.push(immediateParent); + immediateParent = immediateParent.parentNode; + } + + if (selector) { + var selectedElements = π(selector); + var selectedParents = []; + selectedElements.forEach(function(el){ + if (parents.indexOf(el) !== -1) selectedParents.push(el); + }); + + parents = selectedParents; + } + + return parents; + }; + // simple mobile l/r swipe handling HTMLElement.prototype.addSwipes = function (swipeLeftHandler, swipeRightHandler, options) { var startX, @@ -1104,153 +1126,6 @@ var π, π1, πd; π.mods.push(init); })(); -/******************************************************************** - π-accordion.JS - USAGE AND API REFERENCE - ______________________________________________ - DATA ATTRIBUTES: - - title: text that appears on the clickable label - single: more than one child open at a time? - ______________________________________________ - MARKUP AND DEFAULTS: - -