diff --git a/Gemfile b/Gemfile index 78f0cdb3..e9197ff6 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,8 @@ gem 'rails', '~> 5.0.1' gem 'puma', '~> 3.0' # Use Puma as the app server +gem 'turbolinks', '~> 5' # Turbolinks makes navigating your web application faster + gem 'rails-i18n' # Locale data gem 'slim-rails' # Awesome template language that replaces ERB @@ -111,6 +113,7 @@ group :development do gem 'better_errors' # gem 'binding_of_caller' # Adds a REPL console to error pages (disabled, because it's very slow, see https://github.com/charliesome/better_errors/issues/341) + # Doesn't work with turbolinks?! gem 'xray-rails' # Reveals your UI's bones with Cmd-X/Ctrl-X # Rails application preloader diff --git a/Gemfile.lock b/Gemfile.lock index ab765080..250cbeac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -435,6 +435,9 @@ GEM tilt (2.0.5) timeliness (0.3.8) tins (1.13.0) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.0) tzinfo (1.2.2) thread_safe (~> 0.1) uglifier (3.0.4) @@ -541,6 +544,7 @@ DEPENDENCIES sqlite3 strip_attributes terminal-notifier-guard + turbolinks (~> 5) tzinfo-data uglifier (>= 1.3.0) validates_timeliness diff --git a/app/assets/javascripts/a11yfy.js b/app/assets/javascripts/a11yfy.js new file mode 100644 index 00000000..e21b0d01 --- /dev/null +++ b/app/assets/javascripts/a11yfy.js @@ -0,0 +1,465 @@ +###* +# +# jQuery module for accessibility +# +# The MIT License (MIT) +# +# Copyright (c) 2013, 2014 Dylan Barrell +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +### + +do (jQuery) -> + $politeAnnouncer = jQuery('#jquery-a11yfy-politeannouncer') + $assertiveAnnouncer = jQuery('#jquery-a11yfy-assertiveannouncer') + methods = + showAndFocus: (focus) -> + $focus = if focus then jQuery(focus) else focus + @each (index, value) -> + $this = jQuery(value) + $this.show() + if $focus and $focus.length + if platform == 'iOS' + jQuery('body').focus() + setTimeout (-> + $focus.focus() + return + ), 1000 + else + $focus.focus() + return + focus: -> + @each (index, value) -> + $this = jQuery(value) + if platform == 'iOS' + jQuery('body').focus() + setTimeout (-> + $this.focus() + return + ), 1000 + else + $this.focus() + return + validate: (options) -> + opts = jQuery.extend({}, jQuery.fn.a11yfy.defaults.validate, options) + @each (index, value) -> + $this = jQuery(value) + vOptions = jQuery.extend({}, opts.validatorOptions, + invalidHandler: invalidHandler + errorPlacement: errorPlacement + showErrors: showErrors) + + errorPlacement = -> + # do nothing - overrides default behavior + return + + showErrors = -> + # do nothing - overrides default behavior + return + + invalidHandler = (event, validator) -> + `var $this` + id = undefined + invalidIds = [] + $this = jQuery(this) + $errorSummary = $this.find('.a11yfy-error-summary') + $errorSummaryList = jQuery('