Browse Source

Moves some functions from app.js

master
hristoterezov 10 years ago
parent
commit
1057ff36cd

+ 0
- 145
app.js View File

@@ -480,10 +480,6 @@ $(document).bind('iceconnectionstatechange.jingle', function (event, sid, sessio
480 480
     }
481 481
 });
482 482
 
483
-$(document).bind('joined.muc', function (event, jid, info) {
484
-
485
-});
486
-
487 483
 $(document).bind('presence.muc', function (event, jid, info, pres) {
488 484
 
489 485
     //check if the video bridge is available
@@ -750,84 +746,6 @@ function isAudioMuted()
750 746
     return true;
751 747
 }
752 748
 
753
-/**
754
- * Returns an array of the video horizontal and vertical indents,
755
- * so that if fits its parent.
756
- *
757
- * @return an array with 2 elements, the horizontal indent and the vertical
758
- * indent
759
- */
760
-function getCameraVideoPosition(videoWidth,
761
-                                videoHeight,
762
-                                videoSpaceWidth,
763
-                                videoSpaceHeight) {
764
-    // Parent height isn't completely calculated when we position the video in
765
-    // full screen mode and this is why we use the screen height in this case.
766
-    // Need to think it further at some point and implement it properly.
767
-    var isFullScreen = document.fullScreen ||
768
-            document.mozFullScreen ||
769
-            document.webkitIsFullScreen;
770
-    if (isFullScreen)
771
-        videoSpaceHeight = window.innerHeight;
772
-
773
-    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
774
-    var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
775
-
776
-    return [horizontalIndent, verticalIndent];
777
-}
778
-
779
-/**
780
- * Returns an array of the video horizontal and vertical indents.
781
- * Centers horizontally and top aligns vertically.
782
- *
783
- * @return an array with 2 elements, the horizontal indent and the vertical
784
- * indent
785
- */
786
-function getDesktopVideoPosition(videoWidth,
787
-                                 videoHeight,
788
-                                 videoSpaceWidth,
789
-                                 videoSpaceHeight) {
790
-
791
-    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
792
-
793
-    var verticalIndent = 0;// Top aligned
794
-
795
-    return [horizontalIndent, verticalIndent];
796
-}
797
-
798
-/**
799
- * Returns an array of the video dimensions, so that it covers the screen.
800
- * It leaves no empty areas, but some parts of the video might not be visible.
801
- *
802
- * @return an array with 2 elements, the video width and the video height
803
- */
804
-function getCameraVideoSize(videoWidth,
805
-                           videoHeight,
806
-                           videoSpaceWidth,
807
-                           videoSpaceHeight) {
808
-    if (!videoWidth)
809
-        videoWidth = currentVideoWidth;
810
-    if (!videoHeight)
811
-        videoHeight = currentVideoHeight;
812
-
813
-    var aspectRatio = videoWidth / videoHeight;
814
-
815
-    var availableWidth = Math.max(videoWidth, videoSpaceWidth);
816
-    var availableHeight = Math.max(videoHeight, videoSpaceHeight);
817
-
818
-    if (availableWidth / aspectRatio < videoSpaceHeight) {
819
-        availableHeight = videoSpaceHeight;
820
-        availableWidth = availableHeight * aspectRatio;
821
-    }
822
-
823
-    if (availableHeight * aspectRatio < videoSpaceWidth) {
824
-        availableWidth = videoSpaceWidth;
825
-        availableHeight = availableWidth / aspectRatio;
826
-    }
827
-
828
-    return [availableWidth, availableHeight];
829
-}
830
-
831 749
 $(document).ready(function () {
832 750
 
833 751
     if(APIConnector.isEnabled())
@@ -844,10 +762,6 @@ $(document).ready(function () {
844 762
     if (config.chromeExtensionId) {
845 763
         initInlineInstalls();
846 764
     }
847
-
848
-    // By default we use camera
849
-    getVideoSize = getCameraVideoSize;
850
-    getVideoPosition = getCameraVideoPosition;
851 765
 });
852 766
 
853 767
 $(window).bind('beforeunload', function () {
@@ -940,62 +854,3 @@ function populateData() {
940 854
 function buttonClick(id, classname) {
941 855
     $(id).toggleClass(classname); // add the class to the clicked element
942 856
 }
943
-
944
-
945
-/**
946
- * Warning to the user that the conference window is about to be closed.
947
- */
948
-function closePageWarning() {
949
-    /*
950
-    FIXME: do we need a warning when the focus is a server-side one now ?
951
-    if (focus !== null)
952
-        return "You are the owner of this conference call and"
953
-                + " you are about to end it.";
954
-    else*/
955
-    return "You are about to leave this conversation.";
956
-}
957
-
958
-
959
-$(document).bind('error.jingle',
960
-    function (event, session, error)
961
-    {
962
-        console.error("Jingle error", error);
963
-    }
964
-);
965
-
966
-$(document).bind('fatalError.jingle',
967
-    function (event, session, error)
968
-    {
969
-        sessionTerminated = true;
970
-        connection.emuc.doLeave();
971
-        UI.messageHandler.showError(  "Sorry",
972
-            "Internal application error[setRemoteDescription]");
973
-    }
974
-);
975
-
976
-function hangup() {
977
-    disposeConference();
978
-    sessionTerminated = true;
979
-    connection.emuc.doLeave();
980
-    if(config.enableWelcomePage)
981
-    {
982
-        setTimeout(function()
983
-        {
984
-            window.localStorage.welcomePageDisabled = false;
985
-            window.location.pathname = "/";
986
-        }, 10000);
987
-
988
-    }
989
-
990
-    UI.messageHandler.openDialog(
991
-        "Session Terminated",
992
-        "You hung up the call",
993
-        true,
994
-        { "Join again": true },
995
-        function(event, value, message, formVals)
996
-        {
997
-            window.location.reload();
998
-            return false;
999
-        }
1000
-    );
1001
-}

+ 110
- 0
libs/modules/UI.bundle.js View File

@@ -2982,6 +2982,33 @@ var buttonHandlers =
2982 2982
     }
2983 2983
 };
2984 2984
 
2985
+function hangup() {
2986
+    disposeConference();
2987
+    sessionTerminated = true;
2988
+    connection.emuc.doLeave();
2989
+    if(config.enableWelcomePage)
2990
+    {
2991
+        setTimeout(function()
2992
+        {
2993
+            window.localStorage.welcomePageDisabled = false;
2994
+            window.location.pathname = "/";
2995
+        }, 10000);
2996
+
2997
+    }
2998
+
2999
+    UI.messageHandler.openDialog(
3000
+        "Session Terminated",
3001
+        "You hung up the call",
3002
+        true,
3003
+        { "Join again": true },
3004
+        function(event, value, message, formVals)
3005
+        {
3006
+            window.location.reload();
3007
+            return false;
3008
+        }
3009
+    );
3010
+}
3011
+
2985 3012
 /**
2986 3013
  * Starts or stops the recording for the conference.
2987 3014
  */
@@ -4153,8 +4180,91 @@ var largeVideoState = {
4153 4180
     newSrc: ''
4154 4181
 };
4155 4182
 
4183
+// By default we use camera
4184
+var getVideoSize = getCameraVideoSize;
4185
+var getVideoPosition = getCameraVideoPosition;
4186
+
4156 4187
 var defaultLocalDisplayName = "Me";
4157 4188
 
4189
+/**
4190
+ * Returns an array of the video horizontal and vertical indents,
4191
+ * so that if fits its parent.
4192
+ *
4193
+ * @return an array with 2 elements, the horizontal indent and the vertical
4194
+ * indent
4195
+ */
4196
+function getCameraVideoPosition(videoWidth,
4197
+                                videoHeight,
4198
+                                videoSpaceWidth,
4199
+                                videoSpaceHeight) {
4200
+    // Parent height isn't completely calculated when we position the video in
4201
+    // full screen mode and this is why we use the screen height in this case.
4202
+    // Need to think it further at some point and implement it properly.
4203
+    var isFullScreen = document.fullScreen ||
4204
+        document.mozFullScreen ||
4205
+        document.webkitIsFullScreen;
4206
+    if (isFullScreen)
4207
+        videoSpaceHeight = window.innerHeight;
4208
+
4209
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
4210
+    var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
4211
+
4212
+    return [horizontalIndent, verticalIndent];
4213
+}
4214
+
4215
+/**
4216
+ * Returns an array of the video horizontal and vertical indents.
4217
+ * Centers horizontally and top aligns vertically.
4218
+ *
4219
+ * @return an array with 2 elements, the horizontal indent and the vertical
4220
+ * indent
4221
+ */
4222
+function getDesktopVideoPosition(videoWidth,
4223
+                                 videoHeight,
4224
+                                 videoSpaceWidth,
4225
+                                 videoSpaceHeight) {
4226
+
4227
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
4228
+
4229
+    var verticalIndent = 0;// Top aligned
4230
+
4231
+    return [horizontalIndent, verticalIndent];
4232
+}
4233
+
4234
+
4235
+/**
4236
+ * Returns an array of the video dimensions, so that it covers the screen.
4237
+ * It leaves no empty areas, but some parts of the video might not be visible.
4238
+ *
4239
+ * @return an array with 2 elements, the video width and the video height
4240
+ */
4241
+function getCameraVideoSize(videoWidth,
4242
+                            videoHeight,
4243
+                            videoSpaceWidth,
4244
+                            videoSpaceHeight) {
4245
+    if (!videoWidth)
4246
+        videoWidth = currentVideoWidth;
4247
+    if (!videoHeight)
4248
+        videoHeight = currentVideoHeight;
4249
+
4250
+    var aspectRatio = videoWidth / videoHeight;
4251
+
4252
+    var availableWidth = Math.max(videoWidth, videoSpaceWidth);
4253
+    var availableHeight = Math.max(videoHeight, videoSpaceHeight);
4254
+
4255
+    if (availableWidth / aspectRatio < videoSpaceHeight) {
4256
+        availableHeight = videoSpaceHeight;
4257
+        availableWidth = availableHeight * aspectRatio;
4258
+    }
4259
+
4260
+    if (availableHeight * aspectRatio < videoSpaceWidth) {
4261
+        availableWidth = videoSpaceWidth;
4262
+        availableHeight = availableWidth / aspectRatio;
4263
+    }
4264
+
4265
+    return [availableWidth, availableHeight];
4266
+}
4267
+
4158 4268
 /**
4159 4269
  * Sets the display name for the given video span id.
4160 4270
  */

+ 18
- 6
libs/strophe/strophe.jingle.session.js View File

@@ -163,7 +163,7 @@ JingleSession.prototype.accept = function () {
163 163
                         reason: $(stanza).find('error :first')[0].tagName
164 164
                     }:{};
165 165
                     error.source = 'answer';
166
-                    $(document).trigger('error.jingle', [self.sid, error]);
166
+                    JingleSession.onJingleError(self.sid, error);
167 167
                 },
168 168
                 10000);
169 169
         },
@@ -252,7 +252,7 @@ JingleSession.prototype.sendIceCandidate = function (candidate) {
252 252
                             reason: $(stanza).find('error :first')[0].tagName,
253 253
                         }:{};
254 254
                         error.source = 'offer';
255
-                        $(document).trigger('error.jingle', [self.sid, error]);
255
+                        JingleSession.onJingleError(self.sid, error);
256 256
                     },
257 257
                     10000);
258 258
             }
@@ -317,7 +317,7 @@ JingleSession.prototype.sendIceCandidates = function (candidates) {
317 317
                 reason: $(stanza).find('error :first')[0].tagName,
318 318
             }:{};
319 319
             error.source = 'transportinfo';
320
-            $(document).trigger('error.jingle', [this.sid, error]);
320
+            JingleSession.onJingleError(this.sid, error);
321 321
         },
322 322
         10000);
323 323
 };
@@ -363,7 +363,7 @@ JingleSession.prototype.createdOffer = function (sdp) {
363 363
                     reason: $(stanza).find('error :first')[0].tagName,
364 364
                 }:{};
365 365
                 error.source = 'offer';
366
-                $(document).trigger('error.jingle', [self.sid, error]);
366
+                JingleSession.onJingleError(self.sid, error);
367 367
             },
368 368
             10000);
369 369
     }
@@ -433,7 +433,7 @@ JingleSession.prototype.setRemoteDescription = function (elem, desctype) {
433 433
         },
434 434
         function (e) {
435 435
             console.error('setRemoteDescription error', e);
436
-            $(document).trigger('fatalError.jingle', [self, e]);
436
+            JingleSession.onJingleFatalError(self, e);
437 437
         }
438 438
     );
439 439
 };
@@ -600,7 +600,7 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) {
600 600
                             reason: $(stanza).find('error :first')[0].tagName,
601 601
                         }:{};
602 602
                         error.source = 'answer';
603
-                        $(document).trigger('error.jingle', [self.sid, error]);
603
+                        JingleSession.onJingleError(self.sid, error);
604 604
                     },
605 605
                     10000);
606 606
     }
@@ -1180,3 +1180,15 @@ JingleSession.prototype.getStats = function (interval) {
1180 1180
     return this.statsinterval;
1181 1181
 };
1182 1182
 
1183
+JingleSession.onJingleError = function (session, error)
1184
+{
1185
+    console.error("Jingle error", error);
1186
+}
1187
+
1188
+JingleSession.onJingleFatalError = function (session, error)
1189
+{
1190
+    sessionTerminated = true;
1191
+    connection.emuc.doLeave();
1192
+    UI.messageHandler.showError(  "Sorry",
1193
+        "Internal application error[setRemoteDescription]");
1194
+}

+ 27
- 0
modules/UI/toolbars/Toolbar.js View File

@@ -58,6 +58,33 @@ var buttonHandlers =
58 58
     }
59 59
 };
60 60
 
61
+function hangup() {
62
+    disposeConference();
63
+    sessionTerminated = true;
64
+    connection.emuc.doLeave();
65
+    if(config.enableWelcomePage)
66
+    {
67
+        setTimeout(function()
68
+        {
69
+            window.localStorage.welcomePageDisabled = false;
70
+            window.location.pathname = "/";
71
+        }, 10000);
72
+
73
+    }
74
+
75
+    UI.messageHandler.openDialog(
76
+        "Session Terminated",
77
+        "You hung up the call",
78
+        true,
79
+        { "Join again": true },
80
+        function(event, value, message, formVals)
81
+        {
82
+            window.location.reload();
83
+            return false;
84
+        }
85
+    );
86
+}
87
+
61 88
 /**
62 89
  * Starts or stops the recording for the conference.
63 90
  */

+ 83
- 0
modules/UI/videolayout/VideoLayout.js View File

@@ -16,8 +16,91 @@ var largeVideoState = {
16 16
     newSrc: ''
17 17
 };
18 18
 
19
+// By default we use camera
20
+var getVideoSize = getCameraVideoSize;
21
+var getVideoPosition = getCameraVideoPosition;
22
+
19 23
 var defaultLocalDisplayName = "Me";
20 24
 
25
+/**
26
+ * Returns an array of the video horizontal and vertical indents,
27
+ * so that if fits its parent.
28
+ *
29
+ * @return an array with 2 elements, the horizontal indent and the vertical
30
+ * indent
31
+ */
32
+function getCameraVideoPosition(videoWidth,
33
+                                videoHeight,
34
+                                videoSpaceWidth,
35
+                                videoSpaceHeight) {
36
+    // Parent height isn't completely calculated when we position the video in
37
+    // full screen mode and this is why we use the screen height in this case.
38
+    // Need to think it further at some point and implement it properly.
39
+    var isFullScreen = document.fullScreen ||
40
+        document.mozFullScreen ||
41
+        document.webkitIsFullScreen;
42
+    if (isFullScreen)
43
+        videoSpaceHeight = window.innerHeight;
44
+
45
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
46
+    var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
47
+
48
+    return [horizontalIndent, verticalIndent];
49
+}
50
+
51
+/**
52
+ * Returns an array of the video horizontal and vertical indents.
53
+ * Centers horizontally and top aligns vertically.
54
+ *
55
+ * @return an array with 2 elements, the horizontal indent and the vertical
56
+ * indent
57
+ */
58
+function getDesktopVideoPosition(videoWidth,
59
+                                 videoHeight,
60
+                                 videoSpaceWidth,
61
+                                 videoSpaceHeight) {
62
+
63
+    var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
64
+
65
+    var verticalIndent = 0;// Top aligned
66
+
67
+    return [horizontalIndent, verticalIndent];
68
+}
69
+
70
+
71
+/**
72
+ * Returns an array of the video dimensions, so that it covers the screen.
73
+ * It leaves no empty areas, but some parts of the video might not be visible.
74
+ *
75
+ * @return an array with 2 elements, the video width and the video height
76
+ */
77
+function getCameraVideoSize(videoWidth,
78
+                            videoHeight,
79
+                            videoSpaceWidth,
80
+                            videoSpaceHeight) {
81
+    if (!videoWidth)
82
+        videoWidth = currentVideoWidth;
83
+    if (!videoHeight)
84
+        videoHeight = currentVideoHeight;
85
+
86
+    var aspectRatio = videoWidth / videoHeight;
87
+
88
+    var availableWidth = Math.max(videoWidth, videoSpaceWidth);
89
+    var availableHeight = Math.max(videoHeight, videoSpaceHeight);
90
+
91
+    if (availableWidth / aspectRatio < videoSpaceHeight) {
92
+        availableHeight = videoSpaceHeight;
93
+        availableWidth = availableHeight * aspectRatio;
94
+    }
95
+
96
+    if (availableHeight * aspectRatio < videoSpaceWidth) {
97
+        availableWidth = videoSpaceWidth;
98
+        availableHeight = availableWidth / aspectRatio;
99
+    }
100
+
101
+    return [availableWidth, availableHeight];
102
+}
103
+
21 104
 /**
22 105
  * Sets the display name for the given video span id.
23 106
  */

Loading…
Cancel
Save