Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for IE #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions fullscreen/jquery.fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* @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);
return document.fullScreenEnabled ||
document.mozFullScreenEnabled ||
document.webkitFullscreenEnabled ||
document.msFullscreenEnabled;
}

function requestFullScreen(elem){
Expand All @@ -26,13 +26,16 @@
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullScreen) {
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
}

function fullScreenStatus(){
return document.fullscreen ||
document.mozFullScreen ||
document.webkitIsFullScreen ||
document.msFullscreenElement != null ||
false;
}

Expand All @@ -43,11 +46,13 @@
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msCancelFullScreen) {
document.msCancelFullScreen();
}
}

function onFullScreenEvent(callback){
$(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange", function(){
$(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange msfullscreenchange", function(){
// The full screen status is automatically
// passed to our callback as an argument.
callback(fullScreenStatus());
Expand Down Expand Up @@ -113,16 +118,11 @@
}
});

elem.cancel = function(){
cancelFullScreen();
return elem;
};

onFullScreenEvent(function(fullScreen){
if(!fullScreen){
// We have exited full screen.
// Detach event listener
$(document).off( 'fullscreenchange mozfullscreenchange webkitfullscreenchange' );
// Detach event listener
$(document).off( 'fullscreenchange mozfullscreenchange webkitfullscreenchange msfullscreenchange' );
// Remove the class and destroy
// the temporary div

Expand All @@ -132,16 +132,16 @@

// Calling the facultative user supplied callback
if(options.callback) {
options.callback(fullScreen);
}
options.callback(fullScreen);
}
});

return elem;
};

$.fn.cancelFullScreen = function( ) {
cancelFullScreen();
cancelFullScreen();

return this;
return this;
};
}(jQuery));