/** * @class elFinder command "help" * "About" dialog * * @author Dmitry (dio) Levashov **/ (elFinder.prototype.commands.help = function() { "use strict"; var fm = this.fm, self = this, linktpl = '', linktpltgt = '', atpl = '
{author}
{work}
', url = /\{url\}/, link = /\{link\}/, author = /\{author\}/, work = /\{work\}/, r = 'replace', prim = 'ui-priority-primary', sec = 'ui-priority-secondary', lic = 'elfinder-help-license', tab = '
  • {title}
  • ', html = ['
    ', ''); jQuery.inArray('about', parts) !== -1 && about(); jQuery.inArray('shortcuts', parts) !== -1 && shortcuts(); if (jQuery.inArray('help', parts) !== -1) { helpSource = fm.i18nBaseUrl + 'help/%s.html.js'; help(); } jQuery.inArray('integrations', parts) !== -1 && integrations(); jQuery.inArray('debug', parts) !== -1 && debug(); html.push('
    '); content = jQuery(html.join('')); content.find('.ui-tabs-nav li') .on('mouseenter mouseleave', function(e) { jQuery(this).toggleClass('ui-state-hover', e.type === 'mouseenter'); }) .on('focus blur', 'a', function(e) { jQuery(e.delegateTarget).toggleClass('ui-state-focus', e.type === 'focusin'); }) .children() .on('click', function(e) { var link = jQuery(this); e.preventDefault(); e.stopPropagation(); link.parent().addClass(clTabActive).siblings().removeClass(clTabActive); content.children('.ui-tabs-panel').hide().filter(link.attr('href')).show(); }) .filter(':first').trigger('click'); if (useInteg) { tabInteg = content.find('.elfinder-help-tab-integrations').hide(); integDIV = content.find('#'+fm.namespace+'-help-integrations').hide().append(jQuery('
    ').html(fm.i18n('integrationWith'))); fm.bind('helpIntegration', function(e) { var ul = integDIV.children('ul:first'), data, elm, cmdUL, cmdCls; if (e.data) { if (jQuery.isPlainObject(e.data)) { data = Object.assign({ link: '', title: '', banner: '' }, e.data); if (data.title || data.link) { if (!data.title) { data.title = data.link; } if (data.link) { elm = jQuery('').attr('href', data.link).attr('target', '_blank').text(data.title); } else { elm = jQuery('').text(data.title); } if (data.banner) { elm = jQuery('').append(jQuery('').attr(data.banner), elm); } } } else { elm = jQuery(e.data); elm.filter('a').each(function() { var tgt = jQuery(this); if (!tgt.attr('target')) { tgt.attr('target', '_blank');; } }); } if (elm) { tabInteg.show(); if (!ul.length) { ul = jQuery('').appendTo(integDIV); } if (data && data.cmd) { cmdCls = 'elfinder-help-integration-' + data.cmd; cmdUL = ul.find('ul.' + cmdCls); if (!cmdUL.length) { cmdUL = jQuery(''); ul.append(jQuery('
  • ').append(jQuery('').html(fm.i18n('cmd'+data.cmd))).append(cmdUL)); } elm = cmdUL.append(jQuery('
  • ').append(elm)); } else { ul.append(jQuery('
  • ').append(elm)); } } } }).bind('themechange', function() { content.find('div.elfinder-help-term-theme').replaceWith(getTheme()); }); } // debug if (useDebug) { tabDebug = content.find('.elfinder-help-tab-debug').hide(); debugDIV = content.find('#'+fm.namespace+'-help-debug').children('div:first'); debugUL = debugDIV.children('ul:first').on('click', function(e) { e.preventDefault(); e.stopPropagation(); }); self.debug = {}; fm.bind('backenddebug', function(e) { // CAUTION: DO NOT TOUCH `e.data` if (useDebug && e.data && e.data.debug) { self.debug = { options : e.data.options, debug : Object.assign({ cmd : fm.currentReqCmd }, e.data.debug) }; if (self.dialog) { debugRender(); } } }); } content.find('#'+fm.namespace+'-help-about').find('.apiver').text(fm.api); self.dialog = self.fmDialog(content, { title : self.title, width : 530, maxWidth: 'window', maxHeight: 'window', autoOpen : false, destroyOnClose : false, close : function() { if (useDebug) { tabDebug.hide(); debugDIV.tabs('destroy'); } opened = false; } }) .on('click', function(e) { e.stopPropagation(); }) .css({ overflow: 'hidden' }); tabBase = self.dialog.children('.ui-tabs'); tabNav = tabBase.children('.ui-tabs-nav:first'); tabs = tabBase.children('.ui-tabs-panel'); delta = self.dialog.outerHeight(true) - self.dialog.height(); self.dialog.closest('.ui-dialog').on('resize', function() { tabs.height(self.dialog.height() - delta - tabNav.outerHeight(true) - 20); }); if (helpSource) { self.dialog.one('initContents', function() { jQuery.ajax({ url: self.options.helpSource? self.options.helpSource : helpSource.replace('%s', fm.lang), dataType: 'html' }).done(function(source) { jQuery('#'+fm.namespace+'-help-help').html(source); }).fail(function() { jQuery.ajax({ url: helpSource.replace('%s', 'en'), dataType: 'html' }).done(function(source) { jQuery('#'+fm.namespace+'-help-help').html(source); }); }); }); } self.state = 0; fm.trigger('helpBuilded', self.dialog); }).one('open', function() { var debug = false; fm.one('backenddebug', function() { debug =true; }).one('opendone', function() { requestAnimationFrame(function() { if (! debug && useDebug) { useDebug = false; tabDebug.hide(); debugDIV.hide(); debugUL.hide(); } }); }); }); this.getstate = function() { return 0; }; this.exec = function(sel, opts) { var tab = opts? opts.tab : void(0), debugShow = function() { if (useDebug) { debugDIV.tabs(); debugUL.find('a:first').trigger('click'); tabDebug.show(); opened = true; } }; debugShow(); this.dialog.trigger('initContents').elfinderdialog('open').find((tab? '.elfinder-help-tab-'+tab : '.ui-tabs-nav li') + ' a:first').trigger('click'); return jQuery.Deferred().resolve(); }; }).prototype = { forceLoad : true }; // this is required command