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
e927ed67
Commit
e927ed67
authored
Mar 12, 2016
by
Шакарим Сапа
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Добавлено условие на скроллинг
parent
ca21f134
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
+95
-0
common/modules/triggers/components/conditions/conditions/CheckScrolling.php
...ggers/components/conditions/conditions/CheckScrolling.php
+95
-0
No files found.
common/modules/triggers/components/conditions/conditions/CheckScrolling.php
0 → 100644
View file @
e927ed67
<?php
/**
* Created by PhpStorm.
* User: PHOENIX
* Date: 18.02.16
* Time: 17:07
*/
namespace
common\modules\triggers\components\conditions\conditions
;
use
common\modules\messageTemplate\components\Templates
;
use
common\modules\messageTemplate\models\MessageTemplate
;
use
common\modules\triggers\components\conditions\vendor\ConditionBase
;
use
common\modules\triggers\components\conditions\vendor\ConditionInterface
;
use
common\modules\triggers\models\TriggerCondition
;
use
common\modules\triggers\models\TriggerParam
;
use
common\modules\triggers\models\TriggerSchedule
;
use
common\modules\triggers\models\TriggerTrigger
;
use
yii\web\BadRequestHttpException
;
class
CheckScrolling
extends
ConditionBase
implements
ConditionInterface
{
const
CONDITION_ID
=
9
;
public
$name
=
'Скроллинг страницы'
;
public
$params
=
[];
/**
* @param null|string $conditionName
* @return $this mixed
*/
public
static
function
init
(
$conditionName
=
__CLASS__
){
return
parent
::
init
(
$conditionName
);
}
public
function
initScript
(){
// Получили список всех активных (актуальных) триггеров
/** @var TriggerTrigger[] $actualTriggers */
$actualTriggers
=
TriggerTrigger
::
getActualTriggers
(
self
::
CONDITION_ID
);
// Перебираем их в цикле
foreach
(
$actualTriggers
as
$trigger
)
{
// Получили условия триггера на итерации
$conditions
=
TriggerCondition
::
find
()
->
where
([
'trigger_id'
=>
$trigger
->
getPrimaryKey
()])
->
all
();
// Перебираем все условия триггера на итерации
foreach
(
$conditions
as
$condition
)
{
// Пытаемся получить параметр URL в условии
/** @var TriggerParam $paramUrl */
$paramUrl
=
TriggerParam
::
find
()
->
where
([
'condition_id'
=>
$condition
->
getPrimaryKey
(),
'key'
=>
'url'
])
->
one
();
// Пытаемся получить параметр процента на условии
$paramPercent
=
TriggerParam
::
find
()
->
where
([
'condition_id'
=>
$condition
->
getPrimaryKey
(),
'key'
=>
'percent'
])
->
one
();
// Если сработали условия что триггер есть, у него указаны время и URL и при этом он является триггером ДАННОГО типа
echo
(
$paramUrl
!==
null
)
?
'1'
:
'0'
;
if
(
$condition
->
condition_id
==
self
::
CONDITION_ID
&&
$paramUrl
!==
null
&&
$paramUrl
->
value
==
\Yii
::
$app
->
request
->
getUrl
()
&&
$paramPercent
!==
null
&&
!
\Yii
::
$app
->
user
->
isGuest
)
{
$view
=
\Yii
::
$app
->
controller
->
view
;
// Создаем скрипт
$script
=
'var initiated = false; $(document).scroll(function() {
var percent='
.
((
int
)
$paramPercent
->
value
)
.
';
var percent_value = ($(document).height()/100)*percent;
if ($(document).scrollTop()>=percent_value && initiated==false) {
$.ajax({
url: "/triggers/default/inittrigger",
method: "GET",
async: false,
data: {
id: '
.
$trigger
->
getPrimaryKey
()
.
'
},
});
initiated=true;
}
});'
;
// Регистрируем его
$view
->
registerJs
(
$script
,
$view
::
POS_READY
);
}
}
}
}
/**
* @param $time
* @return bool
*/
public
function
check
(
$time
){
return
false
;
}
}
\ No newline at end of file
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