Skip to content

Commit

Permalink
Add designe for categories to domain check
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Jan 5, 2016
1 parent 144a366 commit 6f56a9e
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 60 deletions.
26 changes: 26 additions & 0 deletions src/models/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,30 @@ public function getTransferDataProviderOptions()

return $result;
}

public static function setIsotopeFilterValue($zone)
{
$getClass = function (array $arr) use ($zone) {
$result = '';
foreach ($arr as $cssClass => $items) {
if (in_array($zone, $items)) {
$result = '.' . $cssClass;
break;
}
}
return $result;
};
$categories = [
'adult' => ['sex', 'porn', 'xxx', 'adult'],
'generic' => ['com', 'net', 'org', 'biz', 'co', 'name'],
'european' => ['su', 'ru'],
];
$special = [
'popular' => ['info', 'com', 'net', 'org', 'biz', 'co', 'name'],
'promotion' => ['su', 'ru'],
];
$result = sprintf('%s %s', $getClass($categories), $getClass($special));

return $result;
}
}
3 changes: 2 additions & 1 deletion src/views/domain/_checkDomainLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* @var $state
*/
use yii\helpers\Html;
use hipanel\modules\domain\models\Domain;

?>

<div class="domain-line" data-domain="<?= $line['full_domain_name'] ?>">
<div class="domain-line" data-domain="<?= $line['full_domain_name'] ?>" data-filter="<?= Domain::setIsotopeFilterValue($line['zone']) ?> <?= ($state === 'available') ? '.available' : '.unavailable' ?>">
<div class="col-md-6">
<?php if ($state) : ?>
<span class="domain-img"><i class="fa fa-globe fa-lg"></i></span>
Expand Down
209 changes: 150 additions & 59 deletions src/views/domain/checkDomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,58 @@
use yii\helpers\Html;
use hipanel\modules\domain\assets\DomainCheckPluginAsset;

Yii::$app->assetManager->forceCopy = true; // todo: remove this string
DomainCheckPluginAsset::register($this);
hipanel\frontend\assets\IsotopeAsset::register($this);
Yii::$app->assetManager->forceCopy = true; // todo: remove this string
//
//$this->registerJs(<<<JS
//// init Isotope
//var grid = $('.domain-list').isotope({
// itemSelector: '.domain-line'
//});
//
//// store filter for each group
//var filters = {};
//
//$('.filters').on( 'click', '.btn', function() {
// var _this = $(this);
// // get group key
// var buttonGroup = _this.parents('.list-unstyled');
// var filterGroup = buttonGroup.attr('data-filter-group');
// // set filter for group
// filters[ filterGroup ] = _this.attr('data-filter');
// // combine filters
// var filterValue = concatValues( filters );
// // set filter for Isotope
// grid.isotope({ filter: filterValue });
//});
//// change is-checked class on buttons
//$('.button-group').each( function( i, buttonGroup ) {
// var buttonGroup = $( buttonGroup );
// buttonGroup.on( 'click', 'button', function() {
// buttonGroup.find('.is-checked').removeClass('is-checked');
// $( this ).addClass('is-checked');
// });
//});
// // flatten object by concatting values
//function concatValues( obj ) {
// var value = '';
// for ( var prop in obj ) {
// value += obj[ prop ];
// }
// return value;
//}
//JS
//);


$this->title = Yii::t('app', 'Domain check');
$this->breadcrumbs->setItems([
$this->title,
]);
$model->domain = empty($model->domain) ? Yii::$app->request->get('domain-check') : $model->domain;
if (!empty($results)) {
$this->registerJs(<<<'JS'
$this->registerJs(<<<'JS'
$('.domain-list').domainsCheck({
domainRowClass: '.domain-line',
success: function(data, domain, element) {
Expand All @@ -26,76 +68,124 @@
}
});
JS
);
);
}
?>

<div class="row">
<div class="col-md-8 col-md-offset-2">
<?php if (empty($dropDownZonesOptions)) : ?>
<div class="alert alert-warning alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong><?= Yii::t('app', 'There are no available domain zones')?>!</strong>
<?php if (!empty($results)) : ?>
<div class="row">
<div class="col-md-3">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Status</h3>
</div>
<div class="box-body no-padding">
<ul class="nav nav-pills nav-stacked">
<li><a href="#" data-filter="">All<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".available">Available<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".unavailable">Unavailable<span class="label label-default pull-right">12</span></a></li>
</ul>
</div>
<!-- /.box-body -->
</div>

<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Special</h3>
</div>
<div class="box-body no-padding">
<ul class="nav nav-pills nav-stacked">
<li><a href="#" data-filter="">All<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".popular">Popular Domains<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".promotion">Promotion<span class="label label-default pull-right">12</span></a></li>
</ul>
</div>
<!-- /.box-body -->
</div>

<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Categories</h3>
</div>
<div class="box-body no-padding">
<ul class="nav nav-pills nav-stacked">
<li><a href="#" data-filter="">All<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".adult">Adult<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".generic">Generic<span class="label label-default pull-right">12</span></a></li>
<li><a href="#" data-filter=".european">European<span class="label label-default pull-right">12</span></a></li>
</ul>
</div>
<!-- /.box-body -->
</div>
<?php endif; ?>
<div class="box box-solid">
<!-- /.box-header -->
<div class="box-body">
<?php $form = ActiveForm::begin([
'id' => 'check-domain',
'method' => 'get',
'options' => [
'data-pjax' => false,
],
'fieldConfig' => [
'template' => "{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
],
</div>

<div class="col-md-9">

<div class="row">
<div class="col-md-12">
<?php if (empty($dropDownZonesOptions)) : ?>
<div class="alert alert-warning alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">×</span></button>
<strong><?= Yii::t('app', 'There are no available domain zones') ?>!</strong>
</div>
<?php endif; ?>
<div class="box box-solid">
<!-- /.box-header -->
<div class="box-body">
<?php $form = ActiveForm::begin([
'id' => 'check-domain',
'method' => 'get',
'options' => [
'data-pjax' => false,
],
'fieldConfig' => [
'template' => "{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
],
// 'enableAjaxValidation' => true,
// 'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->scenario]),
]) ?>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<?= $form->field($model, 'domain')->textInput(['placeholder' => Yii::t('app', 'Domain search...'), 'class' => 'form-control input-lg']); ?>
]) ?>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<?= $form->field($model, 'domain')->textInput(['placeholder' => Yii::t('app', 'Domain search...'), 'class' => 'form-control input-lg']); ?>
</div>
</div>
<!-- /.col-md-8 -->
<div class="col-md-4">
<div class="form-group">
<?= $form->field($model, 'zone')->dropDownList($dropDownZonesOptions, ['class' => 'form-control input-lg']); ?>
</div>
</div>
<!-- /.col-md-3 -->
<div
class="col-md-2"><?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-info btn-flat btn-lg btn-block']); ?></div>
<!-- /.col-md-1 -->
</div>
<!-- /.row -->
<?php ActiveForm::end() ?>
</div>
<!-- /.box-body -->
</div>
<!-- /.col-md-8 -->
<div class="col-md-4">
<div class="form-group">
<?= $form->field($model, 'zone')->dropDownList($dropDownZonesOptions, ['class' => 'form-control input-lg']); ?>
</div>
</div>
<!-- /.col-md-3 -->
<div
class="col-md-2"><?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-info btn-flat btn-lg btn-block']); ?></div>
<!-- /.col-md-1 -->
<!-- /.box -->
</div>
<!-- /.row -->
<?php ActiveForm::end() ?>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
</div>

<?php if (!empty($results)) : ?>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="box box-solid">
<!-- /.box-header -->
<div class="box-body no-padding">
<div class="domain-list">
<?php foreach ($results as $line) : ?>
<?= $this->render('_checkDomainLine', ['line' => $line]) ?>
<?php endforeach; ?>

<div class="box box-solid">
<!-- /.box-header -->
<div class="box-body no-padding">
<div class="domain-list">
<?php foreach ($results as $line) : ?>
<?= $this->render('_checkDomainLine', ['line' => $line]) ?>
<?php endforeach; ?>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box-body -->
<!-- /.box -->
</div>
<!-- /.box -->
</div>
</div>
<?php endif; ?>
<style>
.domain-line {
Expand Down Expand Up @@ -145,20 +235,21 @@ class="col-md-2"><?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'bt
color: gray;
}

.domain-line .domain-price .domain-price-year
,del {
.domain-line .domain-price .domain-price-year, del {
color: #ccc;
font-size: 16px;
}

.domain-line .domain-taken {
color: #ccc;
}

.domain-line .domain-whois {
color: gray;
font-size: 12px;
line-height: 16px;
}

.domain-line .domain-name.muted,
.domain-line .domain-zone.muted {
color: #ccc;
Expand Down

0 comments on commit 6f56a9e

Please sign in to comment.