Skip to content

Commit d4bd11b

Browse files
committed
Add table/DataTable tr element focusable
1 parent 47de240 commit d4bd11b

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class HtmlTable extends HtmlSemDoubleElement {
2626
private $_footer;
2727
private $_afterCompileEvents;
2828
private $_activeRowSelector;
29+
private $_focusable=false;
30+
31+
/**
32+
* @return ActiveRow
33+
*/
34+
public function getActiveRowSelector() {
35+
return $this->_activeRowSelector;
36+
}
37+
2938
protected $_innerScript;
3039

3140

@@ -522,4 +531,11 @@ public function addMergeRow($colCount,$value=null){
522531
return $this->getBody()->addMergeRow($colCount,$value);
523532
}
524533

534+
/**
535+
* @param bool $focusable
536+
*/
537+
public function setFocusable(bool $focusable): void {
538+
$this->getBody()->setFocusable($focusable);
539+
}
540+
525541
}

Ajax/semantic/html/collections/table/traits/TableTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function onRow($event, $jsCode, $stopPropagation = false, $preventDefault
8989
}
9090

9191
public function getOnRow($event, $url, $responseElement = "", $parameters = array()) {
92-
$jsCondition = '!$(this).closest("tr").hasClass("active")';
92+
$jsCondition = '!$(this).closest("tr").is(":focus")';
9393
if (isset($parameters['jsCondition'])) {
9494
$jsCondition = '(' . $parameters['jsCondition'] . ' && ' . $jsCondition . ')';
9595
}

Ajax/semantic/html/content/table/HtmlTableContent.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
*/
1616
class HtmlTableContent extends HtmlSemCollection {
17+
protected $_focusable=false;
1718

1819
protected $_tdTagNames = [
1920
"thead" => "th",
@@ -69,6 +70,9 @@ protected function createItem($value) {
6970
$count = $this->count();
7071
$tr = new HtmlTR("");
7172
$tr->setContainer($this, $count);
73+
if($this->_focusable) {
74+
$tr->setProperty('tabindex', $count);
75+
}
7276
$tr->setTdTagName($this->_tdTagNames[$this->tagName]);
7377
if (isset($value) === true) {
7478
$tr->setColCount($value);
@@ -481,4 +485,11 @@ public function _setMerged($value) {
481485
$this->_merged = $value;
482486
return $this;
483487
}
488+
489+
/**
490+
* @param bool $focusable
491+
*/
492+
public function setFocusable(bool $focusable): void {
493+
$this->_focusable = $focusable;
494+
}
484495
}

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* DataTable widget for displaying list of objects
2121
*
22-
* @version 1.1.0
22+
* @version 1.1.1
2323
* @author jc
2424
* @since 2.2
2525
*
@@ -734,4 +734,8 @@ public function setInverted($recursive = true) {
734734
$this->_emptyMessage->setInverted($recursive);
735735
}
736736
}
737+
738+
public function setFocusable(bool $focusable) {
739+
$this->content["table"]->setFocusable($focusable);
740+
}
737741
}

0 commit comments

Comments
 (0)