@hmcts/frontend
Advanced tools
Comparing version 0.0.18-alpha to 0.0.19-alpha
85
all.js
@@ -74,2 +74,87 @@ var HMCTSFrontend = {}; | ||
}; | ||
HMCTSFrontend.FilterToggleButton = function(options) { | ||
this.options = options; | ||
this.container = this.options.toggleButton.container; | ||
this.createToggleButton(); | ||
this.setupResponsiveChecks(); | ||
this.options.filter.container.attr('tabindex', '-1'); | ||
if(this.options.startHidden) { | ||
this.hideMenu(); | ||
} | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.setupResponsiveChecks = function() { | ||
this.mq = window.matchMedia(this.options.bigModeMediaQuery); | ||
this.mq.addListener($.proxy(this, 'checkMode')); | ||
this.checkMode(this.mq); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.createToggleButton = function() { | ||
this.menuButton = $('<button class="govuk-button '+this.options.toggleButton.classes+'" type="button" aria-haspopup="true" aria-expanded="false">'+this.options.toggleButton.showText+'</button>'); | ||
this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick')); | ||
this.options.toggleButton.container.append(this.menuButton); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.checkMode = function(mq) { | ||
if(mq.matches) { | ||
this.enableBigMode(); | ||
} else { | ||
this.enableSmallMode(); | ||
} | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.enableBigMode = function() { | ||
this.showMenu(); | ||
this.removeCloseButton(); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.enableSmallMode = function() { | ||
this.hideMenu(); | ||
this.addCloseButton(); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.addCloseButton = function() { | ||
if(this.options.closeButton) { | ||
this.closeButton = $('<button class="hmcts-filter__close" type="button">'+this.options.closeButton.text+'</button>'); | ||
this.closeButton.on('click', $.proxy(this, 'onCloseClick')); | ||
this.options.closeButton.container.append(this.closeButton); | ||
} | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.onCloseClick = function() { | ||
this.hideMenu(); | ||
this.menuButton.focus(); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.removeCloseButton = function() { | ||
if(this.closeButton) { | ||
this.closeButton.remove(); | ||
this.closeButton = null; | ||
} | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.hideMenu = function() { | ||
this.menuButton.attr('aria-expanded', 'false'); | ||
this.options.filter.container.hide(); | ||
this.menuButton.text(this.options.toggleButton.showText); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.showMenu = function() { | ||
this.menuButton.attr('aria-expanded', 'true'); | ||
this.options.filter.container.show(); | ||
this.menuButton.text(this.options.toggleButton.hideText); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.onMenuButtonClick = function() { | ||
this.toggle(); | ||
}; | ||
HMCTSFrontend.FilterToggleButton.prototype.toggle = function() { | ||
if(this.menuButton.attr('aria-expanded') == 'false') { | ||
this.showMenu(); | ||
this.options.filter.container.focus(); | ||
} else { | ||
this.hideMenu(); | ||
} | ||
}; | ||
HMCTSFrontend.Menu = function(params) { | ||
@@ -76,0 +161,0 @@ this.container = params.container; |
{ | ||
"name": "@hmcts/frontend", | ||
"description": "HMCTS Frontend contains the code you need to start building a user interface for HMCTS.", | ||
"version": "0.0.18-alpha", | ||
"version": "0.0.19-alpha", | ||
"main": "all.js", | ||
@@ -6,0 +6,0 @@ "sass": "all.scss", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
401982
84
8477