#PubShlub
do ($) ->
a = {}
$.publish = (d, c) ->
a[d] and $.each(a[d], ->
if @apply
@apply $, c or []
)| /* | |
| $(selector).access(focus_only) | |
| @param(bool): focus_only - true, false(default) | |
| Problem: | |
| Manually managing focus is cumbersome and pollutes the DOM with @tabindex. | |
| Solution: |
| /* | |
| $.announce(message, method) | |
| @param(string): message - string of text to be spoken | |
| @param(string): method - polite(default), assertive | |
| Problem: | |
| Using multiple @aria-live throughout your app adds complexity and makes it more difficult to control what is spoken when. |
| if typeof Object.create isnt "function" | |
| Object.create = (o, props) -> | |
| F = -> | |
| F:: = o | |
| if typeof (props) is "object" | |
| for prop of props | |
| F[prop] = props[prop] if props.hasOwnProperty((prop)) | |
| new F() |
| $.get_named_guid = function(handle, get_new) { | |
| var _base, | |
| _name = "_" + handle; | |
| get_new = get_new || false; | |
| $.guid = $.guid || 0; | |
| $.named_guids = $.named_guids || []; | |
| _base = $.named_guids["_" + handle]; | |
| if (_base[_name] === null) { |
| $.get_guid = function(get_new) { | |
| get_new = get_new || false; | |
| if ($.guid === null) { | |
| $.guid = 0; | |
| } | |
| if (get_new) { | |
| $.guid++; | |
| } | |
| return $.guid; | |
| }; |
| (function () { | |
| var init, onclick_tracked_item, selector, track_event, track_page, tracked_actions; | |
| selector = '[data-a7s]'; | |
| init = function() { | |
| return $(selector).on('click', onclick_tracked_item); | |
| }; |
#PubShlub
do ($) ->
a = {}
$.publish = (d, c) ->
a[d] and $.each(a[d], ->
if @apply
@apply $, c or []
)##Throttlr Throttle your window events
Throttlr =
dom_event: null
timeout: null
pubsub_event: null
publish_event: ->
#specify your own publish method here, or use PubShlub - https://gist.github.com/patrickfox/c9d29ab6f319364dfe3f
$.publish @pubsub_event| /* | |
| # announce_view_loaded | |
| Requirements: | |
| - An element with `data-page-title` whose: | |
| - text content is the page title: `<h2 data-page-title="">About Us</h2>` -> "About Us" will be used | |
| - value is the page title: `<h3 data-page-title="Real page title">Displayed Heading</h3>` -> "Real page title" will be used | |
| - An announcer element with an ID of `a11y_announcer` - this element needs to be in the DOM at page load and left alone (e.g. not destroyed or moved) | |
| const site_title = '{Your site's name/title} - '; |
| import Ember from 'ember'; | |
| import {announce_view_loaded} from './../helpers/utils'; | |
| export default Ember.Route.extend({ | |
| renderTemplate(args) { | |
| this._super(...args); | |
| //this.render('about'); | |
| Ember.run.scheduleOnce('afterRender', this, function() { | |
| console.log('afterRender'); | |
| announce_view_loaded(); |