Class: Hatemile::Implementation::AccessibleEventImplementation
- Inherits:
-
AccessibleEvent
- Object
- AccessibleEvent
- Hatemile::Implementation::AccessibleEventImplementation
- Defined in:
- lib/hatemile/implementation/accessible_event_implementation.rb
Overview
The AccessibleEventImplementation class is official implementation of AccessibleEvent interface.
Constant Summary collapse
- ID_SCRIPT_EVENT_LISTENER =
The id of script element that replace the event listener methods.
'script-eventlistener'.freeze
- ID_LIST_IDS_SCRIPT =
The id of script element that contains the list of elements that has inaccessible events.
'list-ids-script'.freeze
- ID_FUNCTION_SCRIPT_FIX =
The id of script element that modify the events of elements.
'id-function-script-fix'.freeze
- ID_SCRIPT_COMMON_FUNCTIONS =
The ID of script element that contains the common functions of scripts.
'hatemile-common-functions'.freeze
Instance Method Summary collapse
-
#initialize(parser) ⇒ AccessibleEventImplementation
constructor
Initializes a new object that manipulate the accessibility of the Javascript events of elements of parser.
- #make_accessible_all_click_events ⇒ Object
- #make_accessible_all_drag_and_drop_events ⇒ Object
- #make_accessible_all_hover_events ⇒ Object
- #make_accessible_click_events(element) ⇒ Object
- #make_accessible_drag_events(element) ⇒ Object
- #make_accessible_drop_events(element) ⇒ Object
- #make_accessible_hover_events(element) ⇒ Object
Constructor Details
#initialize(parser) ⇒ AccessibleEventImplementation
Initializes a new object that manipulate the accessibility of the Javascript events of elements of parser.
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 181 def initialize(parser) Hatemile::Helper.require_not_nil(parser) Hatemile::Helper.require_valid_type( parser, Hatemile::Util::Html::HTMLDOMParser ) @parser = parser @id_generator = Hatemile::Util::IDGenerator.new('event') @main_script_added = false @script_list = nil end |
Instance Method Details
#make_accessible_all_click_events ⇒ Object
266 267 268 269 270 271 272 273 274 275 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 266 def make_accessible_all_click_events elements = @parser.find( '[onclick],[onmousedown],[onmouseup],[ondblclick]' ).list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) make_accessible_click_events(element) end end end |
#make_accessible_all_drag_and_drop_events ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 214 def make_accessible_all_drag_and_drop_events draggable_elements = @parser.find( '[ondrag],[ondragstart],[ondragend]' ).list_results draggable_elements.each do |draggable_element| next unless Hatemile::Util::CommonFunctions.is_valid_element?( draggable_element ) make_accessible_drag_events(draggable_element) end droppable_elements = @parser.find( '[ondrop],[ondragenter],[ondragleave],[ondragover]' ).list_results droppable_elements.each do |droppable_element| next unless Hatemile::Util::CommonFunctions.is_valid_element?( droppable_element ) make_accessible_drop_events(droppable_element) end end |
#make_accessible_all_hover_events ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 247 def make_accessible_all_hover_events elements = @parser.find('[onmouseover],[onmouseout]').list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) make_accessible_hover_events(element) end end end |
#make_accessible_click_events(element) ⇒ Object
258 259 260 261 262 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 258 def make_accessible_click_events(element) keyboard_access(element) add_event_in_element(element, 'active') end |
#make_accessible_drag_events(element) ⇒ Object
204 205 206 207 208 209 210 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 204 def make_accessible_drag_events(element) keyboard_access(element) element.set_attribute('aria-grabbed', 'false') add_event_in_element(element, 'drag') end |
#make_accessible_drop_events(element) ⇒ Object
196 197 198 199 200 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 196 def make_accessible_drop_events(element) element.set_attribute('aria-dropeffect', 'none') add_event_in_element(element, 'drop') end |
#make_accessible_hover_events(element) ⇒ Object
239 240 241 242 243 |
# File 'lib/hatemile/implementation/accessible_event_implementation.rb', line 239 def make_accessible_hover_events(element) keyboard_access(element) add_event_in_element(element, 'hover') end |