Something which is always available in YiiBooster
As YiiBooster includes the (almost always) complete Twitter Bootstrap library, some features of it are always enabled and available for you to use. Most notorious are, of course, the tooltips.
Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.
Hover over the links below to see tooltips:
Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral.
Trigger the tooltip via JavaScript:
$('#example').tooltip(options)
Options can be passed via data attributes or JavaScript. For data
attributes, append the option name to data-
,
as in data-animation=""
.
Name | type | default | description |
---|---|---|---|
animation | boolean | true | apply a css fade transition to the tooltip |
html | boolean | true | Insert html into the tooltip. If false, jquery's
text method will be used to insert content
into the dom. Use text if you're worried about XSS attacks.
|
placement | string|function | 'top' | how to position the tooltip - top | bottom | left | right |
selector | string | false | If a selector is provided, tooltip objects will be delegated to the specified targets. |
title | string | function | '' | default title value if `title` tag isn't present |
trigger | string | 'hover' | how tooltip is triggered - click | hover | focus | manual |
delay | number | object | 0 |
delay showing and hiding the tooltip (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is: |
For performance reasons, the Tooltip and Popover data-apis are opt in. If you would like to use them just specify a selector option.
<a href="#" data-toggle="tooltip" title="first tooltip">hover over me</a>
Attaches a tooltip handler to an element collection.
Reveals an element's tooltip.
$('#element').tooltip('show')
Hides an element's tooltip.
$('#element').tooltip('hide')
Toggles an element's tooltip.
$('#element').tooltip('toggle')
Hides and destroys an element's tooltip.
$('#element').tooltip('destroy')
Four options are available: top, right, bottom, and left aligned.
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
<div class="bs-docs-example-popover"> <div class="popover bottom"> <div class="arrow"></div> <h3 class="popover-title">Popover bottom</h3> <div class="popover-content"> <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p> </div> </div> <div class="popover right"> <div class="arrow"></div> <h3 class="popover-title">Popover right</h3> <div class="popover-content"> <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p> </div> </div> <div class="popover top"> <div class="arrow"></div> <h3 class="popover-title">Popover top</h3> <div class="popover-content"> <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p> </div> </div> <div class="popover left"> <div class="arrow"></div> <h3 class="popover-title">Popover left</h3> <div class="popover-content"> <p>Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.</p> </div> </div> </div>
No markup shown as popovers are generated from JavaScript and content within a data
attribute.
$this->widget( 'booster.widgets.TbButton', array( 'label' => 'Top popover', 'context' => 'primary', 'htmlOptions' => array( 'data-title' => 'A Title', 'data-placement' => 'top', 'data-content' => "And here's some amazing content. It's very engaging. right?", 'data-toggle' => 'popover' ), ) ); echo ' '; $this->widget( 'booster.widgets.TbButton', array( 'label' => 'Left popover', 'context' => 'danger', 'htmlOptions' => array( 'data-title' => 'A Title', 'data-placement' => 'left', 'data-content' => "And here's some amazing content. It's very engaging. right?", 'data-toggle' => 'popover' ), ) ); echo ' '; $this->widget( 'booster.widgets.TbButton', array( 'label' => 'Bottom popover', 'context' => 'success', 'htmlOptions' => array( 'data-title' => 'A Title', 'data-placement' => 'bottom', 'data-content' => "And here's some amazing content. It's very engaging. right?", 'data-toggle' => 'popover' ), ) ); echo ' '; $this->widget( 'booster.widgets.TbButton', array( 'label' => 'Right popover', 'context' => 'warning', 'htmlOptions' => array( 'data-title' => 'A Title', 'data-placement' => 'right', 'data-content' => "And here's some amazing content. It's very engaging. right?", 'data-toggle' => 'popover' ), ) );Note The above as you can see is just a Bootstrap button with a meta-tag configuration. Please, check Twitter popover documentation for more information about its options.
The subnavigation on the left is a live demo of the affix plugin.
To easily add affix behavior to any element, just add data-spy="affix"
to the element you want to
spy on. Then use offsets to define when to toggle the pinning of an element on and off.
<div data-spy="affix" data-offset-top="200">...</div>
affix
, affix-top
, and affix-bottom
. Remember to check for a
potentially collapsed parent when the affix kicks in as it's removing content from the normal flow of the page.
Call the affix plugin via JavaScript:
$('#navbar').affix()
When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:
$('[data-spy="affix"]').each(function () { $(this).affix('refresh') });
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
,
as in data-offset-top="200"
.
Name | type | default | description |
---|---|---|---|
offset | number | function | object | 10 | Pixels to offset from screen when calculating position of scroll. If a single number is provide, the
offset will be applied in both top and left directions. To listen for a single direction, or multiple
unique offsets, just provided an object offset: { x: 10 } . Use a function when you need to
dynamically provide an offset (useful for some responsive designs).
|
For simple transition effects, include bootstrap-transition.js once alongside the other JS files. If you're using the compiled (or minified) bootstrap.js, there is no need to include this—it's already there.
A few examples of the transition plugin: