mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Skip links with iframes
This commit is contained in:
parent
b735d8ffab
commit
3494516b6c
@ -610,6 +610,7 @@ define([
|
||||
Framework.create({
|
||||
toolbarContainer: '#cme_toolbox',
|
||||
contentContainer: '#cp-app-code-editor',
|
||||
skipLink: '.CodeMirror',
|
||||
thumbnail: {
|
||||
getContainer: getThumbnailContainer,
|
||||
filter: function (el, before) {
|
||||
|
||||
@ -2666,7 +2666,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||
},
|
||||
sfCommon: common,
|
||||
$container: $bar,
|
||||
$contentContainer: $('#cp-app-oo-container')
|
||||
$contentContainer: $('#cp-app-oo-container'),
|
||||
skipLink: 'iframe[name="frameEditor"]|#editor_sdk'
|
||||
};
|
||||
toolbar = APP.toolbar = Toolbar.create(configTb);
|
||||
toolbar.showColors();
|
||||
|
||||
@ -865,22 +865,35 @@ MessengerUI, Messages, Pages, PadTypes) {
|
||||
|
||||
Bar.createSkipLink = function (toolbar, config) {
|
||||
const targetId = config.skipLink || '#cp-skip-link';
|
||||
const $targetElement = $(targetId);
|
||||
const $skipLink = $('<a>', {
|
||||
'class': 'cp-toolbar-skip-link',
|
||||
'href': targetId,
|
||||
'tabindex': 0,
|
||||
'text': 'Skip to Main Content'
|
||||
'text': 'Skip to Main Content' // XXX
|
||||
});
|
||||
toolbar.$top.append($skipLink);
|
||||
|
||||
$skipLink.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
const $firstFocusable = $targetElement.find('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])').first();
|
||||
if ($firstFocusable.length) {
|
||||
$firstFocusable.trigger('focus');
|
||||
}
|
||||
let split = targetId.split('|'); // split for iframes
|
||||
let $container = $('body');
|
||||
split.some(selector => {
|
||||
let $targetElement = $container.find(selector);
|
||||
if ($targetElement.is('iframe')) {
|
||||
$container = $targetElement.contents();
|
||||
return;
|
||||
}
|
||||
const $firstFocusable = $targetElement.find('a, button, input, select, textarea, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]').first();
|
||||
if ($firstFocusable.length) {
|
||||
$firstFocusable.trigger('focus');
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
});
|
||||
return $skipLink;
|
||||
};
|
||||
|
||||
@ -250,6 +250,7 @@ define([
|
||||
Framework.create({
|
||||
toolbarContainer: '#cme_toolbox',
|
||||
contentContainer: '#cp-app-diagram-editor',
|
||||
skipLink: '#cp-app-diagram-content|body .geSearchSidebar',
|
||||
// validateContent: validateXml,
|
||||
}, function (framework) {
|
||||
onFrameworkReady(framework);
|
||||
|
||||
@ -1335,7 +1335,7 @@ define([
|
||||
Framework.create({
|
||||
toolbarContainer: '#cp-app-pad-toolbar',
|
||||
contentContainer: '#cp-app-pad-editor',
|
||||
skipLink: '#cke_1_contents',
|
||||
skipLink: '#cke_1_contents .cke_wysiwyg_frame|html',
|
||||
patchTransformer: ChainPad.NaiveJSONTransformer,
|
||||
/*thumbnail: {
|
||||
getContainer: function () { return $('iframe').contents().find('html')[0]; },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user