twbs--bootstrap/js
Jacob Thornton 71654cbf69 refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
..
tests fix scrollspy simplify stuff more - break everything. 2011-10-19 23:12:50 -07:00
README.md refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-accordion.js fix scrollspy simplify stuff more - break everything. 2011-10-19 23:12:50 -07:00
bootstrap-alerts.js refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-buttons.js refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-collapsible.js refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-dropdown.js refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-modal.js refactor alerts + add new readme which idefientifies goals for 2.0 js 2011-11-24 18:55:44 -08:00
bootstrap-popover.js add build script for minified files and allow elements to be returned to getContent and title in popovers 2011-11-20 21:36:26 -08:00
bootstrap-scrollspy.js merge in js from 1.4... start working through js docs 2011-11-20 20:58:04 -08:00
bootstrap-tabs.js merge in js from 1.4... start working through js docs 2011-11-20 20:58:04 -08:00
bootstrap-transitions.js merge in js from 1.4... start working through js docs 2011-11-20 20:58:04 -08:00
bootstrap-twipsy.js act on all twipsy instances 2011-11-20 21:06:32 -08:00

README.md

2.0 BOOTSTRAP JS PHILSOPHY These are the highlevel design rules which guide the developement of Bootstrap's js plugins.


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 acknoledge 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').unbind('.data-api')

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

$('body').unbind('.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 pubilc APIs should be a single, chainable method, 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 innitiates the default behavior:

$("#myModal").modal() // initialized with defaults

PLUGIN 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 definiton should take the following form:

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

examples:

backdrop: true
keyboard: false
placement: 'above'

PLUGIN 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
change | changed

DATA ATTRIBUTES

Data attributes should take the following form:

data-(verb) - defines main interaction data-target - defined on controller element (if element interacts with an element other than self) data-(noun) - defines options for element invocation

examples:

// control other targets
data-toggle="modal" data-target="#foo"
data-toggle="view" data-target="#foo"

// 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"