]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Placement auto for popovers
authorJohann-S <johann.servoire@gmail.com>
Wed, 24 May 2017 12:09:36 +0000 (14:09 +0200)
committerJohann-S <johann.servoire@gmail.com>
Wed, 24 May 2017 12:57:40 +0000 (14:57 +0200)
js/src/popover.js
js/tests/visual/popover.html
scss/_popover.scss

index 6c9d7866470f53848a8ac99f8d693ef1a57149aa..a068420d63cdc8be6b42273ca8a3812a6ba8b3ac 100644 (file)
@@ -23,7 +23,7 @@ const Popover = (($) => {
   const EVENT_KEY           = `.${DATA_KEY}`
   const JQUERY_NO_CONFLICT  = $.fn[NAME]
   const CLASS_PREFIX        = 'bs-popover'
-  const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
+  const BSCLS_PREFIX_REGEX  = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
 
   const Default = $.extend({}, Tooltip.Default, {
     placement : 'right',
index 93fa01f9da9eafbb76dd00067a566c557f6b4e5d..2354abf4250179d77eac9c3f6218cf80b078e1ba 100644 (file)
     <div class="container">
       <h1>Popover <small>Bootstrap Visual Test</small></h1>
 
+      <button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="auto" data-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
+        Popover on auto
+      </button>
+
       <button type="button" class="btn btn-secondary" data-container="body" data-toggle="popover" data-placement="top" data-content="Default placement was on top but not enough place">
         Popover on top
       </button>
index 53b5593332f0c1e964841b9967e5ca743b055c50..e3a0d9d6d5eee4f3e8e815aecb5cc5f70af9322b 100644 (file)
       border-left-color: $popover-arrow-color;
     }
   }
+  &.bs-popover-auto {
+    &[x-placement^="top"] {
+      @extend .bs-popover-top;
+    }
+    &[x-placement^="right"] {
+      @extend .bs-popover-right;
+    }
+    &[x-placement^="bottom"] {
+      @extend .bs-popover-bottom;
+    }
+    &[x-placement^="left"] {
+      @extend .bs-popover-left;
+    }
+  }
 }