4
* This class wraps various JavaScript functionalities that are triggered
5
* automatically whenever a certain object is in the DOM or a certain CSS
11
dw_behaviour.focusMarker();
12
dw_behaviour.scrollToMarker();
13
dw_behaviour.removeHighlightOnClick();
14
dw_behaviour.quickSelect();
15
dw_behaviour.checkWindowsShares();
16
dw_behaviour.subscription();
18
dw_behaviour.revisionBoxHandler();
19
jQuery('#page__revisions input[type=checkbox]').live('click',
20
dw_behaviour.revisionBoxHandler
25
* Looks for an element with the ID scroll__here at scrolls to it
27
scrollToMarker: function(){
28
var $obj = jQuery('#scroll__here');
30
$obj[0].scrollIntoView();
35
* Looks for an element with the ID focus__this at sets focus to it
37
focusMarker: function(){
38
jQuery('#focus__this').focus();
42
* Remove all search highlighting when clicking on a highlighted term
44
* @FIXME would be nice to have it fade out
46
removeHighlightOnClick: function(){
47
jQuery('span.search_hit').click(
49
jQuery(e.target).removeClass('search_hit');
55
* Autosubmit quick select forms
57
* When a <select> tag has the class "quickselect", this script will
58
* automatically submit its parent form when the select value changes.
59
* It also hides the submit button of the form.
61
* @author Andreas Gohr <andi@splitbrain.org>
63
quickSelect: function(){
64
jQuery('select.quickselect')
65
.change(function(e){ e.target.form.submit(); })
66
.closest('form').find('input[type=submit]').not('.show').hide();
70
* Display error for Windows Shares on browsers other than IE
72
* @author Michael Klier <chi@chimeric.de>
74
checkWindowsShares: function() {
75
if(!LANG.nosmblinks || typeof(document.all) !== 'undefined') {
76
// No warning requested or none necessary
80
jQuery('a.windows').live('click', function(){
81
alert(LANG.nosmblinks.replace(/\\n/,"\n"));
86
* Hide list subscription style if target is a page
88
* @author Adrian Lang <lang@cosmocode.de>
89
* @author Pierre Spring <pierre.spring@caillou.ch>
91
subscription: function(){
92
var $form, $list, $digest;
94
$form = jQuery('#subscribe__form');
95
if (0 === $form.length) return;
97
$list = $form.find("input[name='sub_style'][value='list']");
98
$digest = $form.find("input[name='sub_style'][value='digest']");
100
$form.find("input[name='sub_target']")
103
var $this = jQuery(this), show_list;
104
if (!$this.prop('checked')) {
108
show_list = $this.val().match(/:$/);
109
$list.parent().dw_toggle(show_list);
110
if (!show_list && $list.prop('checked')) {
111
$digest.prop('checked', 'checked');
120
* disable multiple revisions checkboxes if two are checked
122
* @author Andreas Gohr <andi@splitbrain.org>
124
revisionBoxHandler: function(){
125
var $checked = jQuery('#page__revisions input[type=checkbox]:checked');
126
var $all = jQuery('#page__revisions input[type=checkbox]');
128
if($checked.length < 2){
129
$all.attr('disabled',false);
130
jQuery('#page__revisions input[type=submit]').attr('disabled',true);
132
$all.attr('disabled',true);
133
jQuery('#page__revisions input[type=submit]').attr('disabled',false);
134
for(var i=0; i<$checked.length; i++){
135
$checked[i].disabled = false;
137
$checked[i].checked = false;
146
* Hides elements with a slide animation
148
* @param fn optional callback to run after hiding
149
* @author Adrian Lang <mail@adrianlang.de>
151
jQuery.fn.dw_hide = function(fn) {
152
return this.slideUp('fast', fn);
156
* Unhides elements with a slide animation
158
* @param fn optional callback to run after hiding
159
* @author Adrian Lang <mail@adrianlang.de>
161
jQuery.fn.dw_show = function(fn) {
162
return this.slideDown('fast', fn);
166
* Toggles visibility of an element using a slide element
168
* @param bool the current state of the element (optional)
170
jQuery.fn.dw_toggle = function(bool, fn) {
171
return this.each(function() {
172
var $this = jQuery(this);
173
if (typeof bool === 'undefined') {
174
bool = $this.is(':hidden');
176
$this[bool ? "dw_show" : "dw_hide" ](fn);
180
jQuery(dw_behaviour.init);