summaryrefslogtreecommitdiffstats
path: root/apps/files/js/jquery-visibility.js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-08-17 09:39:21 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-08-17 09:39:21 +0200
commit51c3a3ddaf7efd4dda602c693d5670498978d4fa (patch)
tree8d17c2bd066200f968befd78228327dc01f43d73 /apps/files/js/jquery-visibility.js
parent5b7143885d195d59cd6c3982314f9b92fa60d8aa (diff)
downloadnextcloud-server-51c3a3ddaf7efd4dda602c693d5670498978d4fa.tar.gz
nextcloud-server-51c3a3ddaf7efd4dda602c693d5670498978d4fa.zip
update jquery-visibility in files app
* ref #12877
Diffstat (limited to 'apps/files/js/jquery-visibility.js')
-rw-r--r--apps/files/js/jquery-visibility.js101
1 files changed, 79 insertions, 22 deletions
diff --git a/apps/files/js/jquery-visibility.js b/apps/files/js/jquery-visibility.js
index 18f57d1f2bd..4d65e7771f9 100644
--- a/apps/files/js/jquery-visibility.js
+++ b/apps/files/js/jquery-visibility.js
@@ -1,31 +1,88 @@
-/*! http://mths.be/visibility v1.0.5 by @mathias */
-(function (window, document, $, undefined) {
+/*!
+ * jquery-visibility v1.0.11
+ * Page visibility shim for jQuery.
+ *
+ * Project Website: http://mths.be/visibility
+ *
+ * @version 1.0.11
+ * @license MIT.
+ * @author Mathias Bynens - @mathias
+ * @author Jan Paepke - @janpaepke
+ */
+;(function (root, factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], function ($) {
+ return factory(root, $);
+ });
+ } else if (typeof exports === 'object') {
+ // Node/CommonJS
+ module.exports = factory(root, require('jquery'));
+ } else {
+ // Browser globals
+ factory(root, jQuery);
+ }
+}(this, function(window, $, undefined) {
+ "use strict";
- var prefix,
- property,
- // In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
- eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur',
- prefixes = ['', 'moz', 'ms', 'o', 'webkit'],
- $support = $.support,
- $event = $.event;
+ var
+ document = window.document,
+ property, // property name of document, that stores page visibility
+ vendorPrefixes = ['webkit', 'o', 'ms', 'moz', ''],
+ $support = $.support || {},
+ // In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
+ eventName = 'onfocusin' in document && 'hasFocus' in document ?
+ 'focusin focusout' :
+ 'focus blur';
- while ((property = prefix = prefixes.pop()) != undefined) {
- property = (prefix ? prefix + 'H' : 'h') + 'idden';
- if ($support.pageVisibility = typeof document[property] == 'boolean') {
+ var prefix;
+ while ((prefix = vendorPrefixes.pop()) !== undefined) {
+ property = (prefix ? prefix + 'H': 'h') + 'idden';
+ $support.pageVisibility = document[property] !== undefined;
+ if ($support.pageVisibility) {
eventName = prefix + 'visibilitychange';
break;
}
}
- $(/blur$/.test(eventName) ? window : document).on(eventName, function (event) {
- var type = event.type,
- originalEvent = event.originalEvent;
- // If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`;
- // else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc.
- // In IE9, we need to check the `relatedTarget` property instead.
- if (!/^focus./.test(type) || originalEvent == undefined || (originalEvent.toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) {
- $event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility');
+ // normalize to and update document hidden property
+ function updateState() {
+ if (property !== 'hidden') {
+ document.hidden = $support.pageVisibility ? document[property] : undefined;
}
- });
+ }
+ updateState();
-}(this, document, jQuery));
+ $(/blur$/.test(eventName) ? window : document).on(eventName, function(event) {
+ var type = event.type;
+ var originalEvent = event.originalEvent;
+
+ // Avoid errors from triggered native events for which `originalEvent` is
+ // not available.
+ if (!originalEvent) {
+ return;
+ }
+
+ var toElement = originalEvent.toElement;
+
+ // If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement`
+ // should both be `null` or `undefined`; else, the page visibility hasn’t
+ // changed, but the user just clicked somewhere in the doc. In IE9, we need
+ // to check the `relatedTarget` property instead.
+ if (
+ !/^focus./.test(type) || (
+ toElement === undefined &&
+ originalEvent.fromElement === undefined &&
+ originalEvent.relatedTarget === undefined
+ )
+ ) {
+ $(document).triggerHandler(
+ property && document[property] || /^(?:blur|focusout)$/.test(type) ?
+ 'hide' :
+ 'show'
+ );
+ }
+ // and update the current state
+ updateState();
+ });
+}));