StateModel.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function (Drupal, Backbone) {
  8. Drupal.contextual.StateModel = Backbone.Model.extend({
  9. defaults: {
  10. title: '',
  11. regionIsHovered: false,
  12. hasFocus: false,
  13. isOpen: false,
  14. isLocked: false
  15. },
  16. toggleOpen: function toggleOpen() {
  17. var newIsOpen = !this.get('isOpen');
  18. this.set('isOpen', newIsOpen);
  19. if (newIsOpen) {
  20. this.focus();
  21. }
  22. return this;
  23. },
  24. close: function close() {
  25. this.set('isOpen', false);
  26. return this;
  27. },
  28. focus: function focus() {
  29. this.set('hasFocus', true);
  30. var cid = this.cid;
  31. this.collection.each(function (model) {
  32. if (model.cid !== cid) {
  33. model.close().blur();
  34. }
  35. });
  36. return this;
  37. },
  38. blur: function blur() {
  39. if (!this.get('isOpen')) {
  40. this.set('hasFocus', false);
  41. }
  42. return this;
  43. }
  44. });
  45. })(Drupal, Backbone);