]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixing undefined originalEvent
authorThomas Mueller <thomas.mueller@tmit.eu>
Thu, 14 Feb 2013 11:06:16 +0000 (12:06 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Thu, 14 Feb 2013 11:19:50 +0000 (12:19 +0100)
apps/files/js/jquery-visibility.js

index a824bf6873076b284def2bd5a47c1d6ae52a5611..18f57d1f2bd19eaac9f3f2fa24c6833b1de46630 100644 (file)
@@ -3,7 +3,7 @@
 
        var prefix,
                property,
-// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior
+               // 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,
 
        $(/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)) {
+                       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');
                }
        });