DOMEvent.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * DOMEvent class.
  4. *
  5. * Based on
  6. * @link http://developer.mozilla.org/En/DOM:event
  7. * @author Tobiasz Cudnik <tobiasz.cudnik/gmail.com>
  8. * @package phpQuery
  9. * @todo implement ArrayAccess ?
  10. */
  11. class DOMEvent {
  12. /**
  13. * Returns a boolean indicating whether the event bubbles up through the DOM or not.
  14. *
  15. * @var unknown_type
  16. */
  17. public $bubbles = true;
  18. /**
  19. * Returns a boolean indicating whether the event is cancelable.
  20. *
  21. * @var unknown_type
  22. */
  23. public $cancelable = true;
  24. /**
  25. * Returns a reference to the currently registered target for the event.
  26. *
  27. * @var unknown_type
  28. */
  29. public $currentTarget;
  30. /**
  31. * Returns detail about the event, depending on the type of event.
  32. *
  33. * @var unknown_type
  34. * @link http://developer.mozilla.org/en/DOM/event.detail
  35. */
  36. public $detail; // ???
  37. /**
  38. * Used to indicate which phase of the event flow is currently being evaluated.
  39. *
  40. * NOT IMPLEMENTED
  41. *
  42. * @var unknown_type
  43. * @link http://developer.mozilla.org/en/DOM/event.eventPhase
  44. */
  45. public $eventPhase; // ???
  46. /**
  47. * The explicit original target of the event (Mozilla-specific).
  48. *
  49. * NOT IMPLEMENTED
  50. *
  51. * @var unknown_type
  52. */
  53. public $explicitOriginalTarget; // moz only
  54. /**
  55. * The original target of the event, before any retargetings (Mozilla-specific).
  56. *
  57. * NOT IMPLEMENTED
  58. *
  59. * @var unknown_type
  60. */
  61. public $originalTarget; // moz only
  62. /**
  63. * Identifies a secondary target for the event.
  64. *
  65. * @var unknown_type
  66. */
  67. public $relatedTarget;
  68. /**
  69. * Returns a reference to the target to which the event was originally dispatched.
  70. *
  71. * @var unknown_type
  72. */
  73. public $target;
  74. /**
  75. * Returns the time that the event was created.
  76. *
  77. * @var unknown_type
  78. */
  79. public $timeStamp;
  80. /**
  81. * Returns the name of the event (case-insensitive).
  82. */
  83. public $type;
  84. public $runDefault = true;
  85. public $data = null;
  86. public function __construct($data) {
  87. foreach($data as $k => $v) {
  88. $this->$k = $v;
  89. }
  90. if (! $this->timeStamp)
  91. $this->timeStamp = time();
  92. }
  93. /**
  94. * Cancels the event (if it is cancelable).
  95. *
  96. */
  97. public function preventDefault() {
  98. $this->runDefault = false;
  99. }
  100. /**
  101. * Stops the propagation of events further along in the DOM.
  102. *
  103. */
  104. public function stopPropagation() {
  105. $this->bubbles = false;
  106. }
  107. }