Skip to content

Commit a4369d0

Browse files
committed
BaseHtml events pre and postCompile
+ setColAlignment on HtmlTable
1 parent 2db7b19 commit a4369d0

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Ajax/common/html/BaseHtml.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ abstract class BaseHtml extends BaseWidget {
2222
protected $_wrapAfter=array ();
2323
protected $_bsComponent;
2424
protected $_compiled=false;
25+
protected $_postCompile;
26+
protected $_preCompile;
2527

2628
/**
2729
*
@@ -196,6 +198,10 @@ protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
196198
$beforeCompile($this,$js,$view);
197199
}
198200
}
201+
if(\is_callable($this->_preCompile)){
202+
$pc=$this->_preCompile;
203+
$pc();
204+
}
199205
$this->_compiled=true;
200206
}
201207
}
@@ -219,10 +225,22 @@ public function compile(JsUtils $js=NULL, &$view=NULL) {
219225
$js->addViewElement($this->_identifier, $result, $view);
220226
}
221227
}
228+
if(\is_callable($this->_postCompile)){
229+
$pc=$this->_postCompile;
230+
$pc();
231+
}
222232
return $result;
223233
}
224234

225235
public function __toString() {
226236
return $this->compile();
227237
}
238+
239+
public function onPostCompile($callback){
240+
$this->_postCompile=$callback;
241+
}
242+
243+
public function onPreCompile($callback){
244+
$this->_preCompile=$callback;
245+
}
228246
}

Ajax/semantic/html/base/constants/icons/webContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
use Ajax\common\BaseEnum;
66

7-
abstract class webContent extends BaseEnum {
7+
abstract class WebContent extends BaseEnum {
88
const ALARM="alarm", ALARM_SLASH="alarm slash", ALARM_OUTLINE="alarm outline", ALARM_SLASH_OUTLINE="alarm slash outline", AT="at", BROWSER="browser", BUG="bug", CALENDAR_OUTLINE="calendar outline", CALENDAR="calendar", CLOUD="cloud", CODE="code", COMMENT="comment", COMMENTS="comments", COMMENT_OUTLINE="comment outline", COMMENTS_OUTLINE="comments outline", COPYRIGHT="copyright", DASHBOARD="dashboard", DROPDOWN="dropdown", EXTERNAL_SQUARE="external square", EXTERNAL="external", EYEDROPPER="eyedropper", FEED="feed", FIND="find", HEARTBEAT="heartbeat", HISTORY="history", HOME="home", IDEA="idea", INBOX="inbox", LAB="lab", MAIL="mail", MAIL_OUTLINE="mail outline", MAIL_SQUARE="mail square", MAP="map", OPTIONS="options", PAINT_BRUSH="paint brush", PAYMENT="payment", PHONE="phone", PHONE_SQUARE="phone square", PRIVACY="privacy", PROTECT="protect", SEARCH="search", SETTING="setting", SETTINGS="settings", SHOP="shop", SIDEBAR="sidebar", SIGNAL="signal", SITEMAP="sitemap", TAG="tag", TAGS="tags", TASKS="tasks", TERMINAL="terminal", TEXT_TELEPHONE="text telephone", TICKET="ticket", TROPHY="trophy", WIFI="wifi";
99
}

Ajax/semantic/html/collections/table/HtmlTable.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Ajax\semantic\html\content\table\HtmlTR;
1212
use Ajax\semantic\html\collections\table\traits\TableTrait;
1313
use Ajax\semantic\html\content\table\HtmlTD;
14+
use Ajax\semantic\html\base\constants\TextAlignment;
1415

1516
/**
1617
* Semantic HTML Table component
@@ -228,6 +229,23 @@ public function colLeft($colIndex) {
228229
return $this->colAlign($colIndex, "colLeft");
229230
}
230231

232+
public function setColAlignment($colIndex,$alignment){
233+
switch ($alignment){
234+
case TextAlignment::LEFT:
235+
$function="colLeft";
236+
break;
237+
case TextAlignment::RIGHT:
238+
$function="colRight";
239+
break;
240+
case TextAlignment::CENTER:
241+
$function="colCenter";
242+
break;
243+
default:$function="colLeft";
244+
}
245+
$this->colAlign($colIndex, $function);
246+
return $this;
247+
}
248+
231249
private function colAlign($colIndex, $function) {
232250
if (\is_array($colIndex)) {
233251
foreach ( $colIndex as $cIndex ) {

0 commit comments

Comments
 (0)