Source for file ElementById.class.php

Documentation is available at ElementById.class.php

  1. <?php
  2. /**
  3. * XOAD HTML DOM Element By Id file.
  4. *
  5. * <p>This file defines the {@link XOAD_HTML_DOM_ElementById} Class.</p>
  6. *
  7. * @author Stanimir Angeloff
  8. *
  9. * @package XOAD
  10. *
  11. * @subpackage XOAD_HTML
  12. *
  13. * @version 0.6.0.0
  14. *
  15. */
  16.  
  17. /**
  18. * Loads the file that defines the base class for {@link XOAD_HTML_DOM_ElementById}.
  19. */
  20. require_once(XOAD_HTML_BASE . '/classes/DOM/BaseElement.class.php');
  21.  
  22. /**
  23. * XOAD HTML DOM Element By Id Class.
  24. *
  25. * @author Stanimir Angeloff
  26. *
  27. * @package XOAD
  28. *
  29. * @subpackage XOAD_HTML
  30. *
  31. * @version 0.6.0.0
  32. *
  33. */
  34. class XOAD_HTML_DOM_ElementById extends XOAD_HTML_DOM_BaseElement
  35. {
  36. /**
  37. * Creates a new instance of the {@link XOAD_HTML_DOM_ElementById} class.
  38. *
  39. * @param string $id String that holds the ID of the element.
  40. *
  41. * @access public
  42. *
  43. */
  44. function XOAD_HTML_DOM_ElementById($id)
  45. {
  46. parent::XOAD_HTML_DOM_BaseElement();
  47.  
  48. $this->id = $id;
  49.  
  50. $this->skipKeys[] = 'id';
  51. }
  52.  
  53. /**
  54. * Returns the JavaScript name of the element.
  55. *
  56. * @access public
  57. *
  58. * @return string The JavaScript name of the element.
  59. *
  60. */
  61. function getElement()
  62. {
  63. return '__' . ereg_replace('[^a-zA-Z0-9]', '_', $this->id);
  64. }
  65.  
  66. /**
  67. * This method removes keyboard focus from the element.
  68. *
  69. * <p>Example:</p>
  70. * <code>
  71. * $content =& XOAD_HTML::getElementById('content');
  72. *
  73. * $content->blur();
  74. * </code>
  75. *
  76. * @access public
  77. *
  78. * @return void
  79. *
  80. */
  81. function blur()
  82. {
  83. $this->clientCode .= $this->getElement() . '.blur();';
  84. }
  85.  
  86. /**
  87. * This method sets focus on the element.
  88. *
  89. * <p>Example:</p>
  90. * <code>
  91. * $content =& XOAD_HTML::getElementById('content');
  92. *
  93. * $content->focus();
  94. * </code>
  95. *
  96. * @access public
  97. *
  98. * @return void
  99. *
  100. */
  101. function focus()
  102. {
  103. $this->clientCode .= $this->getElement() . '.focus();';
  104. }
  105.  
  106. /**
  107. * Returns the JavaScript code of the DOM element.
  108. *
  109. * <p>You should not call this method directly.</p>
  110. *
  111. * @access public
  112. *
  113. * @param string $element The JavaScript element name.
  114. *
  115. * @return string JavaScript source code for the DOM element.
  116. *
  117. * @static
  118. *
  119. */
  120. function process()
  121. {
  122. $element = $this->getElement();
  123.  
  124. $returnValue = $element . '=document.getElementById("' . $this->id . '");';
  125.  
  126. $returnValue .= parent::process($element);
  127.  
  128. return $returnValue;
  129. }
  130. }
  131. ?>

Documentation generated on Sat, 12 Nov 2005 20:24:01 +0200 by phpDocumentor 1.3.0RC3