Popovers (Popovers) ye
Sɛbɛnw ni misaliw walasa ka Bootstrap popovers fara ɲɔgɔn kan, i n’a fɔ minnu bɛ sɔrɔ iOS kɔnɔ, fɛn o fɛn na i ka siti kan.
Kuma bɛɛ lajɛlen
Fɛn minnu ka kan ka dɔn ni i bɛ baara kɛ ni popover plugin ye:
- Popovers bɛ u jigi da 3nan ka bibliothèque Popper kan jɔyɔrɔko la. Aw ka kan ka popper.min.js don a kɔnɔ ka kɔn bootstrap.js ɲɛ walima ka baara kɛ ni
bootstrap.bundle.min.js
/bootstrap.bundle.js
ye min kɔnɔ Popper bɛ yen walasa popovers ka baara kɛ! - Popovers bɛ tooltip plugin de wajibiya i n’a fɔ dependency.
- Popovers ye opt-in ye baarakɛcogo kunw na, o la aw yɛrɛ ka kan k’u daminɛ .
- Zero-janya
title
nicontent
nafaw tɛna popover jira abada. - A jira
container: 'body'
walasa ka i yɛrɛ tanga ɲɛfɔli gɛlɛyaw ma yɔrɔw la minnu ka gɛlɛn kosɛbɛ (i n’a fɔ an ka donnakow kuluw, butɔni kuluw, a ɲɔgɔnnaw). - Popovers (popovers) daminɛni fɛn dogolenw kan, o tɛna baara kɛ.
- Popovers for
.disabled
walimadisabled
elements ka kan ka daminɛ wrapper element kan. - Ni a bɛ daminɛ ka bɔ jɛgɛw la minnu bɛ siri tigɛli caman na, popovers bɛna kɛ cɛmancɛ la jɛgɛw bɛɛ bonya bɛɛ cɛ. Aw
.text-nowrap
bɛ baara kɛ ni aw ka<a>
s ye walasa ka aw yɛrɛ tanga nin kɛcogo in ma. - Popovers ka kan ka dogo sani u bɛnkanw ka bɔ DOM kɔnɔ.
- Popovers bɛ se ka daminɛ k’a sababu kɛ fɛn dɔ ye min bɛ DOM biɲɛ dɔ kɔnɔ.
prefers-reduced-motion
media ɲininkali de la. aw ye
an ka sɔrɔli sɛbɛnw yɔrɔ lajɛ min bɛ lamaga dɔgɔyalen na .
Aw bɛ to ka kalan kɛ walasa ka a dɔn popoverw bɛ baara kɛ cogo min na ni misali dɔw ye.
Misali: Popoverw daminɛ yɔrɔ bɛɛ
Popoverw bɛɛ daminɛcogo dɔ ɲɛ dɔ kan o ye k’u sugandi u ka data-bs-toggle
fɛnɲɛnɛma fɛ:
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl)
})
Misali: Baara kɛ ni container
sugandili ye
Ni i ye cogoya dɔw Sɔrɔ bangebaga-yɔrɔ dɔ kan minnu bɛ popover dɔ bali, i b’a fɛ ka ladamu dɔ Jira container
walasa popover ka HTML ka Bɔ o element ‘kɔnɔ o nɔ na.
var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
container: 'body'
})
Misaliya
<button type="button" class="btn btn-lg btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
Sira naani
Sugandili naani bɛ yen: sanfɛ, kinin fɛ, duguma ani numan fɛ. Siraw bɛ miiri ni Bootstrap ye RTL kɔnɔ.
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Top popover">
Popover on top
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Right popover">
Popover on right
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Bottom popover">
Popover on bottom
</button>
<button type="button" class="btn btn-secondary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="Left popover">
Popover on left
</button>
Dismiss kan nata digi
Baara kɛ ni focus
trigger ye walasa ka popovers (popovers) bɔ kɛnɛ kan baarakɛla ka fɛn wɛrɛ digilen na min tɛ toggle element ye.
Markup kɛrɛnkɛrɛnnen wajibiyalen don dismiss-on-next-click kama
Walasa ka cross-browser ni cross-platform kɛcogo ɲuman sɔrɔ, i ka kan ka baara kɛ ni <a>
tag ye, i kana baara kɛ ni <button>
tag ye, wa i ka kan fana ka tabindex
attribut dɔ don a kɔnɔ.
<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
var popover = new bootstrap.Popover(document.querySelector('.popover-dismiss'), {
trigger: 'focus'
})
Eleman minnu bɛ se ka baara kɛ
Fɛn minnu bɛ ni fɛn ye disabled
, olu tɛ ɲɔgɔndan ye, o kɔrɔ ye ko baarakɛlaw tɛ Se k’u jɔ walima k’u digi walasa ka popover (walima baarakɛminɛnw) dɔ Daminɛ. O cogo la, i b’a fɛ ka popover daminɛ ka bɔ wrapper <div>
walima <span>
, ideally made keyboard-focusable using tabindex="0"
.
Popover triggers disabled (popover triggers) la, i bɛ se fana k’a fɛ data-bs-trigger="hover focus"
walasa popover ka jira i n’a fɔ teliya yecogo jaabi i ka baarakɛlaw ye i n’a fɔ u tɛ se ka a jira ko u bɛna fɛn dɔ digi disabled element kan.
<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
<button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>
Sass ye
Yɛlɛma-yɛlɛmaw
$popover-font-size: $font-size-sm;
$popover-bg: $white;
$popover-max-width: 276px;
$popover-border-width: $border-width;
$popover-border-color: rgba($black, .2);
$popover-border-radius: $border-radius-lg;
$popover-inner-border-radius: subtract($popover-border-radius, $popover-border-width);
$popover-box-shadow: $box-shadow;
$popover-header-bg: shade-color($popover-bg, 6%);
$popover-header-color: $headings-color;
$popover-header-padding-y: .5rem;
$popover-header-padding-x: $spacer;
$popover-body-color: $body-color;
$popover-body-padding-y: $spacer;
$popover-body-padding-x: $spacer;
$popover-arrow-width: 1rem;
$popover-arrow-height: .5rem;
$popover-arrow-color: $popover-bg;
$popover-arrow-outer-color: fade-in($popover-border-color, .05);
Baarakɛcogo
Popovers baara kɛ JavaScript fɛ:
var exampleEl = document.getElementById('example')
var popover = new bootstrap.Popover(exampleEl, options)
Popoverw kɛli ka baara kɛ klaviyeti ni dɛmɛni fɛɛrɛw baarakɛlaw ye
Walasa ka sira Di klaviyeti baarakɛlaw ma u k’i ka popoverw baara, i ka kan k’u Fàra HTML yɔrɔw dɔrɔn kan minnu bɛ Se klaviyeti-yɔrɔ-ko laada la ani minnu bɛ Kɛ ɲɔgɔn fɛ (i n’a fɔ jὲɲɔgɔnya walima foroko-kɔlɔsili). Hali n’a y’a Sɔrɔ HTML fɛnɲɛnɛmaw (i n’a fɔ <span>
s) bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka Kɛ ‘fɛn ye min bɛ Se ka ‘ tabindex="0"
kɔnɔnafili ani k’u hakili ɲagami klaviyeti baarakɛlaw kan minnu tɛ ‘ɲɔgɔndɛmɛ ye, wa dɛmɛn-fɛɛrɛ fanba tɛ popover kɔnɔkow Laseli sisan nin ko in na . Ka fara o kan, i kana i jigi da dɔrɔn kan hover
i n’a fɔ i ka popovers (popovers) daminɛfɛn, bawo o bɛna a to u tɛ se ka daminɛ klaviyeti baarakɛlaw fɛ.
Hali n’i bɛ se ka HTML nafama, sigilen don popovers kɔnɔ ni html
sugandi ye, an b’a ɲini i fɛ kosɛbɛ i k’i yɛrɛ tanga kunnafoni hakɛ tɛmɛnenw farali kan. Popoverw bɛ baara kɛ cogo min na sisan, o ye ko, n’u jirala dɔrɔn, u kɔnɔkow bɛ siri trigger element la ni aria-describedby
attribut ye. O de kosɔn, popover kɔnɔkow bɛɛ bɛna laseli dɛmɛn fɛɛrɛbɔlaw ma i n’a fɔ jikuru jan kelen min tɛ tigɛ.
Ka fara o kan, hali n’a bɛ se ka kɛ fana ka kunnafoni-falen-falen-minɛnw (i n’a fɔ formulaire elements walima links) don i ka popover kɔnɔ (ni i ye o fɛnw fara allowList
of allowed attributes and tags kan), i k’a dɔn ko sisan popover tɛ keyboard focus order ɲɛnabɔ. Ni klaviyeti baarakɛla dɔ ye popover da wuli, sinsin bɛ to triggering element kan, wa i n’a fɔ a ka c’a la popover tɛ tugu trigger kɔ teliya la sɛbɛn in jɔcogo la, garanti si tɛ yen ko ka taa ɲɛfɛ/degunTABbɛna klaviyeti baarakɛla dɔ wuli ka don popover yɛrɛ kɔnɔ. Kuma surun na, n’i ye ɲɔgɔndan-minɛnw fara popover kan dɔrɔn, o bɛ se ka kɛ sababu ye ka nin kɔrɔsili ninnu kɛ fɛn ye min tɛ se ka sɔrɔ/min tɛ se ka baara kɛ ni klaviyeti baarakɛlaw ni dɛmɛ-fɛɛrɛw baarakɛlaw ye, walima a dɔgɔyalenba la, o bɛ kɛ sababu ye ka sinsincogo bɛɛ lajɛlen kɛ min tɛ hakili sɔrɔ. O cogo la, aw bɛ jateminɛ kɛ ka baara kɛ ni modal dialogue ye o nɔ na.
Sugandili minnu bɛ kɛ
Sugandili bɛ se ka tɛmɛ data attributes walima JavaScript fɛ. Donanw cogoyaw kama, aw bɛ sugandi tɔgɔ fara data-bs-
, i n’a fɔ a bɛ cogo min na data-bs-animation=""
. Aw ye aw jija ka sugandili tɔgɔ ka case suguya Changer ka bɔ camelCase la ka kɛ kebab-case ye ni aw bɛ sugandiliw tɛmɛ data attributes fɛ. Misali la, sanni i ka baara kɛ ni data-bs-customClass="beautifier"
, baara kɛ ni data-bs-custom-class="beautifier"
.
sanitize
,
sanitizeFn
, ani
allowList
sugandiliw tɛ se ka di ni data attributes ye.
Tɔ̀gɔ | Ka sɛbɛen masin na | Fɔlɔ | Cogojirali |
---|---|---|---|
animation |
boolean ye | true |
CSS fade transition dɔ kɛ ka popover kɛ |
container |
juru | element | nkalon | false |
A bɛ popover fara fɛn kɛrɛnkɛrɛnnen dɔ kan. Misali la: |
content |
juru | element | baarakunda | '' |
Kɔnɔkow nafa dafalen ni Ni baara dɔ dira, a bɛ Weele n'a ka |
delay |
jate | minɛn | 0 |
Delay jirali ni a dogo popover (ms) - o tɛ tali kɛ bololabaarakɛlaw ka trigger suguya la Ni nimɔrɔ dɔ dira, delay bɛ kɛ hide/show fila bɛɛ la Fɛnw jɔcogo ye: |
html |
boolean ye | false |
HTML don popover kɔnɔ. Ni nkalon don, innerText nafolo bɛna kɛ ka kɔnɔkow don DOM kɔnɔ. Baara kɛ ni sɛbɛnni ye ni i bɛ hami XSS binkanniw na. |
placement |
juru | baarakunda | 'right' |
Cogo min na ka popover bila - auto | sanfɛ | duguma | kinin fɛ | jo. Ni baarakɛcogo dɔ bɛ Kɛ ka jɔyɔrɔko Labɛn, a bɛ Weele ni popover DOM node ye a ka argument fɔlɔ ye ani triggering element DOM node k'a Kɛ a filanan ye. A |
selector |
juru | nkalon | false |
Ni sugandili dɔ dira, popover fɛnw bɛna di laɲini kofɔlenw ma. Tiɲɛ na, o bɛ Kɛ walasa ka HTML kɔnɔkow dinamikilenw Dɛmɛ ka popovers (popovers) Fàra u kan. Aw ye nin lajɛ ani misali min bɛ kunnafoni di . |
template |
gaari | '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
Base HTML ka baara kɛ ni popover dabɔli ye. Popover's Popover's
Kɛnɛma-datugulan yɔrɔ ka kan ka kɛ ni |
title |
juru | element | baarakunda | '' |
Title nafa dafalen ni Ni baara dɔ dira, a bɛ Weele n'a ka |
trigger |
gaari | 'click' |
Popover bɛ daminɛ cogo min na - i ka | hover | sinsinnan | min bɛ fɛn bolo la. Aw bɛ se ka tɛmɛ fɛn caman fɛ minnu bɛ se ka kɛ sababu ye; u fara ɲɔgɔn kan ni yɔrɔ dɔ ye. manual tɛ se ka fara ɲɔgɔn kan ni fɛn wɛrɛ ye min bɛ se ka kɛ sababu ye. |
fallbackPlacements |
array (ɲɛnajɛ). | ['top', 'right', 'bottom', 'left'] |
Fallback yɔrɔw ɲɛfɔ ni yɔrɔw lisɛli ye array kɔnɔ (ka kɛɲɛ ni u diyanyekow ye). Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka kɛwale sɛbɛnw lajɛ |
boundary |
juru | fɛn | 'clippingParents' |
Popover ka overflow constraint dancɛ (a bɛ tali kɛ Popper ka preventOverflow modifier dɔrɔn de la). Ka da a kan a bɛ 'clippingParents' ani a bɛ Se ka Sɔn HTMLElement 'kɔnɔ (JavaScript dɔrɔn fɛ). Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka detectOverflow docs lajɛ . |
customClass |
juru | baarakunda | '' |
Aw bɛ kalanw fara popover kan ni a jirala. A kɔlɔsi ko o kalansenw bɛna fara kalansenw kan minnu kofɔlen don jatebɔsen kɔnɔ. Walasa ka kalansen caman fara ɲɔgɔn kan, aw bɛ u faranfasi ni yɔrɔw ye: Aw bɛ se fana ka baarakɛcogo dɔ tɛmɛ min ka kan ka sɛrɛ kelen segin min kɔnɔ kalasi tɔgɔ wɛrɛw bɛ sɔrɔ. |
sanitize |
boolean ye | true |
Saniyali in daminɛ walima k’a bali. Ni activated 'template' , 'content' ani 'title' sugandiliw bɛna saniya. aw ye saniya yɔrɔ lajɛ an ka JavaScript sɛbɛnw kɔnɔ . |
allowList |
minɛn | Nafa min bɛ sɔrɔ a daminɛ na | Fɛn min bɛ ni fɛnw ni taamasiyɛnw ye minnu bɛ Sɔ̀rɔ |
sanitizeFn |
null ka | baarakunda | null |
Yan aw bɛ se ka aw yɛrɛ ka sanitize baarakɛcogo di. O bɛ se ka kɛ nafa ye ni aw b’a fɛ ka baara kɛ ni gafemarayɔrɔ kɛrɛnkɛrɛnnen ye walasa ka saniya kɛ. |
offset |
array | juru | baarakunda | [0, 8] |
Offset ka popover ka kɛɲɛ n’a ka laɲini ye. Aw bɛ se ka sɛrɛ dɔ tɛmɛn data attributes kɔnɔ ni nafaw ye minnu faralen don ɲɔgɔn kan ni koma ye i n’a fɔ: Ni baarakɛcogo dɔ bɛ Kɛ ka offset (fɔcogo) dɔn, a bɛ Weele ni fɛn dɔ ye min kɔnɔ popper (poper) bilali, a ka 'reference (fɔlikan) ani popper rects (popper rects) bɛ min na i n'a fɔ a ka argument (fɔlikan) fɔlɔ. Triggering element DOM node bɛ tɛmɛ i n’a fɔ argument filanan. Baarakɛcogo ka kan ka segin sɛrɛkili dɔ kan ni jateden fila ye: . Walasa ka kunnafoni wɛrɛw sɔrɔ, aw ye Popper ka offset docs lajɛ . |
popperConfig |
null ka | fɛn min bɛ kɛ | baarakunda | null |
Walasa ka Bootstrap ka Popper config default Changer, aw ye Popper ka configuration lajɛ . Ni baarakɛcogo dɔ bɛ Kɛ ka Popper labɛncogo Dabɔ, a bɛ Weele ni fɛn dɔ ye min kɔnɔ Bootstrap ka Popper labɛncogo kɔrɔ bɛ yen. A b’i dɛmɛ ka baara kɛ ni default ye ani k’a fara ɲɔgɔn kan ni i yɛrɛ ka configuration ye. Baarakɛcogo ka kan ka segin Popper ka labɛnni fɛn dɔ kan. |
Data attributes ka ɲɛsin popover kelen-kelen bɛɛ ma
Sugandili minnu bɛ kɛ popover kelen-kelenw na, olu bɛ se ka ɲɛfɔ cogo wɛrɛ la ni kunnafonidilanw ka fɛnw ye, i n’a fɔ a ɲɛfɔlen don cogo min na sanfɛ.
Baara kɛ ni baarakɛcogo ye nipopperConfig
var popover = new bootstrap.Popover(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
Fɛɛrɛw
Fɛɛrɛ minnu tɛ kelen ye ani fɛn caman tigɛli
API fɛɛrɛw bɛɛ ye asynchrone ye ani ka tɛmɛsira dɔ daminɛ . u bɛ segin welebaga ma ni wuli daminɛna dɔrɔn nka sanni a ka ban . Ka fara o kan, fɛɛrɛ weleli min bɛ kɛ tɛmɛsira yɔrɔ dɔ kan, o bɛna jate .
aw ye an ka JavaScript sɛbɛnw lajɛ walasa ka kunnafoni wɛrɛw sɔrɔ .
k'a jira
A bɛ element dɔ ka popover jira. A bɛ Segin welebaga ma sani popover ka jira tiɲɛ na (o kɔrɔ ye ko sanni ko shown.bs.popover
in ka Kɛ). O bɛ jate “bolola” ye min bɛ popover (popover) daminɛ. Popovers minnu tɔgɔ ni u kɔnɔkow bɛɛ ye zeru-janya ye, olu tɛ jira abada.
myPopover.show()
ka dogo
A bɛ element dɔ ka popover dogo. A bɛ Segin welebaga ma sani popover ka dogo tiɲɛ na (o kɔrɔ ye ko sanni ko hidden.bs.popover
in ka Kɛ). O bɛ jate “bolola” ye min bɛ popover (popover) daminɛ.
myPopover.hide()
toggle (toggle) kɛ
A bɛ fɛn dɔ ka popover wuli. A bɛ segin welebaga ma sanni popover ka jira tiɲɛ na walima ka dogo (o kɔrɔ ye ko sanni shown.bs.popover
walima hidden.bs.popover
ko kɛlen ka kɛ). O bɛ jate “bolola” ye min bɛ popover (popover) daminɛ.
myPopover.toggle()
ka a fili
A bɛ fɛn dɔ ka popover dogo ani k’a tiɲɛ (A bɛ kunnafoni maralenw bɔ DOM fɛn kan). Popovers minnu bɛ baara Kɛ ni delegation ye (minnu bɛ Dabɔ ni option selector
ye ) tɛ Se ka Tiɲɛ kelen-kelen na descendant trigger elements kan.
myPopover.dispose()
ka yamaruya
A bɛ element dɔ ka popover seko jira ka jira. Popovers bɛ baara kɛ ni default ye.
myPopover.enable()
ka lajɔ
A bɛ seko bɔ ka ɲɛsin element dɔ ka popover jirali ma. Popover bɛna se ka jira dɔrɔn ni a daminɛna kokura.
myPopover.disable()
toggleA bɛ se ka kɛ
A bɛ se ka fɛn dɔ ka popover jira walima ka dogo.
myPopover.toggleEnabled()
ka lakuraya
A bɛ element dɔ ka popover jɔyɔrɔ kura.
myPopover.update()
getInstance ye
Static method min b’a to i bɛ se ka popover instance sɔrɔ min bɛ tali kɛ DOM element dɔ la
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
sɔrɔWala ka Instance Dabɔ
Static method min b’a To i bɛ popover instance sɔrɔ min bɛ tali Kɛ DOM element dɔ la, walima ka kura Dabɔ n’a sɔrɔla a ma daminɛ
var exampleTriggerEl = document.getElementById('example')
var popover = bootstrap.Popover.getOrCreateInstance(exampleTriggerEl) // Returns a Bootstrap popover instance
Ko minnu kɛra
Ko kɛlen suguya | Cogojirali |
---|---|
jira.bs.popover ye | O ko in bɛ tasuma Bɔ o yɔrɔnin bɛɛ ni show misali fɛɛrɛ Weelera. |
jirala.bs.popover | O ko in bɛ Bɔ ni popover Kɛra yelen ye baarakɛla fɛ (a bɛna CSS 'tɛmɛsiraw makɔnɔ u ka ban). |
dogo.bs.popover ye | O ko in bɛ Fɔ o yɔrɔnin bɛɛ ni hide misali fɛɛrɛ Weelera. |
dogolen.bs.faantanw | O ko in bɛ Bɔ ni popover dogolen Banna baarakɛla fɛ (a bɛna CSS 'tɛmɛsiraw makɔnɔ u ka ban). |
donna.bs.faantanw | O ko in bɛ Bɔ kɛnɛ kan ko kɛlen kɔfɛ show.bs.popover ni popover template farala DOM kan. |
var myPopoverTrigger = document.getElementById('myPopover')
myPopoverTrigger.addEventListener('hidden.bs.popover', function () {
// do something...
})