浏览代码

Handles the case where browser is blocking popups and prevents from opening authentication window.

master
paweldomas 10 年前
父节点
当前提交
78f8521145
共有 2 个文件被更改,包括 12 次插入1 次删除
  1. 7
    0
      app.js
  2. 5
    1
      message_handler.js

+ 7
- 0
app.js 查看文件

1074
                     roomName, doJoinAfterFocus);
1074
                     roomName, doJoinAfterFocus);
1075
                 authenticationWindow = null;
1075
                 authenticationWindow = null;
1076
             });
1076
             });
1077
+        if (!authenticationWindow) {
1078
+            Toolbar.showAuthenticateButton(true);
1079
+            messageHandler.openMessageDialog(
1080
+                null, "Your browser is blocking popup windows from this site." +
1081
+                " Please enable popups in your browser security settings" +
1082
+                " and try again.");
1083
+        }
1077
     });
1084
     });
1078
 };
1085
 };
1079
 
1086
 

+ 5
- 1
message_handler.js 查看文件

89
      * @param h the height of the popup window
89
      * @param h the height of the popup window
90
      * @param onPopupClosed optional callback function called when popup window
90
      * @param onPopupClosed optional callback function called when popup window
91
      *        has been closed.
91
      *        has been closed.
92
+     *
93
+     * @returns popup window object if opened successfully or undefined
94
+     *          in case we failed to open it(popup blocked)
92
      */
95
      */
93
     my.openCenteredPopup = function (url, w, h, onPopupClosed) {
96
     my.openCenteredPopup = function (url, w, h, onPopupClosed) {
94
         var l = window.screenX + (window.innerWidth / 2) - (w / 2);
97
         var l = window.screenX + (window.innerWidth / 2) - (w / 2);
96
         var popup = window.open(
99
         var popup = window.open(
97
             url, '_blank',
100
             url, '_blank',
98
             'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + '');
101
             'top=' + t + ', left=' + l + ', width=' + w + ', height=' + h + '');
99
-        if (onPopupClosed) {
102
+        if (popup && onPopupClosed) {
100
             var pollTimer = window.setInterval(function () {
103
             var pollTimer = window.setInterval(function () {
101
                 if (popup.closed !== false) {
104
                 if (popup.closed !== false) {
102
                     window.clearInterval(pollTimer);
105
                     window.clearInterval(pollTimer);
104
                 }
107
                 }
105
             }, 200);
108
             }, 200);
106
         }
109
         }
110
+        return popup;
107
     };
111
     };
108
 
112
 
109
     /**
113
     /**

正在加载...
取消
保存