2014-01-08 07:03:02 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* All changes should be applied to ./modules/contextual/js/views/VisualView.es6.js
|
|
|
|
* See the following change record for more information,
|
|
|
|
* https://www.drupal.org/node/2873849
|
|
|
|
* @preserve
|
|
|
|
**/
|
2014-01-08 07:03:02 +00:00
|
|
|
|
|
|
|
(function (Drupal, Backbone, Modernizr) {
|
|
|
|
|
2015-10-13 22:37:56 +00:00
|
|
|
'use strict';
|
2014-01-08 07:03:02 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
Drupal.contextual.VisualView = Backbone.View.extend({
|
|
|
|
events: function events() {
|
|
|
|
var touchEndToClick = function touchEndToClick(event) {
|
2014-01-27 21:41:32 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.target.click();
|
|
|
|
};
|
|
|
|
var mapping = {
|
2017-05-19 22:12:53 +00:00
|
|
|
'click .trigger': function clickTrigger() {
|
|
|
|
this.model.toggleOpen();
|
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
'touchend .trigger': touchEndToClick,
|
2017-05-19 22:12:53 +00:00
|
|
|
'click .contextual-links a': function clickContextualLinksA() {
|
|
|
|
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
|
|
|
}
|
|
|
|
return mapping;
|
|
|
|
},
|
2014-01-08 07:03:02 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
initialize: function initialize() {
|
2014-01-27 21:41:32 +00:00
|
|
|
this.listenTo(this.model, 'change', this.render);
|
|
|
|
},
|
2014-01-08 07:03:02 +00:00
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
render: function render() {
|
2014-01-27 21:41:32 +00:00
|
|
|
var isOpen = this.model.get('isOpen');
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
var 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;
|
|
|
|
}
|
2014-01-08 07:03:02 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
})(Drupal, Backbone, Modernizr);
|