|
|
@ -3,149 +3,180 @@
|
|
|
|
* 新增支持IE全屏显示
|
|
|
|
* 新增支持IE全屏显示
|
|
|
|
* Copyright (c) 2019 ruoyi
|
|
|
|
* Copyright (c) 2019 ruoyi
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function(jQuery) {
|
|
|
|
/*jshint browser: true, jquery: true */
|
|
|
|
|
|
|
|
(function($){
|
|
|
|
/**
|
|
|
|
"use strict";
|
|
|
|
* Sets or gets the fullscreen state.
|
|
|
|
|
|
|
|
*
|
|
|
|
// These helper functions available only to our plugin scope.
|
|
|
|
* @param {boolean=} state
|
|
|
|
function supportFullScreen(){
|
|
|
|
* True to enable fullscreen mode, false to disable it. If not
|
|
|
|
var doc = document.documentElement;
|
|
|
|
* specified then the current fullscreen state is returned.
|
|
|
|
|
|
|
|
* @return {boolean|Element|jQuery|null}
|
|
|
|
return ('requestFullscreen' in doc) ||
|
|
|
|
* When querying the fullscreen state then the current fullscreen
|
|
|
|
('msRequestFullscreen' in doc) ||
|
|
|
|
* element (or true if browser doesn't support it) is returned
|
|
|
|
('mozRequestFullScreen' in doc && document.mozFullScreenEnabled) ||
|
|
|
|
* when browser is currently in full screen mode. False is returned
|
|
|
|
('webkitRequestFullScreen' in doc);
|
|
|
|
* if browser is not in full screen mode. Null is returned if
|
|
|
|
}
|
|
|
|
* browser doesn't support fullscreen mode at all. When setting
|
|
|
|
|
|
|
|
* the fullscreen state then the current jQuery selection is
|
|
|
|
function requestFullScreen(elem){
|
|
|
|
* returned for chaining.
|
|
|
|
if (elem.requestFullscreen) {
|
|
|
|
* @this {jQuery}
|
|
|
|
elem.requestFullscreen();
|
|
|
|
*/
|
|
|
|
} else if (elem.mozRequestFullScreen) {
|
|
|
|
function fullScreen(state)
|
|
|
|
elem.mozRequestFullScreen();
|
|
|
|
{
|
|
|
|
} else if (elem.webkitRequestFullScreen) {
|
|
|
|
var e, func, doc;
|
|
|
|
elem.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
|
|
|
|
} else if (elem.msRequestFullscreen) {
|
|
|
|
// Do nothing when nothing was selected
|
|
|
|
elem.msRequestFullscreen();
|
|
|
|
if (!this.length) return this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// We only use the first selected element because it doesn't make sense
|
|
|
|
|
|
|
|
// to fullscreen multiple elements.
|
|
|
|
|
|
|
|
e = (/** @type {Element} */ this[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Find the real element and the document (Depends on whether the
|
|
|
|
|
|
|
|
// document itself or a HTML element was selected)
|
|
|
|
|
|
|
|
if (e.ownerDocument)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
doc = e.ownerDocument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
doc = e;
|
|
|
|
|
|
|
|
e = doc.documentElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fullScreenStatus(){
|
|
|
|
// When no state was specified then return the current state.
|
|
|
|
return document.fullscreen ||
|
|
|
|
if (state == null)
|
|
|
|
document.mozFullScreen ||
|
|
|
|
{
|
|
|
|
document.webkitIsFullScreen ||
|
|
|
|
// When fullscreen mode is not supported then return null
|
|
|
|
document.msFullscreenElement ||
|
|
|
|
if (!((/** @type {?Function} */ doc["exitFullscreen"])
|
|
|
|
false;
|
|
|
|
|| (/** @type {?Function} */ doc["webkitExitFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["msExitFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["mozCancelFullScreen"])))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cancelFullScreen(){
|
|
|
|
// Check fullscreen state
|
|
|
|
if (document.exitFullscreen) {
|
|
|
|
state = !!doc["fullscreenElement"]
|
|
|
|
document.exitFullscreen();
|
|
|
|
|| !!doc["msFullscreenElement"]
|
|
|
|
} else if (document.mozCancelFullScreen) {
|
|
|
|
|| !!doc["webkitIsFullScreen"]
|
|
|
|
document.mozCancelFullScreen();
|
|
|
|
|| !!doc["mozFullScreen"];
|
|
|
|
} else if (document.webkitCancelFullScreen) {
|
|
|
|
if (!state) return state;
|
|
|
|
document.webkitCancelFullScreen();
|
|
|
|
|
|
|
|
} else if (document.msExitFullscreen) {
|
|
|
|
// Return current fullscreen element or "true" if browser doesn't
|
|
|
|
document.msExitFullscreen();
|
|
|
|
// support this
|
|
|
|
}
|
|
|
|
return (/** @type {?Element} */ doc["fullscreenElement"])
|
|
|
|
|
|
|
|
|| (/** @type {?Element} */ doc["webkitFullscreenElement"])
|
|
|
|
|
|
|
|
|| (/** @type {?Element} */ doc["webkitCurrentFullScreenElement"])
|
|
|
|
|
|
|
|
|| (/** @type {?Element} */ doc["msFullscreenElement"])
|
|
|
|
|
|
|
|
|| (/** @type {?Element} */ doc["mozFullScreenElement"])
|
|
|
|
|
|
|
|
|| state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onFullScreenEvent(callback){
|
|
|
|
// When state was specified then enter or exit fullscreen mode.
|
|
|
|
$(document).on("fullscreenchange mozfullscreenchange webkitfullscreenchange", function(){
|
|
|
|
if (state)
|
|
|
|
// The full screen status is automatically
|
|
|
|
{
|
|
|
|
// passed to our callback as an argument.
|
|
|
|
// Enter fullscreen
|
|
|
|
callback(fullScreenStatus());
|
|
|
|
func = (/** @type {?Function} */ e["requestFullscreen"])
|
|
|
|
});
|
|
|
|
|| (/** @type {?Function} */ e["webkitRequestFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ e["webkitRequestFullScreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ e["msRequestFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ e["mozRequestFullScreen"]);
|
|
|
|
|
|
|
|
if (func)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
func.call(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
if(fullScreenStatus()){
|
|
|
|
{
|
|
|
|
// if we are already in fullscreen, exit
|
|
|
|
// Exit fullscreen
|
|
|
|
cancelFullScreen();
|
|
|
|
func = (/** @type {?Function} */ doc["exitFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["webkitExitFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["msExitFullscreen"])
|
|
|
|
|
|
|
|
|| (/** @type {?Function} */ doc["mozCancelFullScreen"]);
|
|
|
|
|
|
|
|
if (func) func.call(doc);
|
|
|
|
return this;
|
|
|
|
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 = $('<div>', {
|
|
|
|
|
|
|
|
'css' : {
|
|
|
|
|
|
|
|
'overflow-y' : 'auto',
|
|
|
|
|
|
|
|
'background' : options.background,
|
|
|
|
|
|
|
|
'width' : '100%',
|
|
|
|
|
|
|
|
'height' : '100%'
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
.insertBefore(elem)
|
|
|
|
|
|
|
|
.append(elem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// You can use the .fullScreen class to
|
|
|
|
|
|
|
|
// apply styling to your element
|
|
|
|
|
|
|
|
elem.addClass( options.fullscreenClass );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Inserting our element in the temporary
|
|
|
|
|
|
|
|
// div, after which we zoom it in fullscreen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requestFullScreen(fs.get(0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs.click(function(e){
|
|
|
|
/**
|
|
|
|
if(e.target == this){
|
|
|
|
* Toggles the fullscreen mode.
|
|
|
|
// If the black bar was clicked
|
|
|
|
*
|
|
|
|
cancelFullScreen();
|
|
|
|
* @return {!jQuery}
|
|
|
|
|
|
|
|
* The jQuery selection for chaining.
|
|
|
|
|
|
|
|
* @this {jQuery}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function toggleFullScreen()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (/** @type {!jQuery} */ fullScreen.call(this,
|
|
|
|
|
|
|
|
!fullScreen.call(this)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elem.cancel = function(){
|
|
|
|
/**
|
|
|
|
cancelFullScreen();
|
|
|
|
* Handles the browser-specific fullscreenchange event and triggers
|
|
|
|
return elem;
|
|
|
|
* a jquery event for it.
|
|
|
|
};
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param {?Event} event
|
|
|
|
|
|
|
|
* The fullscreenchange event.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fullScreenChangeHandler(event)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jQuery(document).trigger(new jQuery.Event("fullscreenchange"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onFullScreenEvent(function(fullScreen){
|
|
|
|
/**
|
|
|
|
if(!fullScreen){
|
|
|
|
* Handles the browser-specific fullscreenerror event and triggers
|
|
|
|
// We have exited full screen.
|
|
|
|
* a jquery event for it.
|
|
|
|
// Detach event listener
|
|
|
|
*
|
|
|
|
$(document).off( 'fullscreenchange mozfullscreenchange webkitfullscreenchange' );
|
|
|
|
* @param {?Event} event
|
|
|
|
// Remove the class and destroy
|
|
|
|
* The fullscreenerror event.
|
|
|
|
// the temporary div
|
|
|
|
*/
|
|
|
|
|
|
|
|
function fullScreenErrorHandler(event)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jQuery(document).trigger(new jQuery.Event("fullscreenerror"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
elem.removeClass( options.fullscreenClass ).insertBefore(fs);
|
|
|
|
/**
|
|
|
|
fs.remove();
|
|
|
|
* Installs the fullscreenchange event handler.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function installFullScreenHandlers()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var e, change, error;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Determine event name
|
|
|
|
|
|
|
|
e = document;
|
|
|
|
|
|
|
|
if (e["webkitCancelFullScreen"])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
change = "webkitfullscreenchange";
|
|
|
|
|
|
|
|
error = "webkitfullscreenerror";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (e["msExitFullscreen"])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
change = "MSFullscreenChange";
|
|
|
|
|
|
|
|
error = "MSFullscreenError";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (e["mozCancelFullScreen"])
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
change = "mozfullscreenchange";
|
|
|
|
|
|
|
|
error = "mozfullscreenerror";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
change = "fullscreenchange";
|
|
|
|
|
|
|
|
error = "fullscreenerror";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calling the facultative user supplied callback
|
|
|
|
// Install the event handlers
|
|
|
|
if(options.callback) {
|
|
|
|
jQuery(document).bind(change, fullScreenChangeHandler);
|
|
|
|
options.callback(fullScreen);
|
|
|
|
jQuery(document).bind(error, fullScreenErrorHandler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return elem;
|
|
|
|
jQuery.fn["fullScreen"] = fullScreen;
|
|
|
|
};
|
|
|
|
jQuery.fn["toggleFullScreen"] = toggleFullScreen;
|
|
|
|
|
|
|
|
installFullScreenHandlers();
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.cancelFullScreen = function( ) {
|
|
|
|
})(jQuery);
|
|
|
|
cancelFullScreen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}(jQuery));
|
|
|
|
|
|
|
|