$(function () {
        var options = {
          trigger: 'manual',
          content: function () {
            return $('#favoriteOptionMenus').html();
          },
          html: true
        };
        var popoverElement = $("#filterOptions");
        popoverElement.mouseenter(function () {
          if (!popoverElement.attr("aria-describedby")) {
            popoverElement.attr("title", GlobalStringsForAssets.SAVE_SEARCH);
          }
        });
        popoverElement.click(function (e) {
          e.stopPropagation();
          if (popoverElement.attr("aria-describedby")) {
            $("#filterOptions").css({ "background-color": "initial", "color": "#2e6da4" });
            popoverElement.popover("destroy");
          } else {
            options.title = "";
            popoverElement.removeAttr("title");
            popoverElement.popover(options);
            popoverElement.popover("show");
            $(".popover-content #newFavoriteName").prop("value", $("#searchbox").val());
            $("#filterOptions").css({ "background-color": "#2e6da4", "color": "white" });
            $('.popover-content #searchFilter').val('');
            GetSavedFilters($(this), '');
            $('#saveFilterButton #btnSaveFavorite').click(function (e) {
              e.preventDefault();
              e.stopPropagation();
              var name = $('.popover-content #newFavoriteName').val();
              if (name == '') {
                _messagebox.newNotify2(GlobalStringsForAssets.ENTER_NAME, "Error");
                $("#filterOptions").css({ "background-color": "initial", "color": "#2e6da4" });
                return false;
              }
              // Create a new filter
              SaveFilter(-1, name, false);
              var itemShowLength = $('.popover.fade.bottom.in').find('ul.toolmenu li .glyphicon-star-empty').length;
              var newFavitor = $('<li class= "toolmenu filterdata"><span class="toolmenu narrow filterdata" filterfav="false"><span class="glyphicon glyphicon-star-empty toolicon"></span> ' + name + '<span class="glyphicon glyphicon-remove" style="float:right;"></span></span></li>');
              var hr_length = $('.popover.fade.bottom.in').find('ul.toolmenu li hr').length;
              if (hr_length != 0) {
                $('.popover.fade.bottom.in').find('ul.toolmenu li hr').after(newFavitor);
              } else {
                if (itemShowLength > 0) {
                  $('.popover.fade.bottom.in').find('ul.toolmenu').append(newFavitor);
                  if (itemShowLength > 10) {
                    for (var i = 10; i < itemShowLength; i++) {
                      $('.popover.fade.bottom.in').find('ul.toolmenu li').eq(i).remove();
                    }
                  }
                } else {
                  $('.popover.fade.bottom.in').find('ul.toolmenu').append($('<li class= "toolmenu filterdata"><hr class="toolmenu" /></li>'));
                  $('.popover.fade.bottom.in').find('ul.toolmenu').append(newFavitor);
                }
              }
              $('.popover.fade.bottom.in li').css("list-style-type", "none");
              $('#newFavoriteName').val('');
              $('#searchbox').val('');
              if ($('.popover.fade.bottom.in ul.toolmenu').innerHeight() >= 200) {
                $('.popover.fade.bottom.in ul.toolmenu').css({ 'height': '200px', 'overflow-y': 'scroll' });
              }
            });
            $('.popover.fade.bottom.in').on('click', 'span.filterdata span.glyphicon-star-empty', function (e) {
              var filterid = $(this).closest('span.filterdata').attr('filterid');
              ChangeFilterFavorite(filterid, true);
              return false;
            });
            $('.popover-content #searchFilter').on('input', function () {
              GetSavedFilters($('#filterOptions'), $('.popover-content #searchFilter').val());
            });
          }
        })
        $('body').on('click', function (e) {
          $('[data-toggle=popover]').each(function () {
            if (
              $(this).attr("aria-describedby")
              && !$(this).is(e.target)
              && $(this).has(e.target).length === 0
              && $('.popover').has(e.target).length === 0
            ) {
              $(this).popover("destroy");
            }
          });
        })
      });
 
 
实现效果如下:

使用Bootstrap Popover实现一个弹框上三角形的代码记录的更多相关文章

  1. popover带箭头弹框

    我们先来看一下效果吧: 分析:这个带箭头的弹框其实是一个控制器,通过Modal方式展现,但跟传统模态方式效果不一样,我们一眼就能看出. Xib方式实现popover: 1.segue的时候选择Pres ...

  2. WPF 如何自定义一个弹框

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 简述: 手工以原生Grid的方式,自定义了一个仿弹窗效果,优点可以自定义,缺点需要自己实现以及维护整个弹窗的效 ...

  3. vue+elementui 新增和编辑如何实现共用一个弹框

    //html代码: //按钮 <el-button type="primary" size="medium" @click="addEquipm ...

  4. vue封装一个弹框组件

    这是一个提示框和对话框,例:   这是一个组件 eject.vue <template> <div class='kz-cont' v-show='showstate'> &l ...

  5. js,ajax,layer笔记(弹出层,在弹出一个弹框)

    整体认识: 因为作用域的问题,js 在页面初次加载时已近加载好了,所以要有第二次弹窗的效果,必须得在第一次成功之后再次让他加载js 代码: /*shaun*/showdetailsPag: funct ...

  6. bootstrap弹框

    http://v3.bootcss.com/javascript/#modals 参考bootstrap官网 模态框做php后端 前端一直不行,但是很多时候 用到ajax都要用到弹框,一直在代码里面找 ...

  7. iOS 可高度自定义的底部弹框

    技术: iOS Objective-C   概述 一个可以让开发者通过编写 tableView 的内容随心所欲的定制自己想要的底部弹框 详细 代码下载:http://www.demodashi.com ...

  8. 弹框alertView

    // 创建一个弹框UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@“标题” message:@“显示的具体内容” delegate:s ...

  9. 自定义 popWindow弹框 工具包

    前言:因为Android 没有像IOS一样的ActionSheet,虽然在github上看到有一些类似ActionSheet的库,总觉得不好用,不如自己写一个弹框通用类,样式全部自已来多好. Step ...

随机推荐

  1. MySQL数据库远程访问权限如何打开(两种方法)

    在我们使用mysql数据库时,有时我们的程序与数据库不在同一机器上,这时我们需要远程访问数据库.缺省状态下,mysql的用户没有远程访问的权限. 下面介绍两种方法,解决这一问题. 1.改表法 可能是你 ...

  2. php中urlencode和urldecode的用法

    URLEncode:是指针对网页url中的中文字符的一种编码转化方式,最常见的就是Baidu.Google等搜索引擎中输入中文查询时候,生成经过Encode过的网页URL.URLEncode的方式一般 ...

  3. Web 文件上传 目录

    0. SpringMVC -- 梗概--源码--贰--上传 1. Web上传文件的原理及实现 2. Web文件上传方法总结大全 3. SpringMVC 文件上传配置,多文件上传,使用的Multipa ...

  4. SQLAlchemy详细教程

    http://www.360doc.com/content/15/0914/16/360939_499094891.shtml

  5. Unity3D Shader 内置函数

    Intrinsic Functions (DirectX HLSL) The following table lists the intrinsic functions available in HL ...

  6. rest_framework框架

    rest_framework框架的认识 它是基于Django的,帮助我们快速开发符合RESTful规范的接口框架. 一  路由 可以通过路由as_view()传参 根据请求方式的不同执行对应不同的方法 ...

  7. iBatis.Net 配置 SQL语句执行 日志

    <configuration> <configSections> ... <sectionGroup name="iBATIS"> <se ...

  8. acm入门练习心得

    A题  两数相加等于n相乘等于m 问是否存在两数 写了超级久没有写出来,因为我的思路是 把m的因子都找出来,加加看,看等不等于n.后来发现m的因子还要考虑负数的情况,还要考虑m是不是负数的情况.太过麻 ...

  9. TOP100summit2017:Riot Games 李仁杰——大数据落地要找到数据和经验的平衡点

      壹佰案例:李仁杰老师您好,很荣幸您能参加第六届TOP100全球软件案例研究峰会,您在大数据和人工智能领域有非常丰富的经验,在这次大会上您将分享什么内容? 李仁杰:这次我主要分享的有两个方面. 一个 ...

  10. POJ 1179 - Polygon - [区间DP]

    题目链接:http://poj.org/problem?id=1179 Time Limit: 1000MS Memory Limit: 10000K Description Polygon is a ...