1 | <?php |
||
19 | class Fotorama extends Widget |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Choose fotorama version from CDNJS |
||
24 | * true - use current version from CDN |
||
25 | * '4.5.0' - use custom version |
||
26 | * |
||
27 | * @var bool | string |
||
28 | */ |
||
29 | public static $useCDN = false; |
||
30 | |||
31 | /** |
||
32 | * Current Fotorama widget version |
||
33 | */ |
||
34 | const VERSION = '4.6.3'; |
||
35 | |||
36 | /** |
||
37 | * Widget options |
||
38 | * |
||
39 | * ```php |
||
40 | * 'options' => [ |
||
41 | * 'width' => '50%', // Number or String. Stage container width in pixels or percents. |
||
42 | * 'minwidth' => '40%', // Number or String. Stage container minimum width in pixels or percents. |
||
43 | * 'maxwidth' => 300, // Number or String. Stage container maximum width in pixels or percents. |
||
44 | * 'height' => 500, // Number or String. Stage container height in pixels or percents. |
||
45 | * 'minheight' => '500px', // Number or String. Stage container minimum height in pixels or percents. |
||
46 | * 'maxheight' => '100px', // Number or String. Stage container maximum height in pixels or percents. |
||
47 | * 'ratio' => 800/600, // Number or String. Width divided by height. Recommended if you’re using percentage width. |
||
48 | * 'margin' => 10, // Number. Horizontal margins for frames in pixels. |
||
49 | * 'glimpse' => '100px', // Number or String. Glimpse size of nearby frames in pixels or percents. |
||
50 | * 'nav' => 'thumbs', // Boolean or String. Navigation style: 'dots' (iPhone-style dots), 'thumbs' (Thumbnails), false (Nothing) |
||
51 | * 'navposition' => 'bottom', // String. Navigation block position relative to stage: 'bottom' or 'top'. |
||
52 | * 'thumbwidth' => 100, // Number. Tumbnail width in pixels. |
||
53 | * 'thumbheight' => 100, // Number. Tumbnail height in pixels. |
||
54 | * 'thumbmargin' => 10, // Number. Size of thumbnail margins. |
||
55 | * 'thumbborderwidth' => 5, // Number. Border width of the active thumbnail. |
||
56 | * 'allowfullscreen' => true, // Boolean or String. Allows fullscreen: false (Default), true, 'native' |
||
57 | * 'fit' => 'cover', // String. How to fit an image into a fotorama: 'contain' (Default), 'cover', 'scaledown', 'none' |
||
58 | * 'transition' => 'slide', // String. Defines what transition to use: 'slide' (Default), 'crossfade', 'dissolve' |
||
59 | * 'transitionduration' => 3000, // Number. Animation length in milliseconds. |
||
60 | * 'captions' => true, // Boolean. Captions visibility. |
||
61 | * 'hash' => false, // Boolean. Hash in urls |
||
62 | * 'startindex' => 3, // Number or String. Index or id of the frame that will be shown upon initialization of the fotorama. |
||
63 | * 'loop' => true, // Boolean. Enables loop. |
||
64 | * 'autoplay' => true, // Boolean or Number. Enables slideshow. Turn it on with true or any interval in milliseconds. |
||
65 | * 'stopautoplayontouch' => '', // Boolean. Stops slideshow at any user action with the fotorama. |
||
66 | * 'keyboard' => true, // Boolean. Enables keyboard navigation. |
||
67 | * 'arrows' => true, // Boolean. Turns on navigation arrows over the frames. |
||
68 | * 'click' => true, // Boolean. Moving between frames by clicking. |
||
69 | * 'swipe' => true, // Boolean. Moving between frames by swiping. |
||
70 | * 'trackpad' => true, // Boolean. Enables trackpad support and horizontal mouse wheel as well. |
||
71 | * 'shuffle' => true, // Boolean. Shuffles frames at launch. |
||
72 | * 'direction' => 'ltr', // String. Sets the frames direction: 'ltr' or 'rtl'. |
||
73 | * 'shadows' => true, // Boolean. Enables shadows. |
||
74 | * ], |
||
75 | * ``` |
||
76 | * |
||
77 | * @var array {@link http://fotorama.io/customize/ Fotorama options} |
||
78 | */ |
||
79 | public $options = []; |
||
80 | |||
81 | /** |
||
82 | * Add items as js objects |
||
83 | * |
||
84 | * ```php |
||
85 | * 'items' => [ |
||
86 | * [ |
||
87 | * 'img' => '1.jpg', |
||
88 | * 'thumb' => '1-thumb.jpg', |
||
89 | * 'full' => '1-full.jpg', // Separate image for the fullscreen mode. |
||
90 | * 'video' => 'http://youtu.be/C3lWwBslWqg', // Youtube, Vimeo or custom iframe URL |
||
91 | * 'id' => 'one', // Custom anchor is used with the hash:true option. |
||
92 | * 'caption' => 'The item caption', |
||
93 | * 'html' => new \yii\web\JsExpression('jQuery("selector")'), // ...or '<div>123</div>'. Custom HTML inside the frame. |
||
94 | * 'fit' => 'cover', // Override the global fit option. |
||
95 | * 'any' => 'Any data relative to the frame you want to store', |
||
96 | * ], |
||
97 | * ], |
||
98 | * ``` |
||
99 | * |
||
100 | * @var array {@link http://fotorama.io/customize/initialization/#frame-object item options} |
||
101 | */ |
||
102 | public $items = []; |
||
103 | |||
104 | /** |
||
105 | * Loader (spinner) object config |
||
106 | * |
||
107 | * ```php |
||
108 | * 'spinner' => [ |
||
109 | * 'lines' => 13, // The number of lines to draw |
||
110 | * 'length' => 20, // The length of each line |
||
111 | * 'width' => 10, // The line thickness |
||
112 | * 'radius' => 30, // The radius of the inner circle |
||
113 | * 'corners' => 1, // Corner roundness (0..1) |
||
114 | * 'rotate' => 0, // The rotation offset |
||
115 | * 'direction' => 1, // 1: clockwise, -1: counterclockwise |
||
116 | * 'color' => '#000', // #rgb or #rrggbb or array of colors |
||
117 | * 'speed' => 1, // Rounds per second |
||
118 | * 'trail' => 60, // Afterglow percentage |
||
119 | * 'shadow' => false, // Whether to render a shadow |
||
120 | * 'hwaccel' => false, // Whether to use hardware acceleration |
||
121 | * 'zIndex' => 1000, // The z-index (defaults to 2000000000) |
||
122 | * 'top' => '50%', // Top position relative to parent |
||
123 | * 'left' => '50%' // Left position relative to parent |
||
124 | * ], |
||
125 | * ``` |
||
126 | * |
||
127 | * @var array {@link http://fgnass.github.io/spin.js/ spin.js options} |
||
128 | */ |
||
129 | public $spinner = []; |
||
130 | |||
131 | /** |
||
132 | * Using of html data-params, if false - js object initialization |
||
133 | * |
||
134 | * @var bool |
||
135 | */ |
||
136 | public $useHtmlData = true; |
||
137 | |||
138 | /** |
||
139 | * Container tag name |
||
140 | * |
||
141 | * @var string |
||
142 | */ |
||
143 | public $tagName = 'div'; |
||
144 | |||
145 | /** |
||
146 | * Html options of the container tag |
||
147 | * |
||
148 | * @var array |
||
149 | */ |
||
150 | public $htmlOptions = []; |
||
151 | |||
152 | /** |
||
153 | * Setup default Fotorama widget options |
||
154 | * {@link http://fotorama.io/customize/options/#defaults} |
||
155 | * |
||
156 | * @param array $options |
||
157 | */ |
||
158 | public static function setDefaults($options = []) |
||
167 | |||
168 | /** |
||
169 | * Initializes the widget. |
||
170 | * This renders the open tag. |
||
171 | */ |
||
172 | public function init() |
||
206 | |||
207 | /** |
||
208 | * Runs the widget. |
||
209 | * This registers the necessary javascript code and renders the close tag. |
||
210 | */ |
||
211 | public function run() |
||
219 | |||
220 | /** |
||
221 | * @param int $position |
||
222 | * @param null $key |
||
223 | */ |
||
224 | public function registerJs($position = View::POS_READY, $key = null) |
||
237 | } |
||
238 |