"Chat"
Bootstrap 3.0.0 Snippet by sergiosardar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container chatBoxContainer">
<div class="row chatBoxHeader" id="chatHeader">
<div class="col-md-10"><text>Chat</text></div>
<div class="col-md-2"><button type="button" class="chat-close-button" onclick="togglePreviewChatBox()"></button></div>
</div>
<div class="row chatBoxArea" id="chatSpace">
</div>
<form onsubmit="return submitPreviewText(document.getElementById('inputBox').value)" id="form">
<div class="row inputRow form-group" id="previewTextInputArea">
<input type="text" class="form-control" placeholder="Preview Reply" id="inputBox">
<input type="submit" value="submit" style="position: absolute; left: -9999px" />
</div>
</form>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.chatBoxContainer{
position:fixed;
bottom:0px;
left:0px;
height:300px;
width:200px;
overflow:hidden;
}
.chatBoxHeader{
background-color:dodgerblue;
display:none;
}
.chatBoxArea{
position:relative;
background:white;
border-style:solid;
border-width:1px;
border-color:#E2E1E1;
height:100%;
overflow-x:hidden;
padding-bottom:60px;
display:none;
}
.inputRow{
position:absolute;
bottom:0;
width:100%;
margin-bottom:0;
padding-bottom:0;
}
.chat-close-button
{
display:block;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function submitPreviewText(text){
//if chat is not visible, make it popup
if($('#chatSpace').css('display') == 'none'){
togglePreviewChatBox();
}
//makes text appear as a bubble in the chat areas
var chat = $("#chatSpace")[0];
var htmlstring = '<div class="col-md-12 chatBoxMessage"><text class="speech-bubble-user" style="padding-left:10px">' + text + '</p></div>';
chat.insertAdjacentHTML('beforeend',htmlstring);
//submit this text to the server
//get response back from the server
$('#inputBox').val("");
//display this response as a bubble in the chat window
return false;
}
function togglePreviewChatBox(){
var chatSpace = $('#chatSpace');
var header = $('#chatHeader');
if (chatSpace.css('display') == 'none') {
chatSpace.css('display',"block");
header.css('display',"block");
} else {
chatSpace.css('display',"none");
header.css('display',"none");
chatSpace.html('');
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: