Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.io/bootstrap/assets/js/bootstrap.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="chatHeader">
    <h4>Chat with a Librarian</h4>
  </div>
  <div id="chatWindow">
    
  <div class="chat-bubble-librarian">
  <div class="chat-bubble-glare-librarian"></div>
    <p>Thank you for contacting the help line how can I help you?</p>
    <div class="chat-bubble-arrow-border-librarian"></div>
    <div class="chat-bubble-arrow-librarian"></div>
 </div>
    
  <div class="chat-bubble-user">
    <div class="chat-bubble-glare-user"></div>
    <p>I have a question about kittens?</p>
    <div class="chat-bubble-arrow-border-user"></div>
    <div class="chat-bubble-arrow-user"></div>
 </div>
    
  <div class="chat-bubble-librarian">
  <div class="chat-bubble-glare-librarian"></div>
    <p>Thats Awesome!</p>
    <div class="chat-bubble-arrow-border-librarian"></div>
    <div class="chat-bubble-arrow-librarian"></div>
 </div>    
    
</div>
  <div id="inputArea">
    <div id="textInputRow" class="row">
    <textarea id="textInput"></textarea>
    <button id="sendButton" class="btn btn-primary">Send</button>
    </div>
  </div>
</body>
</html>
 
body{
  padding-top:30px
}
#chatHeader{
  background-color:#f1f1f1;
  -webkit-border-top-left-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  -moz-border-radius-topleft: 10px;
  -moz-border-radius-topright: 10px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-top:1px solid #C1C1C1;
  border-right:1px solid #C1C1C1;
  border-left:1px solid #C1C1C1;
}
#chatHeader h4{
  margin-left:20px;
  margin-bottom:0px;
  padding-bottom:5px;
  padding-top:5px;
}
#chatWindow{
  overflow-y:auto;
  height:250px;
  text-align: right;
  background-color:#f1f1f1;
  border-bottom:1px solid #C1C1C1;
  border-right:1px solid #C1C1C1;
  border-left:1px solid #C1C1C1;
}
#inputArea{
  background-color:#222222;
  -webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomleft: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
#textInputRow{
  padding-top:10px;
  padding-left:10px;
}
#sendButton{
  height:50px;
  vertical-align:top;
  float:right;
  margin-right:15px
}
.chat-bubble-librarian {
    font-size:14px;
    font-weight: 800;
    line-height:1.3em;
  text-align:left;
    margin:6px;
    padding:6px;
  margin-bottom:10px;
    position:relative;
    width:150px;
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(90,150,40)), color-stop(0.28, rgb(160,215,60)), color-stop(1, rgb(165,255,69)));
    background:-moz-linear-gradient(center top, rgb(90,150,40) 0%, rgb(160,215,60) 28%, rgb(165,255,69) 100%);
        border:1px solid #38691a;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
        border-radius: 10px;
    -webkit-box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px;
    -moz-box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px; /* FF 3.5+ */
        box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px;
}
.chat-bubble-librarian p {
 padding-top:10px
}
.chat-bubble-glare-librarian {
    position: absolute;
    top: 0px;
    left: 4px;
    height: 6px;
    width: 154px;
    padding: 6px 0;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    background: -moz-linear-gradient(top, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
    background: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.9)), to(rgba(255, 255, 255, 0)));
}
.chat-bubble-arrow-librarian {
    border-color: transparent #a5ff45 transparent transparent;
    border-style: solid;
    border-width: 6px;
    height:0;
    width:0;
    position:absolute;
    bottom:-1px;
    left:-3px;
    -webkit-transform: rotate(70deg);
    -moz-transform: rotate(70deg);
        transform: rotate(70deg);
}
.chat-bubble-arrow-border-librarian {
    border-color: transparent #38691a transparent transparent;
    border-style: solid;
    border-width: 6px;
    height:0;
    width:0;
    position:absolute;
    bottom:-3px;
    left:-5px;
    -webkit-transform: rotate(70deg);
    -moz-transform: rotate(70deg);
}
.chat-bubble-user {
    font-size:14px;
    font-weight: 800;
    line-height:1.3em;
    margin:6px;
    display: inline-block;
    text-align: left;
    padding:6px;
  margin-bottom:10px;
    position:relative;
    width:150px;
    background:-webkit-gradient(linear, left top, left bottom, color-stop(0, rgb(90,150,40)), color-stop(0.28, rgb(160,215,60)), color-stop(1, rgb(165,255,69)));
    background:-moz-linear-gradient(center top, rgb(90,150,40) 0%, rgb(160,215,60) 28%, rgb(165,255,69) 100%);
        border:1px solid #38691a;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
        border-radius: 10px;
    -webkit-box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px;
    -moz-box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px; /* FF 3.5+ */
        box-shadow: rgba(160, 215, 60, 0.7) 2px 4px 5px;
}
.chat-bubble-user p {
 padding-top:10px
}
.chat-bubble-glare-user {
    position: absolute;
    top: 0px;
    left: 4px;
    height: 6px;
    width: 154px;
    padding: 6px 0;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    background: -moz-linear-gradient(top, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
    background: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.9)), to(rgba(255, 255, 255, 0)));
}
.chat-bubble-arrow-user {
    border-color: transparent #a5ff45 transparent transparent;
    border-style: solid;
    border-width: 6px;
    height:0;
    width:0;
    position:absolute;
    bottom:-1px;
    left:-3px;
    -webkit-transform: rotate(70deg);
    -moz-transform: rotate(70deg);
        transform: rotate(70deg);
}
.chat-bubble-arrow-border-user {
    border-color: transparent #38691a transparent transparent;
    border-style: solid;
    border-width: 6px;
    height:0;
    width:0;
    position:absolute;
    bottom:-3px;
    left:-5px;
    -webkit-transform: rotate(70deg);
    -moz-transform: rotate(70deg);
}
 
var self = this;
$('#sendButton').click(function(){
  self.addText($('#textInput').val());
  $('#textInput').val("");
});
self.addText = function(text){
  var content =
      "<div class='chat-bubble-user'>"+"<div class='chat-bubble-glare-user'></div><p>"+text+"</p><div class='chat-bubble-arrow-border-user'></div><div class='chat-bubble-arrow-user'></div></div>";
  $('#chatWindow').append(content);
};
$('#textInput').keypress(function(event){
  var keycode = (event.keyCode ? event.keyCode : event.which);
  if(keycode == '13'){
    self.addText($('#textInput').val());    
    $('#textInput').val("");
  }
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
fcalderanpro
0viewers