Commit 0b0fac11 authored by Nikita Hovratov's avatar Nikita Hovratov Committed by Andreas Fernandez
Browse files

[BUGFIX] Fix csh popover position

This fixes the popover position after clicking on a csh link.

Side note:
The popover loads in two steps: First it shows a "loading ..." text and
when the content is fetched the popover must be updated. Before it was
achieved by hiding and then immediately showing the popover again. This
doesn't quite work with bootstrap v5 anymore. The popover is stuck in
the middle of the process before the positioning applies.

New method: Use the "setContent" method of the bootstrap popover
instance. This method is not documented, but it can be used.
Nevertheless we should keep an eye on that, as it's not public API.

Resolves: #93984
Resolves: #93152
Releases: master
Change-Id: If96028bd70bead243af1937cd2f87afed3b61c5f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68962

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Riccardo De Contardi's avatarRiccardo De Contardi <erredeco@gmail.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 87547281
......@@ -163,12 +163,7 @@ class ContextHelp {
content: content,
};
Popover.setOptions($trigger, options);
$trigger
.attr('data-loaded', 'true')
.one('hidden.bs.popover', (): void => {
Popover.show($trigger);
});
Popover.hide($trigger);
$trigger.attr('data-loaded', 'true');
});
}
}
......
......@@ -88,6 +88,7 @@ class Popover {
public setOption($element: JQuery, key: string, value: string): void {
if (key === 'content') {
$element.attr('data-bs-content', value);
$element.data('typo3.bs.popover').setContent(value);
} else {
$element.each((i, el) => {
const popover = $(el).data('typo3.bs.popover');
......
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","./Popover","bootstrap"],(function(t,e,a,o,l){"use strict";a=__importDefault(a);class s{constructor(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".help-link",this.initialize()}static resolveBackend(){return void 0!==window.opener&&null!==window.opener?window.opener.top:top}initialize(){const t=s.resolveBackend();void 0!==t.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=t.TYPO3.settings.ContextHelp.moduleUrl),void 0===TYPO3.ShortcutMenu&&void 0===t.TYPO3.ShortcutMenu&&a.default(".icon-actions-system-shortcut-new").closest(".btn").hide();let e="&nbsp;";void 0!==t.TYPO3.lang&&(e=t.TYPO3.lang.csh_tooltip_loading);const o=a.default(this.selector);o.attr("data-loaded","false").attr("data-bs-html","true").attr("data-bs-original-title",e).attr("data-bs-placement",this.placement).attr("data-bs-trigger",this.trigger),l.popover(o),a.default(document).on("show.bs.popover",this.selector,t=>{const e=a.default(t.currentTarget),o=e.data("description");if(void 0!==o&&""!==o){const t={title:e.data("title")||"",content:o};l.setOptions(e,t)}else"false"===e.attr("data-loaded")&&e.data("table")&&this.loadHelp(e);e.closest(".t3js-module-docheader").length&&l.setOption(e,"placement","bottom")}).on("click",".help-has-link",t=>{a.default(".popover").each((e,o)=>{const l=a.default(o);l.has(t.target).length&&this.showHelpPopup(a.default('[aria-describedby="'+l.attr("id")+'"]'))})}).on("click","body",t=>{a.default(this.selector).each((e,o)=>{const s=a.default(o);s.is(t.target)||0!==s.has(t.target).length||0!==a.default(".popover").has(t.target).length||l.hide(s)})})}showHelpPopup(t){try{const e=window.open(this.helpModuleUrl+"&table="+t.data("table")+"&field="+t.data("field")+"&action=detail","ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return e.focus(),l.hide(t),e}catch(t){}}loadHelp(t){const e=t.data("table"),a=t.data("field");e&&new o(this.ajaxUrl).withQueryArguments({params:{action:"getContextHelp",table:e,field:a}}).get().then(async e=>{const a=await e.resolve(),o={title:a.title||"",content:a.content||"<p></p>"};l.setOptions(t,o),t.attr("data-loaded","true").one("hidden.bs.popover",()=>{l.show(t)}),l.hide(t)})}}return new s}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","TYPO3/CMS/Core/Ajax/AjaxRequest","./Popover","bootstrap"],(function(t,e,a,o,l){"use strict";a=__importDefault(a);class s{constructor(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".help-link",this.initialize()}static resolveBackend(){return void 0!==window.opener&&null!==window.opener?window.opener.top:top}initialize(){const t=s.resolveBackend();void 0!==t.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=t.TYPO3.settings.ContextHelp.moduleUrl),void 0===TYPO3.ShortcutMenu&&void 0===t.TYPO3.ShortcutMenu&&a.default(".icon-actions-system-shortcut-new").closest(".btn").hide();let e="&nbsp;";void 0!==t.TYPO3.lang&&(e=t.TYPO3.lang.csh_tooltip_loading);const o=a.default(this.selector);o.attr("data-loaded","false").attr("data-bs-html","true").attr("data-bs-original-title",e).attr("data-bs-placement",this.placement).attr("data-bs-trigger",this.trigger),l.popover(o),a.default(document).on("show.bs.popover",this.selector,t=>{const e=a.default(t.currentTarget),o=e.data("description");if(void 0!==o&&""!==o){const t={title:e.data("title")||"",content:o};l.setOptions(e,t)}else"false"===e.attr("data-loaded")&&e.data("table")&&this.loadHelp(e);e.closest(".t3js-module-docheader").length&&l.setOption(e,"placement","bottom")}).on("click",".help-has-link",t=>{a.default(".popover").each((e,o)=>{const l=a.default(o);l.has(t.target).length&&this.showHelpPopup(a.default('[aria-describedby="'+l.attr("id")+'"]'))})}).on("click","body",t=>{a.default(this.selector).each((e,o)=>{const s=a.default(o);s.is(t.target)||0!==s.has(t.target).length||0!==a.default(".popover").has(t.target).length||l.hide(s)})})}showHelpPopup(t){try{const e=window.open(this.helpModuleUrl+"&table="+t.data("table")+"&field="+t.data("field")+"&action=detail","ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return e.focus(),l.hide(t),e}catch(t){}}loadHelp(t){const e=t.data("table"),a=t.data("field");e&&new o(this.ajaxUrl).withQueryArguments({params:{action:"getContextHelp",table:e,field:a}}).get().then(async e=>{const a=await e.resolve(),o={title:a.title||"",content:a.content||"<p></p>"};l.setOptions(t,o),t.attr("data-loaded","true")})}}return new s}));
\ No newline at end of file
......@@ -10,4 +10,4 @@
*
* The TYPO3 project - inspiring people to share!
*/
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","bootstrap"],(function(t,e,o,a){"use strict";o=__importDefault(o);return new class{constructor(){this.DEFAULT_SELECTOR='[data-bs-toggle="popover"]',this.initialize()}initialize(t){t=t||this.DEFAULT_SELECTOR,o.default(t).each((t,e)=>{const s=new a.Popover(e);o.default(e).data("typo3.bs.popover",s)})}popover(t){t.each((t,e)=>{const s=new a.Popover(e);o.default(e).data("typo3.bs.popover",s)})}setOptions(t,e){const a=(e=e||{}).title||t.data("title")||"",s=e.content||t.data("bs-content")||"";t.attr("data-bs-original-title",a).attr("data-bs-content",s).attr("data-bs-placement","auto"),o.default.each(e,(e,o)=>{this.setOption(t,e,o)})}setOption(t,e,a){"content"===e?t.attr("data-bs-content",a):t.each((t,s)=>{const n=o.default(s).data("typo3.bs.popover");n&&(n.config[e]=a)})}show(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.show()})}hide(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.hide()})}destroy(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.dispose()})}toggle(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.toggle()})}}}));
\ No newline at end of file
var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};define(["require","exports","jquery","bootstrap"],(function(t,e,o,a){"use strict";o=__importDefault(o);return new class{constructor(){this.DEFAULT_SELECTOR='[data-bs-toggle="popover"]',this.initialize()}initialize(t){t=t||this.DEFAULT_SELECTOR,o.default(t).each((t,e)=>{const s=new a.Popover(e);o.default(e).data("typo3.bs.popover",s)})}popover(t){t.each((t,e)=>{const s=new a.Popover(e);o.default(e).data("typo3.bs.popover",s)})}setOptions(t,e){const a=(e=e||{}).title||t.data("title")||"",s=e.content||t.data("bs-content")||"";t.attr("data-bs-original-title",a).attr("data-bs-content",s).attr("data-bs-placement","auto"),o.default.each(e,(e,o)=>{this.setOption(t,e,o)})}setOption(t,e,a){"content"===e?(t.attr("data-bs-content",a),t.data("typo3.bs.popover").setContent(a)):t.each((t,s)=>{const p=o.default(s).data("typo3.bs.popover");p&&(p.config[e]=a)})}show(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.show()})}hide(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.hide()})}destroy(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.dispose()})}toggle(t){t.each((t,e)=>{const a=o.default(e).data("typo3.bs.popover");a&&a.toggle()})}}}));
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment