68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
|
<?php
|
||
|
namespace nur\v\bs3\plugins;
|
||
|
|
||
|
use nur\b\params\IParametrable;
|
||
|
use nur\b\params\Tparametrable1;
|
||
|
use nur\v\BasePlugin;
|
||
|
use nur\v\js;
|
||
|
|
||
|
class easymdePlugin extends BasePlugin implements IParametrable {
|
||
|
use Tparametrable1;
|
||
|
|
||
|
const CSS = [
|
||
|
"nur-v-bs3/highlightjs/styles/default.min.css",
|
||
|
"nur-v-bs3/easymde/easymde.min.css",
|
||
|
];
|
||
|
|
||
|
const JS = [
|
||
|
"nur-v-bs3/highlightjs/highlight.min.js",
|
||
|
"nur-v-bs3/easymde/easymde.min.js",
|
||
|
];
|
||
|
|
||
|
const SELECTOR = null;
|
||
|
const CONFIG = [
|
||
|
"spellChecker" => false,
|
||
|
"hideIcons" => ["image"],
|
||
|
];
|
||
|
|
||
|
const PARAMETRABLE_PARAMS_SCHEMA = [
|
||
|
"selector" => ["string", null, "sélecteur pour les controles"],
|
||
|
"config" => ["?array", null, "configuration de l'objet"],
|
||
|
];
|
||
|
|
||
|
function __construct(?array $params=null) {
|
||
|
self::set_parametrable_params_defaults($params, [
|
||
|
"selector" => static::SELECTOR,
|
||
|
"config" => static::CONFIG,
|
||
|
]);
|
||
|
$this->initParametrableParams($params);
|
||
|
}
|
||
|
|
||
|
protected $ppSelector;
|
||
|
|
||
|
protected $ppConfig;
|
||
|
|
||
|
const HAVE_JQUERY = true;
|
||
|
|
||
|
function printJquery(): void {
|
||
|
?>
|
||
|
<script type="text/javascript">
|
||
|
jQuery.noConflict()(function($) {
|
||
|
var config = <?=js::qo($this->ppConfig)?>;
|
||
|
var selector = <?=js::qv($this->ppSelector)?>;
|
||
|
var $elements;
|
||
|
if (selector !== "") $elements = $(selector);
|
||
|
if (selector !== "" && $elements.length > 0) {
|
||
|
$elements.each(function () {
|
||
|
config.element = this;
|
||
|
new EasyMDE(config);
|
||
|
});
|
||
|
} else {
|
||
|
new EasyMDE(config);
|
||
|
}
|
||
|
});
|
||
|
</script>
|
||
|
<?php
|
||
|
}
|
||
|
}
|