├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Gruntfile.js ├── LICENSE ├── README.md ├── _locales ├── en_US │ ├── coffee │ │ └── configurations.coffee │ └── js │ │ └── configurations.js └── pt_BR │ ├── coffee │ └── configurations.coffee │ └── js │ └── configurations.js ├── bower.json ├── coffee ├── eventlistener.coffee ├── hatemile-skippers.coffee ├── hatemile-symbols.coffee └── hatemile │ ├── AccessibleAssociation.coffee │ ├── AccessibleCSS.coffee │ ├── AccessibleDisplay.coffee │ ├── AccessibleEvent.coffee │ ├── AccessibleForm.coffee │ ├── AccessibleNavigation.coffee │ ├── implementation │ ├── AccessibleAssociationImplementation.coffee │ ├── AccessibleCSSImplementation.coffee │ ├── AccessibleDisplayScreenReaderImplementation.coffee │ ├── AccessibleEventImplementation.coffee │ ├── AccessibleFormImplementation.coffee │ └── AccessibleNavigationImplementation.coffee │ └── util │ ├── CommonFunctions.coffee │ ├── Configure.coffee │ ├── IDGenerator.coffee │ ├── css │ ├── StyleSheetDeclaration.coffee │ ├── StyleSheetParser.coffee │ ├── StyleSheetRule.coffee │ └── jscssp │ │ ├── JSCSSPDeclaration.coffee │ │ ├── JSCSSPParser.coffee │ │ └── JSCSSPRule.coffee │ └── html │ ├── HTMLDOMElement.coffee │ ├── HTMLDOMNode.coffee │ ├── HTMLDOMParser.coffee │ ├── HTMLDOMTextNode.coffee │ ├── jquery │ └── JQueryHTMLDOMParser.coffee │ └── vanilla │ ├── VanillaHTMLDOMElement.coffee │ ├── VanillaHTMLDOMParser.coffee │ └── VanillaHTMLDOMTextNode.coffee ├── css └── hide_changes.css ├── js ├── eventlistener.js ├── hatemile-skippers.js ├── hatemile-symbols.js └── hatemile │ ├── AccessibleAssociation.js │ ├── AccessibleCSS.js │ ├── AccessibleDisplay.js │ ├── AccessibleEvent.js │ ├── AccessibleForm.js │ ├── AccessibleNavigation.js │ ├── implementation │ ├── AccessibleAssociationImplementation.js │ ├── AccessibleCSSImplementation.js │ ├── AccessibleDisplayScreenReaderImplementation.js │ ├── AccessibleEventImplementation.js │ ├── AccessibleFormImplementation.js │ └── AccessibleNavigationImplementation.js │ └── util │ ├── CommonFunctions.js │ ├── Configure.js │ ├── IDGenerator.js │ ├── css │ ├── StyleSheetDeclaration.js │ ├── StyleSheetParser.js │ ├── StyleSheetRule.js │ └── jscssp │ │ ├── JSCSSPDeclaration.js │ │ ├── JSCSSPParser.js │ │ └── JSCSSPRule.js │ └── html │ ├── HTMLDOMElement.js │ ├── HTMLDOMNode.js │ ├── HTMLDOMParser.js │ ├── HTMLDOMTextNode.js │ ├── jquery │ └── JQueryHTMLDOMParser.js │ └── vanilla │ ├── VanillaHTMLDOMElement.js │ ├── VanillaHTMLDOMParser.js │ └── VanillaHTMLDOMTextNode.js └── package.json /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | [Description of the bug, feature or question] 4 | 5 | ## Steps to Reproduce (for bugs) 6 | 7 | 1. [First Step] 8 | 2. [Second Step] 9 | 3. [and so on...] 10 | 11 | ## Expected behavior 12 | 13 | [What you expected to happen] 14 | 15 | ## Actual behavior 16 | 17 | [What actually happened] 18 | 19 | ## Your Environment 20 | * **Version**: 2.0.2 21 | * **Browser and it version**: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /bower_components/ 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at 3837162+carlsonsantana@users.noreply.github.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | First off, thank you for considering contributing to HaTeMiLe for JavaScript. 4 | 5 | ## Table of contents 6 | 7 | * [Code of conduct](#code-of-conduct) 8 | * [Reporting bugs](#reporting-bugs) 9 | * [Request new feature](#request-new-feature) 10 | * [Translating](#translating) 11 | * [Code contribution](#code-contribution) 12 | * [Pull request](#pull-request) 13 | * [Styleguides](#styleguides) 14 | * [Git commit messages](#git-commit-messages) 15 | * [CoffeeScript styleguide](#coffeeScript-styleguide) 16 | * [Donate](#donate) 17 | 18 | ## Code of conduct 19 | 20 | This project and everyone participating in it is governed by the [HaTeMiLe for JavaScript code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [3837162+carlsonsantana@users.noreply.github.com](mailto:3837162+carlsonsantana@users.noreply.github.com). 21 | 22 | ## Reporting bugs 23 | 24 | This section guides you through submitting a bug report for HaTeMiLe for JavaScript. 25 | 26 | Before submitting a bug report check if you're using the latest version of HaTeMiLe for JavaScript and [ensure the bug was not already reported](https://github.com/hatemile/hatemile-for-javascript/issues). 27 | 28 | If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/hatemile/hatemile-for-javascript/issues/new). 29 | 30 | ## Request new feature 31 | 32 | This section guides you through request new feature for HaTeMiLe for JavaScript. 33 | 34 | Before submitting a request feature check if you're using the latest version of HaTeMiLe for JavaScript and [ensure the feature was not already requested](https://github.com/hatemile/hatemile-for-javascript/issues). 35 | 36 | If you're unable to find an open issue requesting this feature, [open a new one](https://github.com/hatemile/hatemile-for-javascript/issues/new). 37 | 38 | ## Translating 39 | 40 | [To translate the HaTeMiLe you must access our project in Zanata](https://translate.zanata.org/project/view/hatemile), you will need a account to translate. 41 | 42 | ## Code contribution 43 | 44 | If you want submit your code to HaTeMiLe for JavaScript you need follow the code conventions, the styleguides and pull request process. 45 | 46 | ### Pull request 47 | 48 | 1. [Install Node.js](https://nodejs.org/en/download/package-manager/); 49 | 2. [Install the dependencies of HaTeMiLe for JavaScript](https://docs.npmjs.com/cli/install); 50 | 3. [Fork the repository](https://help.github.com/articles/fork-a-repo/); 51 | 4. Start coding :smile:; 52 | 5. [Run grunt](https://gruntjs.com/getting-started) without arguments; 53 | 6. [Commit and push your changes](https://help.github.com/articles/adding-a-file-to-a-repository-using-the-command-line/); 54 | 7. [Do a pull-request](https://help.github.com/articles/creating-a-pull-request/) with a short description explaining briefly what you've done. 55 | 56 | ### Styleguides 57 | 58 | #### Git commit messages 59 | 60 | * Limit to one line 61 | * Limit the line to 72 characters or less 62 | * Reference issues after comma 63 | * Start the commit message with an applicable emoji: 64 | * :tada: `:tada:` Initial commit 65 | * :art: `:art:` Cosmetic 66 | * :racehorse: `:racehorse:` Performance 67 | * :memo: `:memo:` Documentation 68 | * :bug: `:bug:` Bugfix 69 | * :fire: `:fire:` Remove code 70 | * :white_check_mark: `:white_check_mark:` Tests 71 | * :sparkles: `:sparkles:` New Feature 72 | * :recycle: `:recycle:` Refactoring 73 | * :globe_with_meridians: `:globe_with_meridians:` Internationalization 74 | * :octocat: `:octocat:` GitHub especific resource 75 | * :bookmark: `:bookmark:` Version Tag 76 | * :wrench: `:wrench:` Tooling 77 | * :lock: `:lock:` Security 78 | * :card_index: `:card_index:` Metadata 79 | 80 | #### CoffeeScript styleguide 81 | 82 | Run the command `grunt test` in path of HaTeMiLe for JavaScript to test if the CoffeeScript follow these styleguide. 83 | 84 | * Increase a space before and after the arrow operator that declares a function; 85 | * Set proper spacing inside curly braces; 86 | * All class names must be UpperCamelCased; 87 | * Use two space indentation; 88 | * Lines can be no longer than eighty characters; 89 | * Not use implicit parens on function calls; 90 | * Not use string interpolation in a single quoted string; 91 | * Not use nested string interpolation; 92 | * Not use increment (`++`) and decrement (`--`) arithmetic operators; 93 | * Not use trailing semicolons; 94 | * Not use trailing whitespace in your code; 95 | * Not use double quotes unless string interpolation is used or the string contains single quotes; 96 | * Not use `&&`, `||`, `==`, `!=` and `!`. Use `and`, `or`, `is`, `isnt`, and `not` instead; 97 | * Operators must have spaces around them; 98 | * Make sure you have a space after commas. 99 | 100 | ## Donate 101 | 102 | If you'd like to monetarily support HaTeMiLe for Browser development, you can: 103 | * [Donate to us by PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PRY8PY3ANVYT6); 104 | * Donate Bitcoin to **1EhnFFHv2MheyNHViwYWhKjSWoVjSnJMzA** wallet address; 105 | * Donate Ethereum to **0x1f9b88c3fbd4823eac4910f456a4036e24e87f5b** wallet address; 106 | * Donate Litecoin to **LhLTYbH2CwCuAHEkedvmHyTBQTWfCb2aK3** wallet address; 107 | * Donate Dogecoin to **DECZbbUb8kGKau8ycUmdgmfaPbkBTaApjQ** wallet address; 108 | * Donate Tether to **1EnvcNeo1gp27h8mVLMgMuiJvq8UHCENdX** wallet address. -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | // Project configuration. 3 | grunt.initConfig({ 4 | pkg: grunt.file.readJSON('package.json'), 5 | coffee: { 6 | options: { 7 | bare: false 8 | }, 9 | compile: { 10 | files: { 11 | 'js/eventlistener.js': 'coffee/eventlistener.coffee', 12 | 'js/hatemile-symbols.js': 'coffee/hatemile-symbols.coffee', 13 | 'js/hatemile-skippers.js': 'coffee/hatemile-skippers.coffee', 14 | 'js/hatemile/AccessibleAssociation.js': 'coffee/hatemile/AccessibleAssociation.coffee', 15 | 'js/hatemile/AccessibleCSS.js': 'coffee/hatemile/AccessibleCSS.coffee', 16 | 'js/hatemile/AccessibleDisplay.js': 'coffee/hatemile/AccessibleDisplay.coffee', 17 | 'js/hatemile/AccessibleEvent.js': 'coffee/hatemile/AccessibleEvent.coffee', 18 | 'js/hatemile/AccessibleForm.js': 'coffee/hatemile/AccessibleForm.coffee', 19 | 'js/hatemile/AccessibleNavigation.js': 'coffee/hatemile/AccessibleNavigation.coffee', 20 | 'js/hatemile/implementation/AccessibleAssociationImplementation.js': 'coffee/hatemile/implementation/AccessibleAssociationImplementation.coffee', 21 | 'js/hatemile/implementation/AccessibleCSSImplementation.js': 'coffee/hatemile/implementation/AccessibleCSSImplementation.coffee', 22 | 'js/hatemile/implementation/AccessibleDisplayScreenReaderImplementation.js': 'coffee/hatemile/implementation/AccessibleDisplayScreenReaderImplementation.coffee', 23 | 'js/hatemile/implementation/AccessibleEventImplementation.js': 'coffee/hatemile/implementation/AccessibleEventImplementation.coffee', 24 | 'js/hatemile/implementation/AccessibleFormImplementation.js': 'coffee/hatemile/implementation/AccessibleFormImplementation.coffee', 25 | 'js/hatemile/implementation/AccessibleNavigationImplementation.js': 'coffee/hatemile/implementation/AccessibleNavigationImplementation.coffee', 26 | 'js/hatemile/util/CommonFunctions.js': 'coffee/hatemile/util/CommonFunctions.coffee', 27 | 'js/hatemile/util/Configure.js': 'coffee/hatemile/util/Configure.coffee', 28 | 'js/hatemile/util/IDGenerator.js': 'coffee/hatemile/util/IDGenerator.coffee', 29 | 'js/hatemile/util/css/StyleSheetDeclaration.js': 'coffee/hatemile/util/css/StyleSheetDeclaration.coffee', 30 | 'js/hatemile/util/css/StyleSheetParser.js': 'coffee/hatemile/util/css/StyleSheetParser.coffee', 31 | 'js/hatemile/util/css/StyleSheetRule.js': 'coffee/hatemile/util/css/StyleSheetRule.coffee', 32 | 'js/hatemile/util/css/jscssp/JSCSSPDeclaration.js': 'coffee/hatemile/util/css/jscssp/JSCSSPDeclaration.coffee', 33 | 'js/hatemile/util/css/jscssp/JSCSSPParser.js': 'coffee/hatemile/util/css/jscssp/JSCSSPParser.coffee', 34 | 'js/hatemile/util/css/jscssp/JSCSSPRule.js': 'coffee/hatemile/util/css/jscssp/JSCSSPRule.coffee', 35 | 'js/hatemile/util/html/HTMLDOMElement.js': 'coffee/hatemile/util/html/HTMLDOMElement.coffee', 36 | 'js/hatemile/util/html/HTMLDOMNode.js': 'coffee/hatemile/util/html/HTMLDOMNode.coffee', 37 | 'js/hatemile/util/html/HTMLDOMParser.js': 'coffee/hatemile/util/html/HTMLDOMParser.coffee', 38 | 'js/hatemile/util/html/HTMLDOMTextNode.js': 'coffee/hatemile/util/html/HTMLDOMTextNode.coffee', 39 | 'js/hatemile/util/html/jquery/JQueryHTMLDOMParser.js': 'coffee/hatemile/util/html/jquery/JQueryHTMLDOMParser.coffee', 40 | 'js/hatemile/util/html/vanilla/VanillaHTMLDOMElement.js': 'coffee/hatemile/util/html/vanilla/VanillaHTMLDOMElement.coffee', 41 | 'js/hatemile/util/html/vanilla/VanillaHTMLDOMParser.js': 'coffee/hatemile/util/html/vanilla/VanillaHTMLDOMParser.coffee', 42 | 'js/hatemile/util/html/vanilla/VanillaHTMLDOMTextNode.js': 'coffee/hatemile/util/html/vanilla/VanillaHTMLDOMTextNode.coffee', 43 | '_locales/en_US/js/configurations.js': '_locales/en_US/coffee/configurations.coffee', 44 | '_locales/pt_BR/js/configurations.js': '_locales/pt_BR/coffee/configurations.coffee' 45 | } 46 | } 47 | }, 48 | js_beautify: { 49 | options: { 50 | end_with_newline: true, 51 | jslint_happy: true 52 | }, 53 | files: ['js/**/*.js', '_locales/**/*.js'] 54 | }, 55 | codo: { 56 | src: ['coffee/hatemile'] 57 | }, 58 | coffeelint: { 59 | src: ['coffee/**/*.coffee', '_locales/**/*.coffee'], 60 | options: { 61 | 'arrow_spacing': { 62 | 'level': 'error' 63 | }, 64 | 'braces_spacing': { 65 | 'level': 'error' 66 | }, 67 | 'line_endings': { 68 | 'level': 'error' 69 | }, 70 | 'no_unnecessary_double_quotes': { 71 | 'level': 'error' 72 | }, 73 | 'no_implicit_parens': { 74 | 'level': 'error' 75 | }, 76 | 'no_interpolation_in_single_quotes': { 77 | 'level': 'error' 78 | }, 79 | 'no_nested_string_interpolation': { 80 | 'level': 'error' 81 | }, 82 | 'no_plusplus': { 83 | 'level': 'error' 84 | }, 85 | 'prefer_english_operator': { 86 | 'level': 'error' 87 | }, 88 | 'space_operators': { 89 | 'level': 'error' 90 | }, 91 | 'spacing_after_comma': { 92 | 'level': 'error' 93 | }, 94 | 'max_line_length': { 95 | 'limitComments': false 96 | } 97 | } 98 | } 99 | }); 100 | 101 | // Load dependencies. 102 | grunt.loadNpmTasks('grunt-coffeelint'); 103 | grunt.loadNpmTasks('grunt-contrib-coffee'); 104 | grunt.loadNpmTasks('grunt-js-beautify'); 105 | grunt.loadNpmTasks('grunt-codo'); 106 | 107 | // Default task(s). 108 | grunt.registerTask('default', ['coffeelint', 'coffee', 'js_beautify']); 109 | grunt.registerTask('doc', ['codo']); 110 | grunt.registerTask('test', ['coffeelint']); 111 | }; 112 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018 HaTeMiLe 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HaTeMiLe for JavaScript 2 | 3 | HaTeMiLe (HTML Accessible) is a library that can convert a HTML code in a HTML code more accessible. 4 | 5 | ## Accessibility solutions 6 | 7 | * [Associate HTML elements](https://github.com/hatemile/hatemile-for-javascript/wiki/Associate-HTML-elements); 8 | * [Provide a polyfill to CSS Speech and CSS Aural properties](https://github.com/hatemile/hatemile-for-javascript/wiki/Provide-a-polyfill-to-CSS-Speech-and-CSS-Aural-properties); 9 | * [Display inacessible informations of page](https://github.com/hatemile/hatemile-for-javascript/wiki/Display-inacessible-informations-of-page); 10 | * [Enable all functionality of page available from a keyboard](https://github.com/hatemile/hatemile-for-javascript/wiki/Enable-all-functionality-of-page-available-from-a-keyboard); 11 | * [Improve the acessibility of forms](https://github.com/hatemile/hatemile-for-javascript/wiki/Improve-the-acessibility-of-forms); 12 | * [Provide accessibility resources to navigate](https://github.com/hatemile/hatemile-for-javascript/wiki/Provide-accessibility-resources-to-navigate). 13 | 14 | ## Documentation 15 | 16 | To generate the full API documentation of HaTeMiLe of JavaScript: 17 | 18 | 1. [Install Node.js](https://nodejs.org/en/download/package-manager/); 19 | 2. [Install the dependencies of HaTeMiLe of JavaScript](https://docs.npmjs.com/cli/install); 20 | 3. Execute the command `grunt doc` in HaTeMiLe of JavaScript directory. 21 | 22 | ## Usage 23 | 24 | Include the configuration, dependencies and solutions scripts and styles: 25 | 26 | ```html 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ``` 53 | 54 | Instanciate the configuration, the parsers and solution classes and execute them: 55 | 56 | ```javascript 57 | //Configure 58 | var configuration = new hatemile.util.Configure(hatemile_configuration); 59 | //Parsers 60 | var htmlParser = new hatemile.util.html.vanilla.VanillaHTMLDOMParser(document); 61 | var cssParser = new hatemile.util.css.jscssp.JSCSSPParser(document, location.href); 62 | //Execute 63 | var accessibleCSS = new hatemile.implementation.AccessibleCSSImplementation(htmlParser, cssParser, hatemile_configuration_symbols); 64 | accessibleCSS.provideAllSpeakProperties(); 65 | 66 | var accessibleEvent = new hatemile.implementation.AccessibleEventImplementation(htmlParser); 67 | accessibleEvent.makeAccessibleAllDragandDropEvents(); 68 | accessibleEvent.makeAccessibleAllHoverEvents(); 69 | accessibleEvent.makeAccessibleAllClickEvents(); 70 | 71 | var accessibleForm = new hatemile.implementation.AccessibleFormImplementation(htmlParser, configuration); 72 | accessibleForm.markAllRequiredFields() 73 | accessibleForm.markAllRangeFields(); 74 | accessibleForm.markAllAutoCompleteFields(); 75 | accessibleForm.markAllInvalidFields(); 76 | 77 | var accessibleNavigation = new hatemile.implementation.AccessibleNavigationImplementation(htmlParser, configuration, hatemile_configuration_skippers); 78 | accessibleNavigation.provideNavigationByAllHeadings(); 79 | accessibleNavigation.provideNavigationByAllSkippers(); 80 | accessibleNavigation.provideNavigationToAllLongDescriptions(); 81 | 82 | var accessibleAssociation = new hatemile.implementation.AccessibleAssociationImplementation(htmlParser, configuration); 83 | accessibleAssociation.associateAllDataCellsWithHeaderCells(); 84 | accessibleAssociation.associateAllLabelsWithFields(); 85 | 86 | var accessibleScreenReader = new hatemile.implementation.AccessibleDisplayScreenReaderImplementation(htmlParser, configuration, navigator.userAgent); 87 | accessibleScreenReader.displayAllRoles(); 88 | accessibleScreenReader.displayAllCellHeaders(); 89 | accessibleScreenReader.displayAllShortcuts(); 90 | accessibleScreenReader.displayAllWAIARIAStates(); 91 | accessibleScreenReader.displayAllLinksAttributes(); 92 | accessibleScreenReader.displayAllTitles(); 93 | accessibleScreenReader.displayAllDragsAndDrops(); 94 | accessibleScreenReader.displayAllLanguages(); 95 | ``` 96 | 97 | ## Contributing 98 | 99 | If you want contribute with HaTeMiLe for JavaScript, read [contributing guidelines](CONTRIBUTING.md). 100 | 101 | ## See also 102 | * [HaTeMiLe for CSS](https://github.com/hatemile/hatemile-for-css) 103 | * [HaTeMiLe for Java](https://github.com/hatemile/hatemile-for-java) 104 | * [HaTeMiLe for PHP](https://github.com/hatemile/hatemile-for-php) 105 | * [HaTeMiLe for Python](https://github.com/hatemile/hatemile-for-python) 106 | * [HaTeMiLe for Ruby](https://github.com/hatemile/hatemile-for-ruby) 107 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hatemile", 3 | "version": "2.0.0", 4 | "authors": [ 5 | "Carlson Santana Cruz" 6 | ], 7 | "description": "HaTeMiLe (HTML Accessible) is a library that can convert a HTML code in a HTML code more accessible.", 8 | "main": "", 9 | "keywords": [ 10 | "accessibility", 11 | "wcag", 12 | "accessible" 13 | ], 14 | "license": "Apache License, Version 2.0", 15 | "homepage": "https://github.com/hatemile/hatemile-for-javascript", 16 | "ignore": [ 17 | "**/.*", 18 | "node_modules", 19 | "bower_components", 20 | "test", 21 | "tests" 22 | ], 23 | "dependencies": { 24 | "JSCSSP": "jscssp#^0.1.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /coffee/eventlistener.coffee: -------------------------------------------------------------------------------- 1 | if Element.prototype.eventListenerList is undefined 2 | Element.prototype.eventListenerList = {} 3 | Element.prototype.__eventListenerListAdded = false 4 | 5 | Element.prototype.__addEventListener = Element.prototype.addEventListener 6 | Element.prototype.addEventListener = () -> 7 | if not @__eventListenerListAdded 8 | @eventListenerList = {} 9 | @__eventListenerListAdded = true 10 | if @eventListenerList[arguments[0]] is undefined 11 | @eventListenerList[arguments[0]] = [] 12 | @eventListenerList[arguments[0]].push(arguments[1]) 13 | return (@__addEventListener.apply(this, arguments)) 14 | 15 | Element.prototype.__removeEventListener = Element.prototype 16 | .removeEventListener 17 | Element.prototype.removeEventListener = () -> 18 | found = false 19 | if @eventListenerList[arguments[0]] is undefined 20 | @eventListenerList[arguments[0]] = [] 21 | for key in @eventListenerList[arguments[0]] 22 | found = @eventListenerList[arguments[0]][key] is arguments[1] 23 | if found 24 | break 25 | if found 26 | @eventListenerList[arguments[0]].splice(key, 1) 27 | return (@__removeEventListener.apply(this, arguments)) 28 | -------------------------------------------------------------------------------- /coffee/hatemile-skippers.coffee: -------------------------------------------------------------------------------- 1 | @hatemile_configuration_skippers = [ 2 | { 3 | 'selector': 'main,[role=main]', 4 | 'description': 'skipper-main-content', 5 | 'shortcut': '1' 6 | }, 7 | { 8 | 'selector': '#container-shortcuts-after', 9 | 'description': 'skipper-shortcuts-list', 10 | 'shortcut': '9' 11 | }, 12 | { 13 | 'selector': '#container-heading-after', 14 | 'description': 'skipper-table-contents', 15 | 'shortcut': '0' 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /coffee/hatemile-symbols.coffee: -------------------------------------------------------------------------------- 1 | @hatemile_configuration_symbols = [ 2 | {'symbol': '!', 'description': 'symbol-exclamation-mark'} 3 | {'symbol': '"', 'description': 'symbol-double-quotes'} 4 | {'symbol': '#', 'description': 'symbol-number'} 5 | {'symbol': '$', 'description': 'symbol-dollar'} 6 | {'symbol': '%', 'description': 'symbol-percent'} 7 | {'symbol': '&', 'description': 'symbol-ampersand'} 8 | {'symbol': '\'', 'description': 'symbol-single-quote'} 9 | {'symbol': '(', 'description': 'symbol-open-parenthesis'} 10 | {'symbol': ')', 'description': 'symbol-close-parenthesis'} 11 | {'symbol': '*', 'description': 'symbol-asterisk'} 12 | {'symbol': '+', 'description': 'symbol-plus'} 13 | {'symbol': ',', 'description': 'symbol-comma'} 14 | {'symbol': '-', 'description': 'symbol-hyphen'} 15 | {'symbol': '.', 'description': 'symbol-dot'} 16 | {'symbol': '/', 'description': 'symbol-slash'} 17 | {'symbol': ':', 'description': 'symbol-colon'} 18 | {'symbol': ';', 'description': 'symbol-semicolon'} 19 | {'symbol': '<', 'description': 'symbol-less-than'} 20 | {'symbol': '=', 'description': 'symbol-equals'} 21 | {'symbol': '>', 'description': 'symbol-greater-than'} 22 | {'symbol': '?', 'description': 'symbol-question-mark'} 23 | {'symbol': '@', 'description': 'symbol-at'} 24 | {'symbol': '[', 'description': 'symbol-open-bracket'} 25 | {'symbol': '\\', 'description': 'symbol-backslash'} 26 | {'symbol': ']', 'description': 'symbol-close-bracket'} 27 | {'symbol': '^', 'description': 'symbol-caret'} 28 | {'symbol': '_', 'description': 'symbol-underscore'} 29 | {'symbol': '`', 'description': 'symbol-grave-accent'} 30 | {'symbol': '{', 'description': 'symbol-open-brace'} 31 | {'symbol': '|', 'description': 'symbol-vertical-bar'} 32 | {'symbol': '}', 'description': 'symbol-close-brace'} 33 | {'symbol': '~', 'description': 'symbol-tilde'} 34 | ] 35 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleAssociation.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleAssociation interface improve accessibility, associating 21 | # elements. 22 | # 23 | # @abstract 24 | # 25 | class @hatemile.AccessibleAssociation 26 | 27 | # Associate all data cells with header cells of table. 28 | # 29 | # @param [hatemile.util.html.HTMLDOMElement] table The table. 30 | # 31 | associateDataCellsWithHeaderCells: (table) -> 32 | 33 | # Associate all data cells with header cells of all tables of page. 34 | # 35 | associateAllDataCellsWithHeaderCells: () -> 36 | 37 | # Associate label with field. 38 | # 39 | # @param [hatemile.util.html.HTMLDOMElement] label The label. 40 | # 41 | associateLabelWithField: (label) -> 42 | 43 | # Associate all labels of page with fields. 44 | # 45 | associateAllLabelsWithFields: () -> 46 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleCSS.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleCSS interface improve accessibility of CSS. 21 | # 22 | # @abstract 23 | # 24 | class @hatemile.AccessibleCSS 25 | 26 | # Provide the CSS features of speaking and speech properties in element. 27 | # 28 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 29 | # 30 | provideSpeakProperties: (element) -> 31 | 32 | # Provide the CSS features of speaking and speech properties in all elements 33 | # of page. 34 | # 35 | provideAllSpeakProperties: () -> 36 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleDisplay.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleDisplay interface improve accessibility, showing informations. 21 | # 22 | # @abstract 23 | # 24 | class @hatemile.AccessibleDisplay 25 | 26 | # Display the shortcut of element. 27 | # 28 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 29 | # 30 | displayShortcut: (element) -> 31 | 32 | # Display all shortcuts of page. 33 | # 34 | displayAllShortcuts: () -> 35 | 36 | # Display the WAI-ARIA role of element. 37 | # 38 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 39 | # 40 | displayRole: (element) -> 41 | 42 | # Display the WAI-ARIA roles of all elements of page. 43 | # 44 | displayAllRoles: () -> 45 | 46 | # Display the headers of each data cell of table. 47 | # 48 | # @param [hatemile.util.html.HTMLDOMElement] tableCell The table cell. 49 | # 50 | displayCellHeader: (tableCell) -> 51 | 52 | # Display the headers of each data cell of all tables of page. 53 | # 54 | displayAllCellHeaders: () -> 55 | 56 | # Display the WAI-ARIA attributes of element. 57 | # 58 | # @param [hatemile.util.html.HTMLDOMElement] element The element with WAI-ARIA attributes. 59 | # 60 | displayWAIARIAStates: (element) -> 61 | 62 | # Display the WAI-ARIA attributes of all elements of page. 63 | # 64 | displayAllWAIARIAStates: () -> 65 | 66 | # Display the attributes of link. 67 | # 68 | # @param [hatemile.util.html.HTMLDOMElement] link The link element. 69 | # 70 | displayLinkAttributes: (link) -> 71 | 72 | # Display the attributes of all links of page. 73 | # 74 | displayAllLinksAttributes: () -> 75 | 76 | # Display the title of element. 77 | # 78 | # @param [hatemile.util.html.HTMLDOMElement] element The element with title. 79 | # 80 | displayTitle: (element) -> 81 | 82 | # Display the titles of all elements of page. 83 | # 84 | displayAllTitles: () -> 85 | 86 | # Display the language of element. 87 | # 88 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 89 | # 90 | displayLanguage: (element) -> 91 | 92 | # Display the language of all elements of page. 93 | # 94 | displayAllLanguages: () -> 95 | 96 | # Display the alternative text of image. 97 | # 98 | # @param [hatemile.util.html.HTMLDOMElement] image The image. 99 | # 100 | displayAlternativeTextImage: (image) -> 101 | 102 | # Display the alternative text of all images of page. 103 | # 104 | displayAllAlternativeTextImages: () -> 105 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleEvent.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleEvent interface improve the accessibility, making elements 21 | # events available from a keyboard. 22 | # 23 | # @abstract 24 | # 25 | class @hatemile.AccessibleEvent 26 | 27 | # Make the drop events of element available from a keyboard. 28 | # 29 | # @param [hatemile.util.html.HTMLDOMElement] element The element with drop events. 30 | # 31 | makeAccessibleDropEvents: (element) -> 32 | 33 | # Make the drag events of element available from a keyboard. 34 | # 35 | # @param [hatemile.util.html.HTMLDOMElement] element The element with drag events. 36 | # 37 | makeAccessibleDragEvents: (element) -> 38 | 39 | # Make all Drag-and-Drop events of page available from a keyboard. 40 | # 41 | makeAccessibleAllDragandDropEvents: () -> 42 | 43 | # Make the hover events of element available from a keyboard. 44 | # 45 | # @param [hatemile.util.html.HTMLDOMElement] element The element with hover events. 46 | # 47 | makeAccessibleHoverEvents: (element) -> 48 | 49 | # Make all hover events of page available from a keyboard. 50 | # 51 | makeAccessibleAllHoverEvents: () -> 52 | 53 | # Make the click events of element available from a keyboard. 54 | # 55 | # @param [hatemile.util.html.HTMLDOMElement] element The element with click events. 56 | # 57 | makeAccessibleClickEvents: (element) -> 58 | 59 | # Make all click events of page available from a keyboard. 60 | # 61 | makeAccessibleAllClickEvents: () -> 62 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleForm.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleForm interface improve the accessibility of forms. 21 | # 22 | # @abstract 23 | # 24 | class @hatemile.AccessibleForm 25 | 26 | # Mark that the field is required. 27 | # 28 | # @param [hatemile.util.html.HTMLDOMElement] requiredField The required field. 29 | # 30 | markRequiredField: (requiredField) -> 31 | 32 | # Mark that the fields is required. 33 | # 34 | markAllRequiredFields: () -> 35 | 36 | # Mark that the field have range. 37 | # 38 | # @param [hatemile.util.html.HTMLDOMElement] rangeField The range field. 39 | # 40 | markRangeField: (rangeField) -> 41 | 42 | # Mark that the fields have range. 43 | # 44 | markAllRangeFields: () -> 45 | 46 | # Mark that the field have autocomplete. 47 | # 48 | # @param [hatemile.util.html.HTMLDOMElement] autoCompleteField The field with autocomplete. 49 | # 50 | markAutoCompleteField: (autoCompleteField) -> 51 | 52 | # Mark that the fields have autocomplete. 53 | # 54 | markAllAutoCompleteFields: () -> 55 | 56 | # Mark a solution to display that this field is invalid. 57 | # 58 | # @param [hatemile.util.html.HTMLDOMElement] field The field. 59 | # 60 | markInvalidField: (field) -> 61 | 62 | # Mark a solution to display that a fields are invalid. 63 | # 64 | markAllInvalidFields: () -> 65 | -------------------------------------------------------------------------------- /coffee/hatemile/AccessibleNavigation.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # The AccessibleNavigation interface improve the accessibility of navigation. 21 | # 22 | # @abstract 23 | # 24 | class @hatemile.AccessibleNavigation 25 | 26 | # Provide a content skipper for element. 27 | # 28 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 29 | # 30 | provideNavigationBySkipper: (element) -> 31 | 32 | # Provide navigation by content skippers. 33 | # 34 | provideNavigationByAllSkippers: () -> 35 | 36 | # Provide navigation by heading. 37 | # 38 | # @param [hatemile.util.html.HTMLDOMElement] heading The heading element. 39 | # 40 | provideNavigationByHeading: (heading) -> 41 | 42 | # Provide navigation by headings of page. 43 | # 44 | provideNavigationByAllHeadings: () -> 45 | 46 | # Provide an alternative way to access the long description of element. 47 | # 48 | # @param [hatemile.util.html.HTMLDOMElement] image The image with long description. 49 | # 50 | provideNavigationToLongDescription: (image) -> 51 | 52 | # Provide an alternative way to access the longs descriptions of all elements 53 | # of page. 54 | # 55 | provideNavigationToAllLongDescriptions: () -> 56 | -------------------------------------------------------------------------------- /coffee/hatemile/implementation/AccessibleAssociationImplementation.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.implementation 23 | # 24 | @hatemile.implementation or= {} 25 | 26 | # The AccessibleAssociationImplementation class is official implementation of 27 | # {hatemile.AccessibleAssociation}. 28 | # 29 | # @extend hatemile.AccessibleAssociation 30 | # 31 | class @hatemile.implementation.AccessibleAssociationImplementation 32 | 33 | DATA_IGNORE = 'data-ignoreaccessibilityfix' 34 | 35 | # Returns a list that represents the table. 36 | # 37 | # @private 38 | # 39 | # @param [hatemile.util.html.HTMLDOMElement] part The table header, table footer or table body. 40 | # 41 | # @return [Array>] The list that represents the table. 42 | # 43 | _getModelTable: (part) -> 44 | table = [] 45 | rows = @parser.find(part).findChildren('tr').listResults() 46 | for row in rows 47 | table.push(@_getModelRow(@parser.find(row).findChildren('th,td') 48 | .listResults())) 49 | return @_getValidModelTable(table) 50 | 51 | # Returns a list that represents the table with the rowspans. 52 | # 53 | # @private 54 | # 55 | # @param [Array>] originalTable The list that represents the table without the rowspans. 56 | # 57 | # @return [Array>] The list that represents the table with the rowspans. 58 | # 59 | _getValidModelTable: (originalTable) -> 60 | newTable = [] 61 | lengthTable = originalTable.length 62 | if lengthTable > 0 63 | for rowIndex in [0..lengthTable - 1] 64 | originalRow = originalTable[rowIndex] 65 | if newTable[rowIndex] is undefined 66 | newTable[rowIndex] = [] 67 | lengthRow = originalRow.length 68 | if lengthRow > 0 69 | cellsAdded = 0 70 | for cellIndex in [0..lengthRow - 1] 71 | cell = originalRow[cellIndex] 72 | newCellIndex = cellIndex + cellsAdded 73 | newRow = newTable[rowIndex] 74 | while newRow[newCellIndex] isnt undefined 75 | cellsAdded = cellsAdded + 1 76 | newCellIndex = cellIndex + cellsAdded 77 | newRow[newCellIndex] = cell 78 | if cell.hasAttribute('rowspan') 79 | rowspan = parseInt(cell.getAttribute('rowspan')) 80 | newRowIndex = rowIndex 81 | while (rowspan > 1) 82 | rowspan = rowspan - 1 83 | newRowIndex = newRowIndex + 1 84 | if newTable[newRowIndex] is undefined 85 | newTable[newRowIndex] = [] 86 | newTable[newRowIndex][newCellIndex] = cell 87 | return newTable 88 | 89 | # Returns a list that represents the line of table with the colspans. 90 | # 91 | # @private 92 | # 93 | # @param [Array] originalRow The list that represents the line of table without the colspans. 94 | # 95 | # @return [Array] The list that represents the line of table with the colspans. 96 | # 97 | _getModelRow: (originalRow) -> 98 | newRow = [] 99 | length = originalRow.length 100 | if length > 0 101 | newRow = newRow.concat(originalRow) 102 | cellsAdded = 0 103 | for i in [0..length - 1] 104 | if originalRow[i].hasAttribute('colspan') 105 | colspan = parseInt(originalRow[i].getAttribute('colspan')) 106 | while (colspan > 1) 107 | colspan = colspan - 1 108 | cellsAdded = cellsAdded + 1 109 | newRow.splice(i + cellsAdded, 0, originalRow[i]) 110 | return newRow 111 | 112 | # Validate the model that represents the table header. 113 | # 114 | # @private 115 | # 116 | # @param [Array>] header The list that represents the table header. 117 | # 118 | # @return [boolean] True if the table header is valid or false if the table header is not valid. 119 | # 120 | _validateHeader: (header) -> 121 | if header.length is 0 122 | return false 123 | length = -1 124 | for row in header 125 | if row.length is 0 126 | return false 127 | else if length is -1 128 | length = row.length 129 | else if row.length isnt length 130 | return false 131 | return true 132 | 133 | # Returns a list with ids of rows of same column. 134 | # 135 | # @private 136 | # 137 | # @param [Array>] header The list that represents the table header. 138 | # @param [number] index The index of columns. 139 | # 140 | # @return [Array] The list with ids of rows of same column. 141 | # 142 | _getCellsHeadersIds: (header, index) -> 143 | ids = [] 144 | for row in header 145 | cell = row[index] 146 | if (cell.getTagName() is 'TH') and (cell.getAttribute('scope') is 'col') 147 | ids.push(cell.getAttribute('id')) 148 | return ids 149 | 150 | # Associate the data cell with header cell of row. 151 | # 152 | # @private 153 | # 154 | # @param [hatemile.util.html.HTMLDOMElement] element The table body or footer. 155 | # 156 | _associateDataCellsWithHeaderCellsOfRow: (element) -> 157 | table = @_getModelTable(element) 158 | for row in table 159 | headersIds = [] 160 | for cell in row 161 | if cell.getTagName() is 'TH' 162 | @idGenerator.generateId(cell) 163 | headersIds.push(cell.getAttribute('id')) 164 | 165 | cell.setAttribute('scope', 'row') 166 | if headersIds.length > 0 167 | for cell in row 168 | if cell.getTagName() is 'TD' 169 | headers = cell.getAttribute('headers') 170 | for headerId in headersIds 171 | headers = self.hatemile.util.CommonFunctions 172 | .increaseInList(headers, headerId) 173 | if headers isnt null 174 | cell.setAttribute('headers', headers) 175 | return 176 | 177 | # Set the scope of header cells of table header. 178 | # 179 | # @private 180 | # 181 | # @param [hatemile.util.html.HTMLDOMElement] tableHeader The table header. 182 | # 183 | _prepareHeaderCells: (tableHeader) -> 184 | cells = @parser.find(tableHeader).findChildren('tr').findChildren('th') 185 | .listResults() 186 | for cell in cells 187 | @idGenerator.generateId(cell) 188 | if not cell.hasAttribute('scope') 189 | cell.setAttribute('scope', 'col') 190 | return 191 | 192 | # Initializes a new object that improve the accessibility of associations of 193 | # parser. 194 | # 195 | # @param [hatemile.util.html.HTMLDOMParser] parser The HTML parser. 196 | # @param [hatemile.util.Configure] configure The configuration of HaTeMiLe. 197 | # 198 | constructor: (@parser, configure) -> 199 | @idGenerator = new hatemile.util.IDGenerator('association') 200 | 201 | # Associate all data cells with header cells of table. 202 | # 203 | # @param [hatemile.util.html.HTMLDOMElement] table The table. 204 | # 205 | # @see hatemile.AccessibleAssociation#associateDataCellsWithHeaderCells 206 | # 207 | associateDataCellsWithHeaderCells: (table) -> 208 | header = @parser.find(table).findChildren('thead').firstResult() 209 | body = @parser.find(table).findChildren('tbody').firstResult() 210 | footer = @parser.find(table).findChildren('tfoot').firstResult() 211 | if header isnt null 212 | @_prepareHeaderCells(header) 213 | 214 | headerRows = @_getModelTable(header) 215 | if (body isnt null) and (@_validateHeader(headerRows)) 216 | lengthHeader = headerRows[0].length 217 | fakeTable = @_getModelTable(body) 218 | if footer isnt null 219 | fakeTable = fakeTable.concat(@_getModelTable(footer)) 220 | for row in fakeTable 221 | if row.length is lengthHeader 222 | i = 0 223 | for cell in row 224 | headersIds = @_getCellsHeadersIds(headerRows, i) 225 | headers = cell.getAttribute('headers') 226 | for headersId in headersIds 227 | headers = self.hatemile.util.CommonFunctions 228 | .increaseInList(headers, headersId) 229 | if headers isnt null 230 | cell.setAttribute('headers', headers) 231 | i = i + 1 232 | if body isnt null 233 | @_associateDataCellsWithHeaderCellsOfRow(body) 234 | if footer isnt null 235 | @_associateDataCellsWithHeaderCellsOfRow(footer) 236 | return 237 | 238 | # Associate all data cells with header cells of all tables of page. 239 | # 240 | # @see hatemile.AccessibleAssociation#associateAllDataCellsWithHeaderCells 241 | # 242 | associateAllDataCellsWithHeaderCells: () -> 243 | tables = @parser.find('table').listResults() 244 | for table in tables 245 | if self.hatemile.util.CommonFunctions.isValidElement(table) 246 | if @parser.find(table).findDescendants("thead[#{DATA_IGNORE}]," \ 247 | + "tbody[#{DATA_IGNORE}],tfoot[#{DATA_IGNORE}],tr[#{DATA_IGNORE}]," \ 248 | + "th[#{DATA_IGNORE}],td[#{DATA_IGNORE}]").firstResult() is null 249 | @associateDataCellsWithHeaderCells(table) 250 | return 251 | 252 | # Associate label with field. 253 | # 254 | # @param [hatemile.util.html.HTMLDOMElement] label The label. 255 | # 256 | # @see hatemile.AccessibleAssociation#associateLabelWithField 257 | # 258 | associateLabelWithField: (label) -> 259 | if label.getTagName() is 'LABEL' 260 | if label.hasAttribute('for') 261 | field = @parser.find("##{label.getAttribute('for')}").firstResult() 262 | else 263 | field = @parser.find(label).findDescendants('input,select,textarea') 264 | .firstResult() 265 | 266 | if field isnt null 267 | @idGenerator.generateId(field) 268 | label.setAttribute('for', field.getAttribute('id')) 269 | if (field isnt null) and (not field.hasAttribute(DATA_IGNORE)) 270 | if not field.hasAttribute('aria-label') 271 | field.setAttribute('aria-label', label.getTextContent() 272 | .replace(new RegExp('[ \n\t\r]+', 'g'), ' ')) 273 | @idGenerator.generateId(label) 274 | field.setAttribute('aria-labelledby', self.hatemile.util.CommonFunctions 275 | .increaseInList(field.getAttribute('aria-labelledby'), \ 276 | label.getAttribute('id'))) 277 | return 278 | 279 | # Associate all labels of page with fields. 280 | # 281 | # @see hatemile.AccessibleAssociation#associateAllLabelsWithFields 282 | # 283 | associateAllLabelsWithFields: () -> 284 | labels = @parser.find('label').listResults() 285 | for label in labels 286 | if self.hatemile.util.CommonFunctions.isValidElement(label) 287 | @associateLabelWithField(label) 288 | return 289 | -------------------------------------------------------------------------------- /coffee/hatemile/util/CommonFunctions.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # The CommonFunctions class contains the used methods by HaTeMiLe classes. 27 | # 28 | class @hatemile.util.CommonFunctions 29 | 30 | DATA_IGNORE = 'data-ignoreaccessibilityfix' 31 | 32 | # Copy a list of attributes of a element for other element. 33 | # 34 | # @param [hatemile.util.html.HTMLDOMElement] element1 The element that have attributes copied. 35 | # @param [hatemile.util.html.HTMLDOMElement] element2 The element that copy the attributes. 36 | # @param [Array] attributes The list of attributes that will be copied. 37 | # 38 | @setListAttributes: (element1, element2, attributes) -> 39 | for attribute in attributes 40 | if element1.hasAttribute(attribute) 41 | element2.setAttribute(attribute, element1.getAttribute(attribute)) 42 | return 43 | 44 | # Increase a item in a HTML list. 45 | # 46 | # @param [string] list The list. 47 | # @param [string] stringToIncrease The value of item. 48 | # 49 | # @return [string] The HTML list with the item added, if the item not was contained in list. 50 | # 51 | @increaseInList: (list, stringToIncrease) -> 52 | if (list isnt null) and (list.length > 0) and (stringToIncrease isnt null) \ 53 | and (stringToIncrease.length > 0) 54 | if @inList(list, stringToIncrease) 55 | return list 56 | else 57 | return "#{list} #{stringToIncrease}" 58 | else if (stringToIncrease isnt null) and (stringToIncrease.length > 0) 59 | return stringToIncrease 60 | else 61 | return list 62 | 63 | # Verify if the list contains the item. 64 | # 65 | # @param [string] list The list. 66 | # @param [string] stringToSearch The value of item. 67 | # 68 | # @return [boolean] True if the list contains the item or false is not contains. 69 | # 70 | @inList: (list, stringToSearch) -> 71 | if (list isnt null) and (list.length > 0) and (stringToSearch isnt null) \ 72 | and (stringToSearch.length > 0) 73 | array = list.split(new RegExp('[ \n\t\r]+')) 74 | for item in array 75 | if item is stringToSearch 76 | return true 77 | return false 78 | 79 | # Check that the element can be manipulated by HaTeMiLe. 80 | # 81 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 82 | # 83 | # @return [boolean] True if element can be manipulated or false if element cannot be manipulated. 84 | # 85 | @isValidElement: (element) -> 86 | if element.hasAttribute(DATA_IGNORE) 87 | return false 88 | else 89 | parentElement = element.getParentElement() 90 | if parentElement isnt null 91 | tagName = parentElement.getTagName() 92 | if (tagName isnt 'BODY') and (tagName isnt 'HTML') 93 | return @isValidElement(parentElement) 94 | else 95 | return true 96 | else 97 | return true 98 | -------------------------------------------------------------------------------- /coffee/hatemile/util/Configure.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # The Configure class contains the configuration of HaTeMiLe. 25 | # 26 | class @hatemile.util.Configure 27 | 28 | # Initializes a new object that contains the configuration of HaTeMiLe. 29 | # 30 | # @param [Object] parameters The JSON configuration. 31 | # 32 | constructor: (@parameters) -> 33 | 34 | # Returns the parameters of configuration. 35 | # 36 | # @return [Object] The parameters of configuration. 37 | # 38 | getParameters: () -> 39 | clonedParameters = {} 40 | for key, value of @parameters 41 | clonedParameters[key] = value 42 | return clonedParameters 43 | 44 | # Check that the configuration has an parameter. 45 | # 46 | # @param [string] parameter The name of parameter. 47 | # 48 | # @return [boolean] True if the configuration has the parameter or false if the configuration not has the parameter. 49 | # 50 | hasParameter: (parameter) -> 51 | return @parameters[parameter] isnt undefined 52 | 53 | # Returns the value of a parameter of configuration. 54 | # 55 | # @param [string] name The parameter. 56 | # 57 | # @return [string] The value of the parameter. 58 | # 59 | getParameter: (name) -> 60 | if not @hasParameter(name) 61 | throw new Error("Parameter '#{name}' not found.") 62 | return @parameters[name] 63 | -------------------------------------------------------------------------------- /coffee/hatemile/util/IDGenerator.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # The IDGenerator class generate ids for {hatemile.util.html.HTMLDOMElement}. 27 | # 28 | class @hatemile.util.IDGenerator 29 | 30 | # Initializes a new object that generate ids for elements. 31 | # 32 | # @param [string] prefixPart A part of prefix id. 33 | # 34 | constructor: (prefixPart) -> 35 | randomNumber = Math.floor(Math.random() * 9007199254740991).toString() 36 | if prefixPart is undefined 37 | @prefixId = "id-hatemile-#{randomNumber}-" 38 | else 39 | @prefixId = "id-hatemile-#{prefixPart}-#{randomNumber}-" 40 | @count = 0 41 | 42 | # Generate a id for a element. 43 | # 44 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 45 | # 46 | generateId: (element) -> 47 | if not element.hasAttribute('id') 48 | element.setAttribute('id', @prefixId + @count.toString()) 49 | @count = @count + 1 50 | return 51 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/StyleSheetDeclaration.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.css 25 | # 26 | @hatemile.util.css or= {} 27 | 28 | # The StyleSheetDeclaration interface contains the methods for access the CSS 29 | # declaration. 30 | # 31 | # @abstract 32 | # 33 | class @hatemile.util.css.StyleSheetDeclaration 34 | 35 | # Returns the value of declaration. 36 | # 37 | # @return [string] The value of declaration. 38 | # 39 | getValue: () -> 40 | 41 | # Returns a array with the values of declaration. 42 | # 43 | # @return [Array] The array with the values of declaration. 44 | # 45 | getValues: () -> 46 | 47 | # Returns the property of declaration. 48 | # 49 | # @return [string] The property of declaration. 50 | # 51 | getProperty: () -> 52 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/StyleSheetParser.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.css 25 | # 26 | @hatemile.util.css or= {} 27 | 28 | # The StyleSheetParser interface contains the methods for access the CSS parser. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.css.StyleSheetParser 33 | 34 | # Returns the rules of parser by properties. 35 | # 36 | # @param [Array] properties The properties. 37 | # 38 | # @return [Array] The rules. 39 | # 40 | getRules: (properties) -> 41 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/StyleSheetRule.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.css 25 | # 26 | @hatemile.util.css or= {} 27 | 28 | # The StyleSheetRule interface contains the methods for access the CSS rule. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.css.StyleSheetRule 33 | 34 | # Returns that the rule has a declaration with the property. 35 | # 36 | # @param [string] propertyName The name of property. 37 | # 38 | # @return [boolean] True if the rule has a declaration with the property or false if the rule not has a declaration with the property. 39 | # 40 | hasProperty: (propertyName) -> 41 | 42 | # Returns that the rule has declarations. 43 | # 44 | # @return [boolean] True if the rule has the property or false if the rule not has declarations. 45 | # 46 | hasDeclarations: () -> 47 | 48 | # Returns the declarations with the property. 49 | # 50 | # @param [string] propertyName The property. 51 | # 52 | # @return [Array] The declarations with the property. 53 | # 54 | getDeclarations: (propertyName) -> 55 | 56 | # Returns the selector of rule. 57 | # 58 | # @return [string] The selector of rule. 59 | # 60 | getSelector: () -> 61 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/jscssp/JSCSSPDeclaration.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.css 25 | # 26 | @hatemile.util.css or= {} 27 | 28 | # @namespace hatemile.util.css.jscssp 29 | # 30 | @hatemile.util.css.jscssp or= {} 31 | 32 | # The JSCSSPDeclaration class is official implementation of 33 | # {hatemile.util.css.StyleSheetDeclaration} interface for JSCSSP. 34 | # 35 | # @extend hatemile.util.css.StyleSheetDeclaration 36 | # 37 | class @hatemile.util.css.jscssp.JSCSSPDeclaration 38 | 39 | # Initializes a new object that encapsulate the CSS declaration. 40 | # 41 | # @param [jscsspDeclaration] declaration The declaration CSS of rule. 42 | # 43 | constructor: (@declaration) -> 44 | 45 | # Returns the value of declaration. 46 | # 47 | # @return [string] The value of declaration. 48 | # 49 | # @see hatemile.util.css.StyleSheetDeclaration#getValue 50 | # 51 | getValue: () -> 52 | return @declaration.valueText.trim() 53 | 54 | # Returns a array with the values of declaration. 55 | # 56 | # @return [Array] The array with the values of declaration. 57 | # 58 | # @see hatemile.util.css.StyleSheetDeclaration#getValues 59 | # 60 | getValues: () -> 61 | values = [] 62 | for propertyValue in @declaration.values 63 | values.push(propertyValue.value) 64 | return values 65 | 66 | # Returns the property of declaration. 67 | # 68 | # @return [string] The property of declaration. 69 | # 70 | # @see hatemile.util.css.StyleSheetDeclaration#getProperty 71 | # 72 | getProperty: () -> 73 | return @declaration.property 74 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/jscssp/JSCSSPParser.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # @namespace hatemile.util.css 27 | # 28 | @hatemile.util.css or= {} 29 | 30 | # @namespace hatemile.util.css.jscssp 31 | # 32 | @hatemile.util.css.jscssp or= {} 33 | 34 | # The JSCSSPParser class is official implementation of 35 | # {hatemile.util.css.StyleSheetParser} interface for JSCSSP. 36 | # 37 | # @extend hatemile.util.css.StyleSheetParser 38 | # 39 | class @hatemile.util.css.jscssp.JSCSSPParser 40 | 41 | # Returns the absolute path of a URL. 42 | # 43 | # @private 44 | # 45 | # @param [string] currentURL The current URL of document. 46 | # @param [string] otherURL The other URL. 47 | # 48 | # @return [string] The absolute path of other URL. 49 | # 50 | _getAbsolutePath = (currentURL, otherURL) -> 51 | if otherURL.indexOf('//') is 0 52 | if currentURL.indexOf('https://') is 0 53 | return "https:#{otherURL}" 54 | else 55 | return "http:#{otherURL}" 56 | else if otherURL.indexOf('data:') is 0 57 | return null 58 | else 59 | urlRegularExpression = new RegExp('([a-zA-Z][a-zA-Z0-9\\+\\.\\-]*):(\\/' \ 60 | + '\\/)?(?:(?:(?:[a-zA-Z0-9_\\.\\-\\+!$&\'\\(\\)*\\+,;=]|%[0-9a-f]' \ 61 | + '{2})+:)*(?:[a-zA-Z0-9_\\.\\-\\+%!$&\'\\(\\)*\\+,;=]|%[0-9a-f]{2}' \ 62 | + ')+@)?(?:(?:[a-z0-9\\-\\.]|%[0-9a-f]{2})+|(?:\\[(?:[0-9a-f]{0,4}:' \ 63 | + ')*(?:[0-9a-f]{0,4})\\]))(?::[0-9]+)?(?:[\\/|\\?](?:[a-zA-Z0-9_#!' \ 64 | + ':\\.\\?\\+=&@!$\'~*,;\\/\\(\\)\\[\\]\\-]|%[0-9a-f]{2})*)?') 65 | if urlRegularExpression.test(otherURL) 66 | return otherURL 67 | else 68 | stackURL = currentURL.split('/') 69 | stackURL.pop() 70 | if otherURL.indexOf('/') is 0 71 | return "#{stackURL[0]}//#{stackURL[2]}#{otherURL}" 72 | else 73 | relativeParts = otherURL.split('/') 74 | for relativePart in relativeParts 75 | if relativePart is '..' 76 | stackURL.pop() 77 | else if relativePart isnt '.' 78 | stackURL.push(relativePart) 79 | return stackURL.join('/') 80 | 81 | # Returns the text content of document. 82 | # 83 | # @private 84 | # 85 | # @param [HTMLDOMParser] htmlParser The HTML parser. 86 | # 87 | # @return [string] The text content of document. 88 | # 89 | _getCSSContent = (htmlParser, currentURL) -> 90 | content = '' 91 | elements = htmlParser.find('style,link[rel=stylesheet]').listResults() 92 | for element in elements 93 | if element.getTagName() is 'STYLE' 94 | content += element.getTextContent() 95 | if (element.hasAttribute('rel')) and \ 96 | (element.getAttribute('rel') is 'stylesheet') 97 | content += _getContentFromURL(_getAbsolutePath(currentURL, \ 98 | element.getAttribute('href'))) 99 | return content 100 | 101 | # Returns the text content of URL. 102 | # 103 | # @private 104 | # 105 | # @param [string] url The URL. 106 | # 107 | # @return [string] The text content of URL. 108 | # 109 | _getContentFromURL = (url) -> 110 | content = '' 111 | if url.length > 0 112 | httpRequest = false 113 | if window.XMLHttpRequest 114 | httpRequest = new XMLHttpRequest() 115 | else if window.ActiveXObject 116 | try 117 | httpRequest = new ActiveXObject('Msxml2.XMLHTTP') 118 | catch e 119 | try 120 | httpRequest = new ActiveXObject('Microsoft.XMLHTTP') 121 | catch e 122 | if httpRequest 123 | httpRequest.onreadystatechange = () -> 124 | if (@readyState is 4) and (@status is 200) 125 | content = httpRequest.responseText 126 | httpRequest.open('GET', url, false) 127 | httpRequest.send() 128 | return content 129 | 130 | # Initializes a new object that encapsulate the CSS parser. 131 | # 132 | # @overload constructor(jscsspParser) 133 | # Initializes a new object that encapsulate the use JSCSSP parser. 134 | # @param [jscsspStylesheet] jscsspParser The JSCSSP parser. 135 | # 136 | # @overload constructor(htmlParser, currentURL) 137 | # Initializes a new object that load and read all stylesheet of page. 138 | # @param [hatemile.util.html.HTMLDOMParser] htmlParser The HTML parser. 139 | # @param [string] currentURL The current URL of page. 140 | # 141 | # @overload constructor(cssCode) 142 | # Initializes a new object that read the stylesheet of code. 143 | # @param [string] cssCode The CSS code. 144 | # 145 | constructor: (@parser, @currentURL) -> 146 | if not (@parser instanceof jscsspStylesheet) 147 | parser = new CSSParser() 148 | if (@parser.find instanceof Function) and \ 149 | (@parser.listResults instanceof Function) and \ 150 | (@parser.getParser instanceof Function) 151 | @parser = _getCSSContent(@parser, @currentURL) 152 | if (typeof @parser is typeof '') 153 | @parser = parser.parse("body{}#{@parser}", false, false) 154 | 155 | # Returns the rules of parser by properties. 156 | # 157 | # @param [Array] properties The properties. 158 | # 159 | # @return [Array] The rules. 160 | # 161 | # @see hatemile.util.css.StyleSheetParser#getRules 162 | # 163 | getRules: (properties) -> 164 | rules = [] 165 | if (properties is undefined) or (properties.length is 0) 166 | for nativeRule in @parser.cssRules 167 | if nativeRule.type is 1 168 | rules.push(new self.hatemile.util.css.jscssp.JSCSSPRule(nativeRule)) 169 | else 170 | for nativeRule in @parser.cssRules 171 | if nativeRule.type is 1 172 | rule = new self.hatemile.util.css.jscssp.JSCSSPRule(nativeRule) 173 | for property in properties 174 | if rule.hasProperty(property) 175 | rules.push(rule) 176 | break 177 | return rules 178 | -------------------------------------------------------------------------------- /coffee/hatemile/util/css/jscssp/JSCSSPRule.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # @namespace hatemile.util.css 27 | # 28 | @hatemile.util.css or= {} 29 | 30 | # @namespace hatemile.util.css.jscssp 31 | # 32 | @hatemile.util.css.jscssp or= {} 33 | 34 | # The JSCSSPRule class is official implementation of 35 | # {hatemile.util.css.StyleSheetRule} interface for JSCSSP. 36 | # 37 | # @extend hatemile.util.css.StyleSheetRule 38 | # 39 | class @hatemile.util.css.jscssp.JSCSSPRule 40 | 41 | # Initializes a new object that encapsulate the CSS rule. 42 | # 43 | # @param [jscsspStyleRule] rule The JSCSSP rule. 44 | # 45 | constructor: (@rule) -> 46 | 47 | # Returns that the rule has a declaration with the property. 48 | # 49 | # @param [string] propertyName The name of property. 50 | # 51 | # @return [boolean] True if the rule has a declaration with the property or false if the rule not has a declaration with the property. 52 | # 53 | # @see hatemile.util.css.StyleSheetRule#hasProperty 54 | # 55 | hasProperty: (propertyName) -> 56 | for nativeDeclaration in @rule.declarations 57 | declaration = new self.hatemile.util.css.jscssp 58 | .JSCSSPDeclaration(nativeDeclaration) 59 | if propertyName is declaration.getProperty() 60 | return true 61 | return false 62 | 63 | # Returns that the rule has declarations. 64 | # 65 | # @return [boolean] True if the rule has the property or false if the rule not has declarations. 66 | # 67 | # @see hatemile.util.css.StyleSheetRule#hasDeclarations 68 | # 69 | hasDeclarations: () -> 70 | return @rule.declarations.length > 0 71 | 72 | # Returns the declarations with the property. 73 | # 74 | # @param [string] propertyName The property. 75 | # 76 | # @return [Array] The declarations with the property. 77 | # 78 | # @see hatemile.util.css.StyleSheetRule#getDeclarations 79 | # 80 | getDeclarations: (propertyName) -> 81 | declarations = [] 82 | for nativeDeclaration in @rule.declarations 83 | declaration = new self.hatemile.util.css.jscssp 84 | .JSCSSPDeclaration(nativeDeclaration) 85 | if propertyName is declaration.getProperty() 86 | declarations.push(declaration) 87 | return declarations 88 | 89 | # Returns the selector of rule. 90 | # 91 | # @return [string] The selector of rule. 92 | # 93 | # @see hatemile.util.css.StyleSheetRule#getSelector 94 | # 95 | getSelector: () -> 96 | return @rule.mSelectorText 97 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/HTMLDOMElement.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.html 25 | # 26 | @hatemile.util.html or= {} 27 | 28 | # The HTMLDOMElement interface contains the methods for access the HTML element. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.html.HTMLDOMElement extends @hatemile.util.html.HTMLDOMNode 33 | 34 | # Returns the tag name of element. 35 | # 36 | # @return [string] The tag name of element in uppercase letters. 37 | # 38 | getTagName: () -> 39 | 40 | # Returns the value of a attribute. 41 | # 42 | # @param [string] name The name of attribute. 43 | # 44 | # @return [string] The value of the attribute. 45 | # 46 | getAttribute: (name) -> 47 | 48 | # Create or modify a attribute. 49 | # 50 | # @param [string] name The name of attribute. 51 | # @param [string] value The value of attribute. 52 | # 53 | setAttribute: (name, value) -> 54 | 55 | # Remove a attribute of element. 56 | # 57 | # @param [string] name The name of attribute. 58 | # 59 | removeAttribute: (name) -> 60 | 61 | # Check that the element has an attribute. 62 | # 63 | # @param [string] name The name of attribute. 64 | # 65 | # @return [boolean] True if the element has the attribute or false if the element not has the attribute. 66 | # 67 | hasAttribute: (name) -> 68 | 69 | # Check that the element has attributes. 70 | # 71 | # @return [boolean] True if the element has attributes or false if the element not has attributes. 72 | # 73 | hasAttributes: () -> 74 | 75 | # Append a element child. 76 | # 77 | # @param [hatemile.util.html.HTMLDOMElement] element The element that be inserted. 78 | # 79 | # @return [hatemile.util.html.HTMLDOMElement] This element. 80 | # 81 | appendElement: (element) -> 82 | 83 | # Prepend a element child. 84 | # 85 | # @param [hatemile.util.html.HTMLDOMElement] element The element that be inserted. 86 | # 87 | # @return [hatemile.util.html.HTMLDOMElement] This element. 88 | # 89 | prependElement: (element) -> 90 | 91 | # Returns the elements children of this element. 92 | # 93 | # @return [Array] The elements children of this element. 94 | # 95 | getChildrenElements: () -> 96 | 97 | # Returns the children of this element. 98 | # 99 | # @return [Array] The children of this element. 100 | # 101 | getChildren: () -> 102 | 103 | # Joins adjacent Text nodes. 104 | # 105 | # @return [hatemile.util.html.HTMLDOMElement} This element. 106 | # 107 | normalize: () -> 108 | 109 | # Check that the element has elements children. 110 | # 111 | # @return [boolean] True if the element has elements children or false if the element not has elements children. 112 | # 113 | hasChildrenElements: () -> 114 | 115 | # Check that the element has children. 116 | # 117 | # @return [boolean] True if the element has children or false if the element not has children. 118 | # 119 | hasChildren: () -> 120 | 121 | # Returns the inner HTML code of this element. 122 | # 123 | # @return [string] The inner HTML code of this element. 124 | # 125 | getInnerHTML: () -> 126 | 127 | # Returns the HTML code of this element. 128 | # 129 | # @return [string] The HTML code of this element. 130 | # 131 | getOuterHTML: () -> 132 | 133 | # Clone this element. 134 | # 135 | # @return [hatemile.util.html.HTMLDOMElement] The clone. 136 | # 137 | cloneElement: () -> 138 | 139 | # Returns the first element child of this element. 140 | # 141 | # @return [hatemile.util.html.HTMLDOMElement] The first element child of this element. 142 | # 143 | getFirstElementChild: () -> 144 | 145 | # Returns the last element child of this element. 146 | # 147 | # @return [hatemile.util.html.HTMLDOMElement] The last element child of this element. 148 | # 149 | getLastElementChild: () -> 150 | 151 | # Returns the first node child of this element. 152 | # 153 | # @return [hatemile.util.html.HTMLDOMNode] The first node child of this element. 154 | # 155 | getFirstNodeChild: () -> 156 | 157 | # Returns the last node child of this element. 158 | # 159 | # @return [hatemile.util.html.HTMLDOMNode] The last node child of this element. 160 | # 161 | getLastNodeChild: () -> 162 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/HTMLDOMNode.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.html 25 | # 26 | @hatemile.util.html or= {} 27 | 28 | # The HTMLDOMNode interface contains the methods for access the Node. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.html.HTMLDOMNode 33 | 34 | # Returns the text content of node. 35 | # 36 | # @return [string] The text content of node. 37 | # 38 | getTextContent: () -> 39 | 40 | # Insert a node before this node. 41 | # 42 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that be inserted. 43 | # 44 | # @return [hatemile.util.html.HTMLDOMNode] This node. 45 | # 46 | insertBefore: (newNode) -> 47 | 48 | # Insert a node after this node. 49 | # 50 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that be inserted. 51 | # 52 | # @return [hatemile.util.html.HTMLDOMNode] This node. 53 | # 54 | insertAfter: (newNode) -> 55 | 56 | # Remove this node of the parser. 57 | # 58 | # @return [hatemile.util.html.HTMLDOMNode] The removed node. 59 | # 60 | removeNode: () -> 61 | 62 | # Replace this node for other node. 63 | # 64 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that replace this node. 65 | # 66 | # @return [hatemile.util.html.HTMLDOMNode] This node. 67 | # 68 | replaceNode: (newNode) -> 69 | 70 | # Append a text content in node. 71 | # 72 | # @param [string] text The text content. 73 | # 74 | # @return [hatemile.util.html.HTMLDOMNode] This node. 75 | # 76 | appendText: (text) -> 77 | 78 | # Prepend a text content in node. 79 | # 80 | # @param [string] text The text content. 81 | # 82 | # @return [hatemile.util.html.HTMLDOMNode] This node. 83 | # 84 | prependText: (text) -> 85 | 86 | # Returns the parent element of this node. 87 | # 88 | # @return [hatemile.util.html.HTMLDOMElement] The parent element of this node. 89 | # 90 | getParentElement: () -> 91 | 92 | # Returns the native object of this node. 93 | # 94 | # @return [Object] The native object of this node. 95 | # 96 | getData: () -> 97 | 98 | # Modify the native object of this node. 99 | # 100 | # @param [Object] data The native object of this node. 101 | # 102 | setData: (data) -> 103 | 104 | # Indicates whether some other object is equal to this one. 105 | # 106 | # @param [Object] node The reference object with which to compare. 107 | # 108 | # @return [boolean] True if the node is the other object is equals to this one or if the node is not the other object is equals to this one. 109 | # 110 | equals: (node) -> 111 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/HTMLDOMParser.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.html 25 | # 26 | @hatemile.util.html or= {} 27 | 28 | # The HTMLDOMParser interface contains the methods for access a native parser. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.html.HTMLDOMParser 33 | 34 | # Find elements in the parser. 35 | # 36 | # @overload find(selector) 37 | # Find all elements in the parser by selector. 38 | # @param [string] selector The selector. 39 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the elements 40 | # found. 41 | # 42 | # @overload find(element) 43 | # Find if a element is contained in parser. 44 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 45 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the element, if 46 | # the element is contained in parser. 47 | # 48 | find: (selector) -> 49 | 50 | # Find elements in the parser, children of found elements. 51 | # 52 | # @overload findChildren(selector) 53 | # Find all elements in the parser by selector, children of found elements. 54 | # @param [string] selector The selector. 55 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the elements 56 | # found. 57 | # 58 | # @overload findChildren(child) 59 | # Find if a element is a child of found elements. 60 | # @param [hatemile.util.html.HTMLDOMElement] child The element. 61 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the element, if 62 | # the element is child of found elements. 63 | # 64 | findChildren: (selector) -> 65 | 66 | # Find elements in the parser, descendants of found elements. 67 | # 68 | # @overload findDescendants(selector) 69 | # Find all elements in the parser by selector, descendants of found 70 | # elements. 71 | # @param [string] selector The selector. 72 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the elements 73 | # found. 74 | # 75 | # @overload findDescendants(element) 76 | # Find if a element is descendant of found elements. 77 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 78 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the element, if 79 | # the element is descendant of found elements. 80 | # 81 | findDescendants: (selector) -> 82 | 83 | # Find elements in the parser, ancestors of found elements. 84 | # 85 | # @overload findAncestors(selector) 86 | # Find all elements in the parser by selector, ancestors of found elements. 87 | # @param [string] selector The selector. 88 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the elements 89 | # found. 90 | # 91 | # @overload findAncestors(element) 92 | # Find if a element is ancestor of found elements. 93 | # @param [hatemile.util.html.HTMLDOMElement] element The element. 94 | # @return [hatemile.util.html.HTMLDOMParser] The parser with the element, if 95 | # the element is ancestor of found elements. 96 | # 97 | findAncestors: (selector) -> 98 | 99 | # Returns the first element found. 100 | # 101 | # @return [hatemile.util.html.HTMLDOMElement] The first element found or null if not have elements found. 102 | # 103 | firstResult: () -> 104 | 105 | # Returns the last element found. 106 | # 107 | # @return [hatemile.util.html.HTMLDOMElement] The last element found or null if not have elements found. 108 | # 109 | lastResult: () -> 110 | 111 | # Returns a list with all elements found. 112 | # 113 | # @return [Array] The list with all elements found. 114 | # 115 | listResults: () -> 116 | 117 | # Create a element. 118 | # 119 | # @param [string] tag The tag of element. 120 | # 121 | # @return [hatemile.util.html.HTMLDOMElement] The element created. 122 | # 123 | createElement: (tag) -> 124 | 125 | # Returns the HTML code of parser. 126 | # 127 | # @return [string] The HTML code of parser. 128 | # 129 | getHTML: () -> 130 | 131 | # Returns the parser. 132 | # 133 | # @return [Object] The parser or root element of the parser. 134 | # 135 | getParser: () -> 136 | 137 | # Clear the memory of this object. 138 | # 139 | clearParser: () -> 140 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/HTMLDOMTextNode.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | # @namespace hatemile 17 | # 18 | @hatemile or= {} 19 | 20 | # @namespace hatemile.util 21 | # 22 | @hatemile.util or= {} 23 | 24 | # @namespace hatemile.util.html 25 | # 26 | @hatemile.util.html or= {} 27 | 28 | # The HTMLDOMTextNode interface contains the methods for access of the Text. 29 | # 30 | # @abstract 31 | # 32 | class @hatemile.util.html.HTMLDOMTextNode extends \ 33 | @hatemile.util.html.HTMLDOMNode 34 | 35 | # Change the text content of text node. 36 | # 37 | # @param [string] text The new text content. 38 | # 39 | setTextContent: (text) -> 40 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/jquery/JQueryHTMLDOMParser.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # @namespace hatemile.util.html 27 | # 28 | @hatemile.util.html or= {} 29 | 30 | # @namespace hatemile.util.html.jquery 31 | # 32 | @hatemile.util.html.jquery or= {} 33 | 34 | # The class JQueryHTMLDOMParser is official implementation of 35 | # {hatemile.util.html.HTMLDOMParser} interface for the jQuery library. 36 | # 37 | # @extend hatemile.util.html.HTMLDOMParser 38 | # 39 | class @hatemile.util.html.jquery.JQueryHTMLDOMParser 40 | 41 | # Initializes a new object that encapsulate the jQuery. 42 | # 43 | # @overload constructor(htmlCode) 44 | # Initializes a new object that manipulate the HTML code with jQuery and 45 | # document object. 46 | # @param [string] htmlCode The html code. 47 | # 48 | # @overload constructor(doc) 49 | # Initializes a new object that manipulate the page with jQuery and document 50 | # object. 51 | # @param [HTMLDocument] doc The document object of page. 52 | # 53 | # @overload constructor(htmlCode, ownerDocument) 54 | # Initializes a new object that manipulate the HTML code with jQuery and 55 | # ownerDocument object. 56 | # @param [string] htmlCode The html code. 57 | # @param [HTMLDocument] ownerDocument The owner document of parser. 58 | # 59 | # @overload constructor(doc, ownerDocument) 60 | # Initializes a new object that manipulate the page with jQuery and 61 | # ownerDocument object. 62 | # @param [HTMLDocument] doc The document object of page. 63 | # @param [HTMLDocument] ownerDocument The owner document of parser. 64 | # 65 | constructor: (html, ownerDocument) -> 66 | @root = jQuery(html) 67 | @results = [] 68 | if ownerDocument isnt undefined 69 | @ownerDocument = ownerDocument 70 | else if html.ownerDocument isnt undefined 71 | @ownerDocument = html.ownerDocument 72 | else 73 | @ownerDocument = document 74 | 75 | # Find elements in the parser. 76 | # 77 | # @overload find(selector) 78 | # Find all elements in the parser by selector. 79 | # @param [string] selector The selector. 80 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 81 | # the elements found. 82 | # 83 | # @overload find(element) 84 | # Find if a element is contained in parser. 85 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 86 | # element. 87 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 88 | # the element, if the element is contained in parser. 89 | # 90 | # @see hatemile.util.html.HTMLDOMParser#find 91 | # 92 | find: (selector) -> 93 | if (selector instanceof self.hatemile.util.html.vanilla 94 | .VanillaHTMLDOMElement) 95 | selector = selector.getData() 96 | @results = @root.find(selector) 97 | return this 98 | 99 | # Find elements in the parser, children of found elements. 100 | # 101 | # @overload findChildren(selector) 102 | # Find all elements in the parser by selector, children of found elements. 103 | # @param [string] selector The selector. 104 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 105 | # the elements found. 106 | # 107 | # @overload findChildren(child) 108 | # Find if a element is a child of found elements. 109 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] child The 110 | # element. 111 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 112 | # the element, if the element is child of found elements. 113 | # 114 | # @see hatemile.util.html.HTMLDOMParser#findChildren 115 | # 116 | findChildren: (selector) -> 117 | if (selector instanceof self.hatemile.util.html.vanilla 118 | .VanillaHTMLDOMElement) 119 | selector = selector.getData() 120 | @results = jQuery(@results).children(selector) 121 | return this 122 | 123 | # Find elements in the parser, descendants of found elements. 124 | # 125 | # @overload findDescendants(selector) 126 | # Find all elements in the parser by selector, descendants of found 127 | # elements. 128 | # @param [string] selector The selector. 129 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 130 | # the elements found. 131 | # 132 | # @overload findDescendants(element) 133 | # Find if a element is descendant of found elements. 134 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 135 | # element. 136 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 137 | # the element, if the element is descendant of found elements. 138 | # 139 | # @see hatemile.util.html.HTMLDOMParser#findDescendants 140 | # 141 | findDescendants: (selector) -> 142 | if (selector instanceof self.hatemile.util.html.vanilla 143 | .VanillaHTMLDOMElement) 144 | selector = selector.getData() 145 | @results = jQuery(@results).find(selector) 146 | return this 147 | 148 | # Find elements in the parser, ancestors of found elements. 149 | # 150 | # @overload findAncestors(selector) 151 | # Find all elements in the parser by selector, ancestors of found elements. 152 | # @param [string] selector The selector. 153 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 154 | # the elements found. 155 | # 156 | # @overload findAncestors(element) 157 | # Find if a element is ancestor of found elements. 158 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 159 | # element. 160 | # @return [hatemile.util.html.jquery.JQueryHTMLDOMParser] The parser with 161 | # the element, if the element is ancestor of found elements. 162 | # 163 | # @see hatemile.util.html.HTMLDOMParser#findAncestors 164 | # 165 | findAncestors: (selector) -> 166 | if (selector instanceof self.hatemile.util.html.vanilla 167 | .VanillaHTMLDOMElement) 168 | selector = selector.getData() 169 | @results = jQuery(@results).parents(selector) 170 | return this 171 | 172 | # Returns the first element found. 173 | # 174 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The first element found or null if not have elements found. 175 | # 176 | # @see hatemile.util.html.HTMLDOMParser#firstResult 177 | # 178 | firstResult: () -> 179 | if @results.length is 0 180 | return null 181 | return new self.hatemile.util.html.vanilla 182 | .VanillaHTMLDOMElement(@results.get(0)) 183 | 184 | # Returns the last element found. 185 | # 186 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The last element found or null if not have elements found. 187 | # 188 | # @see hatemile.util.html.HTMLDOMParser#lastResult 189 | # 190 | lastResult: () -> 191 | if @results.length is 0 192 | return null 193 | return new self.hatemile.util.html.vanilla 194 | .VanillaHTMLDOMElement(@results.get(@results.length - 1)) 195 | 196 | # Returns a list with all elements found. 197 | # 198 | # @return [Array] The list with all elements found. 199 | # 200 | # @see hatemile.util.html.HTMLDOMParser#listResults 201 | # 202 | listResults: () -> 203 | array = [] 204 | if @results.length > 0 205 | for result in @results 206 | array.push(new self.hatemile.util.html.vanilla 207 | .VanillaHTMLDOMElement(result)) 208 | return array 209 | 210 | # Create a element. 211 | # 212 | # @param [string] tag The tag of element. 213 | # 214 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The element created. 215 | # 216 | # @see hatemile.util.html.HTMLDOMParser#createElement 217 | # 218 | createElement: (tag) -> 219 | return new self.hatemile.util.html.vanilla 220 | .VanillaHTMLDOMElement(@ownerDocument.createElement(tag)) 221 | 222 | # Returns the HTML code of parser. 223 | # 224 | # @return [string] The HTML code of parser. 225 | # 226 | # @see hatemile.util.html.HTMLDOMParser#getHTML 227 | # 228 | getHTML: () -> 229 | return @ownerDocument.documentElement.outerHTML 230 | 231 | # Returns the parser. 232 | # 233 | # @return [Object] The parser or root element of the parser. 234 | # 235 | # @see hatemile.util.html.HTMLDOMParser#getParser 236 | # 237 | getParser: () -> 238 | return @root 239 | 240 | # Clear the memory of this object. 241 | # 242 | # @see hatemile.util.html.HTMLDOMParser#clearParser 243 | # 244 | clearParser: () -> 245 | @results = [] 246 | return 247 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/vanilla/VanillaHTMLDOMParser.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # @namespace hatemile.util.html 27 | # 28 | @hatemile.util.html or= {} 29 | 30 | # @namespace hatemile.util.html.vanilla 31 | # 32 | @hatemile.util.html.vanilla or= {} 33 | 34 | # The class VanillaHTMLDOMParser is official implementation of 35 | # {hatemile.util.html.HTMLDOMParser} interface for JavaScript. 36 | # 37 | # @extend hatemile.util.html.HTMLDOMParser 38 | # 39 | class @hatemile.util.html.vanilla.VanillaHTMLDOMParser 40 | 41 | # Check that the element is descendant of other. 42 | # 43 | # @private 44 | # 45 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] possibleAncestor The possible ancestor. 46 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] possibleDescendant The possible descendant. 47 | # 48 | # @return [boolean] True if the element is descendant of other or false if the element is not descendant of other. 49 | # 50 | _isDescendant = (possibleAncestor, possibleDescendant) -> 51 | ancestor = possibleDescendant.parentNode 52 | while (ancestor isnt undefined) and (ancestor isnt null) 53 | if ancestor is possibleAncestor 54 | return true 55 | ancestor = ancestor.parentNode 56 | return false 57 | 58 | # Initializes a new object that encapsulate the HTMLDocument. 59 | # 60 | # @param [HTMLDocument] ownerDocument The owner document of parser. 61 | # 62 | constructor: (@ownerDocument) -> 63 | @results = [] 64 | 65 | # Find elements in the parser. 66 | # 67 | # @overload find(selector) 68 | # Find all elements in the parser by selector. 69 | # @param [string] selector The selector. 70 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 71 | # the elements found. 72 | # 73 | # @overload find(element) 74 | # Find if a element is contained in parser. 75 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 76 | # element. 77 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 78 | # the element, if the element is contained in parser. 79 | # 80 | # @see hatemile.util.html.HTMLDOMParser#find 81 | # 82 | find: (selector) -> 83 | if (selector instanceof self.hatemile.util.html.vanilla 84 | .VanillaHTMLDOMElement) 85 | @results = [selector.getData()] 86 | else 87 | @results = @ownerDocument.querySelectorAll(selector) 88 | return this 89 | 90 | # Find elements in the parser, children of found elements. 91 | # 92 | # @overload findChildren(selector) 93 | # Find all elements in the parser by selector, children of found elements. 94 | # @param [string] selector The selector. 95 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 96 | # the elements found. 97 | # 98 | # @overload findChildren(child) 99 | # Find if a element is a child of found elements. 100 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] child The 101 | # element. 102 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 103 | # the element, if the element is child of found elements. 104 | # 105 | # @see hatemile.util.html.HTMLDOMParser#findChildren 106 | # 107 | findChildren: (selector) -> 108 | children = [] 109 | if (selector instanceof self.hatemile.util.html.vanilla 110 | .VanillaHTMLDOMElement) 111 | for result in @results 112 | for resultChild in result.children 113 | if selector.getData() is resultChild 114 | children.push(selector.getData()) 115 | break 116 | if children.length > 0 117 | break 118 | else 119 | for result in @results 120 | descendants = result.querySelectorAll(selector) 121 | for descendant in descendants 122 | if descendant.parentNode is result 123 | children.push(descendant) 124 | @results = children 125 | return this 126 | 127 | # Find elements in the parser, descendants of found elements. 128 | # 129 | # @overload findDescendants(selector) 130 | # Find all elements in the parser by selector, descendants of found 131 | # elements. 132 | # @param [string] selector The selector. 133 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 134 | # the elements found. 135 | # 136 | # @overload findDescendants(element) 137 | # Find if a element is descendant of found elements. 138 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 139 | # element. 140 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 141 | # the element, if the element is descendant of found elements. 142 | # 143 | # @see hatemile.util.html.HTMLDOMParser#findDescendants 144 | # 145 | findDescendants: (selector) -> 146 | descendants = [] 147 | if (selector instanceof self.hatemile.util.html.vanilla 148 | .VanillaHTMLDOMElement) 149 | for result in @results 150 | if _isDescendant(result, selector.getData()) 151 | descendants.push(selector.getData()) 152 | break 153 | else 154 | for result in @results 155 | resultDescendants = result.querySelectorAll(selector) 156 | for resultDescendant in resultDescendants 157 | descendants.push(resultDescendant) 158 | @results = descendants 159 | return this 160 | 161 | # Find elements in the parser, ancestors of found elements. 162 | # 163 | # @overload findAncestors(selector) 164 | # Find all elements in the parser by selector, ancestors of found elements. 165 | # @param [string] selector The selector. 166 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 167 | # the elements found. 168 | # 169 | # @overload findAncestors(element) 170 | # Find if a element is ancestor of found elements. 171 | # @param [hatemile.util.html.vanilla.VanillaHTMLDOMElement] element The 172 | # element. 173 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMParser] The parser with 174 | # the element, if the element is ancestor of found elements. 175 | # 176 | # @see hatemile.util.html.HTMLDOMParser#findAncestors 177 | # 178 | findAncestors: (selector) -> 179 | ancestors = [] 180 | if (selector instanceof self.hatemile.util.html.vanilla 181 | .VanillaHTMLDOMElement) 182 | for result in @results 183 | if _isDescendant(selector.getData(), result) 184 | ancestors.push(selector.getData()) 185 | break 186 | else 187 | elements = @ownerDocument.querySelectorAll(selector) 188 | for result in @results 189 | for element in elements 190 | if _isDescendant(element, result) 191 | ancestors.push(element) 192 | @results = ancestors 193 | return this 194 | 195 | # Returns the first element found. 196 | # 197 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The first element found or null if not have elements found. 198 | # 199 | # @see hatemile.util.html.HTMLDOMParser#firstResult 200 | # 201 | firstResult: () -> 202 | if @results.length is 0 203 | return null 204 | return new self.hatemile.util.html.vanilla 205 | .VanillaHTMLDOMElement(@results[0]) 206 | 207 | # Returns the last element found. 208 | # 209 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The last element found or null if not have elements found. 210 | # 211 | # @see hatemile.util.html.HTMLDOMParser#lastResult 212 | # 213 | lastResult: () -> 214 | if @results.length is 0 215 | return null 216 | return new self.hatemile.util.html.vanilla 217 | .VanillaHTMLDOMElement(@results[@results.length - 1]) 218 | 219 | # Returns a list with all elements found. 220 | # 221 | # @return [Array] The list with all elements found. 222 | # 223 | # @see hatemile.util.html.HTMLDOMParser#listResults 224 | # 225 | listResults: () -> 226 | array = [] 227 | for result in @results 228 | array.push(new self.hatemile.util.html.vanilla 229 | .VanillaHTMLDOMElement(result)) 230 | return array 231 | 232 | # Create a element. 233 | # 234 | # @param [string] tag The tag of element. 235 | # 236 | # @return [hatemile.util.html.vanilla.VanillaHTMLDOMElement] The element created. 237 | # 238 | # @see hatemile.util.html.HTMLDOMParser#createElement 239 | # 240 | createElement: (tag) -> 241 | return new self.hatemile.util.html.vanilla 242 | .VanillaHTMLDOMElement(@ownerDocument.createElement(tag)) 243 | 244 | # Returns the HTML code of parser. 245 | # 246 | # @return [string] The HTML code of parser. 247 | # 248 | # @see hatemile.util.html.HTMLDOMParser#getHTML 249 | # 250 | getHTML: () -> 251 | return @ownerDocument.documentElement.outerHTML 252 | 253 | # Returns the parser. 254 | # 255 | # @return [HTMLDocument] The parser or root element of the parser. 256 | # 257 | # @see hatemile.util.html.HTMLDOMParser#getParser 258 | # 259 | getParser: () -> 260 | return @ownerDocument 261 | 262 | # Clear the memory of this object. 263 | # 264 | # @see hatemile.util.html.HTMLDOMParser#clearParser 265 | # 266 | clearParser: () -> 267 | @results = [] 268 | return 269 | -------------------------------------------------------------------------------- /coffee/hatemile/util/html/vanilla/VanillaHTMLDOMTextNode.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | ### 14 | 'use strict' 15 | 16 | self = this 17 | 18 | # @namespace hatemile 19 | # 20 | @hatemile or= {} 21 | 22 | # @namespace hatemile.util 23 | # 24 | @hatemile.util or= {} 25 | 26 | # @namespace hatemile.util.html 27 | # 28 | @hatemile.util.html or= {} 29 | 30 | # @namespace hatemile.util.html.vanilla 31 | # 32 | @hatemile.util.html.vanilla or= {} 33 | 34 | # The VanillaHTMLDOMTextNode class is official implementation of 35 | # {hatemile.util.html.HTMLDOMTextNode} interface for the Javascript. 36 | # 37 | # @extend hatemile.util.html.HTMLDOMTextNode 38 | # 39 | class @hatemile.util.html.vanilla.VanillaHTMLDOMTextNode 40 | 41 | # Initializes a new object that encapsulate the text node. 42 | # 43 | # @param [Text] data The native text node. 44 | # 45 | constructor: (@data) -> 46 | 47 | # Change the text content of text node. 48 | # 49 | # @param [string] text The new text content. 50 | # 51 | # @see hatemile.util.html.HTMLDOMTextNode#setTextContent 52 | # 53 | setTextContent: (text) -> 54 | @data.nodeValue = text 55 | return 56 | 57 | # Returns the text content of node. 58 | # 59 | # @return [string] The text content of node. 60 | # 61 | # @see hatemile.util.html.HTMLDOMTextNode#getTextContent 62 | # 63 | getTextContent: () -> 64 | return @data.nodeValue 65 | 66 | # Insert a node before this node. 67 | # 68 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that be inserted. 69 | # 70 | # @return [hatemile.util.html.HTMLDOMNode] This node. 71 | # 72 | # @see hatemile.util.html.HTMLDOMTextNode#insertBefore 73 | # 74 | insertBefore: (newNode) -> 75 | @data.parentNode.insertBefore(newNode.getData(), @data) 76 | return this 77 | 78 | # Insert a node after this node. 79 | # 80 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that be inserted. 81 | # 82 | # @return [hatemile.util.html.HTMLDOMNode] This node. 83 | # 84 | # @see hatemile.util.html.HTMLDOMTextNode#insertAfter 85 | # 86 | insertAfter: (newNode) -> 87 | parent = @data.parentNode 88 | childs = parent.childNodes 89 | found = false 90 | for child in childs 91 | if (found) 92 | parent.insertBefore(newNode.getData(), child) 93 | return 94 | else if (child is @data) 95 | found = true 96 | parent.appendChild(newNode.getData()) 97 | return this 98 | 99 | # Remove this node of the parser. 100 | # 101 | # @return [hatemile.util.html.HTMLDOMNode] The removed node. 102 | # 103 | # @see hatemile.util.html.HTMLDOMTextNode#removeNode 104 | # 105 | removeNode: () -> 106 | @data.remove() 107 | return this 108 | 109 | # Replace this node for other node. 110 | # 111 | # @param [hatemile.util.html.HTMLDOMNode] newNode The node that replace this node. 112 | # 113 | # @return [hatemile.util.html.HTMLDOMNode] This node. 114 | # 115 | # @see hatemile.util.html.HTMLDOMTextNode#replaceNode 116 | # 117 | replaceNode: (newNode) -> 118 | @data.parentNode.replaceChild(newNode.getData(), @data) 119 | return this 120 | 121 | # Append a text content in node. 122 | # 123 | # @param [string] text The text content. 124 | # 125 | # @return [hatemile.util.html.HTMLDOMNode] This node. 126 | # 127 | # @see hatemile.util.html.HTMLDOMTextNode#appendText 128 | # 129 | appendText: (text) -> 130 | @setTextContent("#{@getTextContent()}#{text}") 131 | return this 132 | 133 | # Prepend a text content in node. 134 | # 135 | # @param [string] text The text content. 136 | # 137 | # @return [hatemile.util.html.HTMLDOMNode] This node. 138 | # 139 | # @see hatemile.util.html.HTMLDOMTextNode#prependText 140 | # 141 | prependText: (text) -> 142 | @setTextContent("#{text}#{@getTextContent()}") 143 | return this 144 | 145 | # Returns the parent element of this node. 146 | # 147 | # @return [hatemile.util.html.HTMLDOMElement] The parent element of this node. 148 | # 149 | # @see hatemile.util.html.HTMLDOMTextNode#getParentElement 150 | # 151 | getParentElement: () -> 152 | parentNode = @data.parentNode 153 | if (parentNode is undefined) or (parentNode is null) 154 | return null 155 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(parentNode) 156 | 157 | # Returns the native object of this node. 158 | # 159 | # @return [Text] The native object of this node. 160 | # 161 | # @see hatemile.util.html.HTMLDOMTextNode#getData 162 | # 163 | getData: () -> 164 | return @data 165 | 166 | # Modify the native object of this node. 167 | # 168 | # @param [Text] data The native object of this node. 169 | # 170 | # @see hatemile.util.html.HTMLDOMTextNode#setData 171 | # 172 | setData: (data) -> 173 | @data = data 174 | return 175 | 176 | # Indicates whether some other object is equal to this one. 177 | # 178 | # @param [Object] node The reference object with which to compare. 179 | # 180 | # @return [boolean] True if the node is the other object is equals to this one or if the node is not the other object is equals to this one. 181 | # 182 | # @see hatemile.util.html.HTMLDOMTextNode#equals 183 | # 184 | equals: (node) -> 185 | if node instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode 186 | if @data is node.getData() 187 | return true 188 | return false 189 | -------------------------------------------------------------------------------- /css/hide_changes.css: -------------------------------------------------------------------------------- 1 | @charset 'UTF-8'; 2 | 3 | .force-read-before, 4 | .force-read-after, 5 | .force-link-before, 6 | .force-link-after, 7 | .screen-reader-only, 8 | #container-heading-before, 9 | #container-heading-after, 10 | #container-skippers, 11 | #container-shortcuts-before, 12 | #container-shortcuts-after { 13 | position: absolute !important; 14 | display: inline-block !important; 15 | width: 1px !important; 16 | height: 1px !important; 17 | padding: 0 !important; 18 | margin: -1px !important; 19 | overflow: hidden !important; 20 | clip: rect(0, 0, 0, 0) !important; 21 | border: none !important; 22 | text-indent: -9999px !important; 23 | } 24 | 25 | [unselectable="on"] { 26 | -moz-user-select: none !important; 27 | -webkit-user-select: none !important; 28 | -ms-user-select: none !important; 29 | user-select: none !important; 30 | } 31 | -------------------------------------------------------------------------------- /js/eventlistener.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | if (Element.prototype.eventListenerList === void 0) { 3 | Element.prototype.eventListenerList = {}; 4 | Element.prototype.__eventListenerListAdded = false; 5 | Element.prototype.__addEventListener = Element.prototype.addEventListener; 6 | Element.prototype.addEventListener = function () { 7 | if (!this.__eventListenerListAdded) { 8 | this.eventListenerList = {}; 9 | this.__eventListenerListAdded = true; 10 | } 11 | if (this.eventListenerList[arguments[0]] === void 0) { 12 | this.eventListenerList[arguments[0]] = []; 13 | } 14 | this.eventListenerList[arguments[0]].push(arguments[1]); 15 | return this.__addEventListener.apply(this, arguments); 16 | }; 17 | Element.prototype.__removeEventListener = Element.prototype.removeEventListener; 18 | Element.prototype.removeEventListener = function () { 19 | var found, i, key, len, ref; 20 | found = false; 21 | if (this.eventListenerList[arguments[0]] === void 0) { 22 | this.eventListenerList[arguments[0]] = []; 23 | } 24 | ref = this.eventListenerList[arguments[0]]; 25 | for (i = 0, len = ref.length; i < len; i++) { 26 | key = ref[i]; 27 | found = this.eventListenerList[arguments[0]][key] === arguments[1]; 28 | if (found) { 29 | break; 30 | } 31 | } 32 | if (found) { 33 | this.eventListenerList[arguments[0]].splice(key, 1); 34 | } 35 | return this.__removeEventListener.apply(this, arguments); 36 | }; 37 | } 38 | 39 | }).call(this); 40 | -------------------------------------------------------------------------------- /js/hatemile-skippers.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | this.hatemile_configuration_skippers = [{ 3 | 'selector': 'main,[role=main]', 4 | 'description': 'skipper-main-content', 5 | 'shortcut': '1' 6 | }, { 7 | 'selector': '#container-shortcuts-after', 8 | 'description': 'skipper-shortcuts-list', 9 | 'shortcut': '9' 10 | }, { 11 | 'selector': '#container-heading-after', 12 | 'description': 'skipper-table-contents', 13 | 'shortcut': '0' 14 | }]; 15 | 16 | }).call(this); 17 | -------------------------------------------------------------------------------- /js/hatemile-symbols.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | this.hatemile_configuration_symbols = [{ 3 | 'symbol': '!', 4 | 'description': 'symbol-exclamation-mark' 5 | }, { 6 | 'symbol': '"', 7 | 'description': 'symbol-double-quotes' 8 | }, { 9 | 'symbol': '#', 10 | 'description': 'symbol-number' 11 | }, { 12 | 'symbol': '$', 13 | 'description': 'symbol-dollar' 14 | }, { 15 | 'symbol': '%', 16 | 'description': 'symbol-percent' 17 | }, { 18 | 'symbol': '&', 19 | 'description': 'symbol-ampersand' 20 | }, { 21 | 'symbol': '\'', 22 | 'description': 'symbol-single-quote' 23 | }, { 24 | 'symbol': '(', 25 | 'description': 'symbol-open-parenthesis' 26 | }, { 27 | 'symbol': ')', 28 | 'description': 'symbol-close-parenthesis' 29 | }, { 30 | 'symbol': '*', 31 | 'description': 'symbol-asterisk' 32 | }, { 33 | 'symbol': '+', 34 | 'description': 'symbol-plus' 35 | }, { 36 | 'symbol': ',', 37 | 'description': 'symbol-comma' 38 | }, { 39 | 'symbol': '-', 40 | 'description': 'symbol-hyphen' 41 | }, { 42 | 'symbol': '.', 43 | 'description': 'symbol-dot' 44 | }, { 45 | 'symbol': '/', 46 | 'description': 'symbol-slash' 47 | }, { 48 | 'symbol': ':', 49 | 'description': 'symbol-colon' 50 | }, { 51 | 'symbol': ';', 52 | 'description': 'symbol-semicolon' 53 | }, { 54 | 'symbol': '<', 55 | 'description': 'symbol-less-than' 56 | }, { 57 | 'symbol': '=', 58 | 'description': 'symbol-equals' 59 | }, { 60 | 'symbol': '>', 61 | 'description': 'symbol-greater-than' 62 | }, { 63 | 'symbol': '?', 64 | 'description': 'symbol-question-mark' 65 | }, { 66 | 'symbol': '@', 67 | 'description': 'symbol-at' 68 | }, { 69 | 'symbol': '[', 70 | 'description': 'symbol-open-bracket' 71 | }, { 72 | 'symbol': '\\', 73 | 'description': 'symbol-backslash' 74 | }, { 75 | 'symbol': ']', 76 | 'description': 'symbol-close-bracket' 77 | }, { 78 | 'symbol': '^', 79 | 'description': 'symbol-caret' 80 | }, { 81 | 'symbol': '_', 82 | 'description': 'symbol-underscore' 83 | }, { 84 | 'symbol': '`', 85 | 'description': 'symbol-grave-accent' 86 | }, { 87 | 'symbol': '{', 88 | 'description': 'symbol-open-brace' 89 | }, { 90 | 'symbol': '|', 91 | 'description': 'symbol-vertical-bar' 92 | }, { 93 | 'symbol': '}', 94 | 'description': 'symbol-close-brace' 95 | }, { 96 | 'symbol': '~', 97 | 'description': 'symbol-tilde' 98 | }]; 99 | 100 | }).call(this); 101 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleAssociation.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleAssociation = (function () { 20 | function AccessibleAssociation() {} 21 | 22 | AccessibleAssociation.prototype.associateDataCellsWithHeaderCells = function (table) {}; 23 | 24 | AccessibleAssociation.prototype.associateAllDataCellsWithHeaderCells = function () {}; 25 | 26 | AccessibleAssociation.prototype.associateLabelWithField = function (label) {}; 27 | 28 | AccessibleAssociation.prototype.associateAllLabelsWithFields = function () {}; 29 | 30 | return AccessibleAssociation; 31 | 32 | })(); 33 | 34 | }).call(this); 35 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleCSS.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleCSS = (function () { 20 | function AccessibleCSS() {} 21 | 22 | AccessibleCSS.prototype.provideSpeakProperties = function (element) {}; 23 | 24 | AccessibleCSS.prototype.provideAllSpeakProperties = function () {}; 25 | 26 | return AccessibleCSS; 27 | 28 | })(); 29 | 30 | }).call(this); 31 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleDisplay.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleDisplay = (function () { 20 | function AccessibleDisplay() {} 21 | 22 | AccessibleDisplay.prototype.displayShortcut = function (element) {}; 23 | 24 | AccessibleDisplay.prototype.displayAllShortcuts = function () {}; 25 | 26 | AccessibleDisplay.prototype.displayRole = function (element) {}; 27 | 28 | AccessibleDisplay.prototype.displayAllRoles = function () {}; 29 | 30 | AccessibleDisplay.prototype.displayCellHeader = function (tableCell) {}; 31 | 32 | AccessibleDisplay.prototype.displayAllCellHeaders = function () {}; 33 | 34 | AccessibleDisplay.prototype.displayWAIARIAStates = function (element) {}; 35 | 36 | AccessibleDisplay.prototype.displayAllWAIARIAStates = function () {}; 37 | 38 | AccessibleDisplay.prototype.displayLinkAttributes = function (link) {}; 39 | 40 | AccessibleDisplay.prototype.displayAllLinksAttributes = function () {}; 41 | 42 | AccessibleDisplay.prototype.displayTitle = function (element) {}; 43 | 44 | AccessibleDisplay.prototype.displayAllTitles = function () {}; 45 | 46 | AccessibleDisplay.prototype.displayLanguage = function (element) {}; 47 | 48 | AccessibleDisplay.prototype.displayAllLanguages = function () {}; 49 | 50 | AccessibleDisplay.prototype.displayAlternativeTextImage = function (image) {}; 51 | 52 | AccessibleDisplay.prototype.displayAllAlternativeTextImages = function () {}; 53 | 54 | return AccessibleDisplay; 55 | 56 | })(); 57 | 58 | }).call(this); 59 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleEvent.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleEvent = (function () { 20 | function AccessibleEvent() {} 21 | 22 | AccessibleEvent.prototype.makeAccessibleDropEvents = function (element) {}; 23 | 24 | AccessibleEvent.prototype.makeAccessibleDragEvents = function (element) {}; 25 | 26 | AccessibleEvent.prototype.makeAccessibleAllDragandDropEvents = function () {}; 27 | 28 | AccessibleEvent.prototype.makeAccessibleHoverEvents = function (element) {}; 29 | 30 | AccessibleEvent.prototype.makeAccessibleAllHoverEvents = function () {}; 31 | 32 | AccessibleEvent.prototype.makeAccessibleClickEvents = function (element) {}; 33 | 34 | AccessibleEvent.prototype.makeAccessibleAllClickEvents = function () {}; 35 | 36 | return AccessibleEvent; 37 | 38 | })(); 39 | 40 | }).call(this); 41 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleForm.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleForm = (function () { 20 | function AccessibleForm() {} 21 | 22 | AccessibleForm.prototype.markRequiredField = function (requiredField) {}; 23 | 24 | AccessibleForm.prototype.markAllRequiredFields = function () {}; 25 | 26 | AccessibleForm.prototype.markRangeField = function (rangeField) {}; 27 | 28 | AccessibleForm.prototype.markAllRangeFields = function () {}; 29 | 30 | AccessibleForm.prototype.markAutoCompleteField = function (autoCompleteField) {}; 31 | 32 | AccessibleForm.prototype.markAllAutoCompleteFields = function () {}; 33 | 34 | AccessibleForm.prototype.markInvalidField = function (field) {}; 35 | 36 | AccessibleForm.prototype.markAllInvalidFields = function () {}; 37 | 38 | return AccessibleForm; 39 | 40 | })(); 41 | 42 | }).call(this); 43 | -------------------------------------------------------------------------------- /js/hatemile/AccessibleNavigation.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | this.hatemile || (this.hatemile = {}); 18 | 19 | this.hatemile.AccessibleNavigation = (function () { 20 | function AccessibleNavigation() {} 21 | 22 | AccessibleNavigation.prototype.provideNavigationBySkipper = function (element) {}; 23 | 24 | AccessibleNavigation.prototype.provideNavigationByAllSkippers = function () {}; 25 | 26 | AccessibleNavigation.prototype.provideNavigationByHeading = function (heading) {}; 27 | 28 | AccessibleNavigation.prototype.provideNavigationByAllHeadings = function () {}; 29 | 30 | AccessibleNavigation.prototype.provideNavigationToLongDescription = function (image) {}; 31 | 32 | AccessibleNavigation.prototype.provideNavigationToAllLongDescriptions = function () {}; 33 | 34 | return AccessibleNavigation; 35 | 36 | })(); 37 | 38 | }).call(this); 39 | -------------------------------------------------------------------------------- /js/hatemile/implementation/AccessibleAssociationImplementation.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).implementation || (base.implementation = {}); 24 | 25 | this.hatemile.implementation.AccessibleAssociationImplementation = (function () { 26 | var DATA_IGNORE; 27 | 28 | DATA_IGNORE = 'data-ignoreaccessibilityfix'; 29 | 30 | AccessibleAssociationImplementation.prototype._getModelTable = function (part) { 31 | var j, len, row, rows, table; 32 | table = []; 33 | rows = this.parser.find(part).findChildren('tr').listResults(); 34 | for (j = 0, len = rows.length; j < len; j++) { 35 | row = rows[j]; 36 | table.push(this._getModelRow(this.parser.find(row).findChildren('th,td').listResults())); 37 | } 38 | return this._getValidModelTable(table); 39 | }; 40 | 41 | AccessibleAssociationImplementation.prototype._getValidModelTable = function (originalTable) { 42 | var cell, cellIndex, cellsAdded, j, k, lengthRow, lengthTable, newCellIndex, newRow, newRowIndex, newTable, originalRow, ref, ref1, rowIndex, rowspan; 43 | newTable = []; 44 | lengthTable = originalTable.length; 45 | if (lengthTable > 0) { 46 | for (rowIndex = j = 0, ref = lengthTable - 1; 0 <= ref ? j <= ref : j >= ref; rowIndex = 0 <= ref ? ++j : --j) { 47 | originalRow = originalTable[rowIndex]; 48 | if (newTable[rowIndex] === void 0) { 49 | newTable[rowIndex] = []; 50 | } 51 | lengthRow = originalRow.length; 52 | if (lengthRow > 0) { 53 | cellsAdded = 0; 54 | for (cellIndex = k = 0, ref1 = lengthRow - 1; 0 <= ref1 ? k <= ref1 : k >= ref1; cellIndex = 0 <= ref1 ? ++k : --k) { 55 | cell = originalRow[cellIndex]; 56 | newCellIndex = cellIndex + cellsAdded; 57 | newRow = newTable[rowIndex]; 58 | while (newRow[newCellIndex] !== void 0) { 59 | cellsAdded = cellsAdded + 1; 60 | newCellIndex = cellIndex + cellsAdded; 61 | } 62 | newRow[newCellIndex] = cell; 63 | if (cell.hasAttribute('rowspan')) { 64 | rowspan = parseInt(cell.getAttribute('rowspan')); 65 | newRowIndex = rowIndex; 66 | while (rowspan > 1) { 67 | rowspan = rowspan - 1; 68 | newRowIndex = newRowIndex + 1; 69 | if (newTable[newRowIndex] === void 0) { 70 | newTable[newRowIndex] = []; 71 | } 72 | newTable[newRowIndex][newCellIndex] = cell; 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | return newTable; 80 | }; 81 | 82 | AccessibleAssociationImplementation.prototype._getModelRow = function (originalRow) { 83 | var cellsAdded, colspan, i, j, length, newRow, ref; 84 | newRow = []; 85 | length = originalRow.length; 86 | if (length > 0) { 87 | newRow = newRow.concat(originalRow); 88 | cellsAdded = 0; 89 | for (i = j = 0, ref = length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { 90 | if (originalRow[i].hasAttribute('colspan')) { 91 | colspan = parseInt(originalRow[i].getAttribute('colspan')); 92 | while (colspan > 1) { 93 | colspan = colspan - 1; 94 | cellsAdded = cellsAdded + 1; 95 | newRow.splice(i + cellsAdded, 0, originalRow[i]); 96 | } 97 | } 98 | } 99 | } 100 | return newRow; 101 | }; 102 | 103 | AccessibleAssociationImplementation.prototype._validateHeader = function (header) { 104 | var j, len, length, row; 105 | if (header.length === 0) { 106 | return false; 107 | } 108 | length = -1; 109 | for (j = 0, len = header.length; j < len; j++) { 110 | row = header[j]; 111 | if (row.length === 0) { 112 | return false; 113 | } else if (length === -1) { 114 | length = row.length; 115 | } else if (row.length !== length) { 116 | return false; 117 | } 118 | } 119 | return true; 120 | }; 121 | 122 | AccessibleAssociationImplementation.prototype._getCellsHeadersIds = function (header, index) { 123 | var cell, ids, j, len, row; 124 | ids = []; 125 | for (j = 0, len = header.length; j < len; j++) { 126 | row = header[j]; 127 | cell = row[index]; 128 | if ((cell.getTagName() === 'TH') && (cell.getAttribute('scope') === 'col')) { 129 | ids.push(cell.getAttribute('id')); 130 | } 131 | } 132 | return ids; 133 | }; 134 | 135 | AccessibleAssociationImplementation.prototype._associateDataCellsWithHeaderCellsOfRow = function (element) { 136 | var cell, headerId, headers, headersIds, j, k, l, len, len1, len2, len3, m, row, table; 137 | table = this._getModelTable(element); 138 | for (j = 0, len = table.length; j < len; j++) { 139 | row = table[j]; 140 | headersIds = []; 141 | for (k = 0, len1 = row.length; k < len1; k++) { 142 | cell = row[k]; 143 | if (cell.getTagName() === 'TH') { 144 | this.idGenerator.generateId(cell); 145 | headersIds.push(cell.getAttribute('id')); 146 | cell.setAttribute('scope', 'row'); 147 | } 148 | } 149 | if (headersIds.length > 0) { 150 | for (l = 0, len2 = row.length; l < len2; l++) { 151 | cell = row[l]; 152 | if (cell.getTagName() === 'TD') { 153 | headers = cell.getAttribute('headers'); 154 | for (m = 0, len3 = headersIds.length; m < len3; m++) { 155 | headerId = headersIds[m]; 156 | headers = self.hatemile.util.CommonFunctions.increaseInList(headers, headerId); 157 | } 158 | if (headers !== null) { 159 | cell.setAttribute('headers', headers); 160 | } 161 | } 162 | } 163 | } 164 | } 165 | }; 166 | 167 | AccessibleAssociationImplementation.prototype._prepareHeaderCells = function (tableHeader) { 168 | var cell, cells, j, len; 169 | cells = this.parser.find(tableHeader).findChildren('tr').findChildren('th').listResults(); 170 | for (j = 0, len = cells.length; j < len; j++) { 171 | cell = cells[j]; 172 | this.idGenerator.generateId(cell); 173 | if (!cell.hasAttribute('scope')) { 174 | cell.setAttribute('scope', 'col'); 175 | } 176 | } 177 | }; 178 | 179 | function AccessibleAssociationImplementation(parser, configure) { 180 | this.parser = parser; 181 | this.idGenerator = new hatemile.util.IDGenerator('association'); 182 | } 183 | 184 | AccessibleAssociationImplementation.prototype.associateDataCellsWithHeaderCells = function (table) { 185 | var body, cell, fakeTable, footer, header, headerRows, headers, headersId, headersIds, i, j, k, l, len, len1, len2, lengthHeader, row; 186 | header = this.parser.find(table).findChildren('thead').firstResult(); 187 | body = this.parser.find(table).findChildren('tbody').firstResult(); 188 | footer = this.parser.find(table).findChildren('tfoot').firstResult(); 189 | if (header !== null) { 190 | this._prepareHeaderCells(header); 191 | headerRows = this._getModelTable(header); 192 | if ((body !== null) && (this._validateHeader(headerRows))) { 193 | lengthHeader = headerRows[0].length; 194 | fakeTable = this._getModelTable(body); 195 | if (footer !== null) { 196 | fakeTable = fakeTable.concat(this._getModelTable(footer)); 197 | } 198 | for (j = 0, len = fakeTable.length; j < len; j++) { 199 | row = fakeTable[j]; 200 | if (row.length === lengthHeader) { 201 | i = 0; 202 | for (k = 0, len1 = row.length; k < len1; k++) { 203 | cell = row[k]; 204 | headersIds = this._getCellsHeadersIds(headerRows, i); 205 | headers = cell.getAttribute('headers'); 206 | for (l = 0, len2 = headersIds.length; l < len2; l++) { 207 | headersId = headersIds[l]; 208 | headers = self.hatemile.util.CommonFunctions.increaseInList(headers, headersId); 209 | } 210 | if (headers !== null) { 211 | cell.setAttribute('headers', headers); 212 | } 213 | i = i + 1; 214 | } 215 | } 216 | } 217 | } 218 | } 219 | if (body !== null) { 220 | this._associateDataCellsWithHeaderCellsOfRow(body); 221 | } 222 | if (footer !== null) { 223 | this._associateDataCellsWithHeaderCellsOfRow(footer); 224 | } 225 | }; 226 | 227 | AccessibleAssociationImplementation.prototype.associateAllDataCellsWithHeaderCells = function () { 228 | var j, len, table, tables; 229 | tables = this.parser.find('table').listResults(); 230 | for (j = 0, len = tables.length; j < len; j++) { 231 | table = tables[j]; 232 | if (self.hatemile.util.CommonFunctions.isValidElement(table)) { 233 | if (this.parser.find(table).findDescendants(("thead[" + DATA_IGNORE + "],") + ("tbody[" + DATA_IGNORE + "],tfoot[" + DATA_IGNORE + "],tr[" + DATA_IGNORE + "],") + ("th[" + DATA_IGNORE + "],td[" + DATA_IGNORE + "]")).firstResult() === null) { 234 | this.associateDataCellsWithHeaderCells(table); 235 | } 236 | } 237 | } 238 | }; 239 | 240 | AccessibleAssociationImplementation.prototype.associateLabelWithField = function (label) { 241 | var field; 242 | if (label.getTagName() === 'LABEL') { 243 | if (label.hasAttribute('for')) { 244 | field = this.parser.find("#" + (label.getAttribute('for'))).firstResult(); 245 | } else { 246 | field = this.parser.find(label).findDescendants('input,select,textarea').firstResult(); 247 | if (field !== null) { 248 | this.idGenerator.generateId(field); 249 | label.setAttribute('for', field.getAttribute('id')); 250 | } 251 | } 252 | if ((field !== null) && (!field.hasAttribute(DATA_IGNORE))) { 253 | if (!field.hasAttribute('aria-label')) { 254 | field.setAttribute('aria-label', label.getTextContent().replace(new RegExp('[ \n\t\r]+', 'g'), ' ')); 255 | } 256 | this.idGenerator.generateId(label); 257 | field.setAttribute('aria-labelledby', self.hatemile.util.CommonFunctions.increaseInList(field.getAttribute('aria-labelledby'), label.getAttribute('id'))); 258 | } 259 | } 260 | }; 261 | 262 | AccessibleAssociationImplementation.prototype.associateAllLabelsWithFields = function () { 263 | var j, label, labels, len; 264 | labels = this.parser.find('label').listResults(); 265 | for (j = 0, len = labels.length; j < len; j++) { 266 | label = labels[j]; 267 | if (self.hatemile.util.CommonFunctions.isValidElement(label)) { 268 | this.associateLabelWithField(label); 269 | } 270 | } 271 | }; 272 | 273 | return AccessibleAssociationImplementation; 274 | 275 | })(); 276 | 277 | }).call(this); 278 | -------------------------------------------------------------------------------- /js/hatemile/util/CommonFunctions.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | this.hatemile.util.CommonFunctions = (function () { 26 | var DATA_IGNORE; 27 | 28 | function CommonFunctions() {} 29 | 30 | DATA_IGNORE = 'data-ignoreaccessibilityfix'; 31 | 32 | CommonFunctions.setListAttributes = function (element1, element2, attributes) { 33 | var attribute, i, len; 34 | for (i = 0, len = attributes.length; i < len; i++) { 35 | attribute = attributes[i]; 36 | if (element1.hasAttribute(attribute)) { 37 | element2.setAttribute(attribute, element1.getAttribute(attribute)); 38 | } 39 | } 40 | }; 41 | 42 | CommonFunctions.increaseInList = function (list, stringToIncrease) { 43 | if ((list !== null) && (list.length > 0) && (stringToIncrease !== null) && (stringToIncrease.length > 0)) { 44 | if (this.inList(list, stringToIncrease)) { 45 | return list; 46 | } else { 47 | return list + " " + stringToIncrease; 48 | } 49 | } else if ((stringToIncrease !== null) && (stringToIncrease.length > 0)) { 50 | return stringToIncrease; 51 | } else { 52 | return list; 53 | } 54 | }; 55 | 56 | CommonFunctions.inList = function (list, stringToSearch) { 57 | var array, i, item, len; 58 | if ((list !== null) && (list.length > 0) && (stringToSearch !== null) && (stringToSearch.length > 0)) { 59 | array = list.split(new RegExp('[ \n\t\r]+')); 60 | for (i = 0, len = array.length; i < len; i++) { 61 | item = array[i]; 62 | if (item === stringToSearch) { 63 | return true; 64 | } 65 | } 66 | } 67 | return false; 68 | }; 69 | 70 | CommonFunctions.isValidElement = function (element) { 71 | var parentElement, tagName; 72 | if (element.hasAttribute(DATA_IGNORE)) { 73 | return false; 74 | } else { 75 | parentElement = element.getParentElement(); 76 | if (parentElement !== null) { 77 | tagName = parentElement.getTagName(); 78 | if ((tagName !== 'BODY') && (tagName !== 'HTML')) { 79 | return this.isValidElement(parentElement); 80 | } else { 81 | return true; 82 | } 83 | } else { 84 | return true; 85 | } 86 | } 87 | }; 88 | 89 | return CommonFunctions; 90 | 91 | })(); 92 | 93 | }).call(this); 94 | -------------------------------------------------------------------------------- /js/hatemile/util/Configure.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | this.hatemile.util.Configure = (function () { 24 | function Configure(parameters) { 25 | this.parameters = parameters; 26 | } 27 | 28 | Configure.prototype.getParameters = function () { 29 | var clonedParameters, key, ref, value; 30 | clonedParameters = {}; 31 | ref = this.parameters; 32 | for (key in ref) { 33 | value = ref[key]; 34 | clonedParameters[key] = value; 35 | } 36 | return clonedParameters; 37 | }; 38 | 39 | Configure.prototype.hasParameter = function (parameter) { 40 | return this.parameters[parameter] !== void 0; 41 | }; 42 | 43 | Configure.prototype.getParameter = function (name) { 44 | if (!this.hasParameter(name)) { 45 | throw new Error("Parameter '" + name + "' not found."); 46 | } 47 | return this.parameters[name]; 48 | }; 49 | 50 | return Configure; 51 | 52 | })(); 53 | 54 | }).call(this); 55 | -------------------------------------------------------------------------------- /js/hatemile/util/IDGenerator.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | this.hatemile.util.IDGenerator = (function () { 26 | function IDGenerator(prefixPart) { 27 | var randomNumber; 28 | randomNumber = Math.floor(Math.random() * 9007199254740991).toString(); 29 | if (prefixPart === void 0) { 30 | this.prefixId = "id-hatemile-" + randomNumber + "-"; 31 | } else { 32 | this.prefixId = "id-hatemile-" + prefixPart + "-" + randomNumber + "-"; 33 | } 34 | this.count = 0; 35 | } 36 | 37 | IDGenerator.prototype.generateId = function (element) { 38 | if (!element.hasAttribute('id')) { 39 | element.setAttribute('id', this.prefixId + this.count.toString()); 40 | this.count = this.count + 1; 41 | } 42 | }; 43 | 44 | return IDGenerator; 45 | 46 | })(); 47 | 48 | }).call(this); 49 | -------------------------------------------------------------------------------- /js/hatemile/util/css/StyleSheetDeclaration.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).css || (base1.css = {}); 24 | 25 | this.hatemile.util.css.StyleSheetDeclaration = (function () { 26 | function StyleSheetDeclaration() {} 27 | 28 | StyleSheetDeclaration.prototype.getValue = function () {}; 29 | 30 | StyleSheetDeclaration.prototype.getValues = function () {}; 31 | 32 | StyleSheetDeclaration.prototype.getProperty = function () {}; 33 | 34 | return StyleSheetDeclaration; 35 | 36 | })(); 37 | 38 | }).call(this); 39 | -------------------------------------------------------------------------------- /js/hatemile/util/css/StyleSheetParser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).css || (base1.css = {}); 24 | 25 | this.hatemile.util.css.StyleSheetParser = (function () { 26 | function StyleSheetParser() {} 27 | 28 | StyleSheetParser.prototype.getRules = function (properties) {}; 29 | 30 | return StyleSheetParser; 31 | 32 | })(); 33 | 34 | }).call(this); 35 | -------------------------------------------------------------------------------- /js/hatemile/util/css/StyleSheetRule.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).css || (base1.css = {}); 24 | 25 | this.hatemile.util.css.StyleSheetRule = (function () { 26 | function StyleSheetRule() {} 27 | 28 | StyleSheetRule.prototype.hasProperty = function (propertyName) {}; 29 | 30 | StyleSheetRule.prototype.hasDeclarations = function () {}; 31 | 32 | StyleSheetRule.prototype.getDeclarations = function (propertyName) {}; 33 | 34 | StyleSheetRule.prototype.getSelector = function () {}; 35 | 36 | return StyleSheetRule; 37 | 38 | })(); 39 | 40 | }).call(this); 41 | -------------------------------------------------------------------------------- /js/hatemile/util/css/jscssp/JSCSSPDeclaration.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).css || (base1.css = {}); 24 | 25 | (base2 = this.hatemile.util.css).jscssp || (base2.jscssp = {}); 26 | 27 | this.hatemile.util.css.jscssp.JSCSSPDeclaration = (function () { 28 | function JSCSSPDeclaration(declaration) { 29 | this.declaration = declaration; 30 | } 31 | 32 | JSCSSPDeclaration.prototype.getValue = function () { 33 | return this.declaration.valueText.trim(); 34 | }; 35 | 36 | JSCSSPDeclaration.prototype.getValues = function () { 37 | var i, len, propertyValue, ref, values; 38 | values = []; 39 | ref = this.declaration.values; 40 | for (i = 0, len = ref.length; i < len; i++) { 41 | propertyValue = ref[i]; 42 | values.push(propertyValue.value); 43 | } 44 | return values; 45 | }; 46 | 47 | JSCSSPDeclaration.prototype.getProperty = function () { 48 | return this.declaration.property; 49 | }; 50 | 51 | return JSCSSPDeclaration; 52 | 53 | })(); 54 | 55 | }).call(this); 56 | -------------------------------------------------------------------------------- /js/hatemile/util/css/jscssp/JSCSSPParser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).css || (base1.css = {}); 26 | 27 | (base2 = this.hatemile.util.css).jscssp || (base2.jscssp = {}); 28 | 29 | this.hatemile.util.css.jscssp.JSCSSPParser = (function () { 30 | var _getAbsolutePath, _getCSSContent, _getContentFromURL; 31 | 32 | _getAbsolutePath = function (currentURL, otherURL) { 33 | var i, len, relativePart, relativeParts, stackURL, urlRegularExpression; 34 | if (otherURL.indexOf('//') === 0) { 35 | if (currentURL.indexOf('https://') === 0) { 36 | return "https:" + otherURL; 37 | } else { 38 | return "http:" + otherURL; 39 | } 40 | } else if (otherURL.indexOf('data:') === 0) { 41 | return null; 42 | } else { 43 | urlRegularExpression = new RegExp('([a-zA-Z][a-zA-Z0-9\\+\\.\\-]*):(\\/' + '\\/)?(?:(?:(?:[a-zA-Z0-9_\\.\\-\\+!$&\'\\(\\)*\\+,;=]|%[0-9a-f]' + '{2})+:)*(?:[a-zA-Z0-9_\\.\\-\\+%!$&\'\\(\\)*\\+,;=]|%[0-9a-f]{2}' + ')+@)?(?:(?:[a-z0-9\\-\\.]|%[0-9a-f]{2})+|(?:\\[(?:[0-9a-f]{0,4}:' + ')*(?:[0-9a-f]{0,4})\\]))(?::[0-9]+)?(?:[\\/|\\?](?:[a-zA-Z0-9_#!' + ':\\.\\?\\+=&@!$\'~*,;\\/\\(\\)\\[\\]\\-]|%[0-9a-f]{2})*)?'); 44 | if (urlRegularExpression.test(otherURL)) { 45 | return otherURL; 46 | } else { 47 | stackURL = currentURL.split('/'); 48 | stackURL.pop(); 49 | if (otherURL.indexOf('/') === 0) { 50 | return stackURL[0] + "//" + stackURL[2] + otherURL; 51 | } else { 52 | relativeParts = otherURL.split('/'); 53 | for (i = 0, len = relativeParts.length; i < len; i++) { 54 | relativePart = relativeParts[i]; 55 | if (relativePart === '..') { 56 | stackURL.pop(); 57 | } else if (relativePart !== '.') { 58 | stackURL.push(relativePart); 59 | } 60 | } 61 | return stackURL.join('/'); 62 | } 63 | } 64 | } 65 | }; 66 | 67 | _getCSSContent = function (htmlParser, currentURL) { 68 | var content, element, elements, i, len; 69 | content = ''; 70 | elements = htmlParser.find('style,link[rel=stylesheet]').listResults(); 71 | for (i = 0, len = elements.length; i < len; i++) { 72 | element = elements[i]; 73 | if (element.getTagName() === 'STYLE') { 74 | content += element.getTextContent(); 75 | } 76 | if ((element.hasAttribute('rel')) && (element.getAttribute('rel') === 'stylesheet')) { 77 | content += _getContentFromURL(_getAbsolutePath(currentURL, element.getAttribute('href'))); 78 | } 79 | } 80 | return content; 81 | }; 82 | 83 | _getContentFromURL = function (url) { 84 | var content, e, error, error1, httpRequest; 85 | content = ''; 86 | if (url.length > 0) { 87 | httpRequest = false; 88 | if (window.XMLHttpRequest) { 89 | httpRequest = new XMLHttpRequest(); 90 | } else if (window.ActiveXObject) { 91 | try { 92 | httpRequest = new ActiveXObject('Msxml2.XMLHTTP'); 93 | } catch (error) { 94 | e = error; 95 | try { 96 | httpRequest = new ActiveXObject('Microsoft.XMLHTTP'); 97 | } catch (error1) { 98 | e = error1; 99 | } 100 | } 101 | } 102 | if (httpRequest) { 103 | httpRequest.onreadystatechange = function () { 104 | if ((this.readyState === 4) && (this.status === 200)) { 105 | return content = httpRequest.responseText; 106 | } 107 | }; 108 | httpRequest.open('GET', url, false); 109 | httpRequest.send(); 110 | } 111 | } 112 | return content; 113 | }; 114 | 115 | function JSCSSPParser(parser1, currentURL1) { 116 | var parser; 117 | this.parser = parser1; 118 | this.currentURL = currentURL1; 119 | if (!(this.parser instanceof jscsspStylesheet)) { 120 | parser = new CSSParser(); 121 | if ((this.parser.find instanceof Function) && (this.parser.listResults instanceof Function) && (this.parser.getParser instanceof Function)) { 122 | this.parser = _getCSSContent(this.parser, this.currentURL); 123 | } 124 | if (typeof this.parser === typeof '') { 125 | this.parser = parser.parse("body{}" + this.parser, false, false); 126 | } 127 | } 128 | } 129 | 130 | JSCSSPParser.prototype.getRules = function (properties) { 131 | var i, j, k, len, len1, len2, nativeRule, property, ref, ref1, rule, rules; 132 | rules = []; 133 | if ((properties === void 0) || (properties.length === 0)) { 134 | ref = this.parser.cssRules; 135 | for (i = 0, len = ref.length; i < len; i++) { 136 | nativeRule = ref[i]; 137 | if (nativeRule.type === 1) { 138 | rules.push(new self.hatemile.util.css.jscssp.JSCSSPRule(nativeRule)); 139 | } 140 | } 141 | } else { 142 | ref1 = this.parser.cssRules; 143 | for (j = 0, len1 = ref1.length; j < len1; j++) { 144 | nativeRule = ref1[j]; 145 | if (nativeRule.type === 1) { 146 | rule = new self.hatemile.util.css.jscssp.JSCSSPRule(nativeRule); 147 | for (k = 0, len2 = properties.length; k < len2; k++) { 148 | property = properties[k]; 149 | if (rule.hasProperty(property)) { 150 | rules.push(rule); 151 | break; 152 | } 153 | } 154 | } 155 | } 156 | } 157 | return rules; 158 | }; 159 | 160 | return JSCSSPParser; 161 | 162 | })(); 163 | 164 | }).call(this); 165 | -------------------------------------------------------------------------------- /js/hatemile/util/css/jscssp/JSCSSPRule.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).css || (base1.css = {}); 26 | 27 | (base2 = this.hatemile.util.css).jscssp || (base2.jscssp = {}); 28 | 29 | this.hatemile.util.css.jscssp.JSCSSPRule = (function () { 30 | function JSCSSPRule(rule) { 31 | this.rule = rule; 32 | } 33 | 34 | JSCSSPRule.prototype.hasProperty = function (propertyName) { 35 | var declaration, i, len, nativeDeclaration, ref; 36 | ref = this.rule.declarations; 37 | for (i = 0, len = ref.length; i < len; i++) { 38 | nativeDeclaration = ref[i]; 39 | declaration = new self.hatemile.util.css.jscssp.JSCSSPDeclaration(nativeDeclaration); 40 | if (propertyName === declaration.getProperty()) { 41 | return true; 42 | } 43 | } 44 | return false; 45 | }; 46 | 47 | JSCSSPRule.prototype.hasDeclarations = function () { 48 | return this.rule.declarations.length > 0; 49 | }; 50 | 51 | JSCSSPRule.prototype.getDeclarations = function (propertyName) { 52 | var declaration, declarations, i, len, nativeDeclaration, ref; 53 | declarations = []; 54 | ref = this.rule.declarations; 55 | for (i = 0, len = ref.length; i < len; i++) { 56 | nativeDeclaration = ref[i]; 57 | declaration = new self.hatemile.util.css.jscssp.JSCSSPDeclaration(nativeDeclaration); 58 | if (propertyName === declaration.getProperty()) { 59 | declarations.push(declaration); 60 | } 61 | } 62 | return declarations; 63 | }; 64 | 65 | JSCSSPRule.prototype.getSelector = function () { 66 | return this.rule.mSelectorText; 67 | }; 68 | 69 | return JSCSSPRule; 70 | 71 | })(); 72 | 73 | }).call(this); 74 | -------------------------------------------------------------------------------- /js/hatemile/util/html/HTMLDOMElement.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, 18 | extend = function (child, parent) { 19 | for (var key in parent) { 20 | if (hasProp.call(parent, key)) child[key] = parent[key]; 21 | } 22 | 23 | function ctor() { 24 | this.constructor = child; 25 | } 26 | ctor.prototype = parent.prototype; 27 | child.prototype = new ctor(); 28 | child.__super__ = parent.prototype; 29 | return child; 30 | }, 31 | hasProp = {}.hasOwnProperty; 32 | 33 | this.hatemile || (this.hatemile = {}); 34 | 35 | (base = this.hatemile).util || (base.util = {}); 36 | 37 | (base1 = this.hatemile.util).html || (base1.html = {}); 38 | 39 | this.hatemile.util.html.HTMLDOMElement = (function (superClass) { 40 | extend(HTMLDOMElement, superClass); 41 | 42 | function HTMLDOMElement() { 43 | return HTMLDOMElement.__super__.constructor.apply(this, arguments); 44 | } 45 | 46 | HTMLDOMElement.prototype.getTagName = function () {}; 47 | 48 | HTMLDOMElement.prototype.getAttribute = function (name) {}; 49 | 50 | HTMLDOMElement.prototype.setAttribute = function (name, value) {}; 51 | 52 | HTMLDOMElement.prototype.removeAttribute = function (name) {}; 53 | 54 | HTMLDOMElement.prototype.hasAttribute = function (name) {}; 55 | 56 | HTMLDOMElement.prototype.hasAttributes = function () {}; 57 | 58 | HTMLDOMElement.prototype.appendElement = function (element) {}; 59 | 60 | HTMLDOMElement.prototype.prependElement = function (element) {}; 61 | 62 | HTMLDOMElement.prototype.getChildrenElements = function () {}; 63 | 64 | HTMLDOMElement.prototype.getChildren = function () {}; 65 | 66 | HTMLDOMElement.prototype.normalize = function () {}; 67 | 68 | HTMLDOMElement.prototype.hasChildrenElements = function () {}; 69 | 70 | HTMLDOMElement.prototype.hasChildren = function () {}; 71 | 72 | HTMLDOMElement.prototype.getInnerHTML = function () {}; 73 | 74 | HTMLDOMElement.prototype.getOuterHTML = function () {}; 75 | 76 | HTMLDOMElement.prototype.cloneElement = function () {}; 77 | 78 | HTMLDOMElement.prototype.getFirstElementChild = function () {}; 79 | 80 | HTMLDOMElement.prototype.getLastElementChild = function () {}; 81 | 82 | HTMLDOMElement.prototype.getFirstNodeChild = function () {}; 83 | 84 | HTMLDOMElement.prototype.getLastNodeChild = function () {}; 85 | 86 | return HTMLDOMElement; 87 | 88 | })(this.hatemile.util.html.HTMLDOMNode); 89 | 90 | }).call(this); 91 | -------------------------------------------------------------------------------- /js/hatemile/util/html/HTMLDOMNode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).html || (base1.html = {}); 24 | 25 | this.hatemile.util.html.HTMLDOMNode = (function () { 26 | function HTMLDOMNode() {} 27 | 28 | HTMLDOMNode.prototype.getTextContent = function () {}; 29 | 30 | HTMLDOMNode.prototype.insertBefore = function (newNode) {}; 31 | 32 | HTMLDOMNode.prototype.insertAfter = function (newNode) {}; 33 | 34 | HTMLDOMNode.prototype.removeNode = function () {}; 35 | 36 | HTMLDOMNode.prototype.replaceNode = function (newNode) {}; 37 | 38 | HTMLDOMNode.prototype.appendText = function (text) {}; 39 | 40 | HTMLDOMNode.prototype.prependText = function (text) {}; 41 | 42 | HTMLDOMNode.prototype.getParentElement = function () {}; 43 | 44 | HTMLDOMNode.prototype.getData = function () {}; 45 | 46 | HTMLDOMNode.prototype.setData = function (data) {}; 47 | 48 | HTMLDOMNode.prototype.equals = function (node) {}; 49 | 50 | return HTMLDOMNode; 51 | 52 | })(); 53 | 54 | }).call(this); 55 | -------------------------------------------------------------------------------- /js/hatemile/util/html/HTMLDOMParser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1; 18 | 19 | this.hatemile || (this.hatemile = {}); 20 | 21 | (base = this.hatemile).util || (base.util = {}); 22 | 23 | (base1 = this.hatemile.util).html || (base1.html = {}); 24 | 25 | this.hatemile.util.html.HTMLDOMParser = (function () { 26 | function HTMLDOMParser() {} 27 | 28 | HTMLDOMParser.prototype.find = function (selector) {}; 29 | 30 | HTMLDOMParser.prototype.findChildren = function (selector) {}; 31 | 32 | HTMLDOMParser.prototype.findDescendants = function (selector) {}; 33 | 34 | HTMLDOMParser.prototype.findAncestors = function (selector) {}; 35 | 36 | HTMLDOMParser.prototype.firstResult = function () {}; 37 | 38 | HTMLDOMParser.prototype.lastResult = function () {}; 39 | 40 | HTMLDOMParser.prototype.listResults = function () {}; 41 | 42 | HTMLDOMParser.prototype.createElement = function (tag) {}; 43 | 44 | HTMLDOMParser.prototype.getHTML = function () {}; 45 | 46 | HTMLDOMParser.prototype.getParser = function () {}; 47 | 48 | HTMLDOMParser.prototype.clearParser = function () {}; 49 | 50 | return HTMLDOMParser; 51 | 52 | })(); 53 | 54 | }).call(this); 55 | -------------------------------------------------------------------------------- /js/hatemile/util/html/HTMLDOMTextNode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, 18 | extend = function (child, parent) { 19 | for (var key in parent) { 20 | if (hasProp.call(parent, key)) child[key] = parent[key]; 21 | } 22 | 23 | function ctor() { 24 | this.constructor = child; 25 | } 26 | ctor.prototype = parent.prototype; 27 | child.prototype = new ctor(); 28 | child.__super__ = parent.prototype; 29 | return child; 30 | }, 31 | hasProp = {}.hasOwnProperty; 32 | 33 | this.hatemile || (this.hatemile = {}); 34 | 35 | (base = this.hatemile).util || (base.util = {}); 36 | 37 | (base1 = this.hatemile.util).html || (base1.html = {}); 38 | 39 | this.hatemile.util.html.HTMLDOMTextNode = (function (superClass) { 40 | extend(HTMLDOMTextNode, superClass); 41 | 42 | function HTMLDOMTextNode() { 43 | return HTMLDOMTextNode.__super__.constructor.apply(this, arguments); 44 | } 45 | 46 | HTMLDOMTextNode.prototype.setTextContent = function (text) {}; 47 | 48 | return HTMLDOMTextNode; 49 | 50 | })(this.hatemile.util.html.HTMLDOMNode); 51 | 52 | }).call(this); 53 | -------------------------------------------------------------------------------- /js/hatemile/util/html/jquery/JQueryHTMLDOMParser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).html || (base1.html = {}); 26 | 27 | (base2 = this.hatemile.util.html).jquery || (base2.jquery = {}); 28 | 29 | this.hatemile.util.html.jquery.JQueryHTMLDOMParser = (function () { 30 | function JQueryHTMLDOMParser(html, ownerDocument) { 31 | this.root = jQuery(html); 32 | this.results = []; 33 | if (ownerDocument !== void 0) { 34 | this.ownerDocument = ownerDocument; 35 | } else if (html.ownerDocument !== void 0) { 36 | this.ownerDocument = html.ownerDocument; 37 | } else { 38 | this.ownerDocument = document; 39 | } 40 | } 41 | 42 | JQueryHTMLDOMParser.prototype.find = function (selector) { 43 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 44 | selector = selector.getData(); 45 | } 46 | this.results = this.root.find(selector); 47 | return this; 48 | }; 49 | 50 | JQueryHTMLDOMParser.prototype.findChildren = function (selector) { 51 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 52 | selector = selector.getData(); 53 | } 54 | this.results = jQuery(this.results).children(selector); 55 | return this; 56 | }; 57 | 58 | JQueryHTMLDOMParser.prototype.findDescendants = function (selector) { 59 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 60 | selector = selector.getData(); 61 | } 62 | this.results = jQuery(this.results).find(selector); 63 | return this; 64 | }; 65 | 66 | JQueryHTMLDOMParser.prototype.findAncestors = function (selector) { 67 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 68 | selector = selector.getData(); 69 | } 70 | this.results = jQuery(this.results).parents(selector); 71 | return this; 72 | }; 73 | 74 | JQueryHTMLDOMParser.prototype.firstResult = function () { 75 | if (this.results.length === 0) { 76 | return null; 77 | } 78 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.results.get(0)); 79 | }; 80 | 81 | JQueryHTMLDOMParser.prototype.lastResult = function () { 82 | if (this.results.length === 0) { 83 | return null; 84 | } 85 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.results.get(this.results.length - 1)); 86 | }; 87 | 88 | JQueryHTMLDOMParser.prototype.listResults = function () { 89 | var array, i, len, ref, result; 90 | array = []; 91 | if (this.results.length > 0) { 92 | ref = this.results; 93 | for (i = 0, len = ref.length; i < len; i++) { 94 | result = ref[i]; 95 | array.push(new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(result)); 96 | } 97 | } 98 | return array; 99 | }; 100 | 101 | JQueryHTMLDOMParser.prototype.createElement = function (tag) { 102 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.ownerDocument.createElement(tag)); 103 | }; 104 | 105 | JQueryHTMLDOMParser.prototype.getHTML = function () { 106 | return this.ownerDocument.documentElement.outerHTML; 107 | }; 108 | 109 | JQueryHTMLDOMParser.prototype.getParser = function () { 110 | return this.root; 111 | }; 112 | 113 | JQueryHTMLDOMParser.prototype.clearParser = function () { 114 | this.results = []; 115 | }; 116 | 117 | return JQueryHTMLDOMParser; 118 | 119 | })(); 120 | 121 | }).call(this); 122 | -------------------------------------------------------------------------------- /js/hatemile/util/html/vanilla/VanillaHTMLDOMElement.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).html || (base1.html = {}); 26 | 27 | (base2 = this.hatemile.util.html).vanilla || (base2.vanilla = {}); 28 | 29 | this.hatemile.util.html.vanilla.VanillaHTMLDOMElement = (function () { 30 | function VanillaHTMLDOMElement(data1) { 31 | this.data = data1; 32 | } 33 | 34 | VanillaHTMLDOMElement.prototype.getTagName = function () { 35 | return this.data.tagName.toUpperCase(); 36 | }; 37 | 38 | VanillaHTMLDOMElement.prototype.getAttribute = function (name) { 39 | if (this.hasAttribute(name)) { 40 | return this.data.getAttribute(name); 41 | } else { 42 | return null; 43 | } 44 | }; 45 | 46 | VanillaHTMLDOMElement.prototype.setAttribute = function (name, value) { 47 | this.data.setAttribute(name, value); 48 | }; 49 | 50 | VanillaHTMLDOMElement.prototype.removeAttribute = function (name) { 51 | if (this.hasAttribute(name)) { 52 | this.data.removeAttribute(name); 53 | } 54 | }; 55 | 56 | VanillaHTMLDOMElement.prototype.hasAttribute = function (name) { 57 | return this.data.hasAttribute(name); 58 | }; 59 | 60 | VanillaHTMLDOMElement.prototype.hasAttributes = function () { 61 | return this.data.hasAttributes(); 62 | }; 63 | 64 | VanillaHTMLDOMElement.prototype.getTextContent = function () { 65 | var child, childs, elementChild, i, len, text; 66 | if (this.data.textContent !== void 0) { 67 | return this.data.textContent; 68 | } 69 | if (this.data.innerText !== void 0) { 70 | return this.data.innerText; 71 | } 72 | text = ''; 73 | childs = this.data.childNodes; 74 | for (i = 0, len = childs.length; i < len; i++) { 75 | child = childs[i]; 76 | if (child.nodeType === this.data.ownerDocument.TEXT_NODE) { 77 | text += child.nodeValue; 78 | } else if (child.nodeType === this.data.ownerDocument.ELEMENT_NODE) { 79 | elementChild = new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(child); 80 | text += elementChild.getTextContent(); 81 | } 82 | } 83 | return text; 84 | }; 85 | 86 | VanillaHTMLDOMElement.prototype.insertBefore = function (newNode) { 87 | this.data.parentNode.insertBefore(newNode.getData(), this.data); 88 | return this; 89 | }; 90 | 91 | VanillaHTMLDOMElement.prototype.insertAfter = function (newNode) { 92 | var child, childs, found, i, len, parent; 93 | parent = this.data.parentNode; 94 | childs = parent.childNodes; 95 | found = false; 96 | for (i = 0, len = childs.length; i < len; i++) { 97 | child = childs[i]; 98 | if (found) { 99 | parent.insertBefore(newNode.getData(), child); 100 | return; 101 | } else if (child === this.data) { 102 | found = true; 103 | } 104 | } 105 | parent.appendChild(newNode.getData()); 106 | return this; 107 | }; 108 | 109 | VanillaHTMLDOMElement.prototype.removeNode = function () { 110 | this.data.remove(); 111 | return this; 112 | }; 113 | 114 | VanillaHTMLDOMElement.prototype.replaceNode = function (newNode) { 115 | this.data.parentNode.replaceChild(newNode.getData(), this.data); 116 | return this; 117 | }; 118 | 119 | VanillaHTMLDOMElement.prototype.appendElement = function (element) { 120 | this.data.appendChild(element.getData()); 121 | return this; 122 | }; 123 | 124 | VanillaHTMLDOMElement.prototype.prependElement = function (element) { 125 | if (this.data.childNodes.length === 0) { 126 | this.appendElement(element); 127 | } else { 128 | this.data.insertBefore(element.getData(), this.data.childNodes[0]); 129 | } 130 | return this; 131 | }; 132 | 133 | VanillaHTMLDOMElement.prototype.getChildrenElements = function () { 134 | var array, child, children, i, len; 135 | children = this.data.children; 136 | array = []; 137 | for (i = 0, len = children.length; i < len; i++) { 138 | child = children[i]; 139 | array.push(new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(child)); 140 | } 141 | return array; 142 | }; 143 | 144 | VanillaHTMLDOMElement.prototype.getChildren = function () { 145 | var array, child, children, i, len; 146 | children = this.data.childNodes; 147 | array = []; 148 | for (i = 0, len = children.length; i < len; i++) { 149 | child = children[i]; 150 | if (child.nodeType === this.data.ownerDocument.TEXT_NODE) { 151 | array.push(new self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode(child)); 152 | } else if (child.nodeType === this.data.ownerDocument.ELEMENT_NODE) { 153 | array.push(new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(child)); 154 | } 155 | } 156 | return array; 157 | }; 158 | 159 | VanillaHTMLDOMElement.prototype.appendText = function (text) { 160 | var child; 161 | child = this.getLastNodeChild(); 162 | if ((child !== null) && (child instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode)) { 163 | child.appendText(text); 164 | } else { 165 | this.data.appendChild(this.data.ownerDocument.createTextNode(text)); 166 | } 167 | return this; 168 | }; 169 | 170 | VanillaHTMLDOMElement.prototype.prependText = function (text) { 171 | var child; 172 | if (!this.hasChildren()) { 173 | this.appendText(text); 174 | } else { 175 | child = this.getFirstNodeChild(); 176 | if (child instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode) { 177 | child.prependText(text); 178 | } else { 179 | this.data.insertBefore(this.data.ownerDocument.createTextNode(text), child.getData()); 180 | } 181 | } 182 | return this; 183 | }; 184 | 185 | VanillaHTMLDOMElement.prototype.normalize = function () { 186 | if (this.data.normalize) { 187 | this.data.normalize(); 188 | } 189 | return this; 190 | }; 191 | 192 | VanillaHTMLDOMElement.prototype.hasChildrenElements = function () { 193 | return this.data.children.length > 0; 194 | }; 195 | 196 | VanillaHTMLDOMElement.prototype.hasChildren = function () { 197 | var child, children, i, len; 198 | if (!this.data.hasChildNodes()) { 199 | return false; 200 | } else { 201 | children = this.data.childNodes; 202 | for (i = 0, len = children.length; i < len; i++) { 203 | child = children[i]; 204 | if ((child.nodeType === this.data.ownerDocument.TEXT_NODE) || (child.nodeType === this.data.ownerDocument.ELEMENT_NODE)) { 205 | return true; 206 | } 207 | } 208 | return false; 209 | } 210 | }; 211 | 212 | VanillaHTMLDOMElement.prototype.getParentElement = function () { 213 | var parentNode; 214 | parentNode = this.data.parentNode; 215 | if (this.getTagName() === 'HTML') { 216 | return null; 217 | } else if ((parentNode === void 0) || (parentNode === null)) { 218 | return null; 219 | } 220 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(parentNode); 221 | }; 222 | 223 | VanillaHTMLDOMElement.prototype.getInnerHTML = function () { 224 | return this.data.innerHTML; 225 | }; 226 | 227 | VanillaHTMLDOMElement.prototype.getOuterHTML = function () { 228 | return this.data.outerHTML; 229 | }; 230 | 231 | VanillaHTMLDOMElement.prototype.getData = function () { 232 | return this.data; 233 | }; 234 | 235 | VanillaHTMLDOMElement.prototype.setData = function (data) { 236 | this.data = data; 237 | }; 238 | 239 | VanillaHTMLDOMElement.prototype.cloneElement = function () { 240 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.data.cloneNode(true)); 241 | }; 242 | 243 | VanillaHTMLDOMElement.prototype.getFirstElementChild = function () { 244 | if (!this.hasChildrenElements()) { 245 | return null; 246 | } 247 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.data.firstElementChild); 248 | }; 249 | 250 | VanillaHTMLDOMElement.prototype.getLastElementChild = function () { 251 | if (!this.hasChildrenElements()) { 252 | return null; 253 | } 254 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.data.lastElementChild); 255 | }; 256 | 257 | VanillaHTMLDOMElement.prototype.getFirstNodeChild = function () { 258 | var child, children, i, len; 259 | if (!this.hasChildren()) { 260 | return null; 261 | } 262 | children = this.data.childNodes; 263 | for (i = 0, len = children.length; i < len; i++) { 264 | child = children[i]; 265 | if (child.nodeType === this.data.ownerDocument.TEXT_NODE) { 266 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode(child); 267 | } else if (child.nodeType === this.data.ownerDocument.ELEMENT_NODE) { 268 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(child); 269 | } 270 | } 271 | return null; 272 | }; 273 | 274 | VanillaHTMLDOMElement.prototype.getLastNodeChild = function () { 275 | var child, children, i, lastChild, len; 276 | if (!this.hasChildren()) { 277 | return null; 278 | } 279 | children = this.data.childNodes; 280 | lastChild = null; 281 | for (i = 0, len = children.length; i < len; i++) { 282 | child = children[i]; 283 | if ((child.nodeType === this.data.ownerDocument.TEXT_NODE) || (child.nodeType === this.data.ownerDocument.ELEMENT_NODE)) { 284 | lastChild = child; 285 | } 286 | } 287 | if (lastChild === null) { 288 | return null; 289 | } else if (lastChild.nodeType === this.data.ownerDocument.TEXT_NODE) { 290 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode(lastChild); 291 | } else if (lastChild.nodeType === this.data.ownerDocument.ELEMENT_NODE) { 292 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(lastChild); 293 | } 294 | }; 295 | 296 | VanillaHTMLDOMElement.prototype.equals = function (node) { 297 | if (node instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 298 | if (this.data === node.getData()) { 299 | return true; 300 | } 301 | } 302 | return false; 303 | }; 304 | 305 | return VanillaHTMLDOMElement; 306 | 307 | })(); 308 | 309 | }).call(this); 310 | -------------------------------------------------------------------------------- /js/hatemile/util/html/vanilla/VanillaHTMLDOMParser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).html || (base1.html = {}); 26 | 27 | (base2 = this.hatemile.util.html).vanilla || (base2.vanilla = {}); 28 | 29 | this.hatemile.util.html.vanilla.VanillaHTMLDOMParser = (function () { 30 | var _isDescendant; 31 | 32 | _isDescendant = function (possibleAncestor, possibleDescendant) { 33 | var ancestor; 34 | ancestor = possibleDescendant.parentNode; 35 | while ((ancestor !== void 0) && (ancestor !== null)) { 36 | if (ancestor === possibleAncestor) { 37 | return true; 38 | } 39 | ancestor = ancestor.parentNode; 40 | } 41 | return false; 42 | }; 43 | 44 | function VanillaHTMLDOMParser(ownerDocument) { 45 | this.ownerDocument = ownerDocument; 46 | this.results = []; 47 | } 48 | 49 | VanillaHTMLDOMParser.prototype.find = function (selector) { 50 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 51 | this.results = [selector.getData()]; 52 | } else { 53 | this.results = this.ownerDocument.querySelectorAll(selector); 54 | } 55 | return this; 56 | }; 57 | 58 | VanillaHTMLDOMParser.prototype.findChildren = function (selector) { 59 | var children, descendant, descendants, i, j, k, l, len, len1, len2, len3, ref, ref1, ref2, result, resultChild; 60 | children = []; 61 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 62 | ref = this.results; 63 | for (i = 0, len = ref.length; i < len; i++) { 64 | result = ref[i]; 65 | ref1 = result.children; 66 | for (j = 0, len1 = ref1.length; j < len1; j++) { 67 | resultChild = ref1[j]; 68 | if (selector.getData() === resultChild) { 69 | children.push(selector.getData()); 70 | break; 71 | } 72 | } 73 | if (children.length > 0) { 74 | break; 75 | } 76 | } 77 | } else { 78 | ref2 = this.results; 79 | for (k = 0, len2 = ref2.length; k < len2; k++) { 80 | result = ref2[k]; 81 | descendants = result.querySelectorAll(selector); 82 | for (l = 0, len3 = descendants.length; l < len3; l++) { 83 | descendant = descendants[l]; 84 | if (descendant.parentNode === result) { 85 | children.push(descendant); 86 | } 87 | } 88 | } 89 | } 90 | this.results = children; 91 | return this; 92 | }; 93 | 94 | VanillaHTMLDOMParser.prototype.findDescendants = function (selector) { 95 | var descendants, i, j, k, len, len1, len2, ref, ref1, result, resultDescendant, resultDescendants; 96 | descendants = []; 97 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 98 | ref = this.results; 99 | for (i = 0, len = ref.length; i < len; i++) { 100 | result = ref[i]; 101 | if (_isDescendant(result, selector.getData())) { 102 | descendants.push(selector.getData()); 103 | break; 104 | } 105 | } 106 | } else { 107 | ref1 = this.results; 108 | for (j = 0, len1 = ref1.length; j < len1; j++) { 109 | result = ref1[j]; 110 | resultDescendants = result.querySelectorAll(selector); 111 | for (k = 0, len2 = resultDescendants.length; k < len2; k++) { 112 | resultDescendant = resultDescendants[k]; 113 | descendants.push(resultDescendant); 114 | } 115 | } 116 | } 117 | this.results = descendants; 118 | return this; 119 | }; 120 | 121 | VanillaHTMLDOMParser.prototype.findAncestors = function (selector) { 122 | var ancestors, element, elements, i, j, k, len, len1, len2, ref, ref1, result; 123 | ancestors = []; 124 | if (selector instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMElement) { 125 | ref = this.results; 126 | for (i = 0, len = ref.length; i < len; i++) { 127 | result = ref[i]; 128 | if (_isDescendant(selector.getData(), result)) { 129 | ancestors.push(selector.getData()); 130 | break; 131 | } 132 | } 133 | } else { 134 | elements = this.ownerDocument.querySelectorAll(selector); 135 | ref1 = this.results; 136 | for (j = 0, len1 = ref1.length; j < len1; j++) { 137 | result = ref1[j]; 138 | for (k = 0, len2 = elements.length; k < len2; k++) { 139 | element = elements[k]; 140 | if (_isDescendant(element, result)) { 141 | ancestors.push(element); 142 | } 143 | } 144 | } 145 | } 146 | this.results = ancestors; 147 | return this; 148 | }; 149 | 150 | VanillaHTMLDOMParser.prototype.firstResult = function () { 151 | if (this.results.length === 0) { 152 | return null; 153 | } 154 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.results[0]); 155 | }; 156 | 157 | VanillaHTMLDOMParser.prototype.lastResult = function () { 158 | if (this.results.length === 0) { 159 | return null; 160 | } 161 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.results[this.results.length - 1]); 162 | }; 163 | 164 | VanillaHTMLDOMParser.prototype.listResults = function () { 165 | var array, i, len, ref, result; 166 | array = []; 167 | ref = this.results; 168 | for (i = 0, len = ref.length; i < len; i++) { 169 | result = ref[i]; 170 | array.push(new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(result)); 171 | } 172 | return array; 173 | }; 174 | 175 | VanillaHTMLDOMParser.prototype.createElement = function (tag) { 176 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(this.ownerDocument.createElement(tag)); 177 | }; 178 | 179 | VanillaHTMLDOMParser.prototype.getHTML = function () { 180 | return this.ownerDocument.documentElement.outerHTML; 181 | }; 182 | 183 | VanillaHTMLDOMParser.prototype.getParser = function () { 184 | return this.ownerDocument; 185 | }; 186 | 187 | VanillaHTMLDOMParser.prototype.clearParser = function () { 188 | this.results = []; 189 | }; 190 | 191 | return VanillaHTMLDOMParser; 192 | 193 | })(); 194 | 195 | }).call(this); 196 | -------------------------------------------------------------------------------- /js/hatemile/util/html/vanilla/VanillaHTMLDOMTextNode.js: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | (function () { 16 | 'use strict'; 17 | var base, base1, base2, self; 18 | 19 | self = this; 20 | 21 | this.hatemile || (this.hatemile = {}); 22 | 23 | (base = this.hatemile).util || (base.util = {}); 24 | 25 | (base1 = this.hatemile.util).html || (base1.html = {}); 26 | 27 | (base2 = this.hatemile.util.html).vanilla || (base2.vanilla = {}); 28 | 29 | this.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode = (function () { 30 | function VanillaHTMLDOMTextNode(data1) { 31 | this.data = data1; 32 | } 33 | 34 | VanillaHTMLDOMTextNode.prototype.setTextContent = function (text) { 35 | this.data.nodeValue = text; 36 | }; 37 | 38 | VanillaHTMLDOMTextNode.prototype.getTextContent = function () { 39 | return this.data.nodeValue; 40 | }; 41 | 42 | VanillaHTMLDOMTextNode.prototype.insertBefore = function (newNode) { 43 | this.data.parentNode.insertBefore(newNode.getData(), this.data); 44 | return this; 45 | }; 46 | 47 | VanillaHTMLDOMTextNode.prototype.insertAfter = function (newNode) { 48 | var child, childs, found, i, len, parent; 49 | parent = this.data.parentNode; 50 | childs = parent.childNodes; 51 | found = false; 52 | for (i = 0, len = childs.length; i < len; i++) { 53 | child = childs[i]; 54 | if (found) { 55 | parent.insertBefore(newNode.getData(), child); 56 | return; 57 | } else if (child === this.data) { 58 | found = true; 59 | } 60 | } 61 | parent.appendChild(newNode.getData()); 62 | return this; 63 | }; 64 | 65 | VanillaHTMLDOMTextNode.prototype.removeNode = function () { 66 | this.data.remove(); 67 | return this; 68 | }; 69 | 70 | VanillaHTMLDOMTextNode.prototype.replaceNode = function (newNode) { 71 | this.data.parentNode.replaceChild(newNode.getData(), this.data); 72 | return this; 73 | }; 74 | 75 | VanillaHTMLDOMTextNode.prototype.appendText = function (text) { 76 | this.setTextContent("" + (this.getTextContent()) + text); 77 | return this; 78 | }; 79 | 80 | VanillaHTMLDOMTextNode.prototype.prependText = function (text) { 81 | this.setTextContent("" + text + (this.getTextContent())); 82 | return this; 83 | }; 84 | 85 | VanillaHTMLDOMTextNode.prototype.getParentElement = function () { 86 | var parentNode; 87 | parentNode = this.data.parentNode; 88 | if ((parentNode === void 0) || (parentNode === null)) { 89 | return null; 90 | } 91 | return new self.hatemile.util.html.vanilla.VanillaHTMLDOMElement(parentNode); 92 | }; 93 | 94 | VanillaHTMLDOMTextNode.prototype.getData = function () { 95 | return this.data; 96 | }; 97 | 98 | VanillaHTMLDOMTextNode.prototype.setData = function (data) { 99 | this.data = data; 100 | }; 101 | 102 | VanillaHTMLDOMTextNode.prototype.equals = function (node) { 103 | if (node instanceof self.hatemile.util.html.vanilla.VanillaHTMLDOMTextNode) { 104 | if (this.data === node.getData()) { 105 | return true; 106 | } 107 | } 108 | return false; 109 | }; 110 | 111 | return VanillaHTMLDOMTextNode; 112 | 113 | })(); 114 | 115 | }).call(this); 116 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hatemile-for-javascript", 3 | "version": "2.0.0", 4 | "description": "HaTeMiLe (HTML Accessible) is a library that can convert a HTML code in a HTML code more accessible.", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/hatemile/hatemile-for-javascript.git" 11 | }, 12 | "keywords": [ 13 | "accessibility", 14 | "assistive-technology", 15 | "screen-reader", 16 | "wcag", 17 | "wai-aria" 18 | ], 19 | "author": "Carlson Santana Cruz", 20 | "license": "Apache-2.0", 21 | "bugs": { 22 | "url": "https://github.com/hatemile/hatemile-for-javascript/issues" 23 | }, 24 | "homepage": "https://github.com/hatemile/hatemile-for-javascript#readme", 25 | "devDependencies": { 26 | "grunt": "^1.0.1", 27 | "grunt-codo": "^0.3.0", 28 | "grunt-coffeelint": "0.0.16", 29 | "grunt-contrib-coffee": "^1.0.0", 30 | "grunt-js-beautify": "^0.1.4" 31 | } 32 | } 33 | --------------------------------------------------------------------------------