forked from mgcrea/angular-strap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtooltip.demo.html
More file actions
252 lines (236 loc) · 10.7 KB
/
tooltip.demo.html
File metadata and controls
252 lines (236 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<div class="bs-docs-section" ng-controller="TooltipDemoCtrl">
<div class="page-header">
<h1 id="tooltips">Tooltips <a class="small" href="//github.com/mgcrea/angular-strap/blob/master/src/tooltip/tooltip.js" target="_blank">tooltip.js</a>
</h1>
<code>mgcrea.ngStrap.tooltip</code>
</div>
<h2 id="tooltips-examples">Examples</h2>
<p>Add small overlays of content on hover, to any element for housing secondary information.</p>
<div class="callout callout-warning">
<h4>Plugin dependency</h4>
<p>Tooltip require the <a href="//github.com/mgcrea/angular-strap/blob/master/src/helpers/dimensions.js" target="_blank">helpers.dimensions</a> module to be loaded.</p>
</div>
<h3>Live demo <a class="small edit-plunkr" data-module-name="mgcrea.ngStrapDocs" data-content-html-url="tooltip/docs/tooltip.demo.html" data-content-js-url="tooltip/docs/tooltip.demo.js" ng-plunkr data-title="edit in plunker" data-placement="right" bs-tooltip>clog.info</a></h3>
<div class="form-group hide">
<label>Title</label>
<input type="text" class="form-control" ng-model="tooltip.title" placeholder="Title">
</div>
<pre class="bs-example-scope">$scope.tooltip = {{tooltip | json}};</pre>
<div class="bs-example" style="padding-bottom: 24px;" append-source>
<!-- Markup for a default tooltip with a scope passed as an object {title:''} -->
<p>Tight pants next level keffiyeh <a href="" data-animation="am-flip-x" bs-tooltip="tooltip">you probably</a> haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown.</p>
<div class="input-group col-xs-5">
<span class="input-group-btn">
<!-- You can also use data-attrs to assign scope variables -->
<button class="btn btn-primary" type="button" data-trigger="click" data-type="success" data-title="{{tooltip.title}}" bs-tooltip>Click me</button>
</span>
<input type="text" class="form-control" data-placement="right" data-type="info" data-container="body" placeholder="Focus to toggle tooltip" data-trigger="focus" bs-tooltip="tooltip">
</div>
<div class="checkbox">
<label data-placement="bottom-left" data-type="info" data-animation="am-fade-and-scale" bs-tooltip="tooltip" bs-enabled="tooltip.checked">
<input type="checkbox" ng-model="tooltip.checked" > Check me to enable my tooltip
</label>
</div>
</div>
<h2 id="tooltips-usage">Usage</h2>
<p>Append a <code>bs-tooltip</code> attribute to any element to enable the directive.</p>
<div class="callout callout-info">
<h4>The module exposes a <code>$tooltip</code>service</h4>
<p>Available for programmatic use (mainly in directives as it requires a DOM element).</p>
<div class="highlight">
<pre>
<code class="javascript" highlight-block>
var myTooltip = $tooltip(element, {title: 'My Title'});
</code>
</pre>
</div>
</div>
<h3>Options</h3>
<p>Options can be passed via data-attributes on the directive or as an object hash to configure the service. For data attributes, append the option name to <code>data-</code>, as in <code>data-animation=""</code>.</p>
<p>For directives, you can naturally inherit the contextual <code>$scope</code> or leverage a custom one with an <a href="http://docs.angularjs.org/guide/expression">AngularJS expression</a> to evaluate as an object directly on the <code>bs-tooltip</code> attribute</p>
<div class="callout callout-info">
<h4>This module supports exotic placement options!</h4>
<p>You can position your popover in corners (such as <code>bottom-left</code>) or any other combination two.</p>
<p>Exotic placement options are not part of the Bootstrap's core, to use them you must use <code>bootstrap-additions.css</code> from the <a href="//github.com/mgcrea/bootstrap-additions" target="_blank">BootstrapAdditions</a> project. This project being not yet fully released, meanwhile, you can use the <a href="//mgcrea.github.io/angular-strap/static/styles/bootstrap-additions.min.css" target="_blank">development snapshot</a> compiled for theses docs.</p>
</div>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">Name</th>
<th style="width: 100px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>animation</td>
<td>string</td>
<td>am-fade</td>
<td>apply a CSS animation powered by <code>ngAnimate</code></td>
</tr>
<tr>
<td>placement</td>
<td>string</td>
<td>'top'</td>
<td>
how to position the tooltip - top | bottom | left | right | auto, or any combination like bottom-left or auto bottom-left.<br>
When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right.
</td>
</tr>
<tr>
<td>trigger</td>
<td>string</td>
<td>'hover focus'</td>
<td>how tooltip is triggered - click | hover | focus | manual</td>
</tr>
<tr>
<td>title</td>
<td>string</td>
<td>''</td>
<td>default title value if <code>title</code>attribute isn't present</td>
</tr>
<tr>
<td>html</td>
<td>boolean</td>
<td>false</td>
<td>replace <code>ng-bind</code> with <code>ng-bind-html</code>, requires <code>ngSanitize</code> to be loaded</td>
</tr>
<tr>
<td>delay</td>
<td>number | object</td>
<td>0</td>
<td>
<p>delay showing and hiding the tooltip (ms) - does not apply to manual trigger type</p>
<p>If a number is supplied, delay is applied to both hide/show</p>
<p>Object structure is:
<code>delay: { show: 500, hide: 100 }</code>
</p>
</td>
</tr>
<tr>
<td>container</td>
<td>string | false</td>
<td>false</td>
<td>
<p>Appends the tooltip to a specific element. Example:
<code>container: 'body'</code>. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.</p>
</td>
</tr>
<tr>
<td>target</td>
<td>string | DOMElement | false</td>
<td>false</td>
<td>
<p>Position the tooltip relative to a specific target element.</p>
</td>
</tr>
<tr>
<td>template</td>
<td>path</td>
<td>false</td>
<td>
<p>If provided, overrides the default template, can be either a remote URL or a cached template id.</p>
<p>It should be a <code>div.tooltip</code> element following Bootstrap styles conventions (<a href="//github.com/mgcrea/angular-strap/blob/master/src/tooltip/tooltip.tpl.html" target="_blank">like this</a>).</p>
</td>
</tr>
<tr>
<td>contentTemplate</td>
<td>path</td>
<td>false</td>
<td>
<p>If provided, fetches the partial and includes it as the inner content, can be either a remote URL or a cached template id.</p>
</td>
</tr>
<tr>
<td>prefixEvent</td>
<td>string</td>
<td>'tooltip'</td>
<td>
<p>If provided, prefixes the events '.hide.before' '.hide' '.show.before' and '.show' with the passed in value. With the default value these events are 'tooltip.hide.before' 'tooltip.hide' 'tooltip.show.before' and 'tooltip.show'</p>
</td>
</tr>
<tr>
<td>id</td>
<td>string</td>
<td>''</td>
<td>
The tooltip instance id for usage in event handlers.
</td>
</tr>
<tr>
<td>viewport</td>
<td>string | object</td>
<td>{ selector: 'body', padding: 0 }</td>
<td>
<p>
Keeps the tooltip within the bounds of this element. Example: viewport: '#viewport' or { "selector": "#viewport", "padding": 0 }
</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="callout callout-info">
<h4>Default options</h4>
<p>You can override global defaults for the plugin with <code>$tooltipProvider.defaults</code></p>
<div class="highlight">
<pre class="bs-exemple-code">
<code class="javascript" highlight-block>
angular.module('myApp')
.config(function($tooltipProvider) {
angular.extend($tooltipProvider.defaults, {
animation: 'am-flip-x',
trigger: 'hover'
});
})
</code>
</pre>
</div>
</div>
<h3>Helper attributes</h3>
<p>Helper attributes can be used together with the directive via data-attributes to support specific functionality. Helper attributes support data binding. To use helper attributes, append the helper attribute name to <code>data-</code>, as in <code>data-bs-show="true"</code>.</p>
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">Name</th>
<th style="width: 100px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>bsShow</td>
<td>boolean | string</td>
<td>false</td>
<td>
<p>shows or hides the tooltip. Supports boolean values or "true"/"false" string values.</p>
<p>You can also specify "tooltip" to show just the tooltip when using several angular-strap directives on the same element.</p>
</td>
</tr>
<tr>
<td>bsEnabled</td>
<td>boolean | string</td>
<td>true</td>
<td>
<p>enables or disables the tooltip trigger. When the tooltip is disabled, calling show() will have no effect.</p>
<p>Supports boolean values or "true" "false" "1" "0" string values.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h3>Scope methods</h3>
<p>Methods available inside the directive scope to toggle visibility.</p>
<h4>$show()</h4>
<p>Reveals the tooltip.</p>
<h4>$hide()</h4>
<p>Hides the tooltip.</p>
<h4>$toggle()</h4>
<p>Toggles the tooltip.</p>
<h4>$setEnabled(isEnabled)</h4>
<p>Enables or disables the tooltip.</p>
</div>