-
Notifications
You must be signed in to change notification settings - Fork 2
Setup
Matej Chalachán edited this page May 21, 2022
·
4 revisions
It is necessary for saving rules on pages
./yii migrate --migrationPath=@vendor/matejch/yii2-page-guide/src/migrations'pageGuide' => [
'class' => \matejch\pageGuide\PageGuide::class,
]By default, it is rendered in place you put widget on
<?= \matejch\pageGuide\widget\PageAssist::widget() ?>You can adjust postion of widget by setting btnPositionCss
<?= \matejch\pageGuide\widget\PageAssist::widget(['btnPositionCss' => 'position: fixed;top: 100px;right: -2px;']) ?>If you want you can add intro.js option into widget with attribute introOptions
More options here intro.js
Example with progress bar
<?= \matejch\pageGuide\widget\PageAssist::widget(['introOptions' => ['showProgress' => true] ]) ?>You can set selectors option in widget that takes array of css selectors
Example
<?= \matejch\pageGuide\widget\PageAssist::widget(['selectors' => ['.form-group','.float-left','#name']]) ?>If no selectors are set, widget attempts to find important elements, in following way:
- inputs
input:not([type=hidden]) - if form is on page then also
.form-groupelements are selected
Available callbacks for intro.js and widget are
oncomplete onexit onbeforeexit onchange onbeforechange onafterchange
Example of usage:
<?= \matejch\pageGuide\widget\PageAssist::widget(['introCallbacks' => [
'onchange' => new \yii\web\JsExpression("function (targetElement) { console.log('next step'); }"),
'oncomplete' => new \yii\web\JsExpression("function () { console.log('Intro completed'); }"),
'onexit' => new \yii\web\JsExpression("function () { console.log('Exit by pressing ESC or Clicking overlay'); }"),
'onbeforeexit' => new \yii\web\JsExpression("function () { console.log('Before closing intro'); }"),
'onbeforechange' => new \yii\web\JsExpression("function (newStepElement) { console.log('Before new step start'); }"),
'onafterchange' => new \yii\web\JsExpression("function (newStepElement) { console.log('After new step start'); }"),
]
]) ?>