summaryrefslogtreecommitdiff
path: root/lib/scripts/behaviour.js
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2015-07-15 21:44:22 +0200
committerAndreas Gohr <andi@splitbrain.org>2015-07-15 21:44:22 +0200
commit82246f10eb9ae3debeadf5913232105aa2694cec (patch)
treeceb75d1d8d023c364a13144c9cf0e4f66d12784a /lib/scripts/behaviour.js
parent0c24c9242169cfbb3e5dd68f8b094624a2c971f3 (diff)
downloadrpg-82246f10eb9ae3debeadf5913232105aa2694cec.tar.gz
rpg-82246f10eb9ae3debeadf5913232105aa2694cec.tar.bz2
improve aria attribute handling. closes #1142
adds aria handling to makeToggle and allows to supress it in dw_toggle
Diffstat (limited to 'lib/scripts/behaviour.js')
-rw-r--r--lib/scripts/behaviour.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js
index 97955dad9..b05949a90 100644
--- a/lib/scripts/behaviour.js
+++ b/lib/scripts/behaviour.js
@@ -1,37 +1,41 @@
/**
* Hides elements with a slide animation
*
- * @param fn optional callback to run after hiding
+ * @param {function} fn optional callback to run after hiding
+ * @param {bool} noaria supress aria-expanded state setting
* @author Adrian Lang <mail@adrianlang.de>
*/
-jQuery.fn.dw_hide = function(fn) {
- this.attr('aria-expanded', 'false');
+jQuery.fn.dw_hide = function(fn, noaria) {
+ if(!noaria) this.attr('aria-expanded', 'false');
return this.slideUp('fast', fn);
};
/**
* Unhides elements with a slide animation
*
- * @param fn optional callback to run after hiding
+ * @param {function} fn optional callback to run after hiding
+ * @param {bool} noaria supress aria-expanded state setting
* @author Adrian Lang <mail@adrianlang.de>
*/
-jQuery.fn.dw_show = function(fn) {
- this.attr('aria-expanded', 'true');
+jQuery.fn.dw_show = function(fn, noaria) {
+ if(!noaria) this.attr('aria-expanded', 'true');
return this.slideDown('fast', fn);
};
/**
* Toggles visibility of an element using a slide element
*
- * @param bool the current state of the element (optional)
+ * @param {bool} state the current state of the element (optional)
+ * @param {function} fn callback after the state has been toggled
+ * @param {bool} noaria supress aria-expanded state setting
*/
-jQuery.fn.dw_toggle = function(bool, fn) {
+jQuery.fn.dw_toggle = function(state, fn, noaria) {
return this.each(function() {
var $this = jQuery(this);
- if (typeof bool === 'undefined') {
- bool = $this.is(':hidden');
+ if (typeof state === 'undefined') {
+ state = $this.is(':hidden');
}
- $this[bool ? "dw_show" : "dw_hide" ](fn);
+ $this[state ? "dw_show" : "dw_hide" ](fn, noaria);
});
};