PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Options / Loading.php

Loading.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Options/Loading.php

100 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Options;
3
4
5 use Averta\WordPress\File\FileSystem;
6 use Depicter\Document\CSS\Selector;
7 use Depicter\Html\Html;
8
9 class Loading
10 {
11 /**
12 * @var object
13 */
14 public $lazyload;
15
16 /**
17 * @var string
18 */
19 public $loadingSymbol = 'dotFlashing-dark';
20
21 /**
22 * @var bool
23 */
24 public $initAfterAppear;
25
26 /**
27 * get html of loading symbol
28 * @return \TypeRocket\Html\Html
29 */
30 public function render() {
31
32 // loadingSymbol consist of two part , the symbolID and dark or light mode
33 $loadingSymbol = explode( '-', $this->loadingSymbol );
34 $loadingMarkup = '';
35 $loadingPath = DEPICTER_PLUGIN_PATH . '/resources/scripts/loadings/snippets/'.$loadingSymbol[0].'/'.$loadingSymbol[1].'.html';
36
37 if ( in_array( $loadingSymbol[0], $this->loadingsList() ) && is_file( $loadingPath ) ) {
38 $loadingMarkup = \Depicter::storage()->filesystem()->read( $loadingPath );
39 }
40
41 return Html::div(
42 [
43 'class' => Selector::prefixify('loading-container') . ' ' . Selector::prefixify('loading ' . $this->loadingSymbol ),
44 ],
45 $loadingMarkup
46 );
47 }
48
49 /**
50 * Get preload value
51 *
52 * @return false|string
53 */
54 public function getValue() {
55 $type = $this->lazyload->type ?? 'sequential';
56
57 switch ( $type ):
58 case 'nearby':
59 return $this->lazyload->nearbyNum ?? 1;
60 break;
61 case 'sequential':
62 return 0;
63 break;
64 case 'all':
65 return 'all';
66 break;
67 default:
68 return false;
69 break;
70 endswitch;
71
72 }
73
74 /**
75 * The list of valid loading symbol names
76 *
77 * @return array
78 */
79 public function loadingsList() {
80 return [
81 'audio',
82 'ballTriangle',
83 'bars',
84 'circles',
85 'dotFlashing',
86 'dotReplacing',
87 'dotStraightSwing',
88 'dotSwing',
89 'grid',
90 'hearts',
91 'oval',
92 'puff',
93 'rings',
94 'spinningCircles',
95 'tailSpin',
96 'threeDots'
97 ];
98 }
99 }
100