kartik\social\VKPlugin::registerAssets PHP Method

registerAssets() protected method

Registers the necessary assets
protected registerAssets ( )
    protected function registerAssets()
    {
        $view = $this->getView();
        $params = $this->getPluginParams();
        $id = $this->options['id'];
        if ($this->type === self::SHARE) {
            $script = 'share.js?91';
            $scriptId = 'vk_share_script_tag';
            $check = 'VK.Share';
            $call = "\$('#{$id}').html(VK.Share.button({$params}))";
        } else {
            $script = 'openapi.js?116';
            $scriptId = 'vk_openapi_script_tag';
            $check = 'VK.Widgets';
            $widget = ucfirst(substr($this->type, 3));
            $call = "VK.Widgets.{$widget}({$params})";
            if ($this->_initVk) {
                $initOpts = Json::encode(['apiId' => $this->apiId, 'onlyWidgets' => true]);
                $js = "VK.init({$initOpts});";
                $view->registerJs($js);
            }
        }
        $view->registerJsFile('//vk.com/js/api/' . $script, ['async' => true, 'id' => $scriptId, 'position' => View::POS_HEAD]);
        $js = <<<SCRIPT
if (window.VK && {$check}) {
    {$call};
} else {
    \$('#{$scriptId}').load(function() {
        {$call};
    });
}
SCRIPT;
        $view->registerJs($js);
    }