Maintenance

All wikis at Biowikifarm are in read-only mode due to the restoration after a severe cyberattack in October 2023.
After 1 year being shut down the Biowikifarm is online again.
You see the latest restored version from 18th October 2023.

MediaWiki:Common.js

From Species-ID
Revision as of 15:31, 11 February 2011 by Andreas Plank (Talk | contribs) (+run init scripts)

Jump to: navigation, search

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: Clear the cache in Tools → Preferences
// <source lang="javascript">
// This JavaScript will be loaded for all users on every page load.
// Except for additions at the end, imported from en.wikipedia.org and modified (parts removed).
// for authors see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history
// NEW: targetHighlighting (Hagedorn) and collapsibleTables (wikipedia) moved to jKey.js!


/* Import more specific scripts if necessary */
if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") { //scripts specific to editing pages
    importScript("MediaWiki:Common.js/edit.js");
}


/* Scripts specific to Internet Explorer */
if (navigator.appName == "Microsoft Internet Explorer") {
    /** Internet Explorer bug fix **************************************************
     *  Description: Fixes IE horizontal scrollbar bug
     *  Maintainers: [[User:Tom-]]?
     */
    var oldWidth;
    var docEl = document.documentElement;

    function fixIEScroll() {
        if (!oldWidth || docEl.clientWidth > oldWidth)
            doFixIEScroll();
        else
            setTimeout(doFixIEScroll, 1);
        oldWidth = docEl.clientWidth;
    }
    
    function doFixIEScroll() {
      docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
    }
    
    document.attachEvent("onreadystatechange", fixIEScroll);
    document.attachEvent("onresize", fixIEScroll);
    
    // In print IE (7?) does not like line-height
    appendCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');
    
    //Import scripts specific to Internet Explorer 6
    // THIS IS A PNG transparency FIX, here commented out:
    // if (navigator.appVersion.substr(22, 1) == "6") {
    //    importScript("MediaWiki:Common.js/IE60Fixes.js");
    // }
} // END "Microsoft Internet Explorer"



/** Table sorting fixes
  *  Description: Disables code in table sorting routine to set classes on even/odd rows
  */
ts_alternate_row_colors = false;

///////////////////////////////////
// confirm deletion using SMW forms (does not work in IE 6!)
//////////////////////////////////
function initConfirmDeleteSubform() {
  $.extend(true, $.jI18n, {
  en: { 
    message : "'Delete this sub form irreversibly?'"
    },
  de: {
    message : "'Dieses Teilformular unwiderruflich löschen?'"
    }
  });
  // default buttons: <input type="button" ... class="remove"/>
  $("input.remove").attr("onClick", function() {// case sensitive not: onclick
    //typeof this.onclick → function
    var currentClickHandlerString = this.getAttributeNode('onclick').value;
    // add a confirm
    return "var removethis = confirm("+$.resource('message')+");  if(removethis) {return " + currentClickHandlerString + "};";
  });
  /* added delete buttons by the SMW-form: <input type="button" />
    add onclick handling */
  $("input.addAnother").click(function () {
    // just new generated div#div_gen_1
   $("div")
     .filter(function() { return this.id.match(/div_gen_\d+/); })
     .find(":button")
     .attr("onClick",function() {// case sensitive not: onclick
      // add a confirm
       return "var removethis = confirm("+$.resource('message')+");  if(removethis) {$('#' + String($(this).parent().attr('id'))).remove();} else {return false;};";
     });
  });
}// end initConfirmDeleteSubform()
 
/*
  function initMarkAllFilledFormElements()
  Description: indicates form elements created by template:Hidden 
  having class indicateHiddenInputs or other fields 
  having class indicateFilledFormElements
*/
function initMarkAllFilledFormElements(){
  /*
  structure of template:Hidden:
 
    div.collapsebox
      ├ div.switcher (float)
      ├ div.collapsetitle
      └ div.collapsecontent
 
    tr.collapsebox
      └ th/td
          ├ div.switcher (float)
          └ div.collapsetitle
    tr.collapsecontent
  */
  var jDivHiddenFormTexts = $(
    // select only input type text + textarea with values
       "div.collapsecontent.indicateHiddenInputs * :text[value!=]" +
     ", div.collapsecontent.indicateHiddenInputs * textarea[value!=]"
    );
  var jTrHiddenFormTexts = $(
    // select only input type text + textarea with values
       "tr.collapsecontent.indicateHiddenInputs *:not(.collapsecontent) :text[value!=]" +
     ", tr.collapsecontent.indicateHiddenInputs *:not(.collapsecontent) textarea[value!=]"
    );
  var jIndicateFilledFormElements = $(
       ".indicateFilledFormElements:text[value!=]" +
     ", textarea[value!=].indicateFilledFormElements "
  );
  /* 
    pale orange:
    hsv →  36 20 99 36 10 99  36 05 99 
           #fce8ca  #fcf2e3   #fcf7f0
    pale yellow
    hsv → 50 18 100  50 10 100
          #fff7d0    #fffbe6
  */
  var bgcolor =       {'background-color':'#fffbe6'};
  var bgcolor_darker = {'background-color':'#fff7d0'};
//  hidden elements
  // <div>
    //indicate the fields itself
    jDivHiddenFormTexts
      .css(bgcolor); //pale orange
    // parent switcher
    jDivHiddenFormTexts
      .parentsUntil('.collapsebox')
      .parent()
      .find('div.switcher')
      .css(bgcolor_darker); //pale orange
 
  // <tr>
    //indicate the fields itself
    jTrHiddenFormTexts
      .css({'background-color':'#fce8ca'}); //pale orange
    jTrHiddenFormTexts
      .parentsUntil('.collapsebox')
      .parent()
      .find('div.switcher')
      .css(bgcolor_darker); //pale orange
//<select>
    $(
      '.collapsecontent.indicateHiddenInputs select option[value!=]:selected' +
      ', select.indicateFilledFormElements option[value!=]:selected'
    ).parent().css(bgcolor);
// all visible form elements
  jIndicateFilledFormElements
     .css(bgcolor); //pale orange
 
}// END initMarkAllFilledFormElements()
 

// jkey source
importScript("MediaWiki:JKey.js");
/*
   NOTE: the resource loader seems to take care of the ready state of this script with forms
   Functions were not loaded at all when enclosed by $(document).ready, therefore
   $(document).ready is not used here at the moment. (AP 2011-01-05)
 
   Following seems to work only outside $(document).ready:
*/
  // initCollapsebox();//collapsible parts
  // page specific
  if(wgAction=="formedit" || wgPageName=="Spezial:FormEdit"){
    initConfirmDeleteSubform();
    initMarkAllFilledFormElements();
  }
// </source>