From ae614416a5d7f5cab6c5b82a0c45f587d7fa9c01 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 12 Jul 2015 19:05:43 +0100 Subject: changed all input type=submit buttons to button type=submit button for better stylability --- lib/scripts/behaviour.js | 6 +++--- lib/scripts/editor.js | 2 +- lib/scripts/fileuploaderextended.js | 4 ++-- lib/scripts/hotkeys.js | 6 +++--- lib/scripts/media.js | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/scripts') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index fb61f6e48..97955dad9 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -107,7 +107,7 @@ var dw_behaviour = { quickSelect: function(){ jQuery('select.quickselect') .change(function(e){ e.target.form.submit(); }) - .closest('form').find('input[type=submit]').not('.show').hide(); + .closest('form').find(':button').not('.show').hide(); }, /** @@ -171,10 +171,10 @@ var dw_behaviour = { if($checked.length < 2){ $all.attr('disabled',false); - jQuery('#page__revisions input[type=submit]').attr('disabled',true); + jQuery('#page__revisions button').attr('disabled',true); }else{ $all.attr('disabled',true); - jQuery('#page__revisions input[type=submit]').attr('disabled',false); + jQuery('#page__revisions button').attr('disabled',false); for(var i=0; i<$checked.length; i++){ $checked[i].disabled = false; if(i>1){ diff --git a/lib/scripts/editor.js b/lib/scripts/editor.js index f4143f0bc..fac084489 100644 --- a/lib/scripts/editor.js +++ b/lib/scripts/editor.js @@ -146,7 +146,7 @@ var dw_editor = { if((e.keyCode == 13 || e.keyCode == 10) && e.ctrlKey) { // Ctrl-Enter (With Chrome workaround) // Submit current edit - jQuery('input#edbtn__save').click(); + jQuery('#edbtn__save').click(); e.preventDefault(); // prevent enter key return false; }else if(e.keyCode == 13){ // Enter diff --git a/lib/scripts/fileuploaderextended.js b/lib/scripts/fileuploaderextended.js index f5786c387..d6a82397d 100644 --- a/lib/scripts/fileuploaderextended.js +++ b/lib/scripts/fileuploaderextended.js @@ -82,7 +82,7 @@ qq.FileUploaderExtended = function(o){ '
' + LANG.media_select + '
' + '' + '
' + - ' ' + + ' ' + ' ' + '
' + '', @@ -189,7 +189,7 @@ qq.extend(qq.FileUploaderExtended.prototype, { var button = '
'; button += ''; button += ''; - button += '
'; + button += ''; jQuery('#mediamanager__uploader').append(button); } } diff --git a/lib/scripts/hotkeys.js b/lib/scripts/hotkeys.js index bff28530d..76a277aea 100644 --- a/lib/scripts/hotkeys.js +++ b/lib/scripts/hotkeys.js @@ -26,7 +26,7 @@ function Hotkeys() { * Initialization * * This function looks up all the accesskeys used in the current page - * (at anchor elements and input elements [type="submit"]) and registers + * (at anchor elements and button elements [type="submit"]) and registers * appropriate shortcuts. * * Secondly, initialization registers listeners on document to catch all @@ -59,10 +59,10 @@ function Hotkeys() { }); /** - * Lookup all input [type="submit"] with accesskey and register event - + * Lookup all button [type="submit"] with accesskey and register event - * perform "click" on a button. */ - var inputs = document.getElementsByTagName("input"); + var inputs = document.getElementsByTagName("button"); t.each(inputs, function(i) { if (i.type == "submit" && i.accessKey != "") { t.addShortcut(t.modifier + '+' + i.accessKey, function() { diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 8ca21ecab..2995addfd 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -119,7 +119,7 @@ var dw_mediamanager = { $both = $listType.add($sortBy); // Remove the submit button - $options.find('input[type=submit]').parent().hide(); + $options.find('button[type=submit]').parent().hide(); // Prepare HTML for jQuery UI buttonset $both.find('label').each(function () { @@ -435,7 +435,7 @@ var dw_mediamanager = { dw_mediamanager.$resizables().resizable('destroy'); if (update_list) { - dw_mediamanager.list.call(jQuery('#mediamanager__page form.options input[type="submit"]')[0]); + dw_mediamanager.list.call(jQuery('#mediamanager__page form.options button[type="submit"]')[0]); } $content.html(data); -- cgit v1.2.3 From 82246f10eb9ae3debeadf5913232105aa2694cec Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 15 Jul 2015 21:44:22 +0200 Subject: improve aria attribute handling. closes #1142 adds aria handling to makeToggle and allows to supress it in dw_toggle --- lib/scripts/behaviour.js | 26 +++++++++++++++----------- lib/scripts/page.js | 13 ++++++++++--- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'lib/scripts') 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 */ -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 */ -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); }); }; diff --git a/lib/scripts/page.js b/lib/scripts/page.js index 7b4958d82..a179ae2a8 100644 --- a/lib/scripts/page.js +++ b/lib/scripts/page.js @@ -109,8 +109,14 @@ dw_page = { * as well. A state indicator is inserted into the handle and can be styled * by CSS. * - * @param selector handle What should be clicked to toggle - * @param selector content This element will be toggled + * To properly reserve space for the expanded element, the sliding animation is + * done on the children of the content. To make that look good and to make sure aria + * attributes are assigned correctly, it's recommended to make sure that the content + * element contains a single child element only. + * + * @param {selector} handle What should be clicked to toggle + * @param {selector} content This element will be toggled + * @param {int} state initial state (-1 = open, 1 = closed) */ makeToggle: function(handle, content, state){ var $handle, $content, $clicky, $child, setClicky; @@ -160,8 +166,9 @@ dw_page = { // Start animation and assure that $toc is hidden/visible $child.dw_toggle(hidden, function () { $content.toggle(hidden); + $content.attr('aria-expanded', hidden); $content.css('min-height',''); // remove min-height again - }); + }, true); }; // the state indicator -- cgit v1.2.3