WordPress.org

Plugin Directory

Changeset 469061


Ignore:
Timestamp:
11/29/11 12:14:58 (2 years ago)
Author:
sanchothefat
Message:

Updated getELementsByClassName js to work with IE 5.5+

Location:
dropdown-menus/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • dropdown-menus/trunk/dropdown-menus.php

    r458196 r469061  
    55Description: Outputs WordPress Menus as a dropdown. Use the widget or the function <code>dropdown_menu();</code> with the same arguments as <code>wp_nav_menu();</code>. 
    66Author: Robert O'Rourke @ interconnect/it 
    7 Version: 0.4 
     7Version: 0.5 
    88Author URI: http://interconnectit.com 
    99*/ 
     
    1111/* 
    1212Changelog: 
     13 
     140.5: 
     15    improved backwards compat with getElementsByClassName. Works back to IE 5.5. Thanks to Rob Nyman http://code.google.com/p/getelementsbyclassname/ 
    1316 
    14170.4: 
     
    6467    if ( is_admin() ) return; ?> 
    6568    <script> 
    66         var dropdowns = document.getElementsByClassName( 'dropdown-menu' ); 
     69        var getElementsByClassName=function(a,b,c){if(document.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||document;var d=c.getElementsByClassName(a),e=b?new RegExp("\\b"+b+"\\b","i"):null,f=[],g;for(var h=0,i=d.length;h<i;h+=1){g=d[h];if(!e||e.test(g.nodeName)){f.push(g)}}return f}}else if(document.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||document;var d=a.split(" "),e="",f="http://www.w3.org/1999/xhtml",g=document.documentElement.namespaceURI===f?f:null,h=[],i,j;for(var k=0,l=d.length;k<l;k+=1){e+="[contains(concat(' ', @class, ' '), ' "+d[k]+" ')]"}try{i=document.evaluate(".//"+b+e,c,g,0,null)}catch(m){i=document.evaluate(".//"+b+e,c,null,0,null)}while(j=i.iterateNext()){h.push(j)}return h}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||document;var d=a.split(" "),e=[],f=b==="*"&&c.all?c.all:c.getElementsByTagName(b),g,h=[],i;for(var j=0,k=d.length;j<k;j+=1){e.push(new RegExp("(^|\\s)"+d[j]+"(\\s|$)"))}for(var l=0,m=f.length;l<m;l+=1){g=f[l];i=false;for(var n=0,o=e.length;n<o;n+=1){i=e[n].test(g.className);if(!i){break}}if(i){h.push(g)}}return h}}return getElementsByClassName(a,b,c)}, 
     70            dropdowns = getElementsByClassName( 'dropdown-menu' ); 
    6771        for ( i=0; i<dropdowns.length; i++ ) 
    6872            dropdowns[i].onchange = function(){ if ( this.value != '' ) window.location.href = this.value; } 
  • dropdown-menus/trunk/readme.txt

    r458196 r469061  
    44Requires at least: 3.0 
    55Tested up to: 3.2.1 
    6 Stable tag: 0.4 
     6Stable tag: 0.5 
    77 
    88Display your WordPress menus as a dropdown select box. Great for mobile designs. 
     
    9393== Changelog == 
    9494 
     95= 0.5 = 
     96* Better cross browser & old browser support using getElementsByClassName by Rob Nyman (http://code.google.com/p/getelementsbyclassname/) 
     97 
    9598= 0.4 = 
    9699* Made the menu use the menu title as the blanking option text 
Note: See TracChangeset for help on using the changeset viewer.