/** * @name jquery fullscreen plugin * @author martin angelov, morten sjøgren * @version 1.2 * @url http://tutorialzine.com/2012/02/enhance-your-website-fullscreen-api/ * @license mit license */ /*jshint browser: true, jquery: true */ (function($){ "use strict"; // these helper functions available only to our plugin scope. function supportfullscreen(){ var doc = document.documentelement; return ('requestfullscreen' in doc) || ('mozrequestfullscreen' in doc && document.mozfullscreenenabled) || ('webkitrequestfullscreen' in doc); } function requestfullscreen(elem){ if (elem.requestfullscreen) { elem.requestfullscreen(); } else if (elem.mozrequestfullscreen) { elem.mozrequestfullscreen(); } else if (elem.webkitrequestfullscreen) { elem.webkitrequestfullscreen(element.allow_keyboard_input); } } function fullscreenstatus(){ return document.fullscreen || document.mozfullscreen || document.webkitisfullscreen || false; } function cancelfullscreen(){ if (document.exitfullscreen) { document.exitfullscreen(); } else if (document.mozcancelfullscreen) { document.mozcancelfullscreen(); } else if (document.webkitcancelfullscreen) { document.webkitcancelfullscreen(); } } function onfullscreenevent(callback){ $(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange", function(){ // the full screen status is automatically // passed to our callback as an argument. callback(fullscreenstatus()); }); } // adding a new test to the jquery support object $.support.fullscreen = supportfullscreen(); // creating the plugin $.fn.fullscreen = function(props){ if(!$.support.fullscreen || this.length !== 1) { // the plugin can be called only // on one element at a time return this; } if(fullscreenstatus()){ // if we are already in fullscreen, exit cancelfullscreen(); return this; } // you can potentially pas two arguments a color // for the background and a callback function var options = $.extend({ 'background' : '#111', 'callback' : $.noop( ), 'fullscreenclass' : 'fullscreen' }, props), elem = this, // this temporary div is the element that is // actually going to be enlarged in full screen fs = $('