Skip to content

Commit

Permalink
Fix bugs and make Widget working
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodeholic committed Jan 8, 2019
1 parent fede48b commit f914aa9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 50 deletions.
8 changes: 3 additions & 5 deletions Assets.php → AssetBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
];
}
48 changes: 48 additions & 0 deletions GaOpOut.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Created by PhpStorm.
* User: levani
* Date: 1/8/19
* Time: 1:39 PM
*/

namespace apollo11\yii2GaOptOut;

use yii\base\Widget;


class GaOpOut extends Widget
{
// view
public $view;

//gap Id
public $gaAppId;

//output call event
public $optOutCallEvent = 'click';

//element selector with link to jsoutput
public $elementSelector = '[href="#jsgaoptout"]';

/**
* @var bool
*/
public $debug = false;

public $showAlterAfterDeactivate = true;

public function init()
{
AssetBundle::register($this->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') . "
});
");
}
}
45 changes: 0 additions & 45 deletions gaOpOut.php

This file was deleted.

0 comments on commit f914aa9

Please sign in to comment.