|
7 | 7 | if (typeof define === "function" && define.amd) { |
8 | 8 | define([ |
9 | 9 | "jquery", |
| 10 | + "pat-logger", |
10 | 11 | "pat-registry", |
11 | 12 | "pat-parser", |
12 | 13 | "pat-base", |
|
19 | 20 | } else { |
20 | 21 | factory(root.$, root.patterns, root.patterns.Parser, root.Base, root.Masonry, root.imagesLoaded); |
21 | 22 | } |
22 | | -}(this, function($, registry, Parser, Base, utils, Masonry, imagesLoaded) { |
| 23 | +}(this, function($, logger, registry, Parser, Base, utils, Masonry, imagesLoaded) { |
23 | 24 | "use strict"; |
| 25 | + var log = logger.getLogger("pat.masonry"); |
24 | 26 | var parser = new Parser("masonry"); |
25 | 27 | parser.addArgument("column-width"); |
26 | | - parser.addArgument("container-style", "{ position: 'relative' }"); |
| 28 | + parser.addArgument("container-style", '{ "position": "relative" }'); |
27 | 29 | parser.addArgument("gutter"); |
28 | 30 | parser.addArgument("hidden-style", "{ opacity: 0, transform: 'scale(0.001)' }"); |
29 | 31 | parser.addArgument("is-fit-width", false); |
|
50 | 52 | }, |
51 | 53 |
|
52 | 54 | initMasonry: function () { |
| 55 | + var containerStyle; |
| 56 | + try { |
| 57 | + containerStyle = JSON.parse(this.options.containerStyle); |
| 58 | + } catch (e) { |
| 59 | + containerStyle = { "position": "relative" }; |
| 60 | + log.warn( |
| 61 | + "Invalid value passed in as containerStyle. Needs to "+ |
| 62 | + "be valid JSON so that it can be converted to an object for Masonry." |
| 63 | + ); |
| 64 | + } |
53 | 65 | this.msnry = new Masonry(this.$el[0], { |
54 | 66 | columnWidth: this.getTypeCastedValue(this.options.columnWidth), |
55 | | - containerStyle: this.options.containerStyle, |
| 67 | + containerStyle: containerStyle, |
56 | 68 | gutter: this.getTypeCastedValue(this.options.gutter), |
57 | 69 | hiddenStyle: this.options.hiddenStyle, |
58 | 70 | isFitWidth: this.options.is["fit-width"], |
|
0 commit comments