MediaWiki:Vector.js

From Wikimini Stock
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: 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 users using the MonoBook skin */

// ============================================================
// BEGIN Enable multiple onload functions

// setup onload functions this way:
// aOnloadFunctions[aOnloadFunctions.length] = function_name; // without brackets!

if (!window.aOnloadFunctions) {
  var aOnloadFunctions = new Array();
}

window.onload = function() {
  if (window.aOnloadFunctions) {
    for (var _i=0; _i<aOnloadFunctions.length; _i++) {
      aOnloadFunctions[_i]();
    }
  }
}

// END Enable multiple onload functions
// ============================================================


// ============================================================================
///////////////////////////////// Évite le double-post dans les pages de discussion LQT
//addOnloadHook( function(){
jQuery( function( ) {

  var wpSave = document.getElementById('wpSave');
    var wpForm = document.getElementById('editform');
    if((wpSave)&&(wpForm)){
        wpSave.onclick = function(){
            document.getElementById('editform').submit();
            document.getElementById('wpSave').disabled = "disabled";            
        }
    }

});///////////////////////////////
// ===========================================================================


///////////////////////////////// Fonctions Javascript liées à des modèles

// ============================================================
// BEGIN Boîtes déroulantes

// set up the words in your language
var NavigationBarHide = '? Hide';
var NavigationBarShow = '? Show';

// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;


function toggleNavigationBar(indexNavigationBar){
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
    if (!NavFrame || !NavToggle) return false;
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) {
            if (NavChild.className == 'NavPic') NavChild.style.display = 'none';
            if (NavChild.className == 'NavContent') NavChild.style.display = 'none';
            if (NavChild.className == 'NavToggle') NavChild.firstChild.data = NavigationBarShow;
        }
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        for (var NavChild = NavFrame.firstChild;NavChild != null;NavChild = NavChild.nextSibling) {
            if (NavChild.className == 'NavPic') NavChild.style.display = 'block';
            if (NavChild.className == 'NavContent') NavChild.style.display = 'block';
            if (NavChild.className == 'NavToggle')  NavChild.firstChild.data = NavigationBarHide;
        }
    }
}

function createNavigationBarToggleButton(){
    var indexNavigationBar = 0;
    var AllDivs = document.getElementsByTagName("div");
    for(var i=0,l=AllDivs.length;i<l;i++) {
        if (hasClass(AllDivs[i], "NavFrame")) {
            var NavFrame = AllDivs[i];
            indexNavigationBar++;
            var NavToggle = document.createElement("a");
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
            var NavToggleText = document.createTextNode(NavigationBarHide);
            NavToggle.appendChild(NavToggleText);
            NavFrame.insertBefore( NavToggle, NavFrame.firstChild);
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
    if (NavigationBarShowDefault < indexNavigationBar) {
        for(var i=1;i<=indexNavigationBar;i++) {
            toggleNavigationBar(i);
        }
    }
}
aOnloadFunctions[aOnloadFunctions.length] = createNavigationBarToggleButton;

// ===========================================================================


// mw.loader.load( '/wiki/resources/lib/tagcanvas.min.js', 'text/javascript' );

$(document).ready(function() {
        try {
          TagCanvas.Start('myCanvas','tags',{
            textColour: '#000000',
            outlineThickness : 1,
            maxSpeed : 0.3,
            depth : 0.75,
            imageScale : null,
            shuffleTags : true
          });
           $('#tags').hide();
        } catch(e) {
          //something went wrong, hide the canvas container
          // $('#myCanvasContainer').hide();
           $('#tags').hide();
        }
      });