Skip to content

Commit 3f01429

Browse files
committed
Releasing 0.9.19
2 parents 22482d9 + 73dd2b6 commit 3f01429

File tree

8 files changed

+104
-43
lines changed

8 files changed

+104
-43
lines changed

css/bootstrap.css

+19
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,22 @@ input.plain-checkbox {
133133
.divider:not(:empty)::after {
134134
margin-left: .5em;
135135
}
136+
137+
.dropdown-button {
138+
padding: .25rem 1.5rem !important;
139+
}
140+
141+
.dropdown-button .btn {
142+
width: 100%;
143+
}
144+
145+
.dropdown-item.nav-link {
146+
padding: .25rem 1.5rem !important;
147+
}
148+
149+
.navbar-dark .dropdown-item.nav-link:hover,
150+
.navbar-dark .dropdown-item.nav-link:active,
151+
.navbar-dark .dropdown-item.nav-link:focus {
152+
color: #333333 !important;
153+
background-color: #f8f9fa !important;
154+
}

js/webapp.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@ WebApp.prototype.DELETE = function(url, ajaxController) {
120120

121121
WebApp.prototype.showSpinner = function(label) {
122122
if (typeof label === undefined) label = this.i18n('pleaseWait');
123-
jQuery('<div id="page-blocker" class="modal" tabindex="-1"><div class="vertical-center"><div class="spinner-border" role="status"><span class="sr-only">'+label+'</span></div></div></div><div class="modal-backdrop show"></div>').appendTo('body');
123+
jQuery('<div id="page-blocker" class="modal" tabindex="-1"><div class="vertical-center"><div class="spinner-border" role="status"><span class="sr-only">'+label+'</span></div></div></div><div id="page-blocker-backdrop" class="modal-backdrop show"></div>').appendTo('body');
124124
jQuery('#page-blocker').show();
125125
};
126126

127127
WebApp.prototype.hideSpinner = function() {
128128
jQuery('#page-blocker').remove();
129+
jQuery('#page-blocker-backdrop').remove();
129130
};
130131

131132
// Register an I18N object for translations
@@ -168,6 +169,20 @@ WebAppAjaxController.prototype.fail = function(ajaxParams, jqXHR, textStatus, er
168169
webApp.hideSpinner();
169170
};
170171

172+
/** A NULL version of a DomAjaxController
173+
****************************************************************************************/
174+
function WebAppNullAjaxController() {
175+
}
176+
177+
WebAppNullAjaxController.prototype.beforeSend = function() {
178+
};
179+
180+
WebAppNullAjaxController.prototype.done = function(ajaxParams, data, textStatus, jqXHR) {
181+
};
182+
183+
WebAppNullAjaxController.prototype.fail = function(ajaxParams, jqXHR, textStatus, errorThrown) {
184+
};
185+
171186
/***************** Modals ************************/
172187
function WebAppModal(id) {
173188
this.id = id;

src/WebApp/BootstrapTheme/DefaultLayout.php

+22-35
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@ public function __construct($theme, $page) {
1818
protected function renderLinks() {
1919
$webroot = $this->app->request->webRoot;
2020
$rc = '<link rel="stylesheet" href="'.$webroot.FontAwesome::getUri().'" rel="stylesheet" type="text/css">'.
21-
'<link rel="stylesheet" href="'.$webroot.Bootstrap::getCssUri().'" rel="stylesheet" type="text/css">'.
22-
'<style>'.
23-
'.dropdown-item.nav-link {'.
24-
'padding: .25rem 1.5rem !important;'.
25-
'}'.
26-
'.navbar-dark .dropdown-item.nav-link:hover,'.
27-
'.navbar-dark .dropdown-item.nav-link:active,'.
28-
'.navbar-dark .dropdown-item.nav-link:focus {'.
29-
'color: #333333 !important;'.
30-
'background-color: #f8f9fa !important;'.
31-
'}'.
32-
'</style>';
21+
'<link rel="stylesheet" href="'.$webroot.Bootstrap::getCssUri().'" rel="stylesheet" type="text/css">';
3322
if ($this->theme->hasFeature(BootstrapTheme::DATEPICKER)) {
3423
$rc .= '<link rel="stylesheet" href="'.Utils::getCssBasePath(TRUE).'/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css">';
3524
}
@@ -109,38 +98,36 @@ protected function renderNavbarContent() {
10998
}
11099
}
111100
$rc .= '</ul>';
112-
$principal = $this->app->getPrincipal();
113-
if ($principal != NULL) {
114-
$rc .= '<ul class="navbar-nav user-menu">';
115-
$userMenu = $this->app->getMenu('user');
116-
if ($userMenu == NULL) {
117-
$userMenu = array();
101+
102+
$userMenu = $this->app->getMenu('user');
103+
if ($userMenu == NULL) {
104+
$userMenu = array();
105+
$principal = $this->app->getPrincipal();
106+
if ($principal != NULL) {
118107
$userItem = new \WebApp\Component\MenuItem($this, $principal->__toString(), '#');
119108
$logoutLink = $this->app->getPageLink('logout');
120109
if ($logoutLink != NULL) $logoutLink = $this->app->router->getCanonicalPath($logoutLink);
121110
else $logoutLink = '';
122111
$userMenu[] = new \WebApp\Component\MenuItem($userItem, 'logout_label', $logoutLink.'?logout');
123112
$userMenu = array($userItem);
124-
}
125-
if (($userMenu != NULL) && is_array($userMenu)) {
126-
//$userMenu[] = new \WebApp\Component\MenuItem($this, 'logout_label', '?logout');
127-
foreach ($userMenu AS $menuItem) {
128-
$rc .= $this->theme->renderComponent($menuItem);
113+
} else if ($this->app->getPageLink('login') != NULL) {
114+
$uri = $this->app->request->uri;
115+
$login = $this->app->router->getCanonicalPath($this->app->getPageLink('login'));
116+
if ($this->app->request->originalPath == $login) {
117+
$uri = $this->app->request->originalPath;
118+
} else {
119+
$uri = $login.'?return='.urlencode($this->app->request->originalPath);
129120
}
130-
131-
}
132-
//$rc .= '<span class="navbar-text align-middle">'.$principal->__toString().'<a class="px-2" href="?logout"><i class="fas fa-sign-out-alt fa-lg"></i></a></span>';
133-
$rc .= '</ul>';
134-
} else if ($this->app->getPageLink('login') != NULL) {
135-
$uri = $this->app->request->uri;
136-
$login = $this->app->router->getCanonicalPath($this->app->getPageLink('login'));
137-
if ($this->app->request->originalPath == $login) {
138-
$uri = $this->app->request->originalPath;
139-
} else {
140-
$uri = $login.'?return='.urlencode($this->app->request->originalPath);
121+
$userMenu[] = '<span class="navbar-text align-middle"><a class="px-2" href="'.$uri.'">'.I18N::_('login_label').'</a></span>';
141122
}
142-
$rc .= '<span class="navbar-text align-middle"><a class="px-2" href="'.$uri.'">'.I18N::_('login_label').'</a></span>';
123+
}
124+
125+
if ($userMenu != NULL) {
126+
$rc .= '<ul class="navbar-nav user-menu">';
127+
$rc .= $this->theme->renderComponent($userMenu);
128+
$rc .= '</ul>';
143129
}
130+
144131
$rc .= '</nav>';
145132
return $rc;
146133
}

src/WebApp/BootstrapTheme/MenuItemRenderer.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,24 @@ public function render() {
1919
$rc .= '<a class="nav-link dropdown-toggle" href="'.$link.'" id="dropDown-'.$this->component->getId().'"'.$target.' role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'.$this->component->getLabel().'</a>'.
2020
'<div class="dropdown-menu bg-dark" aria-labelledby=""dropDown-'.$this->component->getId().'">';
2121
foreach ($this->component->getChildren() AS $child) {
22-
$childLink = $this->createLink($child);
23-
$target = $child->getLinkTarget() != NULL ? ' target="'.$child->getLinkTarget().'"' : '';
24-
$rc .= '<a class="dropdown-item nav-link" href="'.$childLink.'"'.$target.'>'.$child->getLabel().'</a>';
22+
switch(get_class($child)) {
23+
case 'WebApp\Component\MenuItem':
24+
$childLink = $this->createLink($child);
25+
$target = $child->getLinkTarget() != NULL ? ' target="'.$child->getLinkTarget().'"' : '';
26+
$rc .= '<a class="dropdown-item nav-link" href="'.$childLink.'"'.$target.'>'.$child->getLabel().'</a>';
27+
break;
28+
case 'WebApp\Component\MenuButton':
29+
$childLink = $this->createLink($child);
30+
$target = $child->getLinkTarget() != NULL ? ' target="'.$child->getLinkTarget().'"' : '';
31+
$rc .= '<div class="dropdown-button"><a class="btn btn-light" href="'.$childLink.'"'.$target.'>'.$child->getLabel().'</a></div>';
32+
break;
33+
case 'WebApp\Component\Divider':
34+
$rc .= '<div class="dropdown-divider"></div>';
35+
break;
36+
default:
37+
$rc .= $this->theme->renderComponent($child);
38+
break;
39+
}
2540
}
2641
$rc .= '</div>';
2742
} else {
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
/** Component that has a special method that will be called immediately before rendering */
6+
interface LazyInitializer {
7+
8+
public function lazyInit();
9+
}

src/WebApp/Component/MenuButton.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
use \TgI18n\I18N;
6+
7+
class MenuButton extends MenuItem {
8+
9+
public function __construct($parent, $label, $pageLink, $icon = NULL) {
10+
parent::__construct($parent, $label, $pageLink, $icon);
11+
$this->addClass('btn');
12+
}
13+
}

src/WebApp/Theme.php

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public function renderComponent($component) {
107107
}
108108
return $rc;
109109
} else if (is_object($component)) {
110+
if (is_a($component, 'WebApp\\Component\\LazyInitializer')) {
111+
$component->lazyInit();
112+
}
110113
return $this->getRenderer($component)->render();
111114
}
112115
return '';

src/i18n.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
'en' => 'This is the default text of the web-framework modules.',
1111
),
1212
'login_label' => array(
13-
'de' => '<i class="fas fa-sign-in-alt fa-lg"></i> Anmelden',
14-
'en' => '<i class="fas fa-sign-in-alt fa-lg"></i> Login',
13+
'de' => 'Anmelden',
14+
'en' => 'Login',
1515
),
1616
'logout_label' => array(
17-
'de' => '<i class="fas fa-sign-out-alt fa-lg"></i> Abmelden',
18-
'en' => '<i class="fas fa-sign-out-alt fa-lg"></i> Logout',
17+
'de' => 'Abmelden',
18+
'en' => 'Logout',
1919
),
2020
'login_title' => array(
2121
'de' => 'Anmelden',

0 commit comments

Comments
 (0)