diff --git a/Assets.php b/AssetBundle.php similarity index 55% rename from Assets.php rename to AssetBundle.php index 6583c1a..894cc38 100644 --- a/Assets.php +++ b/AssetBundle.php @@ -8,12 +8,10 @@ namespace apollo11\yii2GaOptOut; -use yii\web\AssetBundle; - -class Assets extends AssetBundle +class AssetBundle extends \yii\web\AssetBundle { - public $sourcePath ='@npm-assets/gaopout'; - public $js=[ + public $sourcePath = '@npm/gaoptout'; + public $js = [ 'ApGaOptOut.js' ]; } \ No newline at end of file diff --git a/GaOpOut.php b/GaOpOut.php new file mode 100644 index 0000000..aee6fcf --- /dev/null +++ b/GaOpOut.php @@ -0,0 +1,48 @@ +getView()); + $this->getView()->registerJs(" + new ApGaOptOut({ + gaAppId: '{$this->gaAppId}', + optOutCallEvent: '{$this->optOutCallEvent}', + elementSelector: '{$this->elementSelector}', + debug: " . ($this->debug ? 'true' : 'false') . ", + showAlterAfterDeactivate: " . ($this->showAlterAfterDeactivate ? 'true' : 'false') . " + }); + "); + } +} \ No newline at end of file diff --git a/gaOpOut.php b/gaOpOut.php deleted file mode 100644 index f7146a7..0000000 --- a/gaOpOut.php +++ /dev/null @@ -1,45 +0,0 @@ -registerJs(" - "); - } -} \ No newline at end of file