Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace hipanel\modules\hosting\widgets\ip; | ||
|
||
use Yii; | ||
use yii\base\Widget; | ||
use yii\helpers\Html; | ||
use yii\web\View; | ||
use hipanel\modules\hosting\models\Ip; | ||
|
||
class ApplyPtrChange extends Widget | ||
{ | ||
/** @var Ip */ | ||
public $model; | ||
|
||
/** @var string */ | ||
public $attribute = 'ptr'; | ||
|
||
public function init(): void | ||
{ | ||
$this->view->registerJs( | ||
<<<'JS' | ||
$('.apply-ptr-change').popover({html: true}); | ||
$(document).on('click', function (e) { | ||
$('[data-toggle="popover"], [data-original-title]').each(function () { | ||
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { | ||
(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false | ||
} | ||
}); | ||
}); | ||
JS | ||
, | ||
View::POS_READY | ||
); | ||
$this->view->registerCss( | ||
<<<'CSS' | ||
.apply-ptr-change { | ||
border-bottom: 1px #72afd2 dashed; | ||
font-style: italic; | ||
} | ||
.apply-ptr-change:hover { | ||
text-decoration: none; | ||
} | ||
CSS | ||
); | ||
} | ||
|
||
public function run(): string | ||
{ | ||
return Html::tag( | ||
'a', | ||
$this->model->{$this->attribute} ?? Yii::t('hipanel', 'Empty'), | ||
[ | ||
'class' => 'apply-ptr-change', | ||
'href' => '#', | ||
'data' => [ | ||
'container' => 'body', | ||
'toggle' => 'popover', | ||
'content' => Yii::t( | ||
'hipanel:hosting', | ||
'In order to change you need to {apply}', | ||
[ | ||
'apply' => Html::a( | ||
Yii::t('hipanel:hosting', 'apply for change of PTR records'), | ||
['@ticket/create'], | ||
['target' => '_blank'] | ||
), | ||
] | ||
), | ||
'placement' => 'top', | ||
], | ||
] | ||
); | ||
} | ||
} |