Text is selected when opening notification

0

Follow the code below:

        $("#click_notifications").click(function () {
            if ($('li.nav-item.dropdown.dropdown-notifications').hasClass('open')) {
                $('li.nav-item.dropdown.dropdown-notifications').removeClass('open');
            }
            else {
                $('li.nav-item.dropdown.dropdown-notifications').addClass('open');
            }
        });
/*!
 * bootstrap-dropmenu v0.9.0 (https://skywalkapps.github.io/bootstrap-dropmenu)
 * Copyright 2015 Martin Staněk
 * Licensed under MIT
 */
.dropdown-container {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  float: left;
  min-width: 200px;
  max-width: 330px;
  margin: 2px 0 0;
  list-style: none;
  font-size: 14px;
  background-color: #fff;
  border: 1px solid #ccc;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  background-clip: padding-box;
}
.dropdown-container > .dropdown-menu {
  position: static;
  z-index: 1000;
  float: none!important;
  padding: 10px 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  -webkit-box-shadow: none;
  box-shadow: none;
  max-height: 330px;
  overflow-y: auto;
}
.dropdown-container > .dropdown-menu + .dropdown-menu {
  padding-top: 0;
}
.dropdown-menu > li > a {
  overflow: hidden;
  white-space: nowrap;
  word-wrap: normal;
  text-decoration: none;
  text-overflow: ellipsis;
  -o-text-overflow: ellipsis;
  -webkit-transition: none;
  -o-transition: none;
  transition: none;
}
.dropdown-toggle {
  cursor: pointer;
}
.dropdown-header {
  white-space: nowrap;
}
.open > .dropdown-container > .dropdown-menu,
.open > .dropdown-container {
  display: block;
}
.dropdown-toolbar {
  padding-top: 6px;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 5px;
  background-color: #fff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px 4px 0 0;
}
.dropdown-toolbar > .form-group {
  margin: 5px -10px;
}
.dropdown-toolbar .dropdown-toolbar-actions {
  float: right;
}
.dropdown-toolbar .dropdown-toolbar-title {
  margin: 0;
  font-size: 14px;
}
.dropdown-footer {
  padding: 5px 20px;
  border-top: 1px solid #ccc;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0 0 4px 4px;
}
.anchor-block small {
  display: none;
}
@media (min-width: 992px) {
  .anchor-block small {
display: block;
font-weight: normal;
color: #777777;
  }
  .dropdown-menu > li > a.anchor-block {
padding-top: 6px;
padding-bottom: 6px;
  }
}
@media (min-width: 992px) {
  .dropdown.hoverable:hover > ul {
display: block;
  }
}
.dropdown-position-topright {
  top: auto;
  right: 0;
  bottom: 100%;
  left: auto;
  margin-bottom: 2px;
}
.dropdown-position-topleft {
  top: auto;
  right: auto;
  bottom: 100%;
  left: 0;
  margin-bottom: 2px;
}
.dropdown-position-bottomright {
  right: 0;
  left: auto;
}
.dropmenu-item-label {
  white-space: nowrap;
}
.dropmenu-item-content {
  position: absolute;
  text-align: right;
  max-width: 60px;
  right: 20px;
  color: #777777;
  overflow: hidden;
  white-space: nowrap;
  word-wrap: normal;
  -o-text-overflow: ellipsis;
  text-overflow: ellipsis;
}
small.dropmenu-item-content {
  line-height: 20px;
}
.dropdown-menu > li > a.dropmenu-item {
  position: relative;
  padding-right: 66px;
}
.dropdown-submenu .dropmenu-item-content {
  right: 40px;
}
.dropdown-menu > li.dropdown-submenu > a.dropmenu-item {
  padding-right: 86px;
}
.dropdown-inverse .dropdown-menu {
  background-color: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.9);
}
.dropdown-inverse .dropdown-menu .divider {
  height: 1px;
  margin: 9px 0;
  overflow: hidden;
  background-color: #2b2b2b;
}
.dropdown-inverse .dropdown-menu > li > a {
  color: #cccccc;
}
.dropdown-inverse .dropdown-menu > li > a:hover,
.dropdown-inverse .dropdown-menu > li > a:focus {
  color: #fff;
  background-color: #262626;
}
.dropdown-inverse .dropdown-menu > .active > a,
.dropdown-inverse .dropdown-menu > .active > a:hover,
.dropdown-inverse .dropdown-menu > .active > a:focus {
  color: #fff;
  background-color: #337ab7;
}
.dropdown-inverse .dropdown-menu > .disabled > a,
.dropdown-inverse .dropdown-menu > .disabled > a:hover,
.dropdown-inverse .dropdown-menu > .disabled > a:focus {
  color: #777777;
}
.dropdown-inverse .dropdown-header {
  color: #777777;
}
.table > thead > tr > th.col-actions {
  padding-top: 0;
  padding-bottom: 0;
}
.table > thead > tr > th.col-actions .dropdown-toggle {
  color: #777777;
}
.notifications {
  list-style: none;
  padding: 0; }

.notification {
  display: block;
  padding: 0.8em;
  border-width: 0 0 1px 0;
  border-style: solid;
  border-color: #e9ecef;
  background-color: #ffffff;
  color: #212529;
  text-decoration: none; }
  .notification:last-child {
    border-bottom: 0;
    border-radius: 0 0 0.25rem 0.25rem; }
  .notification:hover, .notification.active:hover {
    background-color: #f9f9f9;
    border-color: #dee2e6;
    text-decoration: none; }
  .notification.active {
    background-color: #efefef; }

.notification-title {
  font-size: 1em;
  margin-bottom: 0; }

.notification-desc {
  margin-bottom: 0;
  font-size: 0.94em; }

.notification-meta {
  color: #868e96; }

.dropdown-notifications > .dropdown-container,
.dropdown-notifications > .dropdown-menu {
  width: 450px;
  max-width: 450px; }

.dropdown-notifications > .dropdown-container {
  margin-top: 0.6rem; }

.dropdown-notifications .dropdown-menu {
  padding: 0; }

.dropdown-notifications .dropdown-toolbar,
.dropdown-notifications .dropdown-footer {
  padding: 0.8em; }

.dropdown-notifications .dropdown-toolbar {
  background: #ffffff; }

.dropdown-notifications .dropdown-footer {
  background: #ced4da; }

.dropdown-notifications .dropdown-toggle::after {
  display: none; }

.navbar .dropdown-notifications .dropdown-menu {
  position: static; }

.notification-icon {
  margin-right: 0.49125rem;
  vertical-align: middle;
  font-style: normal;
  }

.notification-icon:after {
  position: absolute;
  content: attr(data-count);
  margin-left: -0.49125rem;
  margin-top: -0.49125rem;
  padding: 0 4px;
  min-width: 0.9825rem;
  height: 0.9825rem;
  line-height: 0.9825rem;
  background: red;
  border-radius: 10px;
  color: #ffffff;
  text-align: center;
  vertical-align: middle;
  font-size: 0.786rem;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; }

.notification .media-body {
  padding-top: 0; }

.btn-lg .notification-icon:after {
  margin-left: -0.5895rem;
  margin-top: -0.5895rem;
  min-width: 1.179rem;
  height: 1.179rem;
  line-height: 1.179rem;
  font-size: 0.9825rem; }

.btn-xs .notification-icon:after {
  content: '';
  margin-left: -0.29475rem;
  margin-top: -0.147375rem;
  min-width: 0.4465909091rem;
  height: 0.4465909091rem;
  line-height: 0.4465909091rem;
  padding: 0; }

.btn-xs .notification-icon {
  margin-right: 0.245625rem; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script><linkhref="https://cdnjs.cloudflare.com/ajax/libs/open-iconic/1.1.1/font/css/open-iconic-bootstrap.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="#">Tasks</a>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav">
        <li class="nav-item dropdown dropdown-notifications open">
        <a id="click_notifications" class="nav-link dropdown-toggle" data-toggle="dropdown">
          <i data-count="2" class="oi oi-bell notification-icon" aria-label="Nofitication centre"></i>
        </a>

        <div class="dropdown-container">
         <div class="dropdown-toolbar">
            <div class="dropdown-toolbar-actions">
              <a href="#"><i class="glyphicon glyphicon-search"></i> View All</a>
            </div>
            <h3 class="dropdown-toolbar-title">Recent (3)</h3>
          </div><!-- /dropdown-toolbar -->

          <ul class="dropdown-menu notifications">
            <li class="notification">
                <div class="media">
                  <img data-src="holder.js/50x50?bg=cccccc" class="mr-2 img-circle" alt="50x50" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2250%22%20height%3D%2250%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2050%2050%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_163b3713d4b%20text%20%7B%20fill%3A%23919191%3Bfont-weight%3Abold%3Bfont-family%3AArial%2C%20Helvetica%2C%20Open%20Sans%2C%20sans-serif%2C%20monospace%3Bfont-size%3A10pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_163b3713d4b%22%3E%3Crect%20width%3D%2250%22%20height%3D%2250%22%20fill%3D%22%23cccccc%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%226.4765625%22%20y%3D%2229.55625%22%3E50x50%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" data-holder-rendered="true" style="width: 50px; height: 50px;">
                  <div class="media-body">
                    <strong class="notification-title"><a href="#">Dave Lister</a> commented on <a href="#">DWARF-13 - Maintenance</a></strong>
                    <p class="notification-desc">I totally don't wanna do it. Rimmer can do it.</p>

                    <div class="notification-meta">
                      <small class="timestamp">27. 11. 2015, 15:00</small>
                    </div>
                  </div>
                </div>
            </li>

            <li class="notification">
                <div class="media">
                  <img data-src="holder.js/50x50?bg=cccccc" class="mr-2 img-circle" alt="50x50" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2250%22%20height%3D%2250%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2050%2050%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_163b3713d4c%20text%20%7B%20fill%3A%23919191%3Bfont-weight%3Abold%3Bfont-family%3AArial%2C%20Helvetica%2C%20Open%20Sans%2C%20sans-serif%2C%20monospace%3Bfont-size%3A10pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_163b3713d4c%22%3E%3Crect%20width%3D%2250%22%20height%3D%2250%22%20fill%3D%22%23cccccc%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%226.4765625%22%20y%3D%2229.55625%22%3E50x50%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" data-holder-rendered="true" style="width: 50px; height: 50px;">
                  <div class="media-body">
                    <strong class="notification-title"><a href="#">Nikola Tesla</a> resolved <a href="#">T-14 - Awesome stuff</a></strong>

                    <p class="notification-desc">Resolution: Fixed, Work log: 4h</p>

                    <div class="notification-meta">
                      <small class="timestamp">27. 10. 2015, 08:00</small>
                    </div>

                  </div>
                </div>
            </li>

            <li class="notification">
                <div class="media">
                  <img data-src="holder.js/50x50?bg=cccccc" class="mr-2 img-circle" alt="50x50" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2250%22%20height%3D%2250%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2050%2050%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_163b3713d4d%20text%20%7B%20fill%3A%23919191%3Bfont-weight%3Abold%3Bfont-family%3AArial%2C%20Helvetica%2C%20Open%20Sans%2C%20sans-serif%2C%20monospace%3Bfont-size%3A10pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_163b3713d4d%22%3E%3Crect%20width%3D%2250%22%20height%3D%2250%22%20fill%3D%22%23cccccc%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%226.4765625%22%20y%3D%2229.55625%22%3E50x50%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" data-holder-rendered="true" style="width: 50px; height: 50px;">
                  <div class="media-body">
                    <strong class="notification-title"><a href="#">James Bond</a> resolved <a href="#">B-007 - Desolve Spectre organization</a></strong>

                    <div class="notification-meta">
                      <small class="timestamp">1. 9. 2015, 08:00</small>
                    </div>

                  </div>
                </div>
            </li>
          </ul>
        </div>
      </li><!-- /dropdown -->

        <li class="nav-item"><a class="nav-link" href="#">Dashboard</a></li>
        <li class="nav-item"><a class="nav-link" href="#">Projects</a></li>
        <li class="nav-item"><a class="nav-link" href="#">People</a></li>
      </ul>
    </div>
  </nav>

Problem:

When I close and open notification, this happens:

The text is all selected in the notification part.

Any solution?

    
asked by anonymous 02.06.2018 / 00:22

1 answer

0

Issue resolved:

$("#click_notifications").click(function () {
    if ($('li.nav-item.dropdown.dropdown-notifications').hasClass('open')) {
        $('li.nav-item.dropdown.dropdown-notifications').removeClass('open');
    }
    else {
        $('li.nav-item.dropdown.dropdown-notifications').addClass('open');
    }
}).mousedown(function (e) { e.preventDefault(); });
    
02.06.2018 / 01:25