... | ... |
@@ -64,7 +64,7 @@ class ContentGallery extends \Contao\ContentGallery |
64 | 64 |
|
65 | 65 |
// Inject scripts and css |
66 | 66 |
$GLOBALS['TL_JQUERY'][] = '<script src="/system/modules/eSM_justifiedGallery/assets/lib/justifiedGallery/' . $GLOBALS['TL_ASSETS']['JUSTIFIEDGALLERY'] . '/js/jquery.justifiedGallery.min.js"></script>'; |
67 |
- $GLOBALS['TL_JQUERY'][] = "<script>$('.".$strJgClass."').justifiedGallery(".json_encode($config).");</script>"; |
|
67 |
+ $GLOBALS['TL_JQUERY'][] = "<script>(function($) { $('.".$strJgClass."').justifiedGallery(".json_encode($config).");})(jQuery);</script>"; |
|
68 | 68 |
$GLOBALS['TL_CSS'][] = '/system/modules/eSM_justifiedGallery/assets/lib/justifiedGallery/' . $GLOBALS['TL_ASSETS']['JUSTIFIEDGALLERY'] . '/css/justifiedGallery.min.css'; |
69 | 69 |
$GLOBALS['TL_CSS'][] = '/system/modules/eSM_justifiedGallery/assets/css/justifiedGallery.ext.min.css'; |
70 | 70 |
} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,75 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * JustifiedGallery for Contao |
|
5 |
+ * |
|
6 |
+ * Copyright (c) 2016 Benjamin Roth |
|
7 |
+ * |
|
8 |
+ * @license LGPL-3.0+ |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+namespace eSM_justifiedGallery; |
|
12 |
+ |
|
13 |
+ |
|
14 |
+/** |
|
15 |
+ * Extends the core gallery class with justifiedGallery. |
|
16 |
+ */ |
|
17 |
+class ContentGallery extends \Contao\ContentGallery |
|
18 |
+{ |
|
19 |
+ public function generate() |
|
20 |
+ { |
|
21 |
+ |
|
22 |
+ if ($this->eSM_jg_enable) |
|
23 |
+ { |
|
24 |
+ // Overwrite gallery template |
|
25 |
+ $this->galleryTpl = 'gallery_justifiedGallery'; |
|
26 |
+ |
|
27 |
+ // justifiedGallery unique selector |
|
28 |
+ $strJgClass = 'justifiedGallery_' . $this->id; |
|
29 |
+ |
|
30 |
+ $arrCssID = $this->cssID; |
|
31 |
+ $arrClass = array(); |
|
32 |
+ if ($arrCssID[1]) |
|
33 |
+ { |
|
34 |
+ $arrClass = explode(' ', $arrCssID[1]); |
|
35 |
+ } |
|
36 |
+ $arrClass[] = $strJgClass; |
|
37 |
+ $this->cssID = array($arrCssID[0], implode(' ', $arrClass)); |
|
38 |
+ |
|
39 |
+ // justifiedGallery configuration |
|
40 |
+ $config = array |
|
41 |
+ ( |
|
42 |
+ 'selector' => '> figure', |
|
43 |
+ 'captions' => ($this->eSM_jg_captions ? true : false), |
|
44 |
+ 'fixedHeight' => ($this->eSM_jg_fixedHeight ? true : false), |
|
45 |
+ 'waitThumbnailsLoad' => ($this->eSM_jg_waitLoaded ? true : false), |
|
46 |
+ 'lastRow' => 'center' |
|
47 |
+ ); |
|
48 |
+ |
|
49 |
+ if ($this->eSM_jg_height) |
|
50 |
+ { |
|
51 |
+ $config['rowHeight'] = intval($this->eSM_jg_height); |
|
52 |
+ } |
|
53 |
+ |
|
54 |
+ $this->eSM_jg_maxHeight = deserialize($this->eSM_jg_maxHeight); |
|
55 |
+ if (isset($this->eSM_jg_maxHeight['value']) && $this->eSM_jg_maxHeight['value']) |
|
56 |
+ { |
|
57 |
+ $config['maxRowHeight'] = $this->eSM_jg_maxHeight['value'].($this->eSM_jg_maxHeight['unit'] == '%' ? '%' : ''); |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ if ($this->eSM_jg_margins) |
|
61 |
+ { |
|
62 |
+ $config['margins'] = intval($this->eSM_jg_margins); |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ // Inject scripts and css |
|
66 |
+ $GLOBALS['TL_JQUERY'][] = '<script src="/system/modules/eSM_justifiedGallery/assets/lib/justifiedGallery/' . $GLOBALS['TL_ASSETS']['JUSTIFIEDGALLERY'] . '/js/jquery.justifiedGallery.min.js"></script>'; |
|
67 |
+ $GLOBALS['TL_JQUERY'][] = "<script>$('.".$strJgClass."').justifiedGallery(".json_encode($config).");</script>"; |
|
68 |
+ $GLOBALS['TL_CSS'][] = '/system/modules/eSM_justifiedGallery/assets/lib/justifiedGallery/' . $GLOBALS['TL_ASSETS']['JUSTIFIEDGALLERY'] . '/css/justifiedGallery.min.css'; |
|
69 |
+ $GLOBALS['TL_CSS'][] = '/system/modules/eSM_justifiedGallery/assets/css/justifiedGallery.ext.min.css'; |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ return parent::generate(); |
|
73 |
+ } |
|
74 |
+ |
|
75 |
+} |