87 lines
1.8 KiB
PHP
87 lines
1.8 KiB
PHP
|
<?php
|
||
|
namespace nur\v\plugins;
|
||
|
|
||
|
use nur\v\BasePlugin;
|
||
|
use nur\v\v;
|
||
|
use nur\v\vo;
|
||
|
|
||
|
class showmorePlugin extends BasePlugin {
|
||
|
const HAVE_JQUERY = true;
|
||
|
|
||
|
/** @var string classe du conteneur */
|
||
|
const CONTAINER_CLASS = "showmore-container";
|
||
|
/** @var string classe de l'invite à en savoir plus */
|
||
|
const INVITE_CLASS = "showmore-invite";
|
||
|
/** @var string classe du panneau caché par défaut */
|
||
|
const INVITE_CONTENT = "En savoir plus...";
|
||
|
const PANEL_CLASS = "showmore-panel";
|
||
|
|
||
|
function startc(): array {
|
||
|
return v::sdiv(["class" => self::CONTAINER_CLASS]);
|
||
|
}
|
||
|
|
||
|
function invite($vs=null): array {
|
||
|
if ($vs === null) $vs = self::INVITE_CONTENT;
|
||
|
return v::a([
|
||
|
"class" => self::INVITE_CLASS,
|
||
|
"href" => "#",
|
||
|
$vs,
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
function startp(): array {
|
||
|
return v::sdiv(["class" => [self::PANEL_CLASS, "hidden"]]);
|
||
|
}
|
||
|
|
||
|
function endp(): array {
|
||
|
return ["</div>"];
|
||
|
}
|
||
|
|
||
|
function endc(): array {
|
||
|
return ["</div>"];
|
||
|
}
|
||
|
|
||
|
function end(): array {
|
||
|
return ["</div></div>"];
|
||
|
}
|
||
|
|
||
|
function printStartc(): void {
|
||
|
vo::print($this->startc());
|
||
|
}
|
||
|
|
||
|
function printInvite($vs=null): void {
|
||
|
vo::print($this->invite($vs));
|
||
|
}
|
||
|
|
||
|
function printStartp(): void {
|
||
|
vo::print($this->startp());
|
||
|
}
|
||
|
|
||
|
function printEndp(): void {
|
||
|
vo::print($this->endp());
|
||
|
}
|
||
|
|
||
|
function printEndc(): void {
|
||
|
vo::print($this->endc());
|
||
|
}
|
||
|
|
||
|
function printEnd(): void {
|
||
|
vo::print($this->end());
|
||
|
}
|
||
|
|
||
|
function printJquery(): void {
|
||
|
?>
|
||
|
<script type="text/javascript">
|
||
|
jQuery.noConflict()(function($) {
|
||
|
$(".<?=self::INVITE_CLASS?>").click(function() {
|
||
|
let $this = $(this);
|
||
|
$this.addClass("hidden");
|
||
|
$this.closest(".<?=self::CONTAINER_CLASS?>").find(".<?=self::PANEL_CLASS?>").removeClass("hidden");
|
||
|
return false;
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
<?php
|
||
|
}
|
||
|
}
|