mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-14 18:42:30 +03:00
update more readme changes - introduce target specificty convention to more plugins
This commit is contained in:
+23
-5
@@ -1,5 +1,5 @@
|
||||
## 2.0 BOOTSTRAP JS PHILOSOPHY
|
||||
These are the high-level design rules which guide the development of Bootstrap's JS plugins.
|
||||
These are the high-level design rules which guide the development of Bootstrap's plugin apis.
|
||||
|
||||
---
|
||||
|
||||
@@ -28,10 +28,12 @@ All public APIs should be single, chainable methods, and return the collection a
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
### PLUGIN OPTIONS
|
||||
### OPTIONS
|
||||
|
||||
Options should be sparse and add universal value. We should pick the right defaults.
|
||||
|
||||
@@ -51,7 +53,7 @@ examples:
|
||||
|
||||
---
|
||||
|
||||
### PLUGIN EVENTS
|
||||
### 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.
|
||||
|
||||
@@ -60,14 +62,30 @@ All events should have an infinitive and past participle form. The infinitive is
|
||||
|
||||
---
|
||||
|
||||
### 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)* - defines main interaction
|
||||
- data-target || href^=# - defined on controller element (if element interacts with an element other than self)
|
||||
- data-*(noun)* - defines options for element invocation
|
||||
- data-target || href^=# - defined on "control" element (if element controls an element other than self)
|
||||
- data-*(noun)* - defines class instance options
|
||||
|
||||
examples:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user