Skip to content

Commit de8c149

Browse files
committed
Toast terminated
1 parent 1d8d13e commit de8c149

File tree

8 files changed

+96
-33
lines changed

8 files changed

+96
-33
lines changed

Ajax/common/components/BaseComponent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function setParams($params) {
7474
$this->$method($v);
7575
else {
7676
$this->setParam($k, $v);
77-
trigger_error("`".$k."` property n'existe pas", E_USER_NOTICE);
77+
trigger_error("`{$k}` doesn't exists!", E_USER_NOTICE);
7878
}
7979
}
8080

@@ -97,4 +97,5 @@ public function setDebug($value){
9797
public function setVerbose($value){
9898
return $this->setParam("verbose", $value);
9999
}
100+
100101
}

Ajax/common/components/SimpleComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ public function setItemSelector($itemSelector) {
104104
$this->itemSelector=$itemSelector;
105105
return $this;
106106
}
107-
107+
108108
}

Ajax/semantic/components/Modal.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@
44

55
use Ajax\JsUtils;
66

7+
/**
8+
* Ajax\semantic\components$Modal
9+
* This class is part of Ubiquity
10+
* @author jcheron <[email protected]>
11+
* @version 1.0.1
12+
*
13+
*/
714
class Modal extends SimpleSemExtComponent {
815

916
public function __construct(JsUtils $js) {
1017
parent::__construct($js);
11-
$this->uiName="modal";
12-
}
13-
14-
protected function setBehavior($name) {
15-
$this->paramParts[]=[$name];
16-
return $this;
18+
$this->uiName='modal';
1719
}
1820

1921
public function showDimmer(){
20-
return $this->setBehavior("hide dimmer");
22+
return $this->addBehavior('hide dimmer');
2123
}
2224

2325
public function setInverted(){
24-
$this->params["inverted"]=true;
26+
$this->params['inverted']=true;
2527
}
2628

2729
public function setOnHidden($jsCode) {
28-
$jsCode=str_ireplace("\"","%quote%", $jsCode);
29-
return $this->setParam("onHidden", "%function(){".$jsCode."}%");
30+
$this->addComponentEvent('onHidden', $jsCode);
3031
}
3132
}

Ajax/semantic/components/SimpleSemExtComponent.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public function __construct(JsUtils $js=NULL) {
1212
$this->paramParts=array();
1313
}
1414

15+
protected function addBehavior($name) {
16+
$this->paramParts[]=[$name];
17+
return $this;
18+
}
19+
1520
protected function generateParamParts(){
1621
$results=[];
1722
foreach ($this->paramParts as $paramPart){
@@ -38,7 +43,7 @@ public function setParamParts($paramParts) {
3843
}
3944

4045
public function addComponentEvent($event,$jsCode){
41-
$jsCode=str_ireplace("\"","%quote%", $jsCode);
46+
$jsCode=\str_ireplace("\"","%quote%", $jsCode);
4247
return $this->setParam($event, "%function(){".$jsCode."}%");
4348
}
4449

Ajax/semantic/components/Toast.php

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,64 @@
44

55
use Ajax\JsUtils;
66

7+
/**
8+
* Ajax\semantic\components$Toast
9+
* This class is part of Ubiquity
10+
* @author jcheron <[email protected]>
11+
* @version 1.0.0
12+
* @since 2.3.0
13+
*/
714
class Toast extends SimpleSemExtComponent {
815

916
public function __construct(JsUtils $js) {
1017
parent::__construct($js);
11-
$this->uiName="toast";
18+
$this->uiName='toast';
1219
}
1320

14-
protected function setBehavior($name) {
15-
$this->paramParts[]=[$name];
16-
return $this;
21+
public function close(){
22+
return $this->addBehavior('close');
1723
}
1824

19-
public function showDimmer(){
20-
return $this->setBehavior("hide dimmer");
25+
public function setClass($value){
26+
$this->params['class']=$value;
2127
}
22-
28+
2329
public function setCloseIcon(){
24-
$this->params["closeIcon"]=true;
30+
$this->params['closeIcon']=true;
31+
}
32+
33+
public function setShowIcon($value=false){
34+
$this->params['showIcon']=$value;
35+
}
36+
37+
public function setCloseOnClick($value){
38+
$this->params['closeOnClick']=$value;
39+
}
40+
public function setTitle($title){
41+
$this->params['title']=$title;
42+
}
43+
44+
public function setMessage($message){
45+
$this->params['message']=$message;
2546
}
2647

2748
public function setDisplayTime($time){
28-
$this->params["displayTime"]=$time;
49+
$this->params['displayTime']=$time;
50+
}
51+
52+
public function showProgress($value='top'){
53+
$this->params['showProgress']=$value;
2954
}
3055

3156
public function setOnHide($jsCode) {
32-
$jsCode=str_ireplace("\"","%quote%", $jsCode);
33-
return $this->setParam("onHide", "%function(){".$jsCode."}%");
57+
$this->addComponentEvent('onHide', $jsCode);
58+
}
59+
60+
public function setOnApprove($jsCode) {
61+
$this->addComponentEvent('onApprove', $jsCode);
62+
}
63+
64+
public function setOnDeny($jsCode) {
65+
$this->addComponentEvent('onDeny', $jsCode);
3466
}
3567
}

Ajax/semantic/html/base/HtmlSemDoubleElement.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
use Ajax\semantic\html\base\constants\Side;
1414
use Ajax\common\html\html5\HtmlList;
1515
use Ajax\common\html\BaseHtml;
16+
use Ajax\semantic\components\Toast;
1617

1718
/**
1819
* Base class for Semantic double elements
1920
* @author jc
20-
* @version 1.001
21+
* @version 1.0.2
2122
*/
2223
class HtmlSemDoubleElement extends HtmlDoubleElement {
2324
use BaseTrait;
2425
protected $_popup=NULL;
2526
protected $_dimmer=NULL;
27+
protected $_toast=NULL;
2628
protected $_params=array ();
2729

2830

@@ -166,16 +168,36 @@ public function run(JsUtils $js) {
166168
if (isset($this->_popup)) {
167169
$this->_popup->run($js);
168170
}
171+
if (isset($this->_toast)) {
172+
$this->_toast->run($js);
173+
}
169174
return $this->_bsComponent;
170175
}
171176

177+
/**
178+
* @param array $items
179+
* @param boolean $ordered
180+
* @return \Ajax\common\html\html5\HtmlList
181+
*/
172182
public function addList($items,$ordered=false){
173183
$list=new HtmlList("list-".$this->identifier,$items);
174184
$list->setOrdered($ordered);
175185
$list->setClass("ui list");
176186
$this->addContent($list);
177187
return $list;
178188
}
189+
190+
/**
191+
* @param ?array $params
192+
* @return \Ajax\semantic\components\Toast
193+
*/
194+
public function asToast($params=NULL){
195+
$this->_toast=new Toast(null);
196+
if(isset($params)){
197+
$this->_toast->setParams($params);
198+
}
199+
return $this->_toast;
200+
}
179201

180202
/*
181203
* public function __call($name, $arguments){

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ Using the dependency injection, the jQuery object can be injected into **php fra
1717

1818
## Requirements/Dependencies
1919

20-
* PHP >= 5.3.9
20+
* PHP >= 7.0
2121
* JQuery >= 2.0.3
2222
* JQuery UI >= 1.10 [optional]
2323
* Twitter Bootstrap >= 3.3.2 [optional]
24-
* Semantic-UI >= 2.2 [optional]
24+
* Semantic-UI >= 2.2 or Fomantic-UI >= 2.7 [optional]
2525

2626
## Resources
2727
* [API](https://api.kobject.net/phpMv-UI/)
2828
* [Documentation/demo](https://phpmv-ui.kobject.net/)
29+
* [Semantic-ui](https://semantic-ui.com) [Fomantic-ui](https://fomantic-ui.com)
2930

3031
## I - Installation
3132

@@ -41,7 +42,7 @@ Create the composer.json file in the app directory as follows:
4142
```json
4243
{
4344
"require": {
44-
"phpmv/php-mv-ui": "2.3.x-dev"
45+
"phpmv/php-mv-ui": "^2.3"
4546
}
4647
}
4748
```

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
{
22
"name": "phpmv/php-mv-ui",
33
"description": "A JQuery and UI library for php and php MVC frameworks",
4-
"type": "phpMv-UI",
4+
"type": "library",
55
"keywords": [
66
"php",
77
"jquery",
88
"phalcon",
99
"symfony",
1010
"laravel",
1111
"Yii",
12+
"ubiquity",
1213
"codeIgniter",
1314
"twitter bootstrap",
1415
"jquery ui",
1516
"semantic ui",
1617
"framework"
1718
],
1819
"require": {
19-
"php": ">5.3.9",
20+
"php": ">7.0",
2021
"frameworks/jquery": "~2.1"
2122
},
2223
"suggest": {
2324
"components/jqueryui": "~1.11",
2425
"twitter/bootstrap": "~3.3",
25-
"semantic/ui": "~2.2.1"
26+
"fomantic/ui": "~2.7.8"
2627
},
2728
"autoload": {
2829
"psr-4": { "Ajax\\": "Ajax/" }
@@ -32,12 +33,12 @@
3233
{
3334
"name": "Jean-Christophe HERON",
3435
"email": "[email protected]",
35-
"role": "Developer"
36+
"role": "Lead developer"
3637
}
3738
],
3839
"extra": {
3940
"branch-alias": {
40-
"dev-master": "2.3.x-dev"
41+
"dev-master": "2.4.x-dev"
4142
}
4243
}
4344
}

0 commit comments

Comments
 (0)