From 5d08913b298bd6d6e96941214d048e58f9dcf1b2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 11 Dec 2014 20:22:03 +0100 Subject: animate automatic scrolls and don't scroll to border This adds a subtle animation effect when scrolling to the #scroll__here behaviour ID. It also adds a 100px offset to make the object not stick to the browser border. --- lib/scripts/behaviour.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/scripts/behaviour.js') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 6b46add07..707f1c185 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -64,7 +64,9 @@ var dw_behaviour = { scrollToMarker: function(){ var $obj = jQuery('#scroll__here'); if($obj.length) { - $obj[0].scrollIntoView(); + jQuery('html, body').animate({ + scrollTop: $obj.offset().top - 100 + }, 500); } }, -- cgit v1.2.3 From 7326f9142d48853ebe5d362541c0eaa78d4c34e1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 11 Dec 2014 20:27:07 +0100 Subject: fade out search hit colorization --- lib/scripts/behaviour.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/scripts/behaviour.js') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 707f1c185..16676959e 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -79,13 +79,11 @@ var dw_behaviour = { /** * Remove all search highlighting when clicking on a highlighted term - * - * @FIXME would be nice to have it fade out */ removeHighlightOnClick: function(){ jQuery('span.search_hit').click( function(e){ - jQuery(e.target).removeClass('search_hit'); + jQuery(e.target).removeClass('search_hit', 1000); } ); }, -- cgit v1.2.3 From 4063422b2ff7e6a9d56d7335cfdd2a8c87f49132 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 11 Dec 2014 20:41:46 +0100 Subject: offsets are not available for hidden elements --- lib/scripts/behaviour.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/scripts/behaviour.js') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 16676959e..9a2cbaf13 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -64,9 +64,14 @@ var dw_behaviour = { scrollToMarker: function(){ var $obj = jQuery('#scroll__here'); if($obj.length) { - jQuery('html, body').animate({ - scrollTop: $obj.offset().top - 100 - }, 500); + if($obj.offset().top != 0) { + jQuery('html, body').animate({ + scrollTop: $obj.offset().top - 100 + }, 500); + } else { + // hidden object have no offset but can still be scrolled into view + $obj[0].scrollIntoView(); + } } }, -- cgit v1.2.3 From 6fa4721ac57074f958b12cf2cf28a489f24e89e1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 11 Dec 2014 20:51:55 +0100 Subject: add new behaviour: bounce Add the class .bounce to any element to let it bounce slightly for 2 seconds. This is useful to make the user aware of some element. Can be combined with #scroll__here when a long list auto scrolls to a certain item. --- lib/scripts/behaviour.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/scripts/behaviour.js') diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js index 9a2cbaf13..fb61f6e48 100644 --- a/lib/scripts/behaviour.js +++ b/lib/scripts/behaviour.js @@ -56,6 +56,8 @@ var dw_behaviour = { jQuery(document).on('click','#page__revisions input[type=checkbox]', dw_behaviour.revisionBoxHandler ); + + jQuery('.bounce').effect('bounce', {times:10}, 2000 ); }, /** -- cgit v1.2.3 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 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/scripts/behaviour.js') 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){ -- 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 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib/scripts/behaviour.js') 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); }); }; -- cgit v1.2.3