2014-01-08 07:03:02 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2014-01-08 07:03:02 +00:00
|
|
|
|
|
|
|
(function (Drupal, Backbone, Modernizr) {
|
2017-05-19 22:12:53 +00:00
|
|
|
Drupal.contextual.VisualView = Backbone.View.extend({
|
2021-12-18 06:12:16 +00:00
|
|
|
events() {
|
|
|
|
const touchEndToClick = function (event) {
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.target.click();
|
|
|
|
};
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
const mapping = {
|
|
|
|
'click .trigger': function () {
|
2017-05-19 22:12:53 +00:00
|
|
|
this.model.toggleOpen();
|
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
'touchend .trigger': touchEndToClick,
|
2021-12-18 06:12:16 +00:00
|
|
|
'click .contextual-links a': function () {
|
2017-05-19 22:12:53 +00:00
|
|
|
this.model.close().blur();
|
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
'touchend .contextual-links a': touchEndToClick
|
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2015-10-16 10:34:24 +00:00
|
|
|
if (!Modernizr.touchevents) {
|
2017-05-19 22:12:53 +00:00
|
|
|
mapping.mouseenter = function () {
|
|
|
|
this.model.focus();
|
|
|
|
};
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
return mapping;
|
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
|
|
|
initialize() {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const isOpen = this.model.get('isOpen');
|
|
|
|
const isVisible = this.model.get('isLocked') || this.model.get('regionIsHovered') || isOpen;
|
2017-05-19 22:12:53 +00:00
|
|
|
this.$el.toggleClass('open', isOpen).find('.trigger').toggleClass('visually-hidden', !isVisible);
|
2014-01-08 07:03:02 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if ('isOpen' in this.model.changed) {
|
2017-05-19 22:12:53 +00:00
|
|
|
this.$el.closest('.contextual-region').find('.contextual .trigger:not(:first)').toggle(!isOpen);
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
})(Drupal, Backbone, Modernizr);
|