aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/jquery-visibility.js
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-02-11 20:27:05 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-02-11 20:27:05 -0500
commit6eba790a75ba128e3182771a30dbe88733ee0dfc (patch)
treeba313bec694c64928d82e2b76445d6307a305b22 /apps/files/js/jquery-visibility.js
parent6f08b1f829e9d4c49f66b19fdda8c229bc8ae3f3 (diff)
parent04bf8c1b66d6adef0466efae00c32745465767f2 (diff)
downloadnextcloud-server-6eba790a75ba128e3182771a30dbe88733ee0dfc.tar.gz
nextcloud-server-6eba790a75ba128e3182771a30dbe88733ee0dfc.zip
Merge branch 'master' into external_storage_ui_feedback
Conflicts: apps/files_external/js/dropbox.js apps/files_external/js/google.js apps/files_external/js/settings.js apps/files_external/lib/amazons3.php apps/files_external/lib/dropbox.php apps/files_external/lib/google.php apps/files_external/lib/smb.php apps/files_external/lib/swift.php apps/files_external/lib/webdav.php lib/filestorage.php
Diffstat (limited to 'apps/files/js/jquery-visibility.js')
-rw-r--r--apps/files/js/jquery-visibility.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/files/js/jquery-visibility.js b/apps/files/js/jquery-visibility.js
new file mode 100644
index 00000000000..a824bf68730
--- /dev/null
+++ b/apps/files/js/jquery-visibility.js
@@ -0,0 +1,32 @@
+/*! http://mths.be/visibility v1.0.5 by @mathias */
+(function (window, document, $, undefined) {
+
+ 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;
+
+ while ((property = prefix = prefixes.pop()) != undefined) {
+ property = (prefix ? prefix + 'H' : 'h') + 'idden';
+ if ($support.pageVisibility = typeof document[property] == 'boolean') {
+ eventName = prefix + 'visibilitychange';
+ break;
+ }
+ }
+
+ $(/blur$/.test(eventName) ? window : document).on(eventName, function (event) {
+ var type = event.type,
+ originalEvent = event.originalEvent,
+ 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)) {
+ $event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility');
+ }
+ });
+
+}(this, document, jQuery));