Skip to content

Commit

Permalink
Move pos2_name and pos2_value to pos2_nav using data-* attributes
Browse files Browse the repository at this point in the history
Note: data-* are standard attributes

I did not move the back-end part so it is easier to find the places to refactor calls

Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 30, 2020
1 parent 928549a commit d944f08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
27 changes: 10 additions & 17 deletions js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,13 @@ Navigation.loadChildNodes = function (isNode, $expandElem, callback) {
return;
}
$destination = $expandElem.closest('li');
var pos2Name = $expandElem.find('span.pos2_nav');
params = {
'aPath': $expandElem.find('span.aPath').text(),
'vPath': $expandElem.find('span.vPath').text(),
'pos': $expandElem.find('span.pos').text(),
'pos2_name': $expandElem.find('span.pos2_name').text(),
'pos2_value': $expandElem.find('span.pos2_value').text(),
'pos2_name': pos2Name.attr('data-name'),
'pos2_value': pos2Name.attr('data-value'),
'searchClause': '',
'searchClause2': ''
};
Expand Down Expand Up @@ -245,25 +246,17 @@ Navigation.traverseForPaths = function () {
params['n' + count + '_aPath'] = $(this).find('span.aPath').text();
params['n' + count + '_vPath'] = $(this).find('span.vPath').text();

var pos2Name = $(this).find('span.pos2_name').text();
if (! pos2Name) {
pos2Name = $(this)
.parent()
.parent()
.find('span.pos2_name').last()
.text();
}
var pos2Value = $(this).find('span.pos2_value').text();
if (! pos2Value) {
pos2Value = $(this)
var pos2Nav = $(this).find('span.pos2_nav');

if (pos2Nav.length === 0) {
pos2Nav = $(this)
.parent()
.parent()
.find('span.pos2_value').last()
.text();
.find('span.pos2_nav').last();
}

params['n' + count + '_pos2_name'] = pos2Name;
params['n' + count + '_pos2_value'] = pos2Value;
params['n' + count + '_pos2_name'] = pos2Nav.attr('data-name');
params['n' + count + '_pos2_value'] = pos2Nav.attr('data-value');

params['n' + count + '_pos3_name'] = $(this).find('span.pos3_name').text();
params['n' + count + '_pos3_value'] = $(this).find('span.pos3_value').text();
Expand Down
12 changes: 5 additions & 7 deletions libraries/classes/Navigation/NavigationTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -1026,15 +1026,13 @@ private function getPaginationParamsHtml($node)
$retval = '';
$paths = $node->getPaths();
if (isset($paths['aPath_clean'][2])) {
$retval .= "<span class='hide pos2_name'>";
$retval .= $paths['aPath_clean'][2];
$retval .= '</span>';
$retval .= "<span class='hide pos2_value'>";
$retval .= htmlspecialchars((string) $node->pos2);
$retval .= '</span>';
$retval .= '<span class="hide pos2_nav"';
$retval .= ' data-name="' . $paths['aPath_clean'][2] . '"';
$retval .= ' data-value="' . htmlspecialchars((string) $node->pos2) . '"';
$retval .= '"></span>';
}
if (isset($paths['aPath_clean'][4])) {
$retval .= "<span class='hide pos3_name'>";
$retval .= '<span class="hide pos3_name">';
$retval .= $paths['aPath_clean'][4];
$retval .= '</span>';
$retval .= "<span class='hide pos3_value'>";
Expand Down

0 comments on commit d944f08

Please sign in to comment.