Refactored Help plugin to use frames, added Elastic skin support

pull/6040/head
Aleksander Machniak 7 years ago
parent ebfc8448aa
commit 13d203303e

@ -1,4 +1,3 @@
<div id="helplicense" class="readtext">
<h2 style="text-align: center;">GNU GENERAL PUBLIC LICENSE</h2>
<p style="text-align: center;">Version 3, 29 June 2007</p>
@ -685,5 +684,3 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
&lt;<a href="http://www.gnu.org/philosophy/why-not-lgpl.html">http://www.gnu.org/philosophy/why-not-lgpl.html</a>&gt;.</p>
</div>

@ -33,6 +33,55 @@ if (window.rcmail) {
}
return false;
}
});
}
});
rcmail.addEventListener('init', function(prop) {
if (rcmail.env.contentframe && rcmail.task == 'help') {
$('#' + rcmail.env.contentframe).on('load error', function(e) {
// Unlock UI
rcmail.set_busy(false, null, rcmail.env.frame_lock);
rcmail.env.frame_lock = null;
// Select menu item
if (e.type == 'load') {
$(rcmail.env.help_action_item).parents('ul').children().removeClass('selected');
$(rcmail.env.help_action_item).parent().addClass('selected');
}
});
try {
var win = rcmail.get_frame_window(rcmail.env.contentframe);
if (win && win.location.href.indexOf(rcmail.env.blankpage) >= 0) {
show_help_content(rcmail.env.action);
}
}
catch (e) { /* ignore */}
}
});
}
function show_help_content(action, event)
{
var win, target = window,
url = rcmail.env.help_links[action];
if (win = rcmail.get_frame_window(rcmail.env.contentframe)) {
target = win;
url += (url.indexOf('?') > -1 ? '&' : '?') + '_framed=1';
}
if (rcmail.env.extwin) {
url += (url.indexOf('?') > -1 ? '&' : '?') + '_extwin=1';
}
if (/^self/.test(url)) {
url = url.substr(4) + '&_content=1&_task=help&_action=' + action;
}
rcmail.env.help_action_item = event ? event.target : $('[rel="' + action + '"]');
rcmail.show_contentframe(true);
rcmail.location_href(url, target, true);
return false;
}

@ -17,8 +17,6 @@ class help extends rcube_plugin
public $task = '?(?!login|logout).*';
// we've got no ajax handlers
public $noajax = true;
// skip frames
public $noframe = true;
function init()
{
@ -41,18 +39,20 @@ class help extends rcube_plugin
{
$rcmail = rcmail::get_instance();
// add taskbar button
$this->add_button(array(
'command' => 'help',
'class' => 'button-help',
'classsel' => 'button-help button-selected',
'innerclass' => 'button-inner',
'label' => 'help.help',
'type' => 'link',
), 'taskbar');
$this->include_script('help.js');
$rcmail->output->set_env('help_open_extwin', $rcmail->config->get('help_open_extwin', false), true);
if (!$rcmail->output->framed) {
// add taskbar button
$this->add_button(array(
'command' => 'help',
'class' => 'button-help',
'classsel' => 'button-help button-selected',
'innerclass' => 'button-inner',
'label' => 'help.help',
'type' => 'link',
), 'taskbar');
$this->include_script('help.js');
$rcmail->output->set_env('help_open_extwin', $rcmail->config->get('help_open_extwin', false), true);
}
// add style for taskbar button (must be here) and Help UI
$skin_path = $this->local_skin_path();
@ -65,20 +65,39 @@ class help extends rcube_plugin
{
$rcmail = rcmail::get_instance();
if ($rcmail->action == 'about') {
$rcmail->output->set_pagetitle($this->gettext('about'));
}
else if ($rcmail->action == 'license') {
$rcmail->output->set_pagetitle($this->gettext('license'));
}
else {
$rcmail->output->set_pagetitle($this->gettext('help'));
}
// register UI objects
$rcmail->output->add_handlers(array(
'helpcontent' => array($this, 'content'),
'tablink' => array($this, 'tablink'),
'contentframe' => array($this, 'content_frame'),
'helpcontent' => array($this, 'help_content'),
'tablink' => array($this, 'tablink'),
));
if ($rcmail->action == 'about')
$rcmail->output->set_pagetitle($this->gettext('about'));
else if ($rcmail->action == 'license')
$rcmail->output->set_pagetitle($this->gettext('license'));
else
$rcmail->output->set_pagetitle($this->gettext('help'));
$rcmail->output->send(!empty($_GET['_content']) ? 'help.content' : 'help.help');
}
$rcmail->output->send('help.help');
function help_content($attrib)
{
$rcmail = rcmail::get_instance();
// $rcmail->output->set_env('content', $content);
if (!empty($_GET['_content'])) {
if ($rcmail->action == 'about') {
return file_get_contents($this->home . '/content/about.html');
}
else if ($rcmail->action == 'license') {
return file_get_contents($this->home . '/content/license.html');
}
}
}
function tablink($attrib)
@ -87,59 +106,69 @@ class help extends rcube_plugin
$attrib['name'] = 'helplink' . $attrib['action'];
$attrib['href'] = $rcmail->url(array('_action' => $attrib['action'], '_extwin' => !empty($_REQUEST['_extwin']) ? 1 : null));
$attrib['rel'] = $attrib['action'];
// title might be already translated here, so revert to it's initial value
// so button() will translate it correctly
$attrib['title'] = $attrib['label'];
$attrib['onclick'] = sprintf("return show_help_content('%s', event)", $attrib['action']);
return $rcmail->output->button($attrib);
}
function content($attrib)
function content_frame($attrib)
{
$rcmail = rcmail::get_instance();
$rcmail = rcmail::get_instance();
$content = $this->help_metadata();
$src = $content[$rcmail->action] ?: $content['index'];
switch ($rcmail->action) {
case 'about':
if (is_readable($this->home . '/content/about.html')) {
return @file_get_contents($this->home . '/content/about.html');
}
$default = $rcmail->url(array('_task' => 'settings', '_action' => 'about', '_framed' => 1));
$src = $rcmail->config->get('help_about_url', $default);
break;
case 'license':
if (is_readable($this->home . '/content/license.html')) {
return @file_get_contents($this->home . '/content/license.html');
}
$src = $rcmail->config->get('help_license_url', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html');
break;
default:
$src = $rcmail->config->get('help_source');
// resolve task/action for depp linking
$index_map = $rcmail->config->get('help_index_map', array());
$rel = $_REQUEST['_rel'];
list($task,$action) = explode('/', $rel);
if ($add = $index_map[$rel])
$src .= $add;
else if ($add = $index_map[$task])
$src .= $add;
break;
$rcmail->output->set_env('help_links', $content);
return $rcmail->output->frame($attrib, true);
}
function help_metadata()
{
$rcmail = rcmail::get_instance();
$content = array();
// About
if (is_readable($this->home . '/content/about.html')) {
$content['about'] = 'self';
}
else {
$default = $rcmail->url(array('_task' => 'settings', '_action' => 'about', '_framed' => 1));
$content['about'] = $rcmail->config->get('help_about_url', $default);
$content['about'] = $this->resolve_language($content['about']);
}
// default content: iframe
if (!empty($src)) {
$attrib['src'] = $this->resolve_language($src);
// License
if (is_readable($this->home . '/content/license.html')) {
$content['license'] = 'self';
}
else {
$content['license'] = $rcmail->config->get('help_license_url', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html');
$content['license'] = $this->resolve_language($content['license']);
}
if (empty($attrib['id']))
$attrib['id'] = 'rcmailhelpcontent';
// Help Index
$src = $rcmail->config->get('help_source', 'http://docs.roundcube.net/doc/help/1.1/%l/');
$index_map = $rcmail->config->get('help_index_map', array());
// resolve task/action for deep linking
$rel = $_REQUEST['_rel'];
list($task, $action) = explode('/', $rel);
if ($add = $index_map[$rel]) {
$src .= $add;
}
else if ($add = $index_map[$task]) {
$src .= $add;
}
$attrib['name'] = $attrib['id'];
$content['index'] = $this->resolve_language($src);
return $rcmail->output->frame($attrib);
return $content;
}
function error_page($args)

@ -0,0 +1,15 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
<script type="text/javascript" src="/functions.js"></script>
</head>
<body class="iframe" style="margin-top:0">
<div id="help-<roundcube:var name="env:action" />" class="boxcontent">
<roundcube:object name="helpcontent" />
</div>
</body>
</html>

@ -12,6 +12,13 @@ function help_init_settings_tabs()
tab = '#helptab' + (action ? action : 'index');
}
$(tab).addClass('tablink-selected');
$('#' + rcmail.env.contentframe).on('load error', function(e) {
if (e.type == 'load') {
$(rcmail.env.help_action_item).parents('#tabsbar').children().removeClass('tablink-selected');
$(rcmail.env.help_action_item).parent().addClass('tablink-selected');
}
});
}
</script>
</head>
@ -34,7 +41,7 @@ function help_init_settings_tabs()
</div>
<div id="mainscreen" class="box help-box">
<roundcube:object name="helpcontent" id="helpcontentframe" width="100%" height="100%" frameborder="0" src="/watermark.html" />
<roundcube:object name="contentframe" id="helpcontentframe" width="100%" height="100%" frameborder="0" src="/watermark.html" />
</div>
</body>

@ -0,0 +1,9 @@
<roundcube:include file="includes/layout.html" />
<h1 class="voice"><roundcube:object name="steptitle" /></h1>
<div id="help-<roundcube:var name="env:action" />" class="content frame-content">
<roundcube:object name="helpcontent" />
</div>
<roundcube:include file="includes/footer.html" />

@ -0,0 +1,29 @@
<roundcube:include file="includes/layout.html" />
<roundcube:include file="includes/menu.html" />
<div id="sidebar" class="sidebar listbox" role="navigation" aria-labelledby="aria-label-helpnav">
<div class="header">
<a class="button icon menu-button" href="#menu"><span class="inner"><roundcube:label name="menu" /></span></a>
<span id="aria-label-helpnav" class="header-title"><roundcube:label name="help.help" /></span>
</div>
<div class="scroller">
<ul class="listing iconized" data-menu="toolbar-small">
<roundcube:object name="tablink" action="index" type="link-menuitem" label="help.help" class="help" />
<roundcube:object name="tablink" action="about" type="link-menuitem" label="help.about" class="about" />
<roundcube:object name="tablink" action="license" type="link-menuitem" label="help.license" class="license" />
<roundcube:container name="helptabs" id="helptabsbar" />
</ul>
</div>
</div>
<h1 class="voice"><roundcube:label name="help.help" /></h1>
<div id="content" class="content selected" role="main">
<div class="header">
<a class="button icon menu-button" href="#menu"><span class="inner"><roundcube:label name="menu" /></span></a>
<span class="header-title"><roundcube:label name="help.help" /></span>
</div>
<roundcube:object name="contentframe" id="helpcontentframe" src="/watermark.html" title="arialabelhelpcontent" />
</div>
<roundcube:include file="includes/footer.html" />

@ -38,7 +38,3 @@
.toolbar a.button.license {
background: url(help.png) center -130px no-repeat;
}
.iframebox.help_license {
overflow: auto;
}

@ -0,0 +1,16 @@
<roundcube:object name="doctype" value="html5" />
<html>
<head>
<title><roundcube:object name="pagetitle" /></title>
<roundcube:include file="/includes/links.html" />
</head>
<body class="iframe fullheight">
<div id="help-<roundcube:var name="env:action" />" class="boxcontent">
<roundcube:object name="helpcontent" />
</div>
<roundcube:include file="/includes/footer.html" />
</body>
</html>

@ -19,7 +19,7 @@
<div id="pluginbody" class="uibox offset">
<div class="iframebox help_<roundcube:var name='env:action' />">
<roundcube:object name="helpcontent" id="helpcontentframe" style="width:100%; height:100%" frameborder="0" src="/watermark.html" />
<roundcube:object name="contentframe" id="helpcontentframe" style="width:100%; height:100%" frameborder="0" src="/watermark.html" />
</div>
</div>

@ -1203,7 +1203,7 @@ EOF;
$content = html::quote($ver);
}
else if ($object == 'steptitle') {
$content = html::quote($this->get_pagetitle());
$content = html::quote($this->get_pagetitle());
}
else if ($object == 'pagetitle') {
if ($this->devel_mode && !empty($_SESSION['username']))
@ -1475,7 +1475,7 @@ EOF;
}
else if ($attrib['type'] == 'link') {
$btn_content = isset($attrib['content']) ? $attrib['content'] : ($attrib['label'] ? $attrib['label'] : $attrib['command']);
$link_attrib = array_merge(html::$common_attrib, array('href', 'onclick', 'tabindex', 'target'));
$link_attrib = array_merge(html::$common_attrib, array('href', 'onclick', 'tabindex', 'target', 'rel'));
if ($attrib['innerclass'])
$btn_content = html::span($attrib['innerclass'], $btn_content);
}

@ -113,7 +113,7 @@ function rcube_webmail()
this.buttons[command].push(button_prop);
if (this.loaded)
init_button(command, button_prop);
this.init_button(command, button_prop);
};
// register a specific gui object
@ -7384,7 +7384,7 @@ function rcube_webmail()
/********* GUI functionality *********/
/*********************************************************/
var init_button = function(cmd, prop)
this.init_button = function(cmd, prop)
{
var elm = document.getElementById(prop.id);
if (!elm)
@ -7420,7 +7420,7 @@ function rcube_webmail()
continue;
for (var i=0; i<this.buttons[cmd].length; i++) {
init_button(cmd, this.buttons[cmd][i]);
this.init_button(cmd, this.buttons[cmd][i]);
}
}
};

Loading…
Cancel
Save