/** * :path (http://devkick.com/lab/path/) * * :path is a useful jquery selector. * It filters out anchors that matches their href attribute with the window location and their ancestor's trail. * * Adding active classes is very common in navigational elements in order to style an 'active state'. This is normally added server-side. * Instead of adding classes server-side using complicated logic, the :path selector uses javascript to parse the window.location and match it with href attributes. * The plugin works recursively, meaning it can take the entire path to your page and return navigational anchors that points to the page's ancestors as well as itself. * Use CSS or jQuery to parse and style the active element properly. * * :path is a pseudo-class selector so you can continue the chain for easy manipulation * * FEATURES * Works on all relative href paths (including '../') as well as absolute paths * Returns empty if the href points to root * Ignores a custom array of file names, such as index.html * Works on query strings, such as ?s1=home&s2=blog * includes a :current pseudo-class so you can style the anchor that links to the current page location * Tested in Safari 3, Firefox 2, MSIE 6, MSIE 7, Opera 9 * * Version 1.0 * April 28, 2008 * * Copyright (c) 2008 David Hellsing (http://monc.se) * Licensed under the GPL licenses. * http://www.gnu.org/licenses/gpl.txt **/ ;(function($){ /** * * @desc Filters out anchors that matches the window.location trail * @author David Hellsing * @version 1.0 * * @name :path * @type jQuery * * @cat plugins/Utilities * * @example $('ul a:path').parent().addClass('active'); * @desc Adds an 'active' class to the filtered anchors parent inside every