|
1 | 1 | # jQuery Pimcore Toolbox Extensions |
2 | 2 |
|
3 | | -This Library provides all Extensions for the [PIMCORE Toolbox Bundle](https://github.com/dachcom-digital/pimcore-toolbox). |
| 3 | +We're providing some helpful Javascript Plugins to simplify your daily work with the ToolboxBundle. |
| 4 | +This Library provides all jQuery extensions for the [PIMCORE Toolbox Bundle](https://github.com/dachcom-digital/pimcore-toolbox). |
4 | 5 |
|
5 | 6 | ## Installation |
6 | 7 | ```bash |
7 | 8 | npm i jquery-pimcore-toolbox |
8 | 9 | ``` |
9 | 10 |
|
10 | | -*** |
11 | | - |
12 | | -We're providing some helpful Javascript Plugins to simplify your daily work with the ToolboxBundle. |
13 | | -Of course it's up to you to copy those files into your project and modify them as required. |
14 | | - |
15 | | -> Note: Make sure that jQuery has been initialized, before you load one of those toolbox extensions. |
16 | | -
|
17 | | -## Overview |
18 | | -- [Core Plugin](#core-plugin) |
19 | | -- [Google Maps Extension](#google-maps-extension) |
20 | | -- [Video Extension](#video-extension) |
21 | | -- [iFrame Extension](#iframe-extension) |
22 | | -- [Google Opt-Out Extension](#google-opt-out-link-extension) |
23 | | - |
24 | | -## Core Plugin |
25 | | -This Plugin will automatically register all toolbox extensions: |
26 | | - |
27 | | -### Enable Plugin |
28 | | - |
29 | | -```html |
30 | | -<script type="text/javascript" src="{{ asset('bundles/toolbox/js/frontend/plugins/jquery.tb.core.js') }}"></script> |
31 | | -``` |
32 | | - |
33 | | -```javascript |
34 | | -$(function () { |
35 | | - $.toolboxCore({}); |
36 | | -}); |
37 | | -``` |
38 | | - |
39 | | -### Extended Usage |
40 | | -```javascript |
41 | | -$(function () { |
42 | | - $.toolboxCore({ |
43 | | - editmode: false, |
44 | | - theme: 'bootstrap4', |
45 | | - googleMapsHandler: { |
46 | | - enabled: true, |
47 | | - selector: '.toolbox-googlemap', |
48 | | - config: { |
49 | | - centerMapOnResize: true |
50 | | - } |
51 | | - }, |
52 | | - videoHandler: { |
53 | | - enabled: true, |
54 | | - config: { |
55 | | - videoIdExtractor: { |
56 | | - custom: function (videoId) { |
57 | | - console.log(videoId); |
58 | | - return videoId; |
59 | | - } |
60 | | - }, |
61 | | - apiParameter: { |
62 | | - youtube: { |
63 | | - rel: 0 //disable related videos |
64 | | - }, |
65 | | - vimeo: {} |
66 | | - } |
67 | | - } |
68 | | - }, |
69 | | - iframeHandler: { |
70 | | - enabled: true, |
71 | | - config: { |
72 | | - } |
73 | | - } |
74 | | - }); |
75 | | -}); |
76 | | -``` |
77 | | - |
78 | | -## Google Maps Extension |
79 | | -This Extension will enable the google maps rendering. |
80 | | -If you're using the `toolboxCore` instance, you only need to include the javascript file: |
81 | | - |
82 | | -### Enable Extension |
83 | | -```html |
84 | | -<script type="text/javascript" src="{{ asset('bundles/toolbox/js/frontend/plugins/jquery.tb.ext.google-maps.js') }}"></script> |
85 | | -``` |
86 | | - |
87 | | -Single Call (after new elements have been dynamically added for example) |
88 | | -```javascript |
89 | | -$(function () { |
90 | | - $('.toolbox-googlemap').toolboxGoogleMaps({}); |
91 | | -}); |
92 | | -``` |
93 | | - |
94 | | -### Extended Usage |
95 | | -```javascript |
96 | | -$(function () { |
97 | | - $.toolboxGoogleMaps({ |
98 | | - centerMapOnResize: true, |
99 | | - theme: 'bootstrap4' |
100 | | - }); |
101 | | -}); |
102 | | -``` |
103 | | - |
104 | | -### Options |
105 | | --- |
106 | | - |
107 | | -## Video Extension |
108 | | -This Extension will enable the video rendering. |
109 | | -If you're using the `toolboxCore` instance, you only need to include the javascript file: |
110 | | - |
111 | | -### Enable Extension |
112 | | -```html |
113 | | -<script type="text/javascript" src="{{ asset('bundles/toolbox/js/frontend/plugins/jquery.tb.ext.video.js') }}"></script> |
114 | | -``` |
115 | | - |
116 | | -Single Call (after new elements have been dynamically added for example) |
117 | | - |
118 | | -```javascript |
119 | | -$(function () { |
120 | | - $('.toolbox-video').toolboxVideo({}); |
121 | | -}); |
122 | | -``` |
123 | | - |
124 | | -### Extended Usage |
125 | | -```javascript |
126 | | -$(function () { |
127 | | - $.toolboxVideo({ |
128 | | - theme: 'bootstrap4', |
129 | | - videoIdExtractor: { |
130 | | - custom: function (videoId) { |
131 | | - console.log(videoId); |
132 | | - return videoId; |
133 | | - } |
134 | | - }, |
135 | | - resources: { |
136 | | - youtube: 'https://www.youtube.com/iframe_api', |
137 | | - vimeo: 'https://player.vimeo.com/api/player.js', |
138 | | - }, |
139 | | - apiParameter: { |
140 | | - youtube: { |
141 | | - rel: 0 //disable related videos |
142 | | - }, |
143 | | - vimeo: {} |
144 | | - } |
145 | | - }); |
146 | | -}); |
147 | | -``` |
148 | | - |
149 | | -### Video Extended I: Open Video in a Light Box |
150 | | -If you have selected the Light Box option, you need to take care about the video by yourself: |
151 | | - |
152 | | -```javascript |
153 | | -$('.toolbox-video') |
154 | | - .on('toolbox.video.youtube.lightbox', function (ev, params) { |
155 | | - // implement your own openVideo() function somewhere. |
156 | | - openVideo('https://youtube.com/watch?v=' + params.videoId); |
157 | | - }) |
158 | | - .on('toolbox.video.vimeo.lightbox', function (ev, params) { |
159 | | - // implement your own openVideo() function somewhere. |
160 | | - openVideo('https://vimeo.com/' + params.videoId); |
161 | | - }); |
162 | | -``` |
163 | | - |
| 11 | +## Extensions Overview |
| 12 | +- [Core Plugin](./docs/01_core.md) |
| 13 | +- [Google Maps Extension](./docs/02_googleMaps.md) |
| 14 | +- [Video Extension](./docs/03_video.md) |
| 15 | +- [iFrame Extension](./docs/04_iframe.md) |
| 16 | +- [Google Opt-Out Extension](./docs/05_googleOptOut.md) |
164 | 17 |
|
165 | | -### Video Extended II: Use Pimcore Assets as Video |
166 | | -If you're using pimcore video assets, you need to provide your own player api. |
167 | | -Pimcore will render a default html5 video tag in frontend. |
168 | | - |
169 | | -If you want to add the autoplay function, you need to add a play and pause event: |
170 | | - |
171 | | -```javascript |
172 | | -$('.toolbox-video[data-type="asset"]') |
173 | | - .on('toolbox.video.asset.play', function (ev, params) { |
174 | | - // hit the play button of your html5 video. |
175 | | - // this is also the place where to trigger the play state for your custom framework (video.js for example) |
176 | | - console.log($(this).find('video')) |
177 | | - $(this).find('video').get(0).play(); |
178 | | - }) |
179 | | - .on('toolbox.video.asset.pause', function (ev, params) { |
180 | | - // hit the pause button of your html5 video. |
181 | | - $(this).find('video').get(0).pause(); |
182 | | - }); |
183 | | -``` |
184 | | - |
185 | | -### Video Extended III: Use a custom player engine |
186 | | -If you have a different engine, you need to do some further work. |
187 | | - |
188 | | -#### Add some markup |
189 | | -```twig |
190 | | -<div class="col-12"> |
191 | | - <div class="toolbox-element toolbox-video" data-type="custom"> |
192 | | - <div class="video-inner"> |
193 | | - <div class="player" data-play-in-lightbox="false" data-video-uri="Ue80bTM1vmc"></div> |
194 | | - </div> |
195 | | - </div> |
196 | | -</div> |
197 | | -``` |
198 | | - |
199 | | -#### Initialize Player |
200 | | -```javascript |
201 | | -$(function () { |
202 | | - $.toolboxVideo({ |
203 | | - theme: 'bootstrap4', |
204 | | - videoIdExtractor: { |
205 | | - custom: function (videoId) { |
206 | | - // parse your video id |
207 | | - console.log(videoId); |
208 | | - return videoId; |
209 | | - } |
210 | | - } |
211 | | - }); |
212 | | -}); |
213 | | -``` |
214 | | - |
215 | | -### Add a Setup Listener |
216 | | -``` |
217 | | -$('.toolbox-video[data-type="custom"]') |
218 | | - .on('toolbox.video.custom.setup', function (ev, videoClass) { |
219 | | - // setup your element |
220 | | - console.log(videoClass); |
221 | | - }); |
222 | | -``` |
223 | | - |
224 | | -## iFrame Extension |
225 | | -This Extension will enable the iFrame rendering. |
226 | | -We can't provide any out-of-the-box solution for changing the iframe height dynamically (cross-domain policy), so you need to take care about that by yourself. |
227 | | - |
228 | | -If you're using the `toolboxCore` instance, you only need to include the javascript file: |
229 | | - |
230 | | -### Enable Extension |
231 | | -```html |
232 | | -<script type="text/javascript" src="{{ asset('bundles/toolbox/js/frontend/plugins/jquery.tb.ext.iframe.js') }}"></script> |
233 | | -``` |
234 | | - |
235 | | -### Single Call |
236 | | -```javascript |
237 | | -$(function () { |
238 | | - $('.toolbox-iframe').toolboxIframe({}); |
239 | | -}); |
240 | | -``` |
241 | | - |
242 | | -### Events |
243 | | -There are two events available: |
244 | | - |
245 | | -#### Event toolbox.iframe.load |
246 | | - |
247 | | -```javascript |
248 | | -$('.toolbox-iframe').on('toolbox.iframe.load', function(ev) { |
249 | | - console.log($(this), ev); |
250 | | -}) |
251 | | -``` |
252 | | - |
253 | | -#### Event toolbox.iframe.loaded |
254 | | - |
255 | | -```javascript |
256 | | -$('.toolbox-iframe').on('toolbox.iframe.loaded', function(ev) { |
257 | | - console.log($(this), ev); |
258 | | - // use the iframe-resizer plugin for example |
259 | | - // @see https://github.com/davidjbradshaw/iframe-resizer |
260 | | - // $(this).find('iframe').iFrameResize( [{options}] ); |
261 | | -}) |
262 | | -``` |
263 | | - |
264 | | -## Google Opt-Out Link Extension |
265 | | -This Extension searches for google opt-out links. |
266 | | -By clicking on a link with the class `a.google-opt-out-link` a cookie will be stored to prevent future analytic tracking. |
267 | | - |
268 | | -If you're using the `toolboxCore` instance, you only need to include the javascript file: |
269 | | - |
270 | | -### Enable Extension |
271 | | -```html |
272 | | -<script type="text/javascript" src="{{ asset('bundles/toolbox/js/frontend/plugins/jquery.tb.ext.googleOptOutLink.js') }}"></script> |
273 | | -``` |
274 | | - |
275 | | -### Single Call |
276 | | -```javascript |
277 | | -$(function () { |
278 | | - $('a.google-opt-out-link').toolboxGoogleOptOutLink({}); |
279 | | -}); |
280 | | -``` |
281 | | - |
282 | | -### Extended Usage |
283 | | -```javascript |
284 | | -$(function () { |
285 | | - $('a.google-opt-out-link').toolboxGoogleOptOutLink({ |
286 | | - notify: function(message) { |
287 | | - // implement your message style here |
288 | | - console.log(message); |
289 | | - } |
290 | | - }); |
291 | | -}); |
292 | | -``` |
0 commit comments