Skip to content

Commit 0dcdadc

Browse files
committed
Update JsUtilsActionsTrait.php
1 parent bb25ea4 commit 0dcdadc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Ajax/common/traits/JsUtilsActionsTrait.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,28 @@ public function counterOn($element, $event, $counterSelector, $value = 0, $limit
792792
* @return string
793793
*/
794794
public function activateLink($target, $property = 'href', $href = null) {
795+
return $this->execAtLast($this->_activateLink($target, $property, $href));
796+
}
797+
798+
/**
799+
* Returns the javascript code for activate an element if it is active (add the class active)
800+
*
801+
* @param string $target
802+
* the container element
803+
* @param string $property
804+
* default: href
805+
* @param string $href
806+
* the active href (if null, window.location.href is used)
807+
* @return string
808+
*/
809+
public function _activateLink($target, $property = 'href', $href = null) {
795810
$js = '$("' . $target . ' [' . $property . ']").removeClass("active");';
796811
if (isset($href)) {
797812
$js .= 'var href="' . $href . '";';
798813
} else {
799814
$js .= 'var href=window.location.href;';
800815
}
801816
$js .= '$("' . $target . ' [' . $property . ']").each(function(){if(href.includes($(this).attr("' . $property . '"))) $(this).addClass("active");});';
802-
return $this->execAtLast($js);
817+
return $js;
803818
}
804819
}

0 commit comments

Comments
 (0)