/
animate.php
executable file
·67 lines (53 loc) · 1.93 KB
/
animate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
*
* Flextype Animate Plugin
*
* @author Romanenko Sergey / Awilum <awilum@yandex.ru>
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use Flextype\Component\Event\Event;
//
// Add listner for onThemeHeader event
//
Event::addListener('onThemeHeader', function () {
echo(' <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">');
});
// Event: onShortcodesInitialized
Event::addListener('onShortcodesInitialized', function () {
// Shortcode: [animate]Text to animate[/animate]
Entries::shortcode()->addHandler('animate', function(ShortcodeInterface $s) {
if ($s->getParameter('inline') == 'yes') {
$tag = 'span';
} else {
$tag = 'div';
}
if (null !== $s->getParameter('duration')) {
$duration = $s->getParameter('duration');
} else {
$duration = 1;
}
if (null !== $s->getParameter('delay')) {
$delay = $s->getParameter('delay');
} else {
$delay = 0;
}
if (null !== $s->getParameter('type')) {
$type = $s->getParameter('type');
} else {
$type = 'bounceIn';
}
if (null !== $s->getParameter('class')) {
$class = $s->getParameter('class');
} else {
$class = '';
}
$time = '-webkit-animation-duration:' . $duration . 's;-webkit-animation-delay:' . $delay . 's;animation-duration:' . $duration . 's;animation-delay:' . $delay . 's;';
return '<'.$tag.' class="animated '.$type.' '.$class.'" style="' . $time . '" data-animation="' . $type . '" data-duration="' . $duration . '" data-delay="' . $delay . '">'.$s->getContent().'</'.$tag.'>';
});
});