1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- /**
- * DO NOT EDIT THIS FILE.
- * See the following change record for more information,
- * https://www.drupal.org/node/2815083
- * @preserve
- **/
- (function (Drupal, Backbone, Modernizr) {
- Drupal.contextual.VisualView = Backbone.View.extend({
- events: function events() {
- var touchEndToClick = function touchEndToClick(event) {
- event.preventDefault();
- event.target.click();
- };
- var mapping = {
- 'click .trigger': function clickTrigger() {
- this.model.toggleOpen();
- },
- 'touchend .trigger': touchEndToClick,
- 'click .contextual-links a': function clickContextualLinksA() {
- this.model.close().blur();
- },
- 'touchend .contextual-links a': touchEndToClick
- };
- if (!Modernizr.touchevents) {
- mapping.mouseenter = function () {
- this.model.focus();
- };
- }
- return mapping;
- },
- initialize: function initialize() {
- this.listenTo(this.model, 'change', this.render);
- },
- render: function render() {
- var isOpen = this.model.get('isOpen');
- var isVisible = this.model.get('isLocked') || this.model.get('regionIsHovered') || isOpen;
- this.$el.toggleClass('open', isOpen).find('.trigger').toggleClass('visually-hidden', !isVisible);
- if ('isOpen' in this.model.changed) {
- this.$el.closest('.contextual-region').find('.contextual .trigger:not(:first)').toggle(!isOpen);
- }
- return this;
- }
- });
- })(Drupal, Backbone, Modernizr);
|