0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-30 12:24:19 +01:00
Bootstrap/docs/assets/js
billy gates d6ac499ca8 Merge pull request #5309 from erlendfh/dropdown-bugfix
Fixed bug in dropdown toggle where menu would only clear on the first dropdown
2012-10-17 23:00:41 -07:00
..
google-code-prettify pre font-size increase; revert static top navbar, undo contents section for now 2012-08-19 23:01:24 -07:00
application.js removed some old stuff from application.js 2012-08-18 19:24:29 -07:00
bootstrap-affix.js check affix pos on clicks - use timeout for clicks which scroll 2012-09-24 23:59:02 -07:00
bootstrap-alert.js version bump to get this started 2012-09-05 10:00:57 -07:00
bootstrap-button.js version bump to get this started 2012-09-05 10:00:57 -07:00
bootstrap-carousel.js fix carousel event 2012-10-17 22:26:44 -07:00
bootstrap-collapse.js version bump to get this started 2012-09-05 10:00:57 -07:00
bootstrap-dropdown.js Fixed bug in dropdown toggle where menu would only clear on the first drop down 2012-09-27 10:31:40 +02:00
bootstrap-modal.js fixes #5336: reorder focus() call to avoid scrolling 2012-10-16 12:27:43 -04:00
bootstrap-popover.js version bump to get this started 2012-09-05 10:00:57 -07:00
bootstrap-scrollspy.js version bump to get this started 2012-09-05 10:00:57 -07:00
bootstrap-tab.js rebuild 2012-10-17 22:51:39 -07:00
bootstrap-tooltip.js rebuild 2012-10-17 22:51:39 -07:00
bootstrap-transition.js change transition.js, rebuild… travis maybe will be happy? 2012-09-20 16:50:36 -07:00
bootstrap-typeahead.js rebuild - fix missing ( 2012-09-20 16:26:00 -07:00
bootstrap.js Merge pull request #5309 from erlendfh/dropdown-bugfix 2012-10-17 23:00:41 -07:00
bootstrap.min.js rebuild 2012-10-17 22:51:39 -07:00
jquery.js added support for jquery 1.8.* 2012-09-20 16:23:54 -07:00
README.md move js stuff into assets 2012-01-31 13:58:28 -08:00

2.0 BOOTSTRAP JS PHILOSOPHY

These are the high-level design rules which guide the development of Bootstrap's plugin apis.


DATA-ATTRIBUTE API

We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript.

We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with 'data-api'. This looks like this:

$('body').off('.data-api')

To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this:

$('body').off('.alert.data-api')

PROGRAMATIC API

We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API.

All public APIs should be single, chainable methods, and return the collection acted upon.

$(".btn.danger").button("toggle").addClass("fat")

All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior:

$("#myModal").modal() // initialized with defaults
$("#myModal").modal({ keyboard: false }) // initialized with now keyboard
$("#myModal").modal('show') // initializes and invokes show immediately afterqwe2

OPTIONS

Options should be sparse and add universal value. We should pick the right defaults.

All plugins should have a default object which can be modified to effect all instance's default options. The defaults object should be available via $.fn.plugin.defaults.

$.fn.modal.defaults = { … }

An options definition should take the following form:

*noun*: *adjective* - describes or modifies a quality of an instance

examples:

backdrop: true
keyboard: false
placement: 'top'

EVENTS

All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action.

show | shown
hide | hidden

CONSTRUCTORS

Each plugin should expose it's raw constructor on a Constructor property -- accessed in the following way:

$.fn.popover.Constructor

DATA ACCESSOR

Each plugin stores a copy of the invoked class on an object. This class instance can be accessed directly through jQuery's data API like this:

$('[rel=popover]').data('popover') instanceof $.fn.popover.Constructor

DATA ATTRIBUTES

Data attributes should take the following form:

  • data-{{verb}}={{plugin}} - defines main interaction
  • data-target || href^=# - defined on "control" element (if element controls an element other than self)
  • data-{{noun}} - defines class instance options

examples:

// control other targets
data-toggle="modal" data-target="#foo"
data-toggle="collapse" data-target="#foo" data-parent="#bar"

// defined on element they control
data-spy="scroll"

data-dismiss="modal"
data-dismiss="alert"

data-toggle="dropdown"

data-toggle="button"
data-toggle="buttons-checkbox"
data-toggle="buttons-radio"