Commit 76995c53 authored by Виталий Мурашко's avatar Виталий Мурашко

Merge branch 'master' of http://git.task-on.com/ktask/task-on.com

parents db1f2388 3fd251e3
......@@ -101,7 +101,9 @@ class UnisenderAPI {
'createCampaign',
[
'message_id' => $message_id,
'defer' => 1
'defer' => 1,
'track_links' => 1,
'track_read' => 1
]
);
}
......
<?php
namespace common\components\activeRecordBehaviors;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use yii\web\UploadedFile;
class FileUploadBehavior extends Behavior
{
public $path;
public $folder;
public $file;
public $unlinkFile = false;
public $field;
public function events()
{
return [
ActiveRecord::EVENT_BEFORE_UPDATE => 'Save',
ActiveRecord::EVENT_BEFORE_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
private function getAbsolutePath()
{
return Yii::getAlias($this->path);
}
private function uploadFile()
{
if(!file_exists($this->getAbsolutePath()))
{
mkdir($this->getAbsolutePath(), 0777, true);
}
$field = $this->field;
$this->owner->$field = $this->folder . date('dmYHis-') . uniqid() . '.' . $this->file->extension;
$this->file->saveAs($this->getAbsolutePath() . $this->owner->$field);
}
private function deleteFile()
{
$field = $this->field;
if($this->owner->$field && file_exists($this->getAbsolutePath() . $this->owner->$field))
{
unlink($this->getAbsolutePath() . $this->owner->$field);
$this->owner->$field = null;
}
}
public function Save($event)
{
$this->file = UploadedFile::getInstance($this->owner, 'file');
if($this->owner->unlinkFile || $this->file)
{
$this->deleteFile();
}
if($this->file)
{
$this->uploadFile();
}
return true;
}
public function Insert($event)
{
$this->file = UploadedFile::getInstance($this->owner, 'file');
if($this->file)
{
$this->uploadFile();
}
return true;
}
public function Delete($event)
{
$this->deleteFile();
return true;
}
}
<?php
namespace common\components\activeRecordBehaviors;
use yii;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use \common\models\MetaTags;
use common\modules\languages\models\Languages;
class MetaTagBehavior extends Behavior
{
public $meta;
public $actions = [];
public function events()
{
return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
ActiveRecord::EVENT_INIT => 'eventInit',
ActiveRecord::EVENT_AFTER_FIND => 'eventFind',
ActiveRecord::EVENT_AFTER_UPDATE => 'eventSave',
ActiveRecord::EVENT_AFTER_INSERT => 'eventInsert',
ActiveRecord::EVENT_BEFORE_DELETE => 'eventDelete',
];
}
public function Save($event)
public function eventInit($event)
{
if(in_array(Yii::$app->controller->action->id, $this->actions))
{
$langs = Languages::find()->all();
foreach ($langs as $lang)
{
$mt = new MetaTags;
$mt->lang_id = $lang->id;
$this->meta[$lang->id] = $mt;
}
}
}
public function eventFind($event)
{
if(in_array(Yii::$app->controller->action->id, $this->actions))
{
$langs = Languages::find()->all();
foreach ($langs as $lang)
{
$mt = $this->owner->getMetaTags($lang->id)->one();
if(!$mt)
{
$mt = new MetaTags;
$mt->lang_id = $lang->id;
}
$this->meta[$lang->id] = $mt;
}
}
}
public function eventSave($event)
{
$meta = \Yii::$app->request->post('MetaTags');
if ($meta)
......@@ -46,7 +91,7 @@ class MetaTagBehavior extends Behavior
return true;
}
public function Insert($event)
public function eventInsert($event)
{
$meta = \Yii::$app->request->post('MetaTags');
if ($meta)
......@@ -67,7 +112,7 @@ class MetaTagBehavior extends Behavior
return true;
}
public function Delete($event)
public function eventDelete($event)
{
if($this->owner->metaTags)
{
......
......@@ -77,14 +77,6 @@ class PostAdminController extends AdminController
public function actionCreate()
{
$model = new Post();
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = new PostLang;
$lng->lang_id = $lang->id;
$langs[$lang->id] = $lng;
}
if (Yii::$app->request->isPost)
{
......@@ -110,7 +102,6 @@ class PostAdminController extends AdminController
return $this->render('create', [
'model' => $model,
'langs' => $langs,
]);
}
......@@ -123,20 +114,6 @@ class PostAdminController extends AdminController
public function actionUpdate($id)
{
$model = $this->findModel($id);
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = $model->getLang($lang->id)->one();
if(!$lng)
{
$lng = new PostLang;
$lng->lang_id = $lang->id;
}
$langs[$lang->id] = $lng;
}
if (Yii::$app->request->isPost)
{
......@@ -162,7 +139,6 @@ class PostAdminController extends AdminController
return $this->render('update', [
'model' => $model,
'langs' => $langs,
]);
}
......
......@@ -7,6 +7,7 @@ use Yii;
use common\modules\languages\models\Languages;
use common\modules\blog\models\PostLang;
use common\modules\blog\models\PostTags;
use common\models\MetaTags;
/**
* This is the model class for table "posts".
......@@ -54,6 +55,8 @@ class Post extends \common\components\ActiveRecordModel
[['active', 'created_at', 'updated_at'], 'integer'],
[['url'], 'string', 'max' => 255],
[['url'], 'unique'],
[['preview', 'unlinkFile'], 'safe'],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
];
}
......@@ -63,8 +66,21 @@ class Post extends \common\components\ActiveRecordModel
public function behaviors()
{
return [
'meta' => [
'class' => 'common\components\activeRecordBehaviors\MetaTagBehavior',
'actions' => ['create', 'update']
],
'langs' => [
'class' => 'common\modules\blog\components\PostLangBehavior',
'class' => 'common\modules\languages\components\LanguageHelperBehavior',
'field' => 'post_id',
'langClass' => 'common\modules\blog\models\PostLang',
'actions' => ['create', 'update']
],
'file' => [
'class' => 'common\components\activeRecordBehaviors\FileUploadBehavior',
'path' => '@frontend/web',
'folder' => '/uploads/blog/',
'field' => 'preview'
],
];
}
......@@ -78,11 +94,42 @@ class Post extends \common\components\ActiveRecordModel
'id' => 'ID',
'url' => 'Ссылка',
'active' => 'Видимость',
'file' => 'Изображение',
'preview' => 'Изображение',
'unlinkFile' => 'Удалить изображение',
'created_at' => 'Дата добавления',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getMetaTags($lang_id = null)
{
$query = $this->hasMany(MetaTags::className(), ['object_id' => 'id'])->where(['model_id' => get_class($this)]);
if($lang_id)
{
$query->andWhere(['lang_id' => $lang_id]);
}
return $query;
}
/**
* @return \yii\db\ActiveQuery
*/
public function getMetaTag($lang_id = null)
{
$lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id;
return $this->hasOne(MetaTags::className(), ['object_id' => 'id'])->where([
'model_id' => get_class($this),
'lang_id' => $lang_id
]);
}
/**
* @return \yii\db\ActiveQuery
*/
......
......@@ -3,6 +3,9 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\modules\blog\models\Post;
use common\modules\content\widgets\MetaTagsWidget;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
/* @var $form yii\widgets\ActiveForm */
......@@ -10,7 +13,11 @@ use yii\widgets\ActiveForm;
<div class="post-form">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin([
'options' => [
'enctype' => 'multipart/form-data'
]
]); ?>
<?= $form->field($model, 'url')->textInput(['maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html') ?>
......@@ -23,14 +30,23 @@ use yii\widgets\ActiveForm;
'label' => ' '
], false); ?>
<?php if($model->preview)
{
echo Html::img(\Yii::$app->params['frontUrl'] . $model->preview);
} ?>
<?= $form->field($model, 'file')->fileInput() ?>
<?= $form->field($model, 'unlinkFile')->checkbox(); ?>
<ul class="nav nav-pills">
<?php $c = 0; foreach ($langs as $i => $content) : $c++; ?>
<?php $c = 0; foreach ($model->getLangsHelper() as $i => $content) : $c++; ?>
<li class="<?=($c==1?'active':'')?>"><a href="#lang-<?=$content->lang->url?>" data-toggle="tab"><?=$content->lang->name?></a></li>
<?php endforeach; ?>
</ul>
<div class="tab-content">
<?php $c = 0; foreach ($langs as $content) : $c++;
<?php $c = 0; foreach ($model->getLangsHelper() as $content) : $c++;
$lang_id = $content->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$content->lang->url;?>">
......@@ -38,6 +54,11 @@ use yii\widgets\ActiveForm;
<?= $form->field($content, '['.$lang_id.']text')->textArea() ?>
<?= MetaTagsWidget::widget([
'model' => $model->meta[$lang_id],
'form' => $form,
])?>
</div>
<?php endforeach; ?>
</div>
......
......@@ -14,7 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs,
]) ?>
</div>
......@@ -24,7 +24,14 @@ $this->params['breadcrumbs'][] = $this->title;
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'url:url',
[
'attribute' => 'url',
'format' => 'raw',
'value' => function($model)
{
return Html::a($model->url, \Yii::$app->params['frontUrl'] . '/blog/' . $model->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);
}
],
[
'attribute' => 'active',
'filter' => Post::$active_title,
......
......@@ -14,7 +14,6 @@ $this->params['breadcrumbs'][] = 'Update';
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs,
]) ?>
</div>
<?php
namespace common\modules\content\components;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use common\modules\content\models\CoBlocksLang;
class CoBlocksLangBehavior extends Behavior
{
public function events()
{
return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
public function Save($event)
{
$langs = Yii::$app->request->post('CoBlocksLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = CoBlocksLang::find()->where([
'block_id' => $this->owner->id,
'lang_id' => $lang_id,
])->one();
if (!$lang)
{
$lang = new CoBlocksLang;
}
$attributes['block_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes( $attributes );
if(!$lang->save()) die(print_r($lang->errors));
}
}
return true;
}
public function Insert($event)
{
$langs = Yii::$app->request->post('CoBlocksLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = new CoBlocksLang;
$attributes['block_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes($attributes);
$lang->save(false);
}
}
return true;
}
public function Delete($event)
{
if($this->owner->langs)
{
foreach ($this->owner->langs as $lang)
{
$lang->delete();
}
}
return true;
}
}
<?php
namespace common\modules\content\components;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use common\modules\content\models\CoContentLang;
class CoContentLangBehavior extends Behavior
{
public function events()
{
return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
public function Save($event)
{
$langs = Yii::$app->request->post('CoContentLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = CoContentLang::find()->where([
'content_id' => $this->owner->id,
'lang_id' => $lang_id,
])->one();
if (!$lang)
{
$lang = new CoContentLang;
}
$attributes['content_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes( $attributes );
if(!$lang->save()) die(print_r($lang->errors));
}
}
return true;
}
public function Insert($event)
{
$langs = Yii::$app->request->post('CoContentLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = new CoContentLang;
$attributes['content_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes($attributes);
$lang->save(false);
}
}
return true;
}
public function Delete($event)
{
if($this->owner->langs)
{
foreach ($this->owner->langs as $lang)
{
$lang->delete();
}
}
return true;
}
}
......@@ -78,15 +78,7 @@ class BlockAdminController extends AdminController
*/
public function actionCreate()
{
$model = new CoBlocks;
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = new CoBlocksLang;
$lng->lang_id = $lang->id;
$langs[$lang->id] = $lng;
}
$model = new CoBlocks;
Yii::$app->controller->page_title = 'Добавить блок';
......@@ -118,7 +110,6 @@ class BlockAdminController extends AdminController
return $this->render('create', [
'model' => $model,
'langs' => $langs
]);
}
......@@ -130,22 +121,7 @@ class BlockAdminController extends AdminController
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = $model->getLang($lang->id)->one();
if(!$lng)
{
$lng = new CoBlocksLang;
$lng->lang_id = $lang->id;
}
$langs[$lang->id] = $lng;
}
$model = $this->findModel($id);
Yii::$app->controller->page_title = 'Редактировать блок';
......@@ -177,7 +153,6 @@ class BlockAdminController extends AdminController
return $this->render('update', [
'model' => $model,
'langs' => $langs
]);
}
......
......@@ -84,19 +84,6 @@ class ContentAdminController extends AdminController
public function actionCreate()
{
$model = new CoContent;
$langs = [];
$meta = [];
foreach (Languages::find()->all() as $lang)
{
$lng = new CoContentLang;
$lng->lang_id = $lang->id;
$langs[$lang->id] = $lng;
$mt = new \common\models\MetaTags;
$mt->lang_id = $lang->id;
$meta[$lang->id] = $mt;
}
Yii::$app->controller->page_title = 'Добавить страницу';
......@@ -112,18 +99,9 @@ class ContentAdminController extends AdminController
try
{
$model->attributes = Yii::$app->request->post('CoContent');
$model->image = UploadedFile::getInstance($model, 'image');
if($model->validate())
if($model->save())
{
if($model->image)
{
$model->upload();
$model->image = null;
}
$model->save();
$transaction->commit();
return $this->redirect(['manage']);
}
......@@ -137,8 +115,6 @@ class ContentAdminController extends AdminController
return $this->render('create', [
'model' => $model,
'meta' => $meta,
'langs' => $langs
]);
}
......@@ -151,31 +127,6 @@ class ContentAdminController extends AdminController
public function actionUpdate($id)
{
$model = $this->findModel($id);
$langs = [];
$meta = [];
foreach (Languages::find()->all() as $lang)
{
$mt = $model->getMetaTags($lang->id)->one();
if(!$mt)
{
$mt = new \common\models\MetaTags;
$mt->lang_id = $lang->id;
}
$meta[$lang->id] = $mt;
$lng = $model->getLang($lang->id)->one();
if(!$lng)
{
$lng = new CoContentLang;
$lng->lang_id = $lang->id;
}
$langs[$lang->id] = $lng;
}
Yii::$app->controller->page_title = 'Редактировать страницу';
......@@ -191,23 +142,9 @@ class ContentAdminController extends AdminController
try
{
$model->attributes = Yii::$app->request->post('CoContent');
$model->image = UploadedFile::getInstance($model, 'image');
if($model->validate())
if($model->save())
{
if($model->image)
{
if($model->preview)
{
$model->deletePreview();
}
$model->upload();
$model->image = null;
}
$model->save();
$transaction->commit();
return $this->redirect(['manage']);
}
......@@ -221,8 +158,6 @@ class ContentAdminController extends AdminController
return $this->render('update', [
'model' => $model,
'meta' => $meta,
'langs' => $langs,
]);
}
......
......@@ -33,7 +33,7 @@ class PageController extends \common\components\BaseController
$model = CoContent::findOne(['url' => $page]);
}
$content = $model->lang->content;
$content = $model->lang->getFinishedContent();
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords;
......
......@@ -40,8 +40,11 @@ class CoBlocks extends \common\components\ActiveRecordModel
{
return [
'langs' => [
'class' => 'common\modules\content\components\CoBlocksLangBehavior',
]
'class' => 'common\modules\languages\components\LanguageHelperBehavior',
'field' => 'block_id',
'langClass' => 'common\modules\content\models\CoBlocksLang',
'actions' => ['create', 'update']
],
];
}
......@@ -91,8 +94,8 @@ class CoBlocks extends \common\components\ActiveRecordModel
return $model->lang->text;
}
public static function printStaticBlock($block, $addPath = false)
public static function printStaticBlock($block, $params = [])
{
return Yii::$app->getView()->render( '@app/views/layouts/block/' . $block . '.php');
return Yii::$app->getView()->render( '@app/views/layouts/block/' . $block . '.php', $params);
}
}
......@@ -32,10 +32,6 @@ class CoContent extends \common\components\ActiveRecordModel
const CUSTOM_DARK = 'dark';
const CUSTOM_WHITE = 'white';
const PHOTO_FOLDER = '/uploads/content/';
public $image;
public static $cutom_list = [
self::CUSTOM_DARK => 'Темный',
self::CUSTOM_WHITE => 'Светлый',
......@@ -57,9 +53,19 @@ class CoContent extends \common\components\ActiveRecordModel
return [
'meta' => [
'class' => 'common\components\activeRecordBehaviors\MetaTagBehavior',
'actions' => ['create', 'update']
],
'langs' => [
'class' => 'common\modules\content\components\CoContentLangBehavior',
'class' => 'common\modules\languages\components\LanguageHelperBehavior',
'field' => 'content_id',
'langClass' => 'common\modules\content\models\CoContentLang',
'actions' => ['create', 'update']
],
'file' => [
'class' => 'common\components\activeRecordBehaviors\FileUploadBehavior',
'path' => '@frontend/web',
'folder' => '/uploads/content/',
'field' => 'preview'
],
'timestamp' => [
'class' => TimestampBehavior::className(),
......@@ -100,7 +106,7 @@ class CoContent extends \common\components\ActiveRecordModel
{
return [
[['active'], 'integer'],
[['image'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
[['url'], 'required'],
[['url'], 'string', 'max' => 250],
[['category_id', 'priority', 'custom'], 'safe'],
......@@ -118,7 +124,7 @@ class CoContent extends \common\components\ActiveRecordModel
'category_id' => Yii::t('content', 'Category ID'),
'url' => Yii::t('content', 'Url'),
'name' => Yii::t('content', 'Name'),
'image' => 'Превью',
'file' => 'Превью',
'custom' => 'Заголовок',
'priority' => 'Приоритет в Sitemap',
'title' => Yii::t('content', 'Title'),
......@@ -176,36 +182,4 @@ class CoContent extends \common\components\ActiveRecordModel
{
return $this->hasMany(CoContentLang::className(), ['content_id' => 'id']);
}
private function getPath()
{
return Yii::getAlias('@frontend/web') . self::PHOTO_FOLDER;
}
public function upload()
{
if ($this->validate())
{
if(!file_exists($this->getPath()))
{
mkdir($this->getPath(), 0777, true);
}
$this->preview = date('dmYHis-') . uniqid() . '.' . $this->image->extension;
$this->image->saveAs($this->getPath() . $this->preview);
return true;
}
else
{
return false;
}
}
public function deletePreview()
{
if(file_exists($this->getPath() . $this->preview))
{
unlink($this->getPath() . $this->preview);
}
}
}
......@@ -91,10 +91,18 @@ class CoContentLang extends \common\components\ActiveRecordModel
return $this->hasOne(Languages::className(), ['id' => 'lang_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getContent()
{
return $this->hasOne(CoContent::className(), ['id' => 'content_id']);
}
/**
* @return html
*/
public function getContent()
public function getFinishedContent()
{
$content = $this->text;
$content = \common\components\AppManager::prepareWidget($content);
......@@ -118,17 +126,19 @@ class CoContentLang extends \common\components\ActiveRecordModel
}
$arrWhatReplaceNext[] = '[about-reviews]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('about-reviews', true);
$arrReplaceNext[] = CoBlocks::printStaticBlock('about-reviews');
$arrWhatReplaceNext[] = '[reviews]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('reviews', true);
$arrReplaceNext[] = CoBlocks::printStaticBlock('reviews');
$arrWhatReplaceNext[] = '[content-phone]';
$arrReplaceNext[] = \common\models\Settings::getValue('content-phone');
$arrWhatReplaceNext[] = '[cases]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('cases', true);
$arrReplaceNext[] = CoBlocks::printStaticBlock('cases');
$arrWhatReplaceNext[] = '[projects]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('projects', true);
$arrReplaceNext[] = CoBlocks::printStaticBlock('projects');
$arrWhatReplaceNext[] = '[case-subscribe]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('case-subscribe', true);
$arrReplaceNext[] = CoBlocks::printStaticBlock('case-subscribe');
$arrWhatReplaceNext[] = '[case-more]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('case-more', ['model' => $this->content]);
$arrWhatReplaceNext[] = '[footer]';
$arrReplaceNext[] = \Yii::$app->getView()->render('@app/views/layouts/footer');
$arrWhatReplaceNext[] = '[footer-index]';
......
......@@ -30,13 +30,13 @@ use common\modules\content\models\CoBlocks;
<?= $form->field($model, 'title')->textInput(['maxlength' => 250])->hint('Заголовок страницы виден пользователю сайта и как правило оформляется в тег &lt;h1&gt;. Если дизайном страницы не предусмотрен вывод заголовка, то он не будет выводиться даже если был введен в данное поле.') ?>
<ul class="nav nav-pills">
<?php $c = 0; foreach ($langs as $i => $block) : $c++; ?>
<?php $c = 0; foreach ($model->getLangsHelper() as $i => $block) : $c++; ?>
<li class="<?=($c==1?'active':'')?>"><a href="#lang-<?=$block->lang->url?>" data-toggle="tab"><?=$block->lang->name?></a></li>
<?php endforeach; ?>
</ul>
<div class="tab-content">
<?php $c = 0; foreach ($langs as $block) : $c++;
<?php $c = 0; foreach ($model->getLangsHelper() as $block) : $c++;
$lang_id = $block->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$block->lang->url;?>">
......
......@@ -14,7 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs
]) ?>
</div>
......@@ -14,7 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs
]) ?>
</div>
......@@ -47,13 +47,13 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all();
<?php if($model->preview)
{
echo Html::img(\Yii::$app->params['frontUrl'] . CoContent::PHOTO_FOLDER . $model->preview);
echo Html::img(\Yii::$app->params['frontUrl'] . $model->preview);
} ?>
<?= $form->field($model, 'image')->fileInput() ?>
<?= $form->field($model, 'file')->fileInput() ?>
<ul class="nav nav-pills">
<?php $c = 0; foreach ($langs as $i => $content) : $c++; ?>
<?php $c = 0; foreach ($model->getLangsHelper() as $i => $content) : $c++; ?>
<li class="<?=($c==1?'active':'')?>"><a href="#lang-<?=$content->lang->url?>" data-toggle="tab"><?=$content->lang->name?></a></li>
<?php endforeach; ?>
</ul>
......@@ -72,7 +72,7 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all();
?>
<div class="tab-content">
<?php $c = 0; foreach ($langs as $content) : $c++;
<?php $c = 0; foreach ($model->getLangsHelper() as $content) : $c++;
$lang_id = $content->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$content->lang->url;?>">
......@@ -83,7 +83,7 @@ $blocks = \common\modules\content\models\CoBlocks::find()->all();
<?= $form->field($content, '['.$lang_id.']text')->textArea()->hint($block_hint) ?>
<?= MetaTagsWidget::widget([
'model' => $meta[$lang_id],
'model' => $model->meta[$lang_id],
'form' => $form,
])?>
......
......@@ -14,8 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'meta' => $meta,
'langs' => $langs
]) ?>
</div>
......@@ -28,7 +28,7 @@ use common\modules\content\models\CoCategory;
'attribute' => 'url',
'format' => 'raw',
'value' => function($data) {
return Html::a($data->url, Yii::$app->params['frontUrl'].($data->url!='/'?'/':'').$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);$data->category->name;
return Html::a($data->url, Yii::$app->params['frontUrl'].($data->url!='/'?'/':'').$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);
}
],
[
......
......@@ -14,8 +14,6 @@ $this->params['breadcrumbs'][] = $this->title;
<?= $this->render('_form', [
'model' => $model,
'meta' => $meta,
'langs' => $langs,
]) ?>
</div>
\ No newline at end of file
......@@ -4,6 +4,6 @@ use \yii\helpers\Html;
?>
<div class="col-sm-5 col-md-4">
<?php echo \common\modules\content\models\CoBlocks::printStaticBlock( 'faq-form', true);?>
<?php echo \common\modules\content\models\CoBlocks::printStaticBlock( 'faq-form' );?>
</div><!-- /col-sm-5 col-md-4 -->
\ No newline at end of file
<?php
namespace common\modules\blog\components;
namespace common\modules\languages\components;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use common\modules\blog\models\PostLang;
class PostLangBehavior extends Behavior
use common\modules\languages\models\Languages;
class LanguageHelperBehavior extends Behavior
{
private $_langs;
public $langClass;
public $field;
public $langField = 'lang_id';
public $actions = [];
public function events()
{
return [
ActiveRecord::EVENT_INIT => 'eventInit',
ActiveRecord::EVENT_AFTER_FIND => 'eventFind',
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
public function getLangsHelper()
{
return $this->_langs;
}
private function getShotNameClass()
{
return (new \ReflectionClass($this->langClass))->getShortName();
}
public function eventInit($event)
{
if(in_array(Yii::$app->controller->action->id, $this->actions))
{
$langs = Languages::find()->all();
$field = $this->langField;
foreach ($langs as $lang)
{
$lng = new $this->langClass;
$lng->$field = $lang->id;
$this->_langs[$lang->id] = $lng;
}
}
}
public function eventFind($event)
{
if(in_array(Yii::$app->controller->action->id, $this->actions))
{
$langs = Languages::find()->all();
$field = $this->langField;
foreach ($langs as $lang)
{
$lng = $this->owner->getLang($lang->id)->one();
if(!$lng)
{
$lng = new $this->langClass;
$lng->$field = $lang->id;
}
$this->_langs[$lang->id] = $lng;
}
}
}
public function Save($event)
{
$langs = Yii::$app->request->post('PostLang');
$langs = Yii::$app->request->post($this->getShotNameClass());
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = PostLang::find()->where([
'post_id' => $this->owner->id,
'lang_id' => $lang_id,
$class = $this->langClass;
$lang = $class::find()->where([
$this->field => $this->owner->id,
$this->langField => $lang_id,
])->one();
if (!$lang)
{
$lang = new PostLang;
$lang = new $class;
}
$attributes['post_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$attributes[$this->field] = $this->owner->id;
$attributes[$this->langField] = $lang_id;
$lang->setAttributes( $attributes );
if(!$lang->save()) die(print_r($lang->errors));
......@@ -47,15 +111,17 @@ class PostLangBehavior extends Behavior
public function Insert($event)
{
$langs = Yii::$app->request->post('PostLang');
$langs = Yii::$app->request->post($this->getShotNameClass());
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = new PostLang;
$class = $this->langClass;
$lang = new $class;
$attributes['post_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$attributes[$this->field] = $this->owner->id;
$attributes[$this->langField] = $lang_id;
$lang->setAttributes($attributes);
$lang->save(false);
......
......@@ -110,19 +110,8 @@ class ReviewAdminController extends AdminController
'Добавить отзыв'
];
$model->load(Yii::$app->request->post());
$model->image = UploadedFile::getInstance($model, 'image');
if (Yii::$app->request->isPost && $model->validate())
if ($model->load(Yii::$app->request->post()) && $model->save())
{
if($model->image)
{
$model->upload();
$model->image = null;
}
$model->save();
return $this->redirect(['manage']);
}
else
......@@ -152,25 +141,8 @@ class ReviewAdminController extends AdminController
'Редактировать отзыв'
];
$model->load(Yii::$app->request->post());
$model->image = UploadedFile::getInstance($model, 'image');
if (Yii::$app->request->isPost && $model->validate())
if ($model->load(Yii::$app->request->post()) && $model->save())
{
if($model->photo || $model->photo_delete)
{
$model->deletePhoto();
$model->photo = null;
}
if($model->image)
{
$model->upload();
$model->image = null;
}
$model->save();
return $this->redirect(['manage']);
}
else
......
......@@ -14,9 +14,9 @@ return [
'title' => [
'type' => 'text',
],
($model->photo?Html::img(\Yii::$app->params['frontUrl'] . Reviews::PHOTO_FOLDER . $model->photo):''),
'photo_delete' => ['type' => 'checkbox', 'class' => 'form-control',],
'image' => ['type' => 'file', 'class' => 'form-control',],
($model->photo?Html::img(\Yii::$app->params['frontUrl'] . $model->photo):''),
'unlinkFile' => ['type' => 'checkbox', 'class' => 'form-control',],
'file' => ['type' => 'file', 'class' => 'form-control',],
'video' => ['type' => 'text', 'class' => 'form-control',],
'date' => ['type' => 'date', 'class' => 'form-control',],
'text' => ['type' => 'textarea', 'class' => 'form-control'],
......
......@@ -34,11 +34,6 @@ use Yii;
*/
class Reviews extends \common\components\ActiveRecordModel
{
const PHOTO_FOLDER = '/uploads/reviews/';
public $image;
public $photo_delete = false;
private static $rate = [
'rate_usability' => [
0 => 'Не определено',
......@@ -83,12 +78,19 @@ class Reviews extends \common\components\ActiveRecordModel
return 'Отзывы';
}
// public function getUser() {
// return $this->hasOne(\common\modules\scoring\models\ScClient::className(), ['id' => 'user_id']);
// }
public function getOperator() {
return $this->hasOne(\common\modules\users\models\User::className(), ['id' => 'admin_id']);
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'file' => [
'class' => 'common\components\activeRecordBehaviors\FileUploadBehavior',
'path' => '@frontend/web',
'folder' => '/uploads/reviews/',
'field' => 'photo'
],
];
}
/**
......@@ -99,23 +101,16 @@ class Reviews extends \common\components\ActiveRecordModel
return [
[['text', 'date', 'notification_send', 'show_in_module'], 'required'],
[['admin_id', 'priority', 'notification_send', 'order', 'cat_id', 'show_in_module', 'rate_usability', 'rate_loyality', 'rate_profit'], 'integer'],
[['image'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif'],
[['text', 'state', 'attendant_products'], 'string'],
[['admin_id'], 'adminIdValidate'],
[['date', 'answer', 'good', 'bad', 'date_create', 'notification_date', 'rate_usability', 'rate_loyality', 'rate_profit', 'title', 'order', 'photo', 'state', 'video', 'photo_delete'], 'safe'],
[['date', 'answer', 'good', 'bad', 'date_create', 'notification_date', 'rate_usability', 'rate_loyality', 'rate_profit', 'title', 'order', 'photo', 'state', 'video', 'unlinkFile'], 'safe'],
// [['lang'], 'string', 'max' => 2],
[['title'], 'string', 'max' => 250],
[['email', 'video'], 'string', 'max' => 255]
];
}
public function adminIdValidate($attr, $value) {
if(empty($this->answer))
if(empty($this->$attr))
$this->addError($attr, 'Выберите опреатора');
}
/**
* @inheritdoc
*/
......@@ -133,7 +128,7 @@ class Reviews extends \common\components\ActiveRecordModel
'bad' => Yii::t('reviews', 'Не понравилось'),
'photo' => Yii::t('reviews', 'Фото'),
'video' => Yii::t('reviews', 'Ссылка на видео'),
'image' => Yii::t('reviews', 'Фото'),
'file' => Yii::t('reviews', 'Фото'),
'state' => Yii::t('reviews', 'Состояние'),
'date' => Yii::t('reviews', 'Дата'),
'date_create' => Yii::t('reviews', 'Создана'),
......@@ -148,10 +143,17 @@ class Reviews extends \common\components\ActiveRecordModel
'rate_usability' => Yii::t('reviews', 'Удобство'),
'rate_loyality' => Yii::t('reviews', 'Лояльность'),
'rate_profit' => Yii::t('reviews', 'Выгода'),
'photo_delete' => 'Удалить фото'
'unlinkFile' => 'Удалить фото'
];
}
public function adminIdValidate($attr, $value) {
if(empty($this->answer))
if(empty($this->$attr))
$this->addError($attr, 'Выберите опреатора');
}
public function hasComment() {
if(!empty($this->answer))
return true;
......@@ -207,35 +209,8 @@ class Reviews extends \common\components\ActiveRecordModel
return parent::beforeSave($insert);
}
private function getPath()
public function getOperator()
{
return Yii::getAlias('@frontend/web') . self::PHOTO_FOLDER;
}
public function upload()
{
if ($this->validate())
{
if(!file_exists($this->getPath()))
{
mkdir($this->getPath(), 0777, true);
}
$this->photo = date('dmYHis-') . uniqid() . '.' . $this->image->extension;
$this->image->saveAs($this->getPath() . $this->photo);
return true;
}
else
{
return false;
}
}
public function deletePhoto()
{
if(file_exists($this->getPath() . $this->photo))
{
unlink($this->getPath() . $this->photo);
}
return $this->hasOne(\common\modules\users\models\User::className(), ['id' => 'admin_id']);
}
}
......@@ -16,6 +16,7 @@ use common\modules\triggers\models\TriggerTrigger;
use yii\data\ActiveDataProvider;
use yii\helpers\Json;
use yii\web\NotFoundHttpException;
use \common\components\UnisenderAPI;
class TriggerAdminController extends AdminController {
/**
......@@ -52,7 +53,7 @@ class TriggerAdminController extends AdminController {
}
public function actionGetresult($id){
$obj=new \UnisenderAPI();
$obj = new UnisenderAPI();
$result = $obj->getVisitedLinks($id);
var_dump($result);
}
......
......@@ -11,9 +11,9 @@ $newListObject=Json::decode($newList);
if (array_key_exists('result', $newListObject) && array_key_exists('id', $newListObject['result'])) {
$newListId=$newListObject['result']['id'];
// Subscribe user to new List
$subscribe = $sender->subscribe(['list_ids' => $newListId, 'fields[email]' => $email]);
$subscribe = $sender->subscribe(['list_ids' => $newListId, 'fields[email]' => $email, 'double_optin' => 1]);
// Create new message
$newMessage=$sender->createEmailMessage('bystrov', $email, 'Testing Subject', 'Testing Body <br><a href="http://www.google.com/">Testing link</a><a href="{{_UnsubscribeUrl}}">Отписаться</a>', $newListId);
$newMessage=$sender->createEmailMessage('bystrov', $email, 'Testing Subject', 'Testing Body <br><a href="http://www.google.com/">Testing link</a><br><a href="{{_UnsubscribeUrl}}">Отписаться</a>', $newListId);
// Decode result
$newMessageObject=Json::decode($newMessage);
if (array_key_exists('result', $newMessageObject) && array_key_exists('message_id', $newMessageObject['result'])) {
......@@ -21,19 +21,16 @@ if (array_key_exists('result', $newListObject) && array_key_exists('id', $newLis
$newMessageId=$newMessageObject['result']['message_id'];
// Create new campaign
$newCampaign = $sender->createCampaign($newMessageId);
// Parse the result
$newCampaignObject = Json::decode($newCampaign);
if (array_key_exists('result', $newCampaignObject) && array_key_exists('campaign_id', $newCampaignObject['result'])) {
$newCampaignId = $newCampaignObject['result']['campaign_id'];
}
}
}
echo 'Рассылка: '.((isset($newCampaign)) ? $newCampaign : 'Not found');
echo 'Рассылка: '.((isset($newCampaignId)) ? $newCampaignId : 'Not found');
echo '<br>';
echo 'Список: '.((isset($newListId)) ? $newListId : 'Not found');
echo '<br>';
echo 'Сообщение: '.((isset($newMessageId)) ? $newMessageId : 'Not found');
echo '<br>';
echo "<pre>";
print_r(Json::decode($subscribe));
echo "</pre>";
echo '<br>';
echo "<pre>";
print_r(Json::decode($sender->getContactCount($newListId, ['params[search]' => 'email/phone substring'])));
echo "</pre>";
\ No newline at end of file
echo 'Сообщение: '.((isset($newMessageId)) ? $newMessageId : 'Not found');
\ No newline at end of file
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160210_053816_add_column_posts extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->addColumn('posts', 'preview', Schema::TYPE_STRING.'(60) DEFAULT NULL');
}
public function safeDown()
{
$this->dropColumn('posts', 'preview');
}
}
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160210_061532_fix_file_columns extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->alterColumn('posts', 'preview', Schema::TYPE_STRING.'(100) DEFAULT NULL');
$this->alterColumn('co_content', 'preview', Schema::TYPE_STRING.'(100) DEFAULT NULL');
$this->alterColumn('reviews', 'photo', Schema::TYPE_STRING.'(100) DEFAULT NULL');
}
public function safeDown()
{
$this->alterColumn('posts', 'preview', Schema::TYPE_STRING.'(60) DEFAULT NULL');
$this->alterColumn('co_content', 'preview', Schema::TYPE_STRING.'(50) DEFAULT NULL');
$this->alterColumn('reviews', 'photo', Schema::TYPE_STRING.'(50) DEFAULT NULL');
}
}
......@@ -107,7 +107,7 @@ class SiteController extends BaseController
{
$model = \common\modules\content\models\CoContent::findOne(['url' => 'site/error']);
$content = $model->lang->content;
$content = $model->lang->getFinishedContent();
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords;
......
......@@ -22,7 +22,7 @@ $reviews = Reviews::find()
<?php if($review->photo) : ?>
<div class="col-md-3 col-xs-4 col-sm-12">
<div class="rev_img">
<img src="<?=Reviews::PHOTO_FOLDER . $review->photo?>">
<img src="<?=$review->photo?>">
</div>
</div>
<?php endif; ?>
......
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
use common\modules\content\models\CoContent;
use common\modules\bids\models\Bid;
$more = CoContent::find()
->where([
'category_id' => 4,
'active' => true
])
->andWhere(['!=', 'id', $model->id])
->orderBy('RAND()')
->one();
?>
<section class="short_keys_sect">
<div class="container">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<h2 class="short_keys_title">Посмотрите еще один<br/> короткий кейс</h2>
</div>
</div>
<div class="row">
<?php if($more) : ?>
<div class="col-md-6 col-xs-6 col-sm-12">
<div class="short_keys_block">
<img src="<?=$more->preview?>" height="338" width="455">
<a href="<?=Url::to(['/'.$more->url]);?>" style="color:<?if($more->custom==CoContent::CUSTOM_WHITE){?>#fff<?}else{?>#2d3642<?}?>;" class="short_keys_title_link"><?=$more->lang->title?></a>
<div class="short_keys_foot">
<a href="<?=Url::to(['/'.$more->url]);?>" class="short_keys_btn_more"><span>Подробнее</span></a>
<!-- <a href="#" class="short_keys_tags"># Big data</a> -->
</div>
</div>
</div>
<?php endif; ?>
<div class="col-md-6 col-xs-6 col-sm-12">
<div class="subsc_block">
<h2 class="subsc_block_title">Подписаться на обновление</h2>
<div class="subsc_block_txt">Нам будет приятно, если вы захотите подписаться на обновление наших проектов</div>
<?php
$model = new Bid;
$model->scenario = Bid::SCENARIO_SUBSCRIBE;
$form = ActiveForm::begin([
'action' => '/',
'options' => [
'class' => 'subsc_form bids-form',
],
]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>
<?php echo Html::hiddenInput('Bid[form]', Bid::FORM_SUBSCRIBE, ['class' => 'not_clear']); ?>
<?php echo $form->field($model, 'email', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'E-mail*'
]); ?>
<?php echo Html::submitButton('Подписаться', ['class' => 'save-button']); ?>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
</div>
</section>
\ No newline at end of file
......@@ -16,7 +16,7 @@ $models = CoContent::find()
<?php foreach ($models as $model) : ?>
<div class="col-md-6 col-xs-6 col-sm-12">
<div class="keys_block_small">
<img src="<?=CoContent::PHOTO_FOLDER . $model->preview?>" height="338" width="455">
<img src="<?=$model->preview?>" height="338" width="455">
<div class="keys_small_title" <?if($model->custom==CoContent::CUSTOM_WHITE){?>style="color:#fff;"<?}?>><?=$model->lang->title?></div>
<div class="keys_small_foot">
<?=Html::a('<span>Подробнее</span>', ['/'.$model->url], ['class' => 'keys_small_btn_more'])?>
......
......@@ -30,9 +30,9 @@ $cases = CoContent::find()->where([
<span class="others_project__subtitle"><?=$model->lang->title?></span>
<p class="others_project__txt"><?=$model->lang->text?></p>
<a href="<?=Url::to(['/' . $model->url])?>" class="others_project__bt">Подробнее</a>
<a href="<?=Url::to(['/case'])?>" class="others_project__link">Все проекты (<?=$cases->count();?>)</a>
<a href="<?=Url::to(['/portfolio'])?>" class="others_project__link">Все проекты (<?=$cases->count();?>)</a>
</div>
<img src="<?=CoContent::PHOTO_FOLDER . $model->preview?>" height="476" width="489">
<img src="<?=$model->preview?>" height="476" width="489">
</div>
<?php endforeach; ?>
......
......@@ -21,7 +21,7 @@ $reviews = Reviews::find()
<?php if($review->photo) : ?>
<div class="col-md-3 col-xs-4 col-sm-12">
<div class="rev_img">
<img src="<?=Reviews::PHOTO_FOLDER . $review->photo?>">
<img src="<?=$review->photo?>">
</div>
</div>
<?php endif; ?>
......
......@@ -6,8 +6,8 @@
margin: 0;
}
.has-error input {
background: #fff url(../images/icon-fail.png) no-repeat 96% center;
border: 1px solid #E9A2A2;
background: #fff url(../images/icon-fail.png) no-repeat 96% center !important;
border: 1px solid #E9A2A2 !important;
}
/* EAuth widget */
.eauth-list .eauth-service-id-vk .eauth-service-link:before {
......@@ -56,4 +56,19 @@ a.login_form_link, a.login_form_popup_link, a.reg_popup_link, a.reg_form_link{
}
.sh_ft .popup_text, .reg_form .popup_text{
margin-top: 10px;
}
.subsc_form input {
display: block;
width: 273px;
height: 49px;
background: #FDFDFD;
border: 1px solid #E9E9E9;
padding: 0 10px;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
font-size: 16px;
color: #83999e;
}
\ No newline at end of file
This diff is collapsed.
......@@ -347,36 +347,41 @@ $(document).ready(function() {
}
});
});
// $(function () {
// window.validation.init({
// container: '.valid_form',
// });
// });
// $(function () {
// window.validation.init({
// container: '.footer_form',
// });
// });
// $(function () {
// window.validation.init({
// container: '.sect_cont_form',
// });
// });
// $(function () {
// window.validation.init({
// container: '.validreg_form',
// });
// });
// $(function () {
// window.validation.init({
// container: '.sh_reg_form',
// });
// });
// $(function () {
// window.validation.init({
// container: '.keys_mail_form',
// });
// });
$(function () {
window.validation.init({
container: '.valid_form',
});
});
$(function () {
window.validation.init({
container: '.footer_form',
});
});
$(function () {
window.validation.init({
container: '.subsc_form',
});
});
$(function () {
window.validation.init({
container: '.sect_cont_form',
});
});
$(function () {
window.validation.init({
container: '.validreg_form',
});
});
$(function () {
window.validation.init({
container: '.sh_reg_form',
});
});
$(function () {
window.validation.init({
container: '.keys_mail_form',
});
});
$(".toggle-mnu").click(function () {
$(".menu").toggleClass("menu_active");
});
......@@ -422,6 +427,22 @@ $(window).scroll(function() {
"transform" : "translate(0%, -" + st /13 + "%"
});
});
$(window).scroll(function() {
var st = $(this).scrollTop();
$(".appl_p1").css({
"transform" : "translate(0%, -" + st /6 + "%"
});
$(".appl_p2").css({
"transform" : "translate(0%, -" + st /3 + "%"
});
$(".appl_p3").css({
"transform" : "translate(0%, -" + st /8 + "%"
});
$(".appl_p4").css({
"transform" : "translate(0%, -" + st /3 + "%"
});
});
jQuery(function($){
$(document).mouseup(function (e){
var div = $(".d_menu_hide");
......@@ -564,178 +585,20 @@ $(function() {
});
});
$(function() {
$('.ball-link_testing').hover(function() {
if($('.ball_hover').is(':visible')) {
$('.ball_hover').removeClass('show_ball_hover');
}
else {
$('.ball_hover').addClass('show_ball_hover');
}
});
$('.ball-link_testing').hover(function() {
if($('.ball_hover').is(':visible')) {
$('.ball_hover').removeClass('show_ball_hover');
}
else {
$('.ball_hover').addClass('show_ball_hover');
}
});
});
jQuery(document).ready(function(){
$(".box_off").on('click', function () {
$(this).parent().toggleClass("box_off_hide");
});
});
// prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
// other available options:
url: '/users/user/registration', // override for form's 'action' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response type)
};
var optionsPopup = {
beforeSubmit: showRequest, // pre-submit callback
success: showResponsePopup, // post-submit callback
// other available options:
url: '/users/user/registration', // override for form's 'action' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response type)
};
var optionsLogin = {
beforeSubmit: showRequest, // pre-submit callback
success: showResponseLogin, // post-submit callback
// other available options:
url: '/site/login', // override for form's 'action' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response type)
};
var optionsLoginPopup = {
beforeSubmit: showRequest, // pre-submit callback
success: showResponseLoginPopup, // post-submit callback
// other available options:
url: '/site/login', // override for form's 'action' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response type)
};
// bind to the form's submit event
$('#login_form_popup').submit(function() {
$(this).ajaxSubmit(optionsLoginPopup);
return false;
});
// bind to the form's submit event
$('#login_form').submit(function() {
$('.errors_login').html('');
$(this).ajaxSubmit(optionsLogin);
return false;
});
// bind to the form's submit event
$('#sh_reg_form').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
// bind to the form's submit event
$('#reg_form_popup').submit(function() {
$(this).ajaxSubmit(optionsPopup);
return false;
});
$(".submit_form_reg").on('click', function () {
$('#sh_reg_form').ajaxSubmit(options);
return false;
});
$(".submit_form_reg_popup").on('click', function () {
$('#reg_form_popup').ajaxSubmit(optionsPopup);
return false;
});
$(".submit_form_login_popup").on('click', function () {
$('#login_form_popup').ajaxSubmit(optionsLoginPopup);
return false;
});
$(".submit_form_login").on('click', function () {
$('#login_form').ajaxSubmit(optionsLogin);
return false;
});
$(".login_form_link").on('click', function () {
$('#login_form').show();
$('#sh_reg_form').hide();
});
$(".login_form_popup_link").on('click', function () {
$('#login_form_popup').show();
$('#reg_form_popup').hide();
});
$(".reg_popup_link").on('click', function () {
$('#reg_form_popup').show();
$('#login_form_popup').hide();
});
$(".reg_form_link").on('click', function () {
$('#sh_reg_form').show();
$('#login_form').hide();
});
});
// pre-submit callback
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
return true;
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
$('.errors-reg').html('');
if (responseText.errors){
$.each(responseText.errors, function(key,value) {
$('.errors-reg').append(value+'<br>');
$('#sh_reg_form .field-user-'+key).addClass('has-error');
});
}
else{
$('#sh_reg_form').html('<div class="alert alert-block alert-success">Регистрация успешно завершена. Вам отправлено письмо для активации аккаунта.</div>');
}
}
// post-submit callback
function showResponsePopup(responseText, statusText, xhr, $form) {
$('.errors-reg_popup').html('');
if (responseText.errors){
$.each(responseText.errors, function(key,value) {
$('.errors-reg_popup').append(value+'<br>');
$('#reg_form_popup .field-user-'+key).addClass('has-error');
});
}
else{
$('#sh_reg_form').html('<div class="alert alert-block alert-success">Регистрация успешно завершена. Вам отправлено письмо для активации аккаунта.</div>');
$('#reg_form_popup').html('<div class="alert alert-block alert-success">Регистрация успешно завершена. Вам отправлено письмо для активации аккаунта.</div>');
}
}
// post-submit callback
function showResponseLogin(responseText, statusText, xhr, $form) {
$('.errors_login').html('');
if (responseText.errors){
$.each(responseText.errors, function(key,value) {
$('.errors_login').append(value+'<br>');
$('#login_form .field-loginform-'+key).addClass('has-error');
});
}
}
// post-submit callback
function showResponseLoginPopup(responseText, statusText, xhr, $form) {
$('.errors_login_popup').html('');
if (responseText.errors){
$.each(responseText.errors, function(key,value) {
$('.errors_login_popup').append(value+'<br>');
$('#login_form_popup .field-loginform-'+key).addClass('has-error');
});
}
}
\ No newline at end of file
$(this).parent().toggleClass("box_off_hide");
});
});
\ No newline at end of file
This diff is collapsed.
/*
* CSS Styles that are needed by jScrollPane for it to operate correctly.
*
* Include this stylesheet in your site or copy and paste the styles below into your stylesheet - jScrollPane
* may not operate correctly without them.
*/
.jspContainer
{
overflow: hidden;
position: relative;
}
.jspPane
{
position: absolute;
}
.jspVerticalBar
{
position: absolute;
top: 0;
right: 0;
width: 6px;
height: 100%;
background:#E7E9E8;
border-radius:3px;
}
.jspHorizontalBar
{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 5px;
}
.jspVerticalBar *,
.jspHorizontalBar *
{
margin: 0;
padding: 0;
}
.jspCap
{
display: none;
}
.jspHorizontalBar .jspCap
{
float: left;
}
.jspTrack
{
background: #E7E9E8;
position: relative;
border-radius:3px;
}
.jspDrag
{
background: #262E38;
position: relative;
top: 0;
left: 0;
cursor: pointer;
}
.jspHorizontalBar .jspTrack,
.jspHorizontalBar .jspDrag
{
float: left;
height: 100%;
}
.jspArrow
{
background: #50506d;
text-indent: -20000px;
display: block;
cursor: pointer;
}
.jspArrow.jspDisabled
{
cursor: default;
background: #80808d;
}
.jspVerticalBar .jspArrow
{
height: 16px;
}
.jspHorizontalBar .jspArrow
{
width: 16px;
float: left;
height: 100%;
}
.jspVerticalBar .jspArrow:focus
{
outline: none;
}
.jspCorner
{
background: #eeeef4;
float: left;
height: 100%;
}
/* Yuk! CSS Hack for IE6 3 pixel bug :( */
* html .jspCorner
{
margin: 0 -3px 0 0;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment