Open fredeom opened 3 years ago
Hello @fredeom , all right?
Yes, you right.
You can open a PR?
Hello @fredeom , all right?
Yes, you right.
You can open a PR?
Yes, I can. Yes I would, but I don't.
I've added pace-js in asset bundle and registered my own script with paceOptions there. Added pace-js hooks on concrete links and am controling ajax calls.
{
"require": {
"npm-asset/pace-js": "^1.2",
}
}
class AppAsset extends AssetBundle
{
public $js = [
'js/paceOptions.js',
];
}
class PaceAsset extends AssetBundle
{
public $sourcePath = "@npm/pace-js/";
public $js = [
YII_DEBUG ? 'pace.js' : 'pace.min.js'
];
public $jsOptions = [
'position' => \yii\web\View::POS_END
];
public $depends = [
'app\assets\AppAsset'
];
}
AppAsset::register($this);
PaceAsset::register($this);
paceOptions = {
ajax: true,
startOnPageLoad: false,
}
$(".long-get-request").on("click", function (e) {
e.preventDefault();
$('#overlay').show();
Pace.start();
$.get(e.target.href, () => {
$('#overlay').hide();
Pace.stop();
});
});
yii2-pace/src/Pace.php
$this->getView()->registerJs('window.paceOptions=' . Json::encode(ArrayHelper::getValue($paceOptions,'options')), \yii\web\View::
POS_BEGIN);
yii2-pace/src/PaceAsset.php
'position' => \yii\web\View::
POS_HEADYou place pace-js library in head and
window.paceOptions={...}
after that in body, so it isn't used.Am I right?