Class: Hatemile::Implementation::AccessibleDisplayImplementation
- Inherits:
-
AccessibleDisplay
- Object
- AccessibleDisplay
- Hatemile::Implementation::AccessibleDisplayImplementation
- Defined in:
- lib/hatemile/implementation/accessible_display_implementation.rb
Overview
The AccessibleDisplayImplementation class is official implementation of Hatemile::AccessibleDisplay for screen readers.
Constant Summary collapse
- ID_CONTAINER_SHORTCUTS_BEFORE =
The id of list element that contains the description of shortcuts, before the whole content of page.
'container-shortcuts-before'.freeze
- ID_CONTAINER_SHORTCUTS_AFTER =
The id of list element that contains the description of shortcuts, after the whole content of page.
'container-shortcuts-after'.freeze
- CLASS_TEXT_SHORTCUTS =
The HTML class of text of description of container of shortcuts descriptions.
'text-shortcuts'.freeze
- CLASS_FORCE_READ_BEFORE =
The HTML class of content to force the screen reader show the current state of element, before it.
'force-read-before'.freeze
- CLASS_FORCE_READ_AFTER =
The HTML class of content to force the screen reader show the current state of element, after it.
'force-read-after'.freeze
- DATA_ARIA_AUTOCOMPLETE_OF =
The name of attribute that links the content of autocomplete state of field.
'data-ariaautocompleteof'.freeze
- DATA_ARIA_BUSY_OF =
The name of attribute that links the content of busy state of element.
'data-ariabusyof'.freeze
- DATA_ARIA_CHECKED_OF =
The name of attribute that links the content of checked state field.
'data-ariacheckedof'.freeze
- DATA_ARIA_DROPEFFECT_OF =
The name of attribute that links the content of drop effect state of element.
'data-ariadropeffectof'.freeze
- DATA_ARIA_EXPANDED_OF =
The name of attribute that links the content of expanded state of element.
'data-ariaexpandedof'.freeze
- DATA_ARIA_GRABBED_OF =
The name of attribute that links the content of grabbed state of element.
'data-ariagrabbedof'.freeze
- DATA_ARIA_HASPOPUP_OF =
The name of attribute that links the content that show if the field has popup.
'data-ariahaspopupof'.freeze
- DATA_ARIA_LEVEL_OF =
The name of attribute that links the content of level state of element.
'data-arialevelof'.freeze
- DATA_ARIA_ORIENTATION_OF =
The name of attribute that links the content of orientation state of element.
'data-ariaorientationof'.freeze
- DATA_ARIA_PRESSED_OF =
The name of attribute that links the content of pressed state of field.
'data-ariapressedof'.freeze
- DATA_ARIA_RANGE_MIN_OF =
The name of attribute that links the content of minimum range state of field.
'data-attributevalueminof'.freeze
- DATA_ARIA_RANGE_MAX_OF =
The name of attribute that links the content of maximum range state of field.
'data-attributevaluemaxof'.freeze
- DATA_ARIA_REQUIRED_OF =
The name of attribute that links the content of required state of field.
'data-attributerequiredof'.freeze
- DATA_ARIA_SELECTED_OF =
The name of attribute that links the content of selected state of field.
'data-ariaselectedof'.freeze
- DATA_ARIA_SORT_OF =
The name of attribute that links the content of sort state of element.
'data-ariasortof'.freeze
- DATA_ATTRIBUTE_ACCESSKEY_OF =
The name of attribute that links the description of shortcut of element.
'data-attributeaccesskeyof'.freeze
- DATA_ATTRIBUTE_DOWNLOAD_OF =
The name of attribute that links the content of download link.
'data-attributedownloadof'.freeze
- DATA_ATTRIBUTE_HEADERS_OF =
The name of attribute that links the content of header cell with the data cell.
'data-headersof'.freeze
- DATA_ATTRIBUTE_LANGUAGE_OF =
The name of attribute that links the description of language with the element.
'data-languageof'.freeze
- DATA_ATTRIBUTE_TARGET_OF =
The name of attribute that links the content of link that open a new instance.
'data-attributetargetof'.freeze
- DATA_ATTRIBUTE_TITLE_OF =
The name of attribute that links the content of title of element.
'data-attributetitleof'.freeze
- DATA_ROLE_OF =
The name of attribute that links the content of role of element with the element.
'data-roleof'.freeze
Instance Method Summary collapse
- #display_all_alternative_text_images ⇒ Object
- #display_all_cell_headers ⇒ Object
- #display_all_languages ⇒ Object
- #display_all_links_attributes ⇒ Object
- #display_all_roles ⇒ Object
- #display_all_shortcuts ⇒ Object
- #display_all_titles ⇒ Object
- #display_all_waiaria_states ⇒ Object
- #display_alternative_text_image(image) ⇒ Object
- #display_cell_header(table_cell) ⇒ Object
- #display_language(element) ⇒ Object
- #display_link_attributes(link) ⇒ Object
- #display_role(element) ⇒ Object
- #display_shortcut(element) ⇒ Object
- #display_title(element) ⇒ Object
- #display_waiaria_states(element) ⇒ Object
-
#initialize(parser, configure, user_agent = nil) ⇒ AccessibleDisplayImplementation
constructor
Initializes a new object that manipulate the display for screen readers of parser.
Constructor Details
#initialize(parser, configure, user_agent = nil) ⇒ AccessibleDisplayImplementation
Initializes a new object that manipulate the display for screen readers of parser.
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 492 def initialize(parser, configure, user_agent = nil) Hatemile::Helper.require_not_nil(parser, configure) Hatemile::Helper.require_valid_type( parser, Hatemile::Util::Html::HTMLDOMParser ) Hatemile::Helper.require_valid_type( configure, Hatemile::Util::Configure ) Hatemile::Helper.require_valid_type(user_agent, String) @parser = parser @configure = configure @id_generator = Hatemile::Util::IDGenerator.new('display') @shortcut_prefix = get_shortcut_prefix( user_agent, configure.get_parameter('attribute-accesskey-default') ) @aria_autocomplete_both_before = configure.get_parameter( 'aria-autocomplete-both-before' ) @aria_autocomplete_both_after = configure.get_parameter( 'aria-autocomplete-both-after' ) @aria_autocomplete_inline_before = configure.get_parameter( 'aria-autocomplete-inline-before' ) @aria_autocomplete_inline_after = configure.get_parameter( 'aria-autocomplete-inline-after' ) @aria_autocomplete_list_before = configure.get_parameter( 'aria-autocomplete-list-before' ) @aria_autocomplete_list_after = configure.get_parameter( 'aria-autocomplete-list-after' ) @aria_busy_true_before = configure.get_parameter( 'aria-busy-true-before' ) @aria_busy_true_after = configure.get_parameter('aria-busy-true-after') @aria_checked_false_before = configure.get_parameter( 'aria-checked-false-before' ) @aria_checked_false_after = configure.get_parameter( 'aria-checked-false-after' ) @aria_checked_mixed_before = configure.get_parameter( 'aria-checked-mixed-before' ) @aria_checked_mixed_after = configure.get_parameter( 'aria-checked-mixed-after' ) @aria_checked_true_before = configure.get_parameter( 'aria-checked-true-before' ) @aria_checked_true_after = configure.get_parameter( 'aria-checked-true-after' ) @aria_dropeffect_copy_before = configure.get_parameter( 'aria-dropeffect-copy-before' ) @aria_dropeffect_copy_after = configure.get_parameter( 'aria-dropeffect-copy-after' ) @aria_dropeffect_execute_before = configure.get_parameter( 'aria-dropeffect-execute-before' ) @aria_dropeffect_execute_after = configure.get_parameter( 'aria-dropeffect-execute-after' ) @aria_dropeffect_link_before = configure.get_parameter( 'aria-dropeffect-link-before' ) @aria_dropeffect_link_after = configure.get_parameter( 'aria-dropeffect-link-after' ) @aria_dropeffect_move_before = configure.get_parameter( 'aria-dropeffect-move-before' ) @aria_dropeffect_move_after = configure.get_parameter( 'aria-dropeffect-move-after' ) @aria_dropeffect_popup_before = configure.get_parameter( 'aria-dropeffect-popup-before' ) @aria_dropeffect_popup_after = configure.get_parameter( 'aria-dropeffect-popup-after' ) @aria_expanded_false_before = configure.get_parameter( 'aria-expanded-false-before' ) @aria_expanded_false_after = configure.get_parameter( 'aria-expanded-false-after' ) @aria_expanded_true_before = configure.get_parameter( 'aria-expanded-true-before' ) @aria_expanded_true_after = configure.get_parameter( 'aria-expanded-true-after' ) @aria_grabbed_false_before = configure.get_parameter( 'aria-grabbed-false-before' ) @aria_grabbed_false_after = configure.get_parameter( 'aria-grabbed-false-after' ) @aria_grabbed_true_before = configure.get_parameter( 'aria-grabbed-true-before' ) @aria_grabbed_true_after = configure.get_parameter( 'aria-grabbed-true-after' ) @aria_haspopup_true_before = configure.get_parameter( 'aria-haspopup-true-before' ) @aria_haspopup_true_after = configure.get_parameter( 'aria-haspopup-true-after' ) @aria_level_prefix_before = configure.get_parameter( 'aria-level-prefix-before' ) @aria_level_suffix_before = configure.get_parameter( 'aria-level-suffix-before' ) @aria_level_prefix_after = configure.get_parameter( 'aria-level-prefix-after' ) @aria_level_suffix_after = configure.get_parameter( 'aria-level-suffix-after' ) @aria_value_maximum_prefix_before = configure.get_parameter( 'aria-value-maximum-prefix-before' ) @aria_value_maximum_suffix_before = configure.get_parameter( 'aria-value-maximum-suffix-before' ) @aria_value_maximum_prefix_after = configure.get_parameter( 'aria-value-maximum-prefix-after' ) @aria_value_maximum_suffix_after = configure.get_parameter( 'aria-value-maximum-suffix-after' ) @aria_value_minimum_prefix_before = configure.get_parameter( 'aria-value-minimum-prefix-before' ) @aria_value_minimum_suffix_before = configure.get_parameter( 'aria-value-minimum-suffix-before' ) @aria_value_minimum_prefix_after = configure.get_parameter( 'aria-value-minimum-prefix-after' ) @aria_value_minimum_suffix_after = configure.get_parameter( 'aria-value-minimum-suffix-after' ) @aria_orientation_horizontal_before = configure.get_parameter( 'aria-orientation-horizontal-before' ) @aria_orientation_horizontal_after = configure.get_parameter( 'aria-orientation-horizontal-after' ) @aria_orientation_vertical_before = configure.get_parameter( 'aria-orientation-vertical-before' ) @aria_orientation_vertical_after = configure.get_parameter( 'aria-orientation-vertical-after' ) @aria_pressed_false_before = configure.get_parameter( 'aria-pressed-false-before' ) @aria_pressed_false_after = configure.get_parameter( 'aria-pressed-false-after' ) @aria_pressed_mixed_before = configure.get_parameter( 'aria-pressed-mixed-before' ) @aria_pressed_mixed_after = configure.get_parameter( 'aria-pressed-mixed-after' ) @aria_pressed_true_before = configure.get_parameter( 'aria-pressed-true-before' ) @aria_pressed_true_after = configure.get_parameter( 'aria-pressed-true-after' ) @aria_required_true_before = configure.get_parameter( 'aria-required-true-before' ) @aria_required_true_after = configure.get_parameter( 'aria-required-true-after' ) @aria_selected_false_before = configure.get_parameter( 'aria-selected-false-before' ) @aria_selected_false_after = configure.get_parameter( 'aria-selected-false-after' ) @aria_selected_true_before = configure.get_parameter( 'aria-selected-true-before' ) @aria_selected_true_after = configure.get_parameter( 'aria-selected-true-after' ) @aria_sort_ascending_before = configure.get_parameter( 'aria-sort-ascending-before' ) @aria_sort_ascending_after = configure.get_parameter( 'aria-sort-ascending-after' ) @aria_sort_descending_before = configure.get_parameter( 'aria-sort-descending-before' ) @aria_sort_descending_after = configure.get_parameter( 'aria-sort-descending-after' ) @aria_sort_other_before = configure.get_parameter( 'aria-sort-other-before' ) @aria_sort_other_after = configure.get_parameter( 'aria-sort-other-after' ) @attribute_accesskey_before = configure.get_parameter( 'attribute-accesskey-before' ) @attribute_accesskey_after = configure.get_parameter( 'attribute-accesskey-after' ) @attribute_accesskey_prefix_before = configure.get_parameter( 'attribute-accesskey-prefix-before' ) @attribute_accesskey_suffix_before = configure.get_parameter( 'attribute-accesskey-suffix-before' ) @attribute_accesskey_prefix_after = configure.get_parameter( 'attribute-accesskey-prefix-after' ) @attribute_accesskey_suffix_after = configure.get_parameter( 'attribute-accesskey-suffix-after' ) @attribute_download_before = configure.get_parameter( 'attribute-download-before' ) @attribute_download_after = configure.get_parameter( 'attribute-download-after' ) @attribute_headers_prefix_before = configure.get_parameter( 'attribute-headers-prefix-before' ) @attribute_headers_suffix_before = configure.get_parameter( 'attribute-headers-suffix-before' ) @attribute_headers_prefix_after = configure.get_parameter( 'attribute-headers-prefix-after' ) @attribute_headers_suffix_after = configure.get_parameter( 'attribute-headers-suffix-after' ) @attribute_language_prefix_before = configure.get_parameter( 'attribute-language-prefix-before' ) @attribute_language_suffix_before = configure.get_parameter( 'attribute-language-suffix-before' ) @attribute_language_prefix_after = configure.get_parameter( 'attribute-language-prefix-after' ) @attribute_language_suffix_after = configure.get_parameter( 'attribute-language-suffix-after' ) @attribute_role_prefix_before = configure.get_parameter( 'attribute-role-prefix-before' ) @attribute_role_suffix_before = configure.get_parameter( 'attribute-role-suffix-before' ) @attribute_role_prefix_after = configure.get_parameter( 'attribute-role-prefix-after' ) @attribute_role_suffix_after = configure.get_parameter( 'attribute-role-suffix-after' ) @attribute_target_blank_before = configure.get_parameter( 'attribute-target-blank-before' ) @attribute_target_blank_after = configure.get_parameter( 'attribute-target-blank-after' ) @attribute_title_prefix_before = configure.get_parameter( 'attribute-title-prefix-before' ) @attribute_title_suffix_before = configure.get_parameter( 'attribute-title-suffix-before' ) @attribute_title_prefix_after = configure.get_parameter( 'attribute-title-prefix-after' ) @attribute_title_suffix_after = configure.get_parameter( 'attribute-title-suffix-after' ) @list_shortcuts_added = false @list_shortcuts_before = nil @list_shortcuts_after = nil end |
Instance Method Details
#display_all_alternative_text_images ⇒ Object
1352 1353 1354 1355 1356 1357 1358 1359 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1352 def display_all_alternative_text_images images = @parser.find('img').list_results images.each do |image| if Hatemile::Util::CommonFunctions.is_valid_element?(image) display_alternative_text_image(image) end end end |
#display_all_cell_headers ⇒ Object
925 926 927 928 929 930 931 932 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 925 def display_all_cell_headers elements = @parser.find('td[headers],th[headers]').list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_cell_header(element) end end end |
#display_all_languages ⇒ Object
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1316 def display_all_languages elements = @parser.find( 'html[lang],body[lang],body [lang],body [hreflang]' ).list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_language(element) end end end |
#display_all_links_attributes ⇒ Object
1252 1253 1254 1255 1256 1257 1258 1259 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1252 def display_all_links_attributes links = @parser.find('a[download],a[target="_blank"]').list_results links.each do |link| if Hatemile::Util::CommonFunctions.is_valid_element?(link) display_link_attributes(link) end end end |
#display_all_roles ⇒ Object
882 883 884 885 886 887 888 889 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 882 def display_all_roles elements = @parser.find('[role]').list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_role(element) end end end |
#display_all_shortcuts ⇒ Object
851 852 853 854 855 856 857 858 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 851 def display_all_shortcuts elements = @parser.find('[accesskey]').list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_shortcut(element) end end end |
#display_all_titles ⇒ Object
1282 1283 1284 1285 1286 1287 1288 1289 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1282 def display_all_titles elements = @parser.find('body [title]').list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_title(element) end end end |
#display_all_waiaria_states ⇒ Object
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1213 def display_all_waiaria_states elements = @parser.find( '[aria-busy=true],[aria-checked],[aria-dropeffect],' \ '[aria-expanded],[aria-grabbed],[aria-haspopup],[aria-level],' \ '[aria-orientation],[aria-pressed],[aria-selected],[aria-sort],' \ '[aria-required=true],[aria-valuemin],[aria-valuemax],' \ '[aria-autocomplete]' ).list_results elements.each do |element| if Hatemile::Util::CommonFunctions.is_valid_element?(element) display_waiaria_states(element) end end end |
#display_alternative_text_image(image) ⇒ Object
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1329 def display_alternative_text_image(image) if image.has_attribute?('alt') || image.has_attribute?('title') if image.has_attribute?('alt') && !image.has_attribute?('title') image.set_attribute('title', image.get_attribute('alt')) elsif image.has_attribute?('title') && !image.has_attribute?('alt') image.set_attribute('alt', image.get_attribute('title')) end @id_generator.generate_id(image) image.set_attribute( DATA_ATTRIBUTE_TITLE_OF, image.get_attribute('id') ) else image.set_attribute('alt', '') image.set_attribute('role', 'presentation') image.set_attribute('aria-hidden', 'true') end end |
#display_cell_header(table_cell) ⇒ Object
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 893 def display_cell_header(table_cell) return unless table_cell.has_attribute?('headers') text_header = '' ids_headers = table_cell.get_attribute('headers').split(/[ \n\t\r]+/) ids_headers.each do |id_header| header = @parser.find("##{id_header}").first_result next if header.nil? text_header = if text_header.empty? header.get_text_content.strip else "#{text_header} #{header.get_text_content.strip}" end end return if text_header.strip.empty? force_read( table_cell, text_header.gsub(/[ \n\t\r]+/, ' ').strip, @attribute_headers_prefix_before, @attribute_headers_suffix_before, @attribute_headers_prefix_after, @attribute_headers_suffix_after, DATA_ATTRIBUTE_HEADERS_OF ) end |
#display_language(element) ⇒ Object
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1293 def display_language(element) language_code = if element.has_attribute?('lang') element.get_attribute('lang') elsif element.has_attribute?('hreflang') element.get_attribute('hreflang') end language = get_language_description(language_code) return if language.nil? force_read( element, language, @attribute_language_prefix_before, @attribute_language_suffix_before, @attribute_language_prefix_after, @attribute_language_suffix_after, DATA_ATTRIBUTE_LANGUAGE_OF ) end |
#display_link_attributes(link) ⇒ Object
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1230 def display_link_attributes(link) if link.has_attribute?('download') force_read_simple( link, @attribute_download_before, @attribute_download_after, DATA_ATTRIBUTE_DOWNLOAD_OF ) end if link.has_attribute?('target') && link.get_attribute('target') == '_blank' force_read_simple( link, @attribute_target_blank_before, @attribute_target_blank_after, DATA_ATTRIBUTE_TARGET_OF ) end end |
#display_role(element) ⇒ Object
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 862 def display_role(element) return unless element.has_attribute?('role') role_description = get_role_description(element.get_attribute('role')) return if role_description.nil? force_read( element, role_description, @attribute_role_prefix_before, @attribute_role_suffix_before, @attribute_role_prefix_after, @attribute_role_suffix_after, DATA_ROLE_OF ) end |
#display_shortcut(element) ⇒ Object
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 798 def display_shortcut(element) return unless element.has_attribute?('accesskey') description = get_description(element) unless element.has_attribute?('title') element.set_attribute('title', description) @id_generator.generate_id(element) element.set_attribute( DATA_ATTRIBUTE_TITLE_OF, element.get_attribute('id') ) end generate_list_shortcuts unless @list_shortcuts_added keys = element.get_attribute('accesskey').upcase.split(/[ \n\t\r]+/) keys.each do |key| shortcut = "#{@shortcut_prefix} + #{key}" selector = "[#{DATA_ATTRIBUTE_ACCESSKEY_OF}=\"#{key}\"]" force_read( element, shortcut, @attribute_accesskey_prefix_before, @attribute_accesskey_suffix_before, @attribute_accesskey_prefix_after, @attribute_accesskey_suffix_after, DATA_ATTRIBUTE_ACCESSKEY_OF ) item = @parser.create_element('li') item.set_attribute(DATA_ATTRIBUTE_ACCESSKEY_OF, key) item.append_text("#{shortcut}: #{description}") if !@list_shortcuts_before.nil? && @parser.find(@list_shortcuts_before).find_children( selector ).first_result.nil? @list_shortcuts_before.append_element(item.clone_element) end unless !@list_shortcuts_after.nil? && @parser.find(@list_shortcuts_after).find_children( selector ).first_result.nil? next end @list_shortcuts_after.append_element(item.clone_element) end end |
#display_title(element) ⇒ Object
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 1263 def display_title(element) if element.get_tag_name == 'IMG' display_alternative_text_image(element) elsif element.has_attribute?('title') && !element.get_attribute('title').empty? force_read( element, element.get_attribute('title').gsub(/[ \n\t\r]+/, ' ').strip, @attribute_title_prefix_before, @attribute_title_suffix_before, @attribute_title_prefix_after, @attribute_title_suffix_after, DATA_ATTRIBUTE_TITLE_OF ) end end |
#display_waiaria_states(element) ⇒ Object
936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 |
# File 'lib/hatemile/implementation/accessible_display_implementation.rb', line 936 def display_waiaria_states(element) if element.has_attribute?('aria-busy') && element.get_attribute('aria-busy') == 'true' force_read_simple( element, @aria_busy_true_before, @aria_busy_true_after, DATA_ARIA_BUSY_OF ) end if element.has_attribute?('aria-checked') attribute_value = element.get_attribute('aria-checked') if attribute_value == 'true' force_read_simple( element, @aria_checked_true_before, @aria_checked_true_after, DATA_ARIA_CHECKED_OF ) elsif attribute_value == 'false' force_read_simple( element, @aria_checked_false_before, @aria_checked_false_after, DATA_ARIA_CHECKED_OF ) elsif attribute_value == 'mixed' force_read_simple( element, @aria_checked_mixed_before, @aria_checked_mixed_after, DATA_ARIA_CHECKED_OF ) end end if element.has_attribute?('aria-expanded') attribute_value = element.get_attribute('aria-expanded') if attribute_value == 'true' force_read_simple( element, @aria_expanded_true_before, @aria_expanded_true_after, DATA_ARIA_EXPANDED_OF ) elsif attribute_value == 'false' force_read_simple( element, @aria_expanded_false_before, @aria_expanded_false_after, DATA_ARIA_EXPANDED_OF ) end end if element.has_attribute?('aria-haspopup') && element.get_attribute('aria-haspopup') == 'true' force_read_simple( element, @aria_haspopup_true_before, @aria_haspopup_true_after, DATA_ARIA_HASPOPUP_OF ) end if element.has_attribute?('aria-level') force_read( element, element.get_attribute('aria-level'), @aria_level_prefix_before, @aria_level_suffix_before, @aria_level_prefix_after, @aria_level_suffix_after, DATA_ARIA_LEVEL_OF ) end if element.has_attribute?('aria-orientation') attribute_value = element.get_attribute('aria-orientation') if attribute_value == 'vertical' force_read_simple( element, @aria_orientation_vertical_before, @aria_orientation_vertical_after, DATA_ARIA_ORIENTATION_OF ) elsif attribute_value == 'horizontal' force_read_simple( element, @aria_orientation_horizontal_before, @aria_orientation_horizontal_after, DATA_ARIA_ORIENTATION_OF ) end end if element.has_attribute?('aria-pressed') attribute_value = element.get_attribute('aria-pressed') if attribute_value == 'true' force_read_simple( element, @aria_pressed_true_before, @aria_pressed_true_after, DATA_ARIA_PRESSED_OF ) elsif attribute_value == 'false' force_read_simple( element, @aria_pressed_false_before, @aria_pressed_false_after, DATA_ARIA_PRESSED_OF ) elsif attribute_value == 'mixed' force_read_simple( element, @aria_pressed_mixed_before, @aria_pressed_mixed_after, DATA_ARIA_PRESSED_OF ) end end if element.has_attribute?('aria-selected') attribute_value = element.get_attribute('aria-selected') if attribute_value == 'true' force_read_simple( element, @aria_selected_true_before, @aria_selected_true_after, DATA_ARIA_SELECTED_OF ) elsif attribute_value == 'false' force_read_simple( element, @aria_selected_false_before, @aria_selected_false_after, DATA_ARIA_SELECTED_OF ) end end if element.has_attribute?('aria-sort') attribute_value = element.get_attribute('aria-sort') if attribute_value == 'ascending' force_read_simple( element, @aria_sort_ascending_before, @aria_sort_ascending_after, DATA_ARIA_SORT_OF ) elsif attribute_value == 'descending' force_read_simple( element, @aria_sort_descending_before, @aria_sort_descending_after, DATA_ARIA_SORT_OF ) elsif attribute_value == 'other' force_read_simple( element, @aria_sort_other_before, @aria_sort_other_after, DATA_ARIA_SORT_OF ) end end if element.has_attribute?('aria-required') && element.get_attribute('aria-required') == 'true' force_read_simple( element, @aria_required_true_before, @aria_required_true_after, DATA_ARIA_REQUIRED_OF ) end if element.has_attribute?('aria-valuemin') force_read( element, element.get_attribute('aria-valuemin'), @aria_value_minimum_prefix_before, @aria_value_minimum_suffix_before, @aria_value_minimum_prefix_after, @aria_value_minimum_suffix_after, DATA_ARIA_RANGE_MIN_OF ) end if element.has_attribute?('aria-valuemax') force_read( element, element.get_attribute('aria-valuemax'), @aria_value_maximum_prefix_before, @aria_value_maximum_suffix_before, @aria_value_maximum_prefix_after, @aria_value_maximum_suffix_after, DATA_ARIA_RANGE_MAX_OF ) end if element.has_attribute?('aria-autocomplete') attribute_value = element.get_attribute('aria-autocomplete') if attribute_value == 'both' force_read_simple( element, @aria_autocomplete_both_before, @aria_autocomplete_both_after, DATA_ARIA_AUTOCOMPLETE_OF ) elsif attribute_value == 'inline' force_read_simple( element, @aria_autocomplete_list_before, @aria_autocomplete_list_after, DATA_ARIA_AUTOCOMPLETE_OF ) elsif attribute_value == 'list' force_read_simple( element, @aria_autocomplete_inline_before, @aria_autocomplete_inline_after, DATA_ARIA_AUTOCOMPLETE_OF ) end end if element.has_attribute?('aria-dropeffect') attribute_value = element.get_attribute('aria-dropeffect') if attribute_value == 'copy' force_read_simple( element, @aria_dropeffect_copy_before, @aria_dropeffect_copy_after, DATA_ARIA_DROPEFFECT_OF ) elsif attribute_value == 'move' force_read_simple( element, @aria_dropeffect_move_before, @aria_dropeffect_move_after, DATA_ARIA_DROPEFFECT_OF ) elsif attribute_value == 'link' force_read_simple( element, @aria_dropeffect_link_before, @aria_dropeffect_link_after, DATA_ARIA_DROPEFFECT_OF ) elsif attribute_value == 'execute' force_read_simple( element, @aria_dropeffect_execute_before, @aria_dropeffect_execute_after, DATA_ARIA_DROPEFFECT_OF ) elsif attribute_value == 'popup' force_read_simple( element, @aria_dropeffect_popup_before, @aria_dropeffect_popup_after, DATA_ARIA_DROPEFFECT_OF ) end end return unless element.has_attribute?('aria-grabbed') attribute_value = element.get_attribute('aria-grabbed') if attribute_value == 'true' force_read_simple( element, @aria_grabbed_true_before, @aria_grabbed_true_after, DATA_ARIA_GRABBED_OF ) elsif attribute_value == 'false' force_read_simple( element, @aria_grabbed_false_before, @aria_grabbed_false_after, DATA_ARIA_GRABBED_OF ) end end |