summaryrefslogtreecommitdiff
path: root/lib/scripts/behaviour.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/behaviour.js')
-rw-r--r--lib/scripts/behaviour.js47
1 files changed, 29 insertions, 18 deletions
diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js
index 6b46add07..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);
});
};
@@ -56,6 +60,8 @@ var dw_behaviour = {
jQuery(document).on('click','#page__revisions input[type=checkbox]',
dw_behaviour.revisionBoxHandler
);
+
+ jQuery('.bounce').effect('bounce', {times:10}, 2000 );
},
/**
@@ -64,7 +70,14 @@ var dw_behaviour = {
scrollToMarker: function(){
var $obj = jQuery('#scroll__here');
if($obj.length) {
- $obj[0].scrollIntoView();
+ 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();
+ }
}
},
@@ -77,13 +90,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);
}
);
},
@@ -100,7 +111,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();
},
/**
@@ -164,10 +175,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){