Issue #492720 by pivica, seutje, nod_, JamesAn, sun: Refactor system.js file and use Drupal form states and form ajax.

Replacement PR for https://github.com/backdrop/backdrop/pull/306.

Backdrop issue: https://github.com/backdrop/backdrop-issues/issues/211
Drupal.org issue: https://drupal.org/node/492720