Commit fab9fc75 authored by andre's avatar andre

новая верстка блога

parent 4af81c37
/**
* Created by andre on 21.06.2016.
*/
$('form.bids-form').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, filebool = false, file, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
data.append("Bid[file]", file);
}
xhr.open("POST", form.attr('action'), true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
form.find('.has-error').removeClass('has-error');
if(response.success)
{
if(form.find('.message-box').length > 0)
{
form.find('.message-box').fadeIn('fast');
form.find('.content').css('visibility','hidden');
setTimeout(function(){
form.find('.message-box').fadeOut('fast');
form.find('.content').css('visibility','visible');
}, 2000);
}
form.find('input:not(.not_clear), textarea').val('');
form.find('#files-zone').html('');
$('.dz-preview.dz-processing').remove();
dataLayer.push({
'event': 'UA_event',
'Catagory': form.data('tag'),
'Action': form.data('title'),
'Label': 'Успешно'
});
}
else
{
errors = [];
$.each(response, function(key, value) {
form.find('.field-'+key).addClass('has-error');
errors = errors.concat(value);
});
dataLayer.push({
'event': 'UA_event',
'Catagory': 'Ошибки',
'Action': form.data('form'),
'Label': errors
});
}
}
}
}).on('submit', function(e){
return false;
});
\ No newline at end of file
......@@ -51,15 +51,6 @@ use common\modules\languages\models\Languages;
<!-- add 22.05.16 -->
</div>
<!-- <div class="sidebar_module">-->
<!-- <div class="sidebar_module_body">-->
<!-- <a href="#feedback" class="sidebar_btn popup-form">-->
<!-- --><?//=\Yii::t('blog', 'Offer a subject');?>
<!-- <div class="blog_toltip_right">--><?//=\Yii::t('blog', 'Offer a subject and we will publish about it')?><!--</div>-->
<!-- </a>-->
<!-- <a href="#article" class="sidebar_btn popup-form">--><?//=\Yii::t('blog', 'Send an article')?><!--</a>-->
<!-- </div>-->
<!-- </div>-->
</div>
<?php $posts = Post::find();
......
......@@ -49,6 +49,4 @@ $this->registerJs("initScrollPager()", yii\web\View::POS_END);
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
<?//=$this->render('@common/modules/blog/views/post/_sidebar_form.php');?>
<?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
......@@ -48,5 +48,3 @@ GeneratorAsset::register($this);
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
<?//=$this->render('@common/modules/blog/views/post/_sidebar_form.php');?>
......@@ -75,6 +75,4 @@ $('.article_short_txt').find('img').click(function() {
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
<?//=$this->render('@common/modules/blog/views/post/_sidebar_form.php');?>
<?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
......@@ -6,7 +6,7 @@ $('form.bids-form').on('beforeSubmit', function(e) {
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
......@@ -42,6 +42,7 @@ $('form.bids-form').on('beforeSubmit', function(e) {
setTimeout(function(){
form.find('.message-box').fadeOut('fast');
form.find('.content').css('visibility','visible');
form.closest(".mfp-content").find(".mfp-close").click()
}, 2000);
}
......
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