MediaWiki:Common.js

De Shir.fr | Chants, louange, paroles et accords.
(Différences entre les versions)
Aller à : Navigation, rechercher
Ligne 7 : Ligne 7 :
 
   ga('create', 'UA-47729280-2', 'auto');
 
   ga('create', 'UA-47729280-2', 'auto');
 
   ga('send', 'pageview');
 
   ga('send', 'pageview');
 +
/* ML */
 +
 +
/* ML 20160911 fullscreen, cf. http://html5-demos.appspot.com/static/fullscreen.html */
 +
document.cancelFullScreen = document.webkitExitFullscreen || document.mozCancelFullScreen || document.exitFullscreen;
 +
 +
var elem = document.querySelector(document.webkitExitFullscreen ? "#fs" : "#fs-container");
 +
 +
document.addEventListener('keydown', function(e) {
 +
  switch (e.keyCode) {
 +
    case 13: // ENTER. ESC should also take you out of fullscreen by default.
 +
      e.preventDefault();
 +
      document.cancelFullScreen(); // explicitly go out of fs.
 +
      break;
 +
    case 70: // f
 +
      enterFullscreen();
 +
      break;
 +
  }
 +
}, false);
 +
 +
function toggleFS(el) {
 +
  if (el.webkitEnterFullScreen) {
 +
    el.webkitEnterFullScreen();
 +
  } else {
 +
    if (el.mozRequestFullScreen) {
 +
      el.mozRequestFullScreen();
 +
    } else {
 +
      el.requestFullscreen();
 +
    }
 +
  }
 +
 +
  el.ondblclick = exitFullscreen;
 +
}
 +
 +
function onFullScreenEnter() {
 +
  console.log("Entered fullscreen!");
 +
  elem.onwebkitfullscreenchange = onFullScreenExit;
 +
  elem.onmozfullscreenchange = onFullScreenExit;
 +
};
 +
 +
// Called whenever the browser exits fullscreen.
 +
function onFullScreenExit() {
 +
  console.log("Exited fullscreen!");
 +
};
 +
 +
// Note: FF nightly needs about:config full-screen-api.enabled set to true.
 +
function enterFullscreen() {
 +
  console.log("enterFullscreen()");
 +
  elem.onwebkitfullscreenchange = onFullScreenEnter;
 +
  elem.onmozfullscreenchange = onFullScreenEnter;
 +
  elem.onfullscreenchange = onFullScreenEnter;
 +
  if (elem.webkitRequestFullscreen) {
 +
    elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
 +
  } else {
 +
    if (elem.mozRequestFullScreen) {
 +
      elem.mozRequestFullScreen();
 +
    } else {
 +
      elem.requestFullscreen();
 +
    }
 +
  }
 +
  document.getElementById('enter-exit-fs').onclick = exitFullscreen;
 +
}
 +
 +
function exitFullscreen() {
 +
  console.log("exitFullscreen()");
 +
  document.cancelFullScreen();
 +
  document.getElementById('enter-exit-fs').onclick = enterFullscreen;
 +
}
 
/* ML */
 
/* ML */

Version du 11 septembre 2016 à 13:42

/* ML 20160901 GoogleAnalytics */
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-47729280-2', 'auto');
  ga('send', 'pageview');
/* ML */

/* ML 20160911 fullscreen, cf. http://html5-demos.appspot.com/static/fullscreen.html */
document.cancelFullScreen = document.webkitExitFullscreen || document.mozCancelFullScreen || document.exitFullscreen;

var elem = document.querySelector(document.webkitExitFullscreen ? "#fs" : "#fs-container");

document.addEventListener('keydown', function(e) {
  switch (e.keyCode) {
    case 13: // ENTER. ESC should also take you out of fullscreen by default.
      e.preventDefault();
      document.cancelFullScreen(); // explicitly go out of fs.
      break;
    case 70: // f
      enterFullscreen();
      break;
  }
}, false);

function toggleFS(el) {
  if (el.webkitEnterFullScreen) {
    el.webkitEnterFullScreen();
  } else {
    if (el.mozRequestFullScreen) {
      el.mozRequestFullScreen();
    } else {
      el.requestFullscreen();
    }
  }

  el.ondblclick = exitFullscreen;
}

function onFullScreenEnter() {
  console.log("Entered fullscreen!");
  elem.onwebkitfullscreenchange = onFullScreenExit;
  elem.onmozfullscreenchange = onFullScreenExit;
};

// Called whenever the browser exits fullscreen.
function onFullScreenExit() {
  console.log("Exited fullscreen!");
};

// Note: FF nightly needs about:config full-screen-api.enabled set to true.
function enterFullscreen() {
  console.log("enterFullscreen()");
  elem.onwebkitfullscreenchange = onFullScreenEnter;
  elem.onmozfullscreenchange = onFullScreenEnter;
  elem.onfullscreenchange = onFullScreenEnter;
  if (elem.webkitRequestFullscreen) {
    elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  } else {
    if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else {
      elem.requestFullscreen();
    }
  }
  document.getElementById('enter-exit-fs').onclick = exitFullscreen;
}

function exitFullscreen() {
  console.log("exitFullscreen()");
  document.cancelFullScreen();
  document.getElementById('enter-exit-fs').onclick = enterFullscreen;
}
/* ML */
Outils personnels
Espaces de noms
Variantes
Actions
Navigation
Boîte à outils
Réseaux sociaux