Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
4df28556
Commit
4df28556
authored
Jun 21, 2016
by
andre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
новая верстка блога
parent
fab9fc75
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
78 deletions
+32
-78
common/modules/blog/assets/src/js/generator.js
common/modules/blog/assets/src/js/generator.js
+2
-76
common/modules/blog/controllers/PostController.php
common/modules/blog/controllers/PostController.php
+29
-1
common/modules/blog/views/post/_sidebar.php
common/modules/blog/views/post/_sidebar.php
+1
-1
No files found.
common/modules/blog/assets/src/js/generator.js
View file @
4df28556
/**
* 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.bids-form
'
).
on
(
'
click
'
,
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
;
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
})
\ No newline at end of file
common/modules/blog/controllers/PostController.php
View file @
4df28556
...
...
@@ -26,6 +26,7 @@ class PostController extends BaseController
'Tag'
=>
'Просмотр тега'
,
'View'
=>
'Просмотр записи'
,
'Send-article'
=>
'Послать статью'
,
'Set-cookie'
=>
'Установить куки'
,
];
}
...
...
@@ -187,4 +188,31 @@ class PostController extends BaseController
throw
new
NotFoundHttpException
(
'The requested page does not exist.'
);
}
}
/**
* Запишет или удалит хэштэг в куки
* используется на странице блога в списке категорий, для отбора статей по хэштегам
*/
public
function
actionSetCookie
(
$hashtag
)
{
$session
=
Yii
::
$app
->
session
;
if
(
$session
->
isActive
)
{
$cookie
=
$session
->
get
(
'blog_hashtag'
);
$cookie
=
$cookie
?
$cookie
:
[];
$key
=
array_search
(
$hashtag
,
$cookie
);
if
(
$key
!==
false
)
{
unset
(
$cookie
[
$key
]);
}
else
{
$cookie
[]
=
$hashtag
;
}
$session
->
set
(
'blog_hashtag'
,
$cookie
);
}
return
true
;
}
}
common/modules/blog/views/post/_sidebar.php
View file @
4df28556
...
...
@@ -30,7 +30,7 @@ use common\modules\languages\models\Languages;
<div
class=
"categories_form"
>
<form>
<?php
foreach
(
$tags
as
$tag
)
:
?>
<input
type=
"checkbox"
class=
"checkbox_btn"
id=
"checkbox-
<?=
$tag
->
id
?>
"
>
<input
action=
"
<?=
\yii\helpers\Url
::
to
([
"/blog/post/set-cookie"
,
"hashtag"
=>
$tag
->
name
])
?>
"
type=
"checkbox"
class=
"checkbox_btn"
id=
"checkbox-
<?=
$tag
->
id
?>
"
>
<label
for=
"checkbox-
<?=
$tag
->
id
?>
"
>
<?=
$tag
->
name
?>
</label>
<?php
endforeach
;
?>
</form>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment