Commit b842620e authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Use non-minified version of bootstrap-accessibility"

parents 45f29a68 d2d8b8e3
/*! bootstrap-accessibility-plugin - v1.0.4 - 2014-11-03
* https://github.com/paypal/bootstrap-accessibility-plugin
* Copyright (c) 2014 PayPal Accessibility Team; Licensed BSD */
!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){var modalOpener=this.$element.parent().find('[data-target="#'+this.$element.attr("id")+'"]');modalhide.apply(this,arguments),modalOpener.focus(),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var focEls=this.$element.find(":tabbable"),lastEl=focEls[focEls.length-1];$(document).on("keydown.bs.modal",$.proxy(function(ev){!this.$element.has(ev.target).length&&ev.shiftKey&&9===ev.keyCode&&(lastEl.focus(),ev.preventDefault())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.modal",$.proxy(function(){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}),$(toggle).parent().on("hidden.bs.dropdown",function(){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(){var $this=$(this),that=this;setTimeout(function(){$.contains(that,document.activeElement)||($this.parent().removeClass("open"),$this.parent().find("[data-toggle=dropdown]").attr("aria-expanded","false"))},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse");colltab.attr("id",collid),collparent&&(colltab.attr({role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.hasClass("in")?(colltab.attr({"aria-controls":collpanel.attr("id"),"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({role:"tabpanel",tabindex:"0","aria-labelledby":collid,"aria-hidden":"false"})):(colltab.attr({"aria-controls":collpanel.attr("id"),tabindex:"-1"}),collpanel.attr({role:"tabpanel",tabindex:"-1","aria-labelledby":collid,"aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){{var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent}this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.click(),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(){var $this=$(this),prev=$this.find('[data-slide="prev"]'),next=$this.find('[data-slide="next"]'),$options=$this.find(".item"),$listbox=$options.parent();$this.attr({"data-interval":"false","data-wrap":"false"}),$listbox.attr("role","listbox"),$options.attr("role","option");var spanPrev=document.createElement("span");spanPrev.setAttribute("class","sr-only"),spanPrev.innerHTML="Previous";var spanNext=document.createElement("span");spanNext.setAttribute("class","sr-only"),spanNext.innerHTML="Next",prev.attr("role","button"),next.attr("role","button"),prev.append(spanPrev),next.append(spanNext),$options.each(function(){var item=$(this);item.attr(item.hasClass("active")?{"aria-selected":"true",tabindex:"0"}:{"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $active=this.$element.find(".item.active"),$next=next||$active[type]();slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){$active.attr({"aria-selected":!1,tabIndex:"-1"}),$next.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$ul=$this.closest("div[role=listbox]"),$items=$ul.find("[role=option]"),$parent=$ul.parent(),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$items.index($items.filter(".active")),(37==k||38==k)&&(index--,0>index?index=$items.length-1:($parent.carousel("prev"),setTimeout(function(){$items[index].focus()},150))),(39==k||40==k)&&(index++,index==$items.length?index=0:($parent.carousel("next"),setTimeout(function(){$items[index].focus()},150))),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","div[role=option]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery);
bootstrap-accessibility-plugin
==============================
Website: https://github.com/paypal/bootstrap-accessibility-plugin/
Version: 3.1.1
Changes:
* None
/* ========================================================================
* Extends Bootstrap v3.1.1
* Copyright (c) <2014> eBay Software Foundation
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of eBay or any of its subsidiaries or affiliates nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ======================================================================== */
(function($) {
"use strict";
// GENERAL UTILITY FUNCTIONS
// ===============================
var uniqueId = function(prefix) {
return (prefix || 'ui-id') + '-' + Math.floor((Math.random()*1000)+1)
}
var removeMultiValAttributes = function (el, attr, val) {
var describedby = (el.attr( attr ) || "").split( /\s+/ )
, index = $.inArray(val, describedby)
if ( index !== -1 ) {
describedby.splice( index, 1 )
}
describedby = $.trim( describedby.join( " " ) )
if (describedby ) {
el.attr( attr, describedby )
} else {
el.removeAttr( attr )
}
}
// selectors Courtesy: https://github.com/jquery/jquery-ui/blob/master/ui/core.js
var focusable = function ( element, isTabIndexNotNaN ) {
var map, mapName, img,
nodeName = element.nodeName.toLowerCase();
if ( "area" === nodeName ) {
map = element.parentNode;
mapName = map.name;
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
return false;
}
img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
return !!img && visible( img );
}
return ( /input|select|textarea|button|object/.test( nodeName ) ?
!element.disabled :
"a" === nodeName ?
element.href || isTabIndexNotNaN :isTabIndexNotNaN) && visible( element ); // the element and all of its ancestors must be visible
}
var visible = function ( element ) {
return $.expr.filters.visible( element ) &&
!$( element ).parents().addBack().filter(function() {
return $.css( this, "visibility" ) === "hidden";
}).length;
}
$.extend( $.expr[ ":" ], {
data: $.expr.createPseudo ?
$.expr.createPseudo(function( dataName ) {
return function( elem ) {
return !!$.data( elem, dataName );
};
}) :
// support: jQuery <1.8
function( elem, i, match ) {
return !!$.data( elem, match[ 3 ] );
},
focusable: function( element ) {
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
},
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
isTabIndexNaN = isNaN( tabIndex );
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
}
});
// Modal Extension
// ===============================
$('.modal-dialog').attr( {'role' : 'document'})
var modalhide = $.fn.modal.Constructor.prototype.hide
$.fn.modal.Constructor.prototype.hide = function(){
var modalOpener = this.$element.parent().find('[data-target="#' + this.$element.attr('id') + '"]')
modalhide.apply(this, arguments)
modalOpener.focus()
$(document).off('keydown.bs.modal')
}
var modalfocus = $.fn.modal.Constructor.prototype.enforceFocus
$.fn.modal.Constructor.prototype.enforceFocus = function(){
var focEls = this.$element.find(":tabbable")
, lastEl = focEls[focEls.length-1]
$(document).on('keydown.bs.modal', $.proxy(function (ev) {
if(!this.$element.has(ev.target).length && ev.shiftKey && ev.keyCode === 9) {
lastEl.focus()
ev.preventDefault();
}
}, this))
modalfocus.apply(this, arguments)
}
// DROPDOWN Extension
// ===============================
var toggle = '[data-toggle=dropdown]'
, $par
, firstItem
, focusDelay = 200
, menus = $(toggle).parent().find('ul').attr('role','menu')
, lis = menus.find('li').attr('role','presentation')
lis.find('a').attr({'role':'menuitem', 'tabIndex':'-1'})
$(toggle).attr({ 'aria-haspopup':'true', 'aria-expanded': 'false'})
$(toggle).parent().on('shown.bs.dropdown',function(e){
$par = $(this)
var $toggle = $par.find(toggle)
$toggle.attr('aria-expanded','true')
$toggle.on('keydown.bs.dropdown', $.proxy(function (ev) {
setTimeout(function(){
firstItem = $('.dropdown-menu [role=menuitem]:visible', $par)[0]
try{ firstItem.focus()} catch(ex) {}
}, focusDelay)
}, this))
})
$(toggle).parent().on('hidden.bs.dropdown',function(e){
$par = $(this)
var $toggle = $par.find(toggle)
$toggle.attr('aria-expanded','false')
})
$(document)
.on('focusout.dropdown.data-api', '.dropdown-menu', function(e){
var $this = $(this)
, that = this
setTimeout(function() {
if(!$.contains(that, document.activeElement)){
$this.parent().removeClass('open')
$this.parent().find('[data-toggle=dropdown]').attr('aria-expanded','false')
}
}, 150)
})
.on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , $.fn.dropdown.Constructor.prototype.keydown)
// Tab Extension
// ===============================
var $tablist = $('.nav-tabs, .nav-pills')
, $lis = $tablist.children('li')
, $tabs = $tablist.find('[data-toggle="tab"], [data-toggle="pill"]')
if($tabs){
$tablist.attr('role', 'tablist')
$lis.attr('role', 'presentation')
$tabs.attr('role', 'tab')
}
$tabs.each(function( index ) {
var tabpanel = $($(this).attr('href'))
, tab = $(this)
, tabid = tab.attr('id') || uniqueId('ui-tab')
tab.attr('id', tabid)
if(tab.parent().hasClass('active')){
tab.attr( { 'tabIndex' : '0', 'aria-selected' : 'true', 'aria-controls': tab.attr('href').substr(1) } )
tabpanel.attr({ 'role' : 'tabpanel', 'tabIndex' : '0', 'aria-hidden' : 'false', 'aria-labelledby':tabid })
}else{
tab.attr( { 'tabIndex' : '-1', 'aria-selected' : 'false', 'aria-controls': tab.attr('href').substr(1) } )
tabpanel.attr( { 'role' : 'tabpanel', 'tabIndex' : '-1', 'aria-hidden' : 'true', 'aria-labelledby':tabid } )
}
})
$.fn.tab.Constructor.prototype.keydown = function (e) {
var $this = $(this)
, $items
, $ul = $this.closest('ul[role=tablist] ')
, index
, k = e.which || e.keyCode
$this = $(this)
if (!/(37|38|39|40)/.test(k)) return
$items = $ul.find('[role=tab]:visible')
index = $items.index($items.filter(':focus'))
if (k == 38 || k == 37) index-- // up & left
if (k == 39 || k == 40) index++ // down & right
if(index < 0) index = $items.length -1
if(index == $items.length) index = 0
var nextTab = $items.eq(index)
if(nextTab.attr('role') ==='tab'){
nextTab.tab('show') //Comment this line for dynamically loaded tabPabels, to save Ajax requests on arrow key navigation
.focus()
}
// nextTab.focus()
e.preventDefault()
e.stopPropagation()
}
$(document).on('keydown.tab.data-api','[data-toggle="tab"], [data-toggle="pill"]' , $.fn.tab.Constructor.prototype.keydown)
var tabactivate = $.fn.tab.Constructor.prototype.activate;
$.fn.tab.Constructor.prototype.activate = function (element, container, callback) {
var $active = container.find('> .active')
$active.find('[data-toggle=tab], [data-toggle=pill]').attr({ 'tabIndex' : '-1','aria-selected' : false })
$active.filter('.tab-pane').attr({ 'aria-hidden' : true,'tabIndex' : '-1' })
tabactivate.apply(this, arguments)
element.addClass('active')
element.find('[data-toggle=tab], [data-toggle=pill]').attr({ 'tabIndex' : '0','aria-selected' : true })
element.filter('.tab-pane').attr({ 'aria-hidden' : false,'tabIndex' : '0' })
}
// Collapse Extension
// ===============================
var $colltabs = $('[data-toggle="collapse"]')
$colltabs.each(function( index ) {
var colltab = $(this)
, collpanel = (colltab.attr('data-target')) ? $(colltab.attr('data-target')) : $(colltab.attr('href'))
, parent = colltab.attr('data-parent')
, collparent = parent && $(parent)
, collid = colltab.attr('id') || uniqueId('ui-collapse')
colltab.attr('id', collid)
if(collparent){
colltab.attr({ 'role':'tab', 'aria-selected':'false', 'aria-expanded':'false' })
$(collparent).find('div:not(.collapse,.panel-body), h4').attr('role','presentation')
collparent.attr({ 'role' : 'tablist', 'aria-multiselectable' : 'true' })
if(collpanel.hasClass('in')){
colltab.attr({ 'aria-controls': collpanel.attr('id'), 'aria-selected':'true', 'aria-expanded':'true', 'tabindex':'0' })
collpanel.attr({ 'role':'tabpanel', 'tabindex':'0', 'aria-labelledby':collid, 'aria-hidden':'false' })
}else{
colltab.attr({'aria-controls' : collpanel.attr('id'), 'tabindex':'-1' })
collpanel.attr({ 'role':'tabpanel', 'tabindex':'-1', 'aria-labelledby':collid, 'aria-hidden':'true' })
}
}
})
var collToggle = $.fn.collapse.Constructor.prototype.toggle
$.fn.collapse.Constructor.prototype.toggle = function(){
var prevTab = this.$parent && this.$parent.find('[aria-expanded="true"]') , href
if(prevTab){
var prevPanel = prevTab.attr('data-target') || (href = prevTab.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')
, $prevPanel = $(prevPanel)
, $curPanel = this.$element
, par = this.$parent
, curTab
if (this.$parent) curTab = this.$parent.find('[data-toggle=collapse][href="#' + this.$element.attr('id') + '"]')
collToggle.apply(this, arguments)
if ($.support.transition) {
this.$element.one($.support.transition.end, function(){
prevTab.attr({ 'aria-selected':'false','aria-expanded':'false', 'tabIndex':'-1' })
$prevPanel.attr({ 'aria-hidden' : 'true','tabIndex' : '-1'})
curTab.attr({ 'aria-selected':'true','aria-expanded':'true', 'tabIndex':'0' })
if($curPanel.hasClass('in')){
$curPanel.attr({ 'aria-hidden' : 'false','tabIndex' : '0' })
}else{
curTab.attr({ 'aria-selected':'false','aria-expanded':'false'})
$curPanel.attr({ 'aria-hidden' : 'true','tabIndex' : '-1' })
}
})
}
}else{
collToggle.apply(this, arguments)
}
}
$.fn.collapse.Constructor.prototype.keydown = function (e) {
var $this = $(this)
, $items
, $tablist = $this.closest('div[role=tablist] ')
, index
, k = e.which || e.keyCode
$this = $(this)
if (!/(32|37|38|39|40)/.test(k)) return
if(k==32) $this.click()
$items = $tablist.find('[role=tab]')
index = $items.index($items.filter(':focus'))
if (k == 38 || k == 37) index-- // up & left
if (k == 39 || k == 40) index++ // down & right
if(index < 0) index = $items.length -1
if(index == $items.length) index = 0
$items.eq(index).focus()
e.preventDefault()
e.stopPropagation()
}
$(document).on('keydown.collapse.data-api','[data-toggle="collapse"]' , $.fn.collapse.Constructor.prototype.keydown)
// Carousel Extension
// ===============================
$('.carousel').each(function (index) {
var $this = $(this)
, prev = $this.find('[data-slide="prev"]')
, next = $this.find('[data-slide="next"]')
, $options = $this.find('.item')
, $listbox = $options.parent()
$this.attr( { 'data-interval' : 'false', 'data-wrap' : 'false' } )
$listbox.attr('role', 'listbox')
$options.attr('role', 'option')
var spanPrev = document.createElement('span')
spanPrev.setAttribute('class', 'sr-only')
spanPrev.innerHTML='Previous'
var spanNext = document.createElement('span')
spanNext.setAttribute('class', 'sr-only')
spanNext.innerHTML='Next'
prev.attr('role', 'button')
next.attr('role', 'button')
prev.append(spanPrev)
next.append(spanNext)
$options.each(function () {
var item = $(this)
if(item.hasClass('active')){
item.attr({ 'aria-selected': 'true', 'tabindex' : '0' })
}else{
item.attr({ 'aria-selected': 'false', 'tabindex' : '-1' })
}
})
})
var slideCarousel = $.fn.carousel.Constructor.prototype.slide
$.fn.carousel.Constructor.prototype.slide = function (type, next) {
var $active = this.$element.find('.item.active')
, $next = next || $active[type]()
slideCarousel.apply(this, arguments)
$active
.one('bsTransitionEnd', function () {
$active.attr({'aria-selected':false, 'tabIndex': '-1'})
$next.attr({'aria-selected':true, 'tabIndex': '0'})
//.focus()
})
}
var $this;
$.fn.carousel.Constructor.prototype.keydown = function (e) {
$this = $this || $(this)
if(this instanceof Node) $this = $(this)
var $ul = $this.closest('div[role=listbox]')
, $items = $ul.find('[role=option]')
, $parent = $ul.parent()
, k = e.which || e.keyCode
, index
, i
if (!/(37|38|39|40)/.test(k)) return
index = $items.index($items.filter('.active'))
if (k == 37 || k == 38) { // Up
index--
if(index < 0) index = $items.length -1
else {
$parent.carousel('prev')
setTimeout(function () {
$items[index].focus()
// $this.prev().focus()
}, 150)
}
}
if (k == 39 || k == 40) { // Down
index++
if(index == $items.length) {
index = 0
}
else {
$parent.carousel('next')
setTimeout(function () {
$items[index].focus()
// $this.next().focus()
}, 150)
}
}
e.preventDefault()
e.stopPropagation()
}
$(document).on('keydown.carousel.data-api', 'div[role=option]', $.fn.carousel.Constructor.prototype.keydown)
})(jQuery);
......@@ -39,7 +39,7 @@
{/foreach}
<script type="application/javascript" src="{$WWWROOT}/lib/bootstrap/assets/javascripts/bootstrap.js?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{$WWWROOT}/js/javascript-templates/js/tmpl.min.js?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{theme_url filename='js/bootstrap-accessibility.min.js'}?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{theme_url filename='js/bootstrap-accessibility/bootstrap-accessibility.js'}?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{$WWWROOT}js/jquery.rating.js?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{theme_url filename='js/masonry.min.js'}?v={$CACHEVERSION}"></script>
<script type="application/javascript" src="{$WWWROOT}/js/select2/select2.full.js?v={$CACHEVERSION}"></script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment