-
Notifications
You must be signed in to change notification settings - Fork 638
/
ContextHelp.js
13 lines (13 loc) · 2.88 KB
/
ContextHelp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports","jquery","./Popover","bootstrap"],function(a,b,c,d){"use strict";var e=function(){function a(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".t3-help-link",this.initialize()}return a.resolveBackend=function(){return"undefined"!=typeof window.opener&&null!==window.opener?window.opener.top:top},a.prototype.initialize=function(){var b=this,e=a.resolveBackend();"undefined"!=typeof e.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=e.TYPO3.settings.ContextHelp.moduleUrl),"undefined"==typeof TYPO3.ShortcutMenu&&"undefined"==typeof e.TYPO3.ShortcutMenu&&c(".icon-actions-system-shortcut-new").closest(".btn").hide();var f=" ";"undefined"!=typeof e.TYPO3.lang&&(f=e.TYPO3.lang.csh_tooltip_loading);var g=c(this.selector);g.attr("data-loaded","false").attr("data-html","true").attr("data-original-title",f).attr("data-placement",this.placement).attr("data-trigger",this.trigger),d.popover(g),c(document).on("show.bs.popover",this.selector,function(a){var e=c(a.currentTarget),f=e.data("description");"undefined"!=typeof f&&""!==f?d.setOptions(e,{title:e.data("title"),content:f}):"false"===e.attr("data-loaded")&&e.data("table")&&b.loadHelp(e),e.closest(".t3js-module-docheader").length&&d.setOption(e,"placement","bottom")}).on("shown.bs.popover",this.selector,function(a){var b=c(a.target).data("bs.popover").$tip;b.find(".popover-title").is(":visible")||b.addClass("no-title")}).on("click",".tipIsLinked",function(a){c(".popover").each(function(d,e){var f=c(e);f.has(a.target).length&&(console.log(f.data("bs.popover")),b.showHelpPopup(f.data("bs.popover").$element))})}).on("click","body",function(a){c(b.selector).each(function(b,e){var f=c(e);f.is(a.target)||0!==f.has(a.target).length||0!==c(".popover").has(a.target).length||d.hide(f)})})},a.prototype.showHelpPopup=function(a){try{var b=window.open(this.helpModuleUrl+"&tx_documentation_help_documentationcshmanual[table]="+a.data("table")+"&tx_documentation_help_documentationcshmanual[field]="+a.data("field"),"ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return b.focus(),d.hide(a),b}catch(a){}},a.prototype.loadHelp=function(a){var b=a.data("table"),e=a.data("field");b&&c.getJSON(this.ajaxUrl,{params:{action:"getContextHelp",table:b,field:e}}).done(function(b){var c=b.title||"",e=b.content||"<p></p>";d.setOptions(a,{title:c,content:e}),a.attr("data-loaded","true").one("hidden.bs.popover",function(){d.show(a)}),d.hide(a)})},a}();return new e});