Skip to content

Commit 22482d9

Browse files
committed
Releasing 0.9.15
2 parents 7b9355f + fc603a8 commit 22482d9

File tree

13 files changed

+153
-16
lines changed

13 files changed

+153
-16
lines changed

css/bootstrap.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,23 @@ input.plain-checkbox {
113113
margin-right: 0.5em;
114114
}
115115

116+
.divider {
117+
display: flex;
118+
align-items: center;
119+
text-align: center;
120+
}
121+
122+
.divider::before,
123+
.divider::after {
124+
content: '';
125+
flex: 1;
126+
border-bottom: 1px solid #ccc;
127+
}
128+
129+
.divider:not(:empty)::before {
130+
margin-right: .5em;
131+
}
132+
133+
.divider:not(:empty)::after {
134+
margin-left: .5em;
135+
}

src/WebApp/BootstrapTheme/DefaultLayout.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function renderLinks() {
5454
}
5555

5656
protected function renderBody() {
57-
$rc = '<body>'.
57+
$rc = '<body lang="'.$this->app->request->language.'">'.
5858
'<div class="full-page">'.
5959
$this->renderNavbar().
6060
$this->renderContent().
@@ -199,7 +199,7 @@ protected function renderJavascript() {
199199
'<script>jQuery(document).ready(function () { $(\'.datepicker\').datepicker({ format: \''.I18N::_('datepicker_format').'\'}) })</script>';
200200
}
201201
if ($this->theme->hasFeature(BootstrapTheme::TABS)) {
202-
$rc .= '<script type="text/javascript">jQuery(document).on(\'click\', \'ul.nav-tabs a\', function(e) { e.preventDefault(); jQuery(this).tab(\'show\');});</script>';
202+
$rc .= '<script type="text/javascript">jQuery(document).on(\'click\', \'ul.nav-tabs a\', function(e) { e.preventDefault(); jQuery(this).tab(\'show\').parent().addClass(\'active\'); jQuery(this).parent().siblings().removeClass(\'active\');});</script>';
203203
}
204204
if ($this->theme->hasFeature(BootstrapTheme::REMOTESEARCH)) {
205205
$rc .= '<script src="'.Utils::getJavascriptBasePath(TRUE).'/remote-search.js"></script>';

src/WebApp/BootstrapTheme/HorizontalFormRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public function render() {
4444
public function renderFieldSets() {
4545
// Construct the components
4646
$tabSet = new \WebApp\Component\TabSet(NULL, $this->component->getId().'fieldsets');
47+
$tabSet->addClass('tabbed-fieldsets');
4748
foreach ($this->component->getFieldSets() AS $fieldSet) {
4849
if ($fieldSet->isVisible()) {
4950
$tab = $tabSet->createTab($fieldSet->getId(), $fieldSet->getLabel(), $fieldSet);
50-
$tab->addClass('jumbotron');
5151
$tab->addClass('p-4');
5252
}
5353
}

src/WebApp/Component/Component.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ public function getId() {
4242

4343
public function setId($id) {
4444
$this->id = $id;
45+
return $this;
4546
}
4647

4748
public function getClass() {
4849
return $this->getAttribute('class');
4950
}
5051

51-
public function addClass($class) {
52-
$this->addAttribute('class', $class);
52+
public function addClass(...$classes) {
53+
foreach ($classes AS $class) {
54+
$this->addAttribute('class', $class);
55+
}
5356
return $this;
5457
}
5558

src/WebApp/Component/Divider.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
class Divider extends Div {
6+
7+
public function __construct($parent, $child = NULL) {
8+
parent::__construct($parent, $child);
9+
$this->addClass('divider');
10+
}
11+
}
12+

src/WebApp/Component/InputGroup.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
class InputGroup extends FormElement {
6+
7+
public function __construct($parent, $label) {
8+
parent::__construct($parent, NULL);
9+
$this->setLabel($label);
10+
$this->setGroup(TRUE);
11+
$this->addClass('input-group');
12+
}
13+
14+
public function setPrepend($prepend) {
15+
$this->prepend = $prepend;
16+
return $this;
17+
}
18+
19+
public function getPrepend() {
20+
return $this->prepend;
21+
}
22+
23+
public function setAppend($append) {
24+
$this->append = $append;
25+
return $this;
26+
}
27+
28+
public function getAppend() {
29+
return $this->append;
30+
}
31+
32+
}
33+

src/WebApp/Component/Link.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public function getOnClick() {
1515
}
1616

1717
public function setOnClick($onClick) {
18-
$this->setAttribute('onclick', $onclick);
18+
$this->setAttribute('onclick', $onClick);
19+
return $this;
1920
}
2021

2122
public function getUrl() {
@@ -24,6 +25,7 @@ public function getUrl() {
2425

2526
public function setUrl($url) {
2627
$this->setAttribute('href', $url);
28+
return $this;
2729
}
2830

2931
public function getTarget() {
@@ -32,6 +34,7 @@ public function getTarget() {
3234

3335
public function setTarget($target) {
3436
$this->setAttribute('target', $target);
37+
return $this;
3538
}
3639

3740
public function getEnabled() {
@@ -44,6 +47,7 @@ public function setEnabled($value) {
4447
} else {
4548
$this->addClass('disabled');
4649
}
50+
return $this;
4751
}
4852

4953
}

src/WebApp/Component/LoginForm.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ class LoginForm extends Div {
1010
protected $form;
1111
protected $footer;
1212
protected $socialLogins;
13+
protected $return;
1314

14-
public function __construct($parent, $socialLogins = FALSE, $tfa = FALSE) {
15+
public function __construct($parent, $socialLogins = FALSE, $tfa = FALSE, $return = NULL) {
1516
parent::__construct($parent);
1617
$this->request = \TgUtils\Request::getRequest();
1718
$this->addClass('login-form');
1819
$this->header = $this->createHeader();
1920
$this->body = $this->createBody();
2021
$this->footer = $this->createFooter();
21-
$this->form = $this->createForm($tfa);
22+
$this->form = $this->createForm($tfa, $return);
2223
$this->socialLogins = $socialLogins ? $this->createSocialLogins() : NULL;
2324
}
2425

@@ -45,14 +46,14 @@ protected function createBody() {
4546
return $container;
4647
}
4748

48-
protected function createForm($tfa) {
49+
protected function createForm($tfa, $return) {
4950
$form = new Form($this->body, 'loginForm', Form::VERTICAL);
5051
$form->setMethod('POST');
5152
$this->createUserInput($form);
5253
$this->createPasswordInput($form);
5354
if ($tfa) $this->createTFAInput($form);
5455
$this->createPersistentCheck($form);
55-
$this->createReturnInput($form);
56+
$this->createReturnInput($form, $return);
5657
$this->createLoginButton($form);
5758
return $form;
5859
}
@@ -80,8 +81,8 @@ protected function createPersistentCheck($form) {
8081
return new HiddenInput($form, 'persist', '1');
8182
}
8283

83-
protected function createReturnInput($form) {
84-
$return = $this->request->getParam('return');
84+
protected function createReturnInput($form, $return) {
85+
if ($return == NULL) $return = $this->request->getParam('return');
8586
if ($return != NULL) {
8687
$returnUri = parse_url($return);
8788
if (isset($returnUri['query'])) {

src/WebApp/Component/PriceInput.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
use TgUtils\FormatUtils;
6+
7+
class PriceInput extends InputGroup {
8+
9+
public function __construct($parent, $id, $value = null, $currency = NULL) {
10+
parent::__construct($parent, NULL);
11+
$this->setId('input-group-'.$id);
12+
$this->input = new NumberInput($this, $id, FormatUtils::formatPrice($value != NULL ? $value : 0, '', NULL, ''));
13+
$this->input->setStep(0.01);
14+
$this->input->setMin(0);
15+
$this->currency = $currency;
16+
$this->currencyElem = new Text(NULL, $this->currency);
17+
$this->currencyElem->addClass('input-group-text');
18+
$this->setPrepend($this->currencyElem);
19+
}
20+
21+
public function getCurrency() {
22+
return $this->currency;
23+
}
24+
25+
public function setCurrency($value) {
26+
$this->currency = $value;
27+
}
28+
29+
public function getInput() {
30+
return $this->input;
31+
}
32+
}
33+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace WebApp\DefaultTheme;
4+
5+
class InputGroupRenderer extends ContainerRenderer {
6+
7+
public function __construct($theme, $component) {
8+
parent::__construct($theme, $component);
9+
}
10+
11+
12+
public function render() {
13+
$rc = $this->renderStartTag('div');
14+
$prepend = $this->component->getPrepend();
15+
if ($prepend != NULL) {
16+
$rc .= '<div class="input-group-prepend">'.
17+
$this->theme->renderComponent($prepend).
18+
'</div>';
19+
}
20+
$rc .= $this->renderChildren();
21+
$append = $this->component->getAppend();
22+
if ($append != NULL) {
23+
$rc .= '<div class="input-group-append">'.
24+
$this->theme->renderComponent($append).
25+
'</div>';
26+
}
27+
$rc .= $this->renderEndTag('div');
28+
return $rc;
29+
}
30+
}
31+

0 commit comments

Comments
 (0)