fg-collapsible
Advanced tools
Comparing version 0.6.0 to 0.7.0
{ | ||
"name": "fg-collapsible", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Toggle your collapsible content", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -89,14 +89,38 @@ /* | ||
this._addA11yAttrs(); | ||
this.content.addClass( this.options.contentClass ); | ||
}, | ||
_addA11yAttrs: function(){ | ||
this.header.attr( "role", "button" ); | ||
this.header.attr( "tabindex", "0" ); | ||
if( this.options.instructions ){ | ||
this.header.attr( "title", this.options.instructions ); | ||
} | ||
}, | ||
this.header.attr( "role", "button" ); | ||
_removeA11yAttrs: function(){ | ||
this.header.removeAttr( "role" ); | ||
this.header.removeAttr( "tabindex" ); | ||
this.header.removeAttr( "title" ); | ||
}, | ||
this.header.attr( "tabindex", "0" ); | ||
_isNonInteractive: function(){ | ||
var computedContent = window.getComputedStyle( this.content[ 0 ], null ); | ||
var computedHeader = window.getComputedStyle( this.header[ 0 ], null ); | ||
return computedContent.getPropertyValue( "display" ) !== "none" && computedContent.getPropertyValue( "visibility" ) !== "hidden" && computedHeader.getPropertyValue( "cursor" ) === "default"; | ||
}, | ||
this.content.addClass( this.options.contentClass ); | ||
_checkInteractivity: function(){ | ||
if( this._isNonInteractive() ){ | ||
this._removeA11yAttrs(); | ||
} | ||
else{ | ||
this._addA11yAttrs(); | ||
} | ||
}, | ||
_bindEvents: function(){ | ||
@@ -125,2 +149,14 @@ var self = this; | ||
} | ||
this._checkInteractivity(); | ||
var resizepoll; | ||
$( window ).bind( "resize", function(){ | ||
if( resizepoll ){ | ||
clearTimeout( resizepoll ); | ||
} | ||
resizepoll = setTimeout( function(){ | ||
self._checkInteractivity.call( self ); | ||
}, 150 ); | ||
} ); | ||
}, | ||
@@ -134,2 +170,3 @@ | ||
this.element.addClass( this.options.expandedClass ); | ||
this.header.attr( "aria-expanded", "true" ); | ||
this.collapsed = false; | ||
@@ -148,2 +185,3 @@ }, | ||
this.element.removeClass( this.options.expandedClass ); | ||
this.header.attr( "aria-expanded", "false" ); | ||
this.collapsed = true; | ||
@@ -150,0 +188,0 @@ }, |
@@ -30,2 +30,5 @@ /* | ||
}) | ||
.bind( "mousemove." + pluginName, function(){ | ||
touchCancel = true; | ||
}) | ||
.bind( "touchstart." + pluginName + " pointerdown." + pluginName + " MSPointerDown." + pluginName, function( a ){ | ||
@@ -67,3 +70,3 @@ targetTop = a.target.getBoundingClientRect().top; | ||
var exclusiveHover = $collapsible.is( "[data-collapsible-hover='exclusive']" ); | ||
var mouseovertimestamp = 0; | ||
var mouseovertimestamp; | ||
@@ -94,2 +97,3 @@ if( hover ){ | ||
.bind( "mouseleave." + pluginName, function(){ | ||
mouseovertimestamp = null; | ||
if( !startedByTouch && isMenu() && $( e.target ).is( $collapsible ) ){ | ||
@@ -101,3 +105,7 @@ $collapsible.data( pluginName ).collapse(); | ||
.bind( "click", function( e ){ | ||
if( !mouseovertimestamp ){ | ||
return; | ||
} | ||
var timesincemouseover = new Date().getTime() - mouseovertimestamp; | ||
if( $( e.target ).is( self.header ) && isMenu() && $( e.target ).is( "a[href]" ) && !startedByTouch && timesincemouseover > 300 ){ | ||
@@ -189,6 +197,8 @@ window.location.href = e.target.href; | ||
} | ||
}); | ||
} | ||
@@ -195,0 +205,0 @@ } ); |
@@ -19,3 +19,9 @@ /* collapsible extension for navbar functionality */ | ||
$moreBtn.attr( "aria-label", "Navigation" ); | ||
$moreBtn | ||
.attr( "aria-label", "More items" ) | ||
.bind( "click", function(){ | ||
if( $collapsible.is( ".collapsible-expanded" ) ){ | ||
$collapsible.find( "." + itemMenuClass ).eq(0).focus(); | ||
} | ||
} ); | ||
@@ -22,0 +28,0 @@ var resetItems = function(){ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
337500
9530