home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / styles / CSSCondition.as next >
Encoding:
Text File  |  2011-11-11  |  2.5 KB  |  106 lines

  1. package mx.styles
  2. {
  3.    public class CSSCondition
  4.    {
  5.       private var _kind:String;
  6.       
  7.       private var _value:String;
  8.       
  9.       public function CSSCondition(param1:String, param2:String)
  10.       {
  11.          super();
  12.          this._kind = param1;
  13.          this._value = param2;
  14.       }
  15.       
  16.       public function get kind() : String
  17.       {
  18.          return this._kind;
  19.       }
  20.       
  21.       public function get specificity() : int
  22.       {
  23.          if(this.kind == CSSConditionKind.ID)
  24.          {
  25.             return 100;
  26.          }
  27.          if(this.kind == CSSConditionKind.CLASS)
  28.          {
  29.             return 10;
  30.          }
  31.          if(this.kind == CSSConditionKind.PSEUDO)
  32.          {
  33.             return 10;
  34.          }
  35.          return 0;
  36.       }
  37.       
  38.       public function get value() : String
  39.       {
  40.          return this._value;
  41.       }
  42.       
  43.       public function matchesStyleClient(param1:IAdvancedStyleClient) : Boolean
  44.       {
  45.          var _loc3_:Array = null;
  46.          var _loc4_:uint = 0;
  47.          var _loc2_:Boolean = false;
  48.          if(this.kind == CSSConditionKind.CLASS)
  49.          {
  50.             if(param1.styleName != null && param1.styleName is String)
  51.             {
  52.                _loc3_ = param1.styleName.split(/\s+/);
  53.                _loc4_ = 0;
  54.                while(_loc4_ < _loc3_.length)
  55.                {
  56.                   if(_loc3_[_loc4_] == this.value)
  57.                   {
  58.                      _loc2_ = true;
  59.                      break;
  60.                   }
  61.                   _loc4_++;
  62.                }
  63.             }
  64.          }
  65.          else if(this.kind == CSSConditionKind.ID)
  66.          {
  67.             if(param1.id == this.value)
  68.             {
  69.                _loc2_ = true;
  70.             }
  71.          }
  72.          else if(this.kind == CSSConditionKind.PSEUDO)
  73.          {
  74.             if(param1.matchesCSSState(this.value))
  75.             {
  76.                _loc2_ = true;
  77.             }
  78.          }
  79.          return _loc2_;
  80.       }
  81.       
  82.       public function toString() : String
  83.       {
  84.          var _loc1_:String = null;
  85.          if(this.kind == CSSConditionKind.CLASS)
  86.          {
  87.             _loc1_ = "." + this.value;
  88.          }
  89.          else if(this.kind == CSSConditionKind.ID)
  90.          {
  91.             _loc1_ = "#" + this.value;
  92.          }
  93.          else if(this.kind == CSSConditionKind.PSEUDO)
  94.          {
  95.             _loc1_ = ":" + this.value;
  96.          }
  97.          else
  98.          {
  99.             _loc1_ = "";
  100.          }
  101.          return _loc1_;
  102.       }
  103.    }
  104. }
  105.  
  106.