Mentions Autocomplete with AtWho

by Dug Sohn

HTML

<script src="https://cdn.rawgit.com/ichord/At.js/801c87dc/dist/js/jquery.atwho.min.js"></script>
<script src="https://cdn.rawgit.com/ichord/Caret.js/master/dist/jquery.caret.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<br/>
<br> Type @ for Comments, * for resource

<p>
</p>

<div class="container">
  <div class="row">
    <nav class="navbar navbar-default bg-light">
      <div class="container-fluid">
        <div class="navbar-header">
          <a class="navbar-brand" href="#">Comment</a>
        </div>
      </div>
    </nav>
    <div contentEditable="true" id="inputor" class="contentEditable"></div>

</div>
  </div>

<br />

CSS

.atwho-view {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  margin-top: 18px;
  background: white;
  color: black;
  border: 1px solid #DDD;
  border-radius: 3px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  min-width: 120px;
  z-index: 11110 !important;
}

.atwho-view .atwho-header {
  padding: 5px;
  margin: 5px;
  cursor: pointer;
  border-bottom: solid 1px #eaeff1;
  color: #6f8092;
  font-size: 11px;
  font-weight: bold;
}

.contentEditable {
  border: 1px solid #ddd;
  height: 400px;
  width: 100%;
  border-top : 0;
  overflow-y:auto;
  padding: 30px 20px 10px;
}


.atwho-view .atwho-header .small {
  color: #6f8092;
  float: right;
  padding-top: 2px;
  margin-right: -5px;
  font-size: 12px;
  font-weight: normal;
}

.atwho-view .atwho-header:hover {
  cursor: default;
}

.atwho-view .cur {
  background: #3366FF;
  color: white;
}

.atwho-view .cur small {
  color: white;
}

.atwho-view strong {
  color: #3366FF;
}

.atwho-view .cur strong {
  color: white;
  font: bold;
}

.atwho-view ul {
  /* width: 100px; */
  list-style: none;
  padding: 0;
  margin: auto;
  max-height: 200px;
  overflow-y: auto;
}

.atwho-view ul li {
  display: block;
  padding: 5px 10px;
  border-bottom: 1px solid #DDD;
  cursor: pointer;
  /* border-top: 1px solid #C8C8C8; */
}

.atwho-view small {
  font-size: smaller;
  color: #777;
  font-weight: normal;
}

.fa-red {
  color: red;
}

#inputcity {
  width: 300px;
  height: 100px;
  background-color: white;
}
.row {
  position:relative
}
.navbar { 
  position: absolute;
  top:0;
  width:100%;
}

JavaScript

// Initialize author field
$('#inputor').atwho({
  at: "@",
  data: ['Peter Smiht', 'Tom Jones', 'Anne Jone']
});

$('#inputor').atwho({
  at: "#",
  data: ['Defect 20', 'Defect 30', 'Export Wrong User'],
  insertTpl: '<i class="fa fa-cog fa-red"></i> <a href="#">${name}</a>'
});