Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / _includes / js / overview.html
1 <div class="bs-docs-section">
2   <h1 id="js-overview" class="page-header">Overview</h1>
3
4   <h2 id="js-individual-compiled">Individual or compiled</h2>
5   <p>Plugins can be included individually (using Bootstrap's individual <code>*.js</code> files), or all at once (using <code>bootstrap.js</code> or the minified <code>bootstrap.min.js</code>).</p>
6
7   <div class="bs-callout bs-callout-danger" id="callout-overview-not-both">
8     <h4>Using the compiled JavaScript</h4>
9     <p>Both <code>bootstrap.js</code> and <code>bootstrap.min.js</code> contain all plugins in a single file. Include only one.</p>
10   </div>
11
12   <div class="bs-callout bs-callout-danger" id="callout-overview-dependencies">
13     <h4>Plugin dependencies</h4>
14     <p>Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included <strong>before</strong> the plugin files). <a href="{{ site.repo }}/blob/v{{ site.current_version }}/bower.json">Consult our <code>bower.json</code></a> to see which versions of jQuery are supported.</p>
15   </div>
16
17   <h2 id="js-data-attrs">Data attributes</h2>
18   <p>You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first-class API and should be your first consideration when using a plugin.</p>
19
20   <p>That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the document namespaced with <code>data-api</code>. This looks like this:</p>
21 {% highlight js %}
22 $(document).off('.data-api')
23 {% endhighlight %}
24
25   <p>Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:</p>
26 {% highlight js %}
27 $(document).off('.alert.data-api')
28 {% endhighlight %}
29
30   <div class="bs-callout bs-callout-danger" id="callout-overview-single-data">
31     <h4>Only one plugin per element via data attributes</h4>
32     <p>Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element.</p>
33   </div>
34
35   <h2 id="js-programmatic-api">Programmatic API</h2>
36   <p>We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.</p>
37 {% highlight js %}
38 $('.btn.danger').button('toggle').addClass('fat')
39 {% endhighlight %}
40
41   <p>All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):</p>
42 {% highlight js %}
43 $('#myModal').modal()                      // initialized with defaults
44 $('#myModal').modal({ keyboard: false })   // initialized with no keyboard
45 $('#myModal').modal('show')                // initializes and invokes show immediately
46 {% endhighlight %}
47
48   <p>Each plugin also exposes its raw constructor on a <code>Constructor</code> property: <code>$.fn.popover.Constructor</code>. If you'd like to get a particular plugin instance, retrieve it directly from an element: <code>$('[rel="popover"]').data('popover')</code>.</p>
49
50   <h4>Default settings</h4>
51   <p>You can change the default settings for a plugin by modifying the plugin's <code>Constructor.DEFAULTS</code> object:</p>
52 {% highlight js %}
53 $.fn.modal.Constructor.DEFAULTS.keyboard = false // changes default for the modal plugin's `keyboard` option to false
54 {% endhighlight %}
55
56   <h2 id="js-noconflict">No conflict</h2>
57   <p>Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call <code>.noConflict</code> on the plugin you wish to revert the value of.</p>
58 {% highlight js %}
59 var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
60 $.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
61 {% endhighlight %}
62
63   <h2 id="js-events">Events</h2>
64   <p>Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. <code>show</code>) is triggered at the start of an event, and its past participle form (ex. <code>shown</code>) is triggered on the completion of an action.</p>
65   <p>As of 3.0.0, all Bootstrap events are namespaced.</p>
66   <p>All infinitive events provide <code>preventDefault</code> functionality. This provides the ability to stop the execution of an action before it starts.</p>
67 {% highlight js %}
68 $('#myModal').on('show.bs.modal', function (e) {
69   if (!data) return e.preventDefault() // stops modal from being shown
70 })
71 {% endhighlight %}
72
73   <h2 id="js-version-nums">Version numbers</h2>
74   <p>The version of each of Bootstrap's jQuery plugins can be accessed via the <code>VERSION</code> property of the plugin's constructor. For example, for the tooltip plugin:</p>
75 {% highlight js %}
76 $.fn.tooltip.Constructor.VERSION // => "{{ site.current_version }}"
77 {% endhighlight %}
78
79   <h2 id="js-disabled">No special fallbacks when JavaScript is disabled</h2>
80   <p>Bootstrap's plugins don't fall back particularly gracefully when JavaScript is disabled. If you care about the user experience in this case, use <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript"><code>&lt;noscript&gt;</code></a> to explain the situation (and how to re-enable JavaScript) to your users, and/or add your own custom fallbacks.</p>
81
82   <div class="bs-callout bs-callout-warning" id="callout-third-party-libs">
83     <h4>Third-party libraries</h4>
84     <p><strong>Bootstrap does not officially support third-party JavaScript libraries</strong> like Prototype or jQuery UI. Despite <code>.noConflict</code> and namespaced events, there may be compatibility problems that you need to fix on your own.</p>
85   </div>
86 </div>