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

MediaWiki:Common.js

From JFA Wiki
Revision as of 17:49, 31 January 2019 by Gregfuller (talk | contribs)

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.

/* 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', '

Justice for Animals .org

');

})


// 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')
   }


}