2014-01-08 07:03:02 +00:00
|
|
|
/**
|
2022-09-09 06:26:42 +00:00
|
|
|
* @file
|
|
|
|
* A Backbone View that provides keyboard interaction for a contextual link.
|
|
|
|
*/
|
2014-01-08 07:03:02 +00:00
|
|
|
|
|
|
|
(function (Drupal, Backbone) {
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
2024-04-25 19:28:47 +00:00
|
|
|
* @deprecated in drupal:9.4.0 and is removed from drupal:12.0.0. There is no
|
2022-09-09 06:26:42 +00:00
|
|
|
* replacement.
|
|
|
|
*/
|
|
|
|
Drupal.contextual.KeyboardView = Backbone.View.extend(
|
|
|
|
/** @lends Drupal.contextual.KeyboardView# */ {
|
|
|
|
/**
|
|
|
|
* @type {object}
|
|
|
|
*/
|
|
|
|
events: {
|
|
|
|
'focus .trigger': 'focus',
|
|
|
|
'focus .contextual-links a': 'focus',
|
|
|
|
'blur .trigger': function () {
|
|
|
|
this.model.blur();
|
|
|
|
},
|
|
|
|
'blur .contextual-links a': function () {
|
|
|
|
// Set up a timeout to allow a user to tab between the trigger and the
|
|
|
|
// contextual links without the menu dismissing.
|
|
|
|
const that = this;
|
|
|
|
this.timer = window.setTimeout(() => {
|
|
|
|
that.model.close().blur();
|
|
|
|
}, 150);
|
|
|
|
},
|
2017-05-19 22:12:53 +00:00
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Provides keyboard interaction for a contextual link.
|
|
|
|
*
|
|
|
|
* @constructs
|
|
|
|
*
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
|
|
|
initialize() {
|
|
|
|
/**
|
|
|
|
* The timer is used to create a delay before dismissing the contextual
|
|
|
|
* links on blur. This is only necessary when keyboard users tab into
|
|
|
|
* contextual links without edit mode (i.e. without TabbingManager).
|
|
|
|
* That means that if we decide to disable tabbing of contextual links
|
|
|
|
* without edit mode, all this timer logic can go away.
|
|
|
|
*
|
|
|
|
* @type {NaN|number}
|
|
|
|
*/
|
|
|
|
this.timer = NaN;
|
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Sets focus on the model; Clears the timer that dismisses the links.
|
|
|
|
*/
|
|
|
|
focus() {
|
|
|
|
// Clear the timeout that might have been set by blurring a link.
|
|
|
|
window.clearTimeout(this.timer);
|
|
|
|
this.model.focus();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
})(Drupal, Backbone);
|