states.js 995 B

123456789101112131415161718192021222324
  1. (function($) {
  2. // Unbind core state.js from document first so we can then override below.
  3. $(document).unbind('state:disabled');
  4. /**
  5. * Global state change handlers. These are bound to "document" to cover all
  6. * elements whose state changes. Events sent to elements within the page
  7. * bubble up to these handlers. We use this system so that themes and modules
  8. * can override these state change handlers for particular parts of a page.
  9. */
  10. $(document).bind('state:disabled', function(e) {
  11. // Only act when this change was triggered by a dependency and not by the
  12. // element monitoring itself.
  13. if (e.trigger) {
  14. $(e.target)
  15. .attr('disabled', e.value)
  16. .closest('.form-item, .form-submit, .form-wrapper').toggleClass('form-disabled', e.value)
  17. .find(':input').attr('disabled', e.value);
  18. // Note: WebKit nightlies don't reflect that change correctly.
  19. // See https://bugs.webkit.org/show_bug.cgi?id=23789
  20. }
  21. });
  22. })(jQuery);