Changeset 6723


Ignore:
Timestamp:
Feb 12, 2015, 9:00:47 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1920: Use 'classList' for manipulating DOM element classes

Location:
trunk/www/include/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/include/scripts/main-2.js

    r6694 r6723  
    430430    if (element)
    431431    {
    432       if (element.className.indexOf(className) != -1) return;
    433       element.className = element.className+' '+className;
     432      element.classList.add(className);
    434433    }
    435434  }
     
    445444    if (element)
    446445    {
    447       element.className = element.className.replace(className, '');
     446      element.classList.remove(className);
    448447    }
    449448  }
     
    465464      if (addIfTrue == undefined)
    466465      {
    467         addIfTrue = element.className.indexOf(className) == -1;
    468       }
    469       if (addIfTrue)
    470       {
    471         doc.addClass(element, className);
     466        element.classList.toggle(className);
     467      }
     468      else if (addIfTrue)
     469      {
     470        element.classList.add(className);
    472471      }
    473472      else
    474473      {
    475         doc.removeClass(element, className);
     474        element.classList.remove(className);
    476475      }
    477476    }
     
    485484  {
    486485    element = Doc.element(element);
    487     return element.className.indexOf('disabled') >= 0;
     486    return element.classList.contains('disabled');
    488487  }
    489488 
     
    751750    if (pointerEvents == null)
    752751    {
    753       disabled = event.currentTarget.className.indexOf('disabled')>=0;
     752      disabled = event.currentTarget.classList.contains('disabled');
    754753    }
    755754    else
  • trunk/www/include/scripts/menu.js

    r6610 r6723  
    309309  internal.menuOnMouseOver = function(event)
    310310  {
    311     if (event.target.className.indexOf('menuitem') == -1) return;
     311    if (!event.target.classList.contains('menuitem')) return;
    312312    menu.hideSubMenus(event.currentTarget);
    313313  }
Note: See TracChangeset for help on using the changeset viewer.