To get updates on new site content, like us on Facebook or follow us on Twitter.

Difference between revisions of "MediaWiki:Common.js"

From JFA Wiki
Line 3: Line 3:
 
//Insert 'Justice for Animals .org' in the DOM, for the header
 
//Insert 'Justice for Animals .org' in the DOM, for the header
 
jQuery(document).ready(function () {
 
jQuery(document).ready(function () {
document.body.insertAdjacentHTML( 'afterbegin', '<div id="jfatitle">Justice for Animals .org</div>');
+
document.body.insertAdjacentHTML( 'afterbegin', '<div id="jfatitle"><a href="/Main_Page">Justice for Animals .org</a></div>');
jQuery("#jfatitle").click(function() {
+
 
window.location = "/main_page";
 
  return false;
 
});
 
 
 
 
})
 
})

Revision as of 21:56, 1 February 2019

/* Any JavaScript here will be loaded for all users on every page load. */

//Insert 'Justice for Animals .org' in the DOM, for the header jQuery(document).ready(function () {

document.body.insertAdjacentHTML( 'afterbegin', '

<a href="/Main_Page">Justice for Animals .org</a>

');


})


// Outline functionality: supports only one outline per page jQuery(document).ready(function () {

   jQuery('.outline-wrapper li p').replaceWith(function () {
       return this.innerHTML;
   });
   jQuery(".total-wrapper").each(function (index) {
       jQuery(this).find('.outline-wrapper li').addClass('folding-terminal');
       jQuery(this).find('.outline-wrapper li:has(ul)')
           .addClass('folding-link plusbox')
           .removeClass('folding-terminal')
           .click(function (event) {


               //console.log(this);
               //console.log(event.target);


               if (this == event.target) {
                   if (jQuery(this).children().is(':hidden')) {
                       jQuery(this).addClass('minusbox').removeClass('plusbox');
                   } else {
                       jQuery(this).addClass('plusbox').removeClass('minusbox')
                   }
                   jQuery(this).children().toggle();
               }
           })
           .children().hide();
       /* this has gotta come after li clixk in the chain */
       var this_total_wrapper = this;
       jQuery(this).find('.outline-expand-all')
           .click(function (event) {
               jQuery(this_total_wrapper).find('.outline-wrapper li').show();
               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)').children().show();


               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)')
                   .addClass('minusbox')
                   .removeClass('plusbox');
               return false;
           });
       jQuery(this).find('.outline-collapse-all')
           .click(function (event) {
               jQuery(this_total_wrapper).find('.outline-wrapper li').show();
               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)').children().hide();
               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)')
                   .addClass('plusbox')
                   .removeClass('minusbox');
               jQuery(this_total_wrapper).find('.outline-wrapper li').hide();
               return false;
           });
       jQuery(this).find('.outline-title')
           .click(function (event) {
               jQuery(this_total_wrapper).find('.outline-wrapper li').show();
               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)').children().hide();
               jQuery(this_total_wrapper).find('.outline-wrapper li:has(ul)')
                   .addClass('plusbox')
                   .removeClass('minusbox');
               return false;
           });


   });


   // classify special nodes so they can be styled independently
   jQuery(".outline-wrapper li").each(function (index, value) {
       if ('Context'.indexOf(value.firstChild.data.trim()) >= 0 ||
           'Meta'.indexOf(value.firstChild.data.trim()) >= 0 ||
           'Source'.indexOf(value.firstChild.data.trim()) >= 0 ||
           'Extra'.indexOf(value.firstChild.data.trim()) >= 0) {
               jQuery(this).addClass('outline-special-node');
       }
   });


});


function old_junk() {

   jQuery('.outline-title').click(function () {
       jQuery('.outline-wrapper li:has(ul)').hide();
       //jQuery('.outline-wrapper li').addClass('folding-terminal');
       jQuery('.outline-wrapper li:has(ul)')
           .addClass('plusbox')
           .removeClass('minusbox');
       return false;
   });


   jQuery('.outline-collapse-all').click(function () {
       collapse_all();
       return false;
   });
   jQuery('.outline-expand-all').click(function () {
       expand_all();
       return false;
   });
   function collapse_all() {
       jQuery('.outline-wrapper li:has(ul)').children().hide();
       //jQuery('.outline-wrapper li').addClass('folding-terminal');
       jQuery('.outline-wrapper li:has(ul)')
           .addClass('plusbox')
           .removeClass('minusbox');
   }
   function expand_all() {
       jQuery('.outline-wrapper li:has(ul)').children().show();
       //jQuery('.outline-wrapper li').addClass('folding-terminal');
       jQuery('.outline-wrapper li:has(ul)')
           .addClass('minusbox')
           .removeClass('plusbox')
   }


}