瀏覽代碼

Fixes chat panel broken layout. Closes #5.

j8
Yana Stamcheva 11 年之前
父節點
當前提交
028c8f27c2
共有 3 個檔案被更改,包括 105 行新增67 行删除
  1. 57
    25
      app.js
  2. 38
    33
      css/main.css
  3. 10
    9
      index.html

+ 57
- 25
app.js 查看文件

@@ -46,7 +46,7 @@ function init() {
46 46
             if (RTC.browser == 'firefox') {
47 47
                 getUserMediaWithConstraints(['audio']);
48 48
             } else {
49
-                getUserMediaWithConstraints(['audio', 'video'], config.resolution || '360');
49
+                getUserMediaWithConstraints(['audio', 'video'], '360');
50 50
             }
51 51
             document.getElementById('connect').disabled = true;
52 52
         } else {
@@ -99,6 +99,7 @@ function doJoin() {
99 99
 $(document).bind('mediaready.jingle', function (event, stream) {
100 100
     connection.jingle.localStream = stream;
101 101
     RTC.attachMediaStream($('#localVideo'), stream);
102
+    document.getElementById('localVideo').muted = true;
102 103
     document.getElementById('localVideo').autoplay = true;
103 104
     document.getElementById('localVideo').volume = 0;
104 105
 
@@ -106,13 +107,7 @@ $(document).bind('mediaready.jingle', function (event, stream) {
106 107
     updateLargeVideo(localVideoSrc, true, 0);
107 108
 
108 109
     $('#localVideo').click(function () {
109
-        updateLargeVideo($(this).attr('src'), true, 0);
110
-        $('video').each(function (idx, el) {
111
-            if (el.id.indexOf('mixedmslabel') != -1) {
112
-                el.volume = 0;
113
-                el.volume = 1;
114
-            }
115
-        });
110
+        updateLargeVideo($(this).attr('src'), true, 1);
116 111
     });
117 112
 
118 113
     doJoin();
@@ -432,13 +427,6 @@ $(document).bind('presentationadded.muc', function (event, jid, presUrl, current
432 427
                 });
433 428
 
434 429
     $('#presentation>iframe').attr('id', preziPlayer.options.preziId);
435
-
436
-//    $('#presentation>iframe').load(function (){
437
-//        console.log("IFRAME LOADED!!!!!!!!!!!!!!!!");
438
-//    });
439
-//    $('#presentation>iframe').ready(function (){
440
-//        console.log("IFRAME READY!!!!!!!!!!!!!!!!");
441
-//    });
442 430
                  
443 431
     preziPlayer.on(PreziPlayer.EVENT_STATUS, function(event) {
444 432
         console.log("prezi status", event.value);
@@ -554,6 +542,7 @@ function toggleAudio() {
554 542
 }
555 543
 
556 544
 function resizeLarge() {
545
+    resizeChat();
557 546
     var availableHeight = window.innerHeight;
558 547
     var chatspaceWidth = $('#chatspace').width();
559 548
 
@@ -588,10 +577,8 @@ function resizeThumbnails() {
588 577
     var availableHeight = window.innerHeight - $('#largeVideo').height() - 79;
589 578
     var numvids = $('#remoteVideos>span:visible').length;
590 579
 
591
-    var chatWidth = $('#chatspace').width();
592
-
593 580
     // Remove the 1px borders arround videos and the chat width.
594
-    var availableWinWidth = $('#remoteVideos').width() - 2 * numvids - chatWidth - 50;
581
+    var availableWinWidth = $('#remoteVideos').width() - 2 * numvids - 50;
595 582
     var availableWidth = availableWinWidth / numvids;
596 583
     var aspectRatio = 16.0 / 9.0;
597 584
     var maxHeight = Math.min(160, availableHeight);
@@ -599,12 +586,35 @@ function resizeThumbnails() {
599 586
     if (availableHeight < availableWidth / aspectRatio) {
600 587
         availableWidth = Math.floor(availableHeight * aspectRatio);
601 588
     }
589
+
602 590
     // size videos so that while keeping AR and max height, we have a nice fit
603 591
     $('#remoteVideos').height(availableHeight+26); // add the 2*18px-padding-top border used for highlighting shadow.
604 592
     $('#remoteVideos>span').width(availableWidth);
605 593
     $('#remoteVideos>span').height(availableHeight);
606 594
 }
607 595
 
596
+function resizeChat() {
597
+    var availableHeight = window.innerHeight;
598
+    var availableWidth = window.innerWidth;
599
+
600
+    var chatWidth = 200;
601
+    if (availableWidth*0.2 < 200)
602
+        chatWidth = availableWidth*0.2;
603
+
604
+    $('#chatspace').width(chatWidth);
605
+    $('#chatspace').height(availableHeight - 40);
606
+
607
+    resizeChatConversation();
608
+}
609
+
610
+function resizeChatConversation() {
611
+    var usermsgStyleHeight = document.getElementById("usermsg").style.height;
612
+    var usermsgHeight = usermsgStyleHeight.substring(0, usermsgStyleHeight.indexOf('px'));
613
+
614
+    $('#chatconversation').width($('#chatspace').width() - 10);
615
+    $('#chatconversation').height(window.innerHeight - 50 - parseInt(usermsgHeight));
616
+}
617
+
608 618
 $(document).ready(function () {
609 619
     $('#nickinput').keydown(function(event) {
610 620
         if (event.keyCode == 13) {
@@ -632,7 +642,11 @@ $(document).ready(function () {
632 642
         }
633 643
     });
634 644
 
635
-    $('#usermsg').autosize();
645
+    var onTextAreaResize = function() {
646
+        resizeChatConversation();
647
+        scrollChatToBottom();
648
+    };
649
+    $('#usermsg').autosize({callback: onTextAreaResize});
636 650
 
637 651
     // Set the defaults for prompt dialogs.
638 652
     jQuery.prompt.setDefaults({persistent: false});
@@ -972,18 +986,30 @@ function updateLockButton() {
972 986
 function openChat() {
973 987
     var chatspace = $('#chatspace');
974 988
     var videospace = $('#videospace');
975
-    var onAnimationProgress = function () {
989
+
990
+    var onShow = function () {
991
+        resizeLarge();
992
+        $('#chatspace').show("slide", { direction: "right", duration: 500});
993
+    };
994
+    var onHide = function () {
995
+        $('#chatspace').hide("slide", { direction: "right", duration: 500});
976 996
         resizeLarge();
977
-        videospace.css({right:chatspace.width()});
978 997
     };
979 998
 
980
-    if (chatspace.css("opacity") == 1) {
981
-        chatspace.animate({width: 0, opacity: 0}, {duration: 1000, progress: onAnimationProgress});
999
+    if (chatspace.css("display") == 'block') {
1000
+        videospace.animate({right: 0}, {queue: false, duration: 500, progress: onHide});
982 1001
     }
983 1002
     else {
984
-        chatspace.animate({width:"20%", opacity: 1}, {duration: 1000, progress: onAnimationProgress});
1003
+        videospace.animate({right: chatspace.width()},
1004
+                           {queue: false,
1005
+                            duration: 500,
1006
+                            progress: onShow,
1007
+                            complete: function() {
1008
+                                scrollChatToBottom();
1009
+                            }
1010
+                           });
985 1011
     }
986
-    
1012
+
987 1013
     // Request the focus in the nickname field or the chat input field.
988 1014
     if ($('#nickinput').is(':visible'))
989 1015
         $('#nickinput').focus();
@@ -1069,3 +1095,9 @@ function createFocusIndicatorElement(parentElement) {
1069 1095
     focusIndicator.title = "The owner of this conference"
1070 1096
     parentElement.appendChild(focusIndicator);
1071 1097
 }
1098
+
1099
+function scrollChatToBottom() {
1100
+    setTimeout(function() {
1101
+        $('#chatconversation').scrollTop($('#chatconversation')[0].scrollHeight);
1102
+    }, 5);
1103
+}

+ 38
- 33
css/main.css 查看文件

@@ -5,6 +5,7 @@ html, body{
5 5
     font-family:'YanoneKaffeesatzLight',Verdana,Tahoma,Arial;
6 6
 	font-weight: 400;
7 7
     background: #e9e9e9;
8
+    overflow-x: hidden;
8 9
 }
9 10
 
10 11
 #videospace {
@@ -84,31 +85,32 @@ html, body{
84 85
 }
85 86
 
86 87
 #chatspace {
87
-    display:block;
88
+    display:none;
88 89
     position:absolute;
89 90
     float: right;
90 91
     top: 40px;
91 92
     bottom: 0px;
92 93
     right: 0px;
93
-    width:0;
94
-    opacity: 0;
94
+    width: 20%;
95
+    max-width: 200px;
95 96
     overflow: hidden;
96
-    background-color:#f6f6f6;
97
+    background-color:#dfebf1;
97 98
     border-left:1px solid #424242;
98 99
 }
99 100
 
100 101
 #chatconversation {
101
-    display:block;
102
-    position:relative;
103
-    top: -120px;
104
-    float:top;
105
-    text-align:left;
106
-    line-height:20px;
107
-    font-size:14px;
108
-    padding:5px;
109
-    height:90%;
110
-    overflow:scroll;
111
-    visibility:hidden;
102
+    position: relative;
103
+    top: 5px;
104
+    padding: 5px;
105
+    text-align: left;
106
+    line-height: 20px;
107
+    font-size: 10pt;
108
+    width: 100%;
109
+    height: 95%;
110
+    overflow-y: scroll;
111
+    overflow-x: hidden;
112
+    word-wrap: break-word;
113
+    visibility: hidden;
112 114
 }
113 115
 
114 116
 .localuser {
@@ -120,20 +122,31 @@ html, body{
120 122
 }
121 123
 
122 124
 #usermsg {
123
-    position:absolute;
124
-    bottom: 5px;
125
-    left: 5px;
126
-    right: 5px;
127
-    width: 95%;
128
-    height: 40px;
125
+    position: relative;
126
+    width: 100%;
127
+    height: 5%;
128
+    padding: 5px;
129 129
     z-index: 5;
130
-    visibility:hidden;
131 130
     max-height:150px;
131
+    min-height:50px;
132
+    visibility:hidden;
133
+    border: 0px none;
134
+    border-top: 1px solid #cccccc;
135
+    background: #FFFFFF;
136
+    box-shadow: none;
137
+    border-radius:0;
138
+    font-size: 10pt;
139
+}
140
+
141
+#usermsg: hover {
142
+    border: 0px none;
143
+    border-top: 1px solid #cccccc;
144
+    box-shadow: none;
132 145
 }
133 146
 
134 147
 #nickname {
135
-    position:relative;
136
-    text-align:center;
148
+    position: absolute;
149
+    text-align: center;
137 150
     color: #9d9d9d;
138 151
     font-size: 18;
139 152
     top: 100px;
@@ -163,7 +176,7 @@ html, body{
163 176
     display:block;
164 177
     height:39px;
165 178
     text-align:center;
166
-    background-color:#087dba;
179
+    background-color: #2591e5;
167 180
 }
168 181
 
169 182
 #left {
@@ -272,7 +285,6 @@ a.button:hover {
272 285
 }
273 286
 
274 287
 input[type='text'], textarea {
275
-    border: 0px none;
276 288
     display: inline-block;
277 289
     font-size: 14px;
278 290
     padding: 5px;
@@ -331,13 +343,6 @@ form {
331 343
     display: block;
332 344
 }
333 345
 
334
-/* Animated text area. */
335
-.animated {
336
-    -webkit-transition: height 0.2s;
337
-    -moz-transition: height 0.2s;
338
-    transition: height 0.2s;
339
-}
340
-
341 346
 #downloadlog {
342 347
     position: absolute;
343 348
     bottom: 5;

+ 10
- 9
index.html 查看文件

@@ -4,17 +4,18 @@
4 4
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
5 5
     <script src="libs/strophejingle.bundle.js?v=7"></script><!-- strophe.jingle bundle -->
6 6
     <script src="libs/colibri.js?v=7"></script><!-- colibri focus implementation -->
7
+    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
7 8
     <script src="muc.js?v=4"></script><!-- simple MUC library -->
8
-    <script src="estos_log.js?v=3"></script><!-- simple stanza logger -->
9
-    <script src="app.js?v=14"></script><!-- application logic -->
9
+    <script src="estos_log.js?v=2"></script><!-- simple stanza logger -->
10
+    <script src="app.js?v=11"></script><!-- application logic -->
10 11
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
11 12
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=11"/>
12
-    <link rel="stylesheet" href="css/jquery-impromptu.css?v=4">
13
-    <link rel="stylesheet" href="css/modaldialog.css?v=4">
14
-    <script src="libs/jquery-impromptu.js?v=4"></script>
15
-    <script src="libs/jquery.autosize.js?v=4"></script>
16
-    <script src="config.js?v=5"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
17
-    <script src="libs/prezi_player.js?v=3"></script>
13
+    <link rel="stylesheet" href="css/jquery-impromptu.css?v=3">
14
+    <link rel="stylesheet" href="css/modaldialog.css?v=3">
15
+    <script src="libs/jquery-impromptu.js"></script>
16
+    <script src="libs/jquery.autosize.js"></script>
17
+    <script src="config.js"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
18
+    <script src="libs/prezi_player.js"></script>
18 19
   </head>
19 20
   <body>
20 21
     <div id="header">
@@ -74,7 +75,7 @@
74 75
         
75 76
         <!--div><i class="fa fa-comments">&nbsp;</i><span class='nick'></span>:&nbsp;<span class='chattext'></span></div-->
76 77
         <div id="chatconversation"></div>
77
-        <textarea id="usermsg" class= "animated" placeholder='Enter text...' autofocus></textarea>
78
+        <textarea id="usermsg" placeholder='Enter text...' autofocus></textarea>
78 79
     </div>
79 80
     <a id="downloadlog" onclick='dump(event.target);'><i title="Download support information" class="fa fa-cloud-download"></i></a>
80 81
     <script>

Loading…
取消
儲存