public function testMain()
 {
     SwiperAsset::register(\Yii::$app->getView());
 }
Beispiel #2
0
    /**
     * Registers the initializer of Swiper plugin
     *
     * @see \romkaChev\yii2\swiper\Swiper::$pluginOptions
     * @return Swiper
     */
    protected function registerClientScript()
    {
        $view = $this->getView();
        SwiperAsset::register($view);
        $id = $this->containerOptions['id'];
        $pluginOptions = Json::encode($this->pluginOptions);
        $variableName = 'swiper' . Inflector::id2camel($this->containerOptions['id']);
        $view->registerJs(new JsExpression(<<<JS
        //noinspection JSUnnecessarySemicolon
        ;var {$variableName} = new Swiper('#{$id}', {$pluginOptions});
JS
));
        return $this;
    }