server/php/basic/public_html/static/lib/screenfull/screenfull.js
author durandn
Thu, 21 Apr 2016 15:18:19 +0200
changeset 605 13d355fd09bf
parent 558 1a47a5f00d83
permissions -rw-r--r--
updated uri to allow optional trailing slash on single resource URIs (django automatic redirects don't carry over the Authorization header that can sometimes be needed, for instance with OAuth)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
558
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     1
/*!
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     2
* screenfull
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     3
* v2.0.0 - 2014-12-22
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     4
* (c) Sindre Sorhus; MIT License
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     5
*/
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     6
(function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     7
	'use strict';
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     8
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
     9
	var isCommonjs = typeof module !== 'undefined' && module.exports;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    10
	var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    11
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    12
	var fn = (function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    13
		var val;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    14
		var valLength;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    15
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    16
		var fnMap = [
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    17
			[
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    18
				'requestFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    19
				'exitFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    20
				'fullscreenElement',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    21
				'fullscreenEnabled',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    22
				'fullscreenchange',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    23
				'fullscreenerror'
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    24
			],
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    25
			// new WebKit
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    26
			[
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    27
				'webkitRequestFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    28
				'webkitExitFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    29
				'webkitFullscreenElement',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    30
				'webkitFullscreenEnabled',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    31
				'webkitfullscreenchange',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    32
				'webkitfullscreenerror'
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    33
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    34
			],
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    35
			// old WebKit (Safari 5.1)
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    36
			[
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    37
				'webkitRequestFullScreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    38
				'webkitCancelFullScreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    39
				'webkitCurrentFullScreenElement',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    40
				'webkitCancelFullScreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    41
				'webkitfullscreenchange',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    42
				'webkitfullscreenerror'
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    43
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    44
			],
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    45
			[
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    46
				'mozRequestFullScreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    47
				'mozCancelFullScreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    48
				'mozFullScreenElement',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    49
				'mozFullScreenEnabled',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    50
				'mozfullscreenchange',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    51
				'mozfullscreenerror'
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    52
			],
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    53
			[
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    54
				'msRequestFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    55
				'msExitFullscreen',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    56
				'msFullscreenElement',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    57
				'msFullscreenEnabled',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    58
				'MSFullscreenChange',
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    59
				'MSFullscreenError'
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    60
			]
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    61
		];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    62
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    63
		var i = 0;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    64
		var l = fnMap.length;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    65
		var ret = {};
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    66
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    67
		for (; i < l; i++) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    68
			val = fnMap[i];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    69
			if (val && val[1] in document) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    70
				for (i = 0, valLength = val.length; i < valLength; i++) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    71
					ret[fnMap[0][i]] = val[i];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    72
				}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    73
				return ret;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    74
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    75
		}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    76
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    77
		return false;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    78
	})();
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    79
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    80
	var screenfull = {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    81
		request: function (elem) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    82
			var request = fn.requestFullscreen;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    83
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    84
			elem = elem || document.documentElement;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    85
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    86
			// Work around Safari 5.1 bug: reports support for
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    87
			// keyboard in fullscreen even though it doesn't.
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    88
			// Browser sniffing, since the alternative with
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    89
			// setTimeout is even worse.
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    90
			if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    91
				elem[request]();
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    92
			} else {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    93
				elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    94
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    95
		},
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    96
		exit: function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    97
			document[fn.exitFullscreen]();
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    98
		},
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
    99
		toggle: function (elem) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   100
			if (this.isFullscreen) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   101
				this.exit();
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   102
			} else {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   103
				this.request(elem);
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   104
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   105
		},
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   106
		raw: fn
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   107
	};
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   108
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   109
	if (!fn) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   110
		if (isCommonjs) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   111
			module.exports = false;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   112
		} else {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   113
			window.screenfull = false;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   114
		}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   115
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   116
		return;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   117
	}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   118
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   119
	Object.defineProperties(screenfull, {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   120
		isFullscreen: {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   121
			get: function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   122
				return !!document[fn.fullscreenElement];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   123
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   124
		},
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   125
		element: {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   126
			enumerable: true,
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   127
			get: function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   128
				return document[fn.fullscreenElement];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   129
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   130
		},
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   131
		enabled: {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   132
			enumerable: true,
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   133
			get: function () {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   134
				// Coerce to boolean in case of old WebKit
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   135
				return !!document[fn.fullscreenEnabled];
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   136
			}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   137
		}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   138
	});
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   139
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   140
	if (isCommonjs) {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   141
		module.exports = screenfull;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   142
	} else {
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   143
		window.screenfull = screenfull;
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   144
	}
1a47a5f00d83 grunt and copy server the new renkan version and the new lib screenfull
rougeronj
parents:
diff changeset
   145
})();