//--------------------------------------
//               PowerUI
//
//        For documentation or 
//    if you have any issues, visit
//        powerUI.kulestar.com
//
//    Copyright  2013 Kulestar Ltd
//          www.kulestar.com
//--------------------------------------

using System;

namespace Css{
	
	/// <summary>
	/// Describes if an element currently is enabled
	/// <summary>

	sealed class IsEnabled:CssKeyword{
		
		public override string Name{
			get{
				return "enabled";
			}
		}
		
		public override SelectorMatcher GetSelectorMatcher(){
			return new EnabledMatcher();
		}
		
	}
	
	/// <summary>
	/// Handles the matching process for :enabled.
	/// </summary>
	
	sealed class EnabledMatcher:LocalMatcher{
		
		public override bool TryMatch(Dom.Node node){
			
			if(node==null){
				return false;
			}
			
			return (node.getAttribute("disabled")==null && node.getAttribute("readonly")==null);
			
		}
		
	}
	
}