Coding standards


NOTE:  Content from the old Development page has been ported into this page to avoid any confusion. This page is in-progress and we'll be making additions frequently so please check back for updates. Please note any questions or claifications here so they can be answered.

 

General Guidelines

 

 

 

.noConflict() compliance

 

Wrap plugins in a closure that passes jQuery in as a parameter. Inside the closure, only reference jQuery through the parameter variable.

 

(function( $ ) {

     // inside here only reference $, not jQuery

}( jQuery ) );

 

 

passing elements as options or parameters

 

Whenever a user can specify an element, they should be able to provide any of the following:

 

 

TODO: move everything below here to widget factory docs and link to that doc from here.

 

getting/setting options after init

 

add notes about how to listen to options

 

callbacks

 

add notes about how to trigger callbacks and what to pass in the ui object

 

specifying icons

 

add notes about how to specify which icons to use, e.g., which close icon.

 

specifying events

 

add notes about how to specify which events should trigger an action

- click, ctrl+click, mouseover

 

applying CSS classes

 

- applying hover states

- applying focus states

 

z-index and stacking

 

Widgets that append elements to the page should use the .ui-front stacking technique.

These widgets will have an appendTo option but will not have a zIndex option.

The default for appendTo should be null, which means to walk up the DOM from the associated element looking for an existing element with the ui-front class. For example, the autocomplete widget's menu is appended to the DOM, and walks up from the associated input field.

If an element is found with the ui-front class, the element being appended will be appended to the found element.

If no element is found, the element is appended to the body.

If the user explicitly sets the appendTo option, then no searching is performed and the specified element is used.

The appended element must also have the ui-front class added, which will apply a z-index to the element. The element must also have it's position style set to absolute or fixed by some other class.