summaryrefslogtreecommitdiff
path: root/lib/scripts/behaviour.js
diff options
context:
space:
mode:
authorKate Arzamastseva <pshns@ukr.net>2011-08-25 15:01:15 +0300
committerKate Arzamastseva <pshns@ukr.net>2011-08-25 15:01:15 +0300
commit47e84e7a9713558efde9ea83063d3e0830651622 (patch)
tree8416e23249ee823249a98c8a0fbf88cfe26b80d7 /lib/scripts/behaviour.js
parent80525638759a0bfe0ca5d83d9b06430f0d94c2ac (diff)
parent1c5f7481f4e685ad3ffe9ba48ed47ed75196e64a (diff)
downloadrpg-47e84e7a9713558efde9ea83063d3e0830651622.tar.gz
rpg-47e84e7a9713558efde9ea83063d3e0830651622.tar.bz2
merging
Diffstat (limited to 'lib/scripts/behaviour.js')
-rw-r--r--lib/scripts/behaviour.js125
1 files changed, 80 insertions, 45 deletions
diff --git a/lib/scripts/behaviour.js b/lib/scripts/behaviour.js
index f3fcccdfe..cfdc89157 100644
--- a/lib/scripts/behaviour.js
+++ b/lib/scripts/behaviour.js
@@ -1,6 +1,3 @@
-/*jslint sloppy: true */
-/*global jQuery, LANG, document, alert */
-
/**
* Automatic behaviours
*
@@ -13,11 +10,15 @@ var dw_behaviour = {
init: function(){
dw_behaviour.focusMarker();
dw_behaviour.scrollToMarker();
- dw_behaviour.closeMsgOnClick();
dw_behaviour.removeHighlightOnClick();
dw_behaviour.quickSelect();
dw_behaviour.checkWindowsShares();
- dw_behaviour.initTocToggle();
+ dw_behaviour.subscription();
+
+ dw_behaviour.revisionBoxHandler();
+ jQuery('#page__revisions input[type=checkbox]').click(
+ dw_behaviour.revisionBoxHandler
+ );
},
/**
@@ -38,17 +39,6 @@ var dw_behaviour = {
},
/**
- * Close messages shown by the msg() PHP function by click
- */
- closeMsgOnClick: function(){
- jQuery('div.success, div.info, div.error, div.notify').click(
- function(e){
- jQuery(e.target).fadeOut('fast');
- }
- );
- },
-
- /**
* Remove all search highlighting when clicking on a highlighted term
*
* @FIXME would be nice to have it fade out
@@ -95,52 +85,97 @@ var dw_behaviour = {
},
/**
- * Adds the toggle switch to the TOC
+ * Hide list subscription style if target is a page
+ *
+ * @author Adrian Lang <lang@cosmocode.de>
+ * @author Pierre Spring <pierre.spring@caillou.ch>
*/
- initTocToggle: function() {
- var $header = jQuery('#toc__header');
- if(!$header.length) return;
- var $toc = jQuery('#toc__inside');
-
- var $clicky = jQuery(document.createElement('span'))
- .attr('id','toc__toggle')
- .css('cursor','pointer')
- .click(function(){
- $toc.slideToggle();
- setClicky();
- });
- $header.prepend($clicky);
-
- var setClicky = function(){
- if($toc.css('display') == 'none'){
- $clicky.html('<span>+</span>');
- $clicky[0].className = 'toc_open';
- }else{
- $clicky.html('<span>&minus;</span>');
- $clicky[0].className = 'toc_close';
- }
- };
+ subscription: function(){
+ var $form, $list, $digest;
+
+ $form = jQuery('#subscribe__form');
+ if (0 === $form.length) return;
+
+ $list = $form.find("input[name='sub_style'][value='list']");
+ $digest = $form.find("input[name='sub_style'][value='digest']");
+
+ $form.find("input[name='sub_target']")
+ .click(
+ function () {
+ var $this = jQuery(this), show_list;
+ if (!$this.prop('checked')) {
+ return;
+ }
+
+ show_list = $this.val().match(/:$/);
+ $list.parent().dw_toggle(show_list);
+ if (!show_list && $list.prop('checked')) {
+ $digest.prop('checked', 'checked');
+ }
+ }
+ )
+ .filter(':checked')
+ .click();
+ },
- setClicky();
+ /**
+ * disable multiple revisions checkboxes if two are checked
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ revisionBoxHandler: function(){
+ var $checked = jQuery('#page__revisions input[type=checkbox]:checked');
+ var $all = jQuery('#page__revisions input[type=checkbox]');
+
+ if($checked.length < 2){
+ $all.attr('disabled',false);
+ jQuery('#page__revisions input[type=submit]').attr('disabled',true);
+ }else{
+ $all.attr('disabled',true);
+ jQuery('#page__revisions input[type=submit]').attr('disabled',false);
+ for(var i=0; i<$checked.length; i++){
+ $checked[i].disabled = false;
+ if(i>1){
+ $checked[i].checked = false;
+ }
+ }
+ }
}
};
+/**
+ * Hides elements with a slide animation
+ *
+ * @param fn optional callback to run after hiding
+ * @author Adrian Lang <mail@adrianlang.de>
+ */
jQuery.fn.dw_hide = function(fn) {
return this.slideUp('fast', fn);
};
-jQuery.fn.dw_show = function() {
- return this.slideDown('fast');
+/**
+ * Unhides elements with a slide animation
+ *
+ * @param fn optional callback to run after hiding
+ * @author Adrian Lang <mail@adrianlang.de>
+ */
+jQuery.fn.dw_show = function(fn) {
+ return this.slideDown('fast', fn);
};
-jQuery.fn.dw_toggle = function(bool) {
+/**
+ * Toggles visibility of an element using a slide element
+ *
+ * @param bool the current state of the element (optional)
+ */
+jQuery.fn.dw_toggle = function(bool, fn) {
return this.each(function() {
var $this = jQuery(this);
if (typeof bool === 'undefined') {
bool = $this.is(':hidden');
}
- $this[bool ? "dw_show" : "dw_hide" ]();
+ $this[bool ? "dw_show" : "dw_hide" ](fn);
});
};