Pylons/deform — pull request #250 by alephex (2014-12-12 12:49:47+00:00)
Title: Default to no autofocus

This is an alternative to pull request #244

Commenters on issue #249 have raised the point that changing the default behaviour to not performing any auto-focusing of input elements may be a better approach. From a *mobile first* standpoint, I agree. Removing default auto-focusing is unlikely to break anybody's UI, but on the off-chance, a switch to include the HTML attribute *autofocus* is fairly straight forward to implement.

The function focusFirstInput() has been removed entirely. Default behaviour is to perform no auto-focusing of any input element. The option has been created for the user to set the HTML attribute *autofocus* in the schema for a form.

[The autofocus HTML attribute](http://www.w3.org/TR/html5/forms.html#autofocusing-a-form-control:-the-autofocus-attribute) can be added to an input element by including `autofocus=True` when defining a schema node. For example:
```python
ip = colander.SchemaNode(
colander.String(),
title='input',
missing='',
autofocus=True
)
```
This will result in an input element with the *autofocus* attribute set. Eg.
```html

```
If autofocus is None, False or omitted from the schema, the attribute will not be set.

* Behaviour is changed to disable automatic focusing by default
* The autofocus HTML attribute for an element can be (optionally) set in the form's schema

While the *autofocus* attribute has long been supported on desktops (FF 4+, Chrome 5+, IE 10+, Safari 5+, Opera 9.5+), mobile support is patchy (iOS Safari: No, Opera Mini: No, Android Browser 3+, BlackBerry 7+). We could force it by doing something like,

```javascript
if(!('autofocus' in document.createElement('input'))) {
// Focus on some element
}
```
but it would probably be better to let the user decide if they want to implement it themselves.