* Sets or gets the fullscreen state. * * @param {boolean=} state * True to enable fullscreen mode, false to disable it. If not * specified then the current fullscreen state is returned. * @return {boolean|Element|jQuery|null} * When querying the fullscreen stat
(state)
| 25 | * @this {jQuery} |
| 26 | */ |
| 27 | function fullScreen(state) |
| 28 | { |
| 29 | var e, func, doc; |
| 30 | |
| 31 | // Do nothing when nothing was selected |
| 32 | if (!this.length) return this; |
| 33 | |
| 34 | // We only use the first selected element because it doesn't make sense |
| 35 | // to fullscreen multiple elements. |
| 36 | e = (/** @type {Element} */ this[0]); |
| 37 | |
| 38 | // Find the real element and the document (Depends on whether the |
| 39 | // document itself or a HTML element was selected) |
| 40 | if (e.ownerDocument) |
| 41 | { |
| 42 | doc = e.ownerDocument; |
| 43 | } |
| 44 | else |
| 45 | { |
| 46 | doc = e; |
| 47 | e = doc.documentElement; |
| 48 | } |
| 49 | |
| 50 | // When no state was specified then return the current state. |
| 51 | if (state == null) |
| 52 | { |
| 53 | // When fullscreen mode is not supported then return null |
| 54 | if (!((/** @type {?Function} */ doc["exitFullscreen"]) |
| 55 | || (/** @type {?Function} */ doc["webkitExitFullscreen"]) |
| 56 | || (/** @type {?Function} */ doc["webkitCancelFullScreen"]) |
| 57 | || (/** @type {?Function} */ doc["msExitFullscreen"]) |
| 58 | || (/** @type {?Function} */ doc["mozCancelFullScreen"]))) |
| 59 | { |
| 60 | return null; |
| 61 | } |
| 62 | |
| 63 | // Check fullscreen state |
| 64 | state = fullScreenState(doc); |
| 65 | if (!state) return state; |
| 66 | |
| 67 | // Return current fullscreen element or "true" if browser doesn't |
| 68 | // support this |
| 69 | return (/** @type {?Element} */ doc["fullscreenElement"]) |
| 70 | || (/** @type {?Element} */ doc["webkitFullscreenElement"]) |
| 71 | || (/** @type {?Element} */ doc["webkitCurrentFullScreenElement"]) |
| 72 | || (/** @type {?Element} */ doc["msFullscreenElement"]) |
| 73 | || (/** @type {?Element} */ doc["mozFullScreenElement"]) |
| 74 | || state; |
| 75 | } |
| 76 | |
| 77 | // When state was specified then enter or exit fullscreen mode. |
| 78 | if (state) |
| 79 | { |
| 80 | // Enter fullscreen |
| 81 | func = (/** @type {?Function} */ e["requestFullscreen"]) |
| 82 | || (/** @type {?Function} */ e["webkitRequestFullscreen"]) |
| 83 | || (/** @type {?Function} */ e["webkitRequestFullScreen"]) |
| 84 | || (/** @type {?Function} */ e["msRequestFullscreen"]) |
nothing calls this directly
no test coverage detected