| 1 |
<?php |
| 2 |
|
| 3 |
class Meow_MGL_Builders_Justified extends Meow_MGL_Builders_Core { |
| 4 |
|
| 5 |
public function __construct( $atts, $infinite, $isPreview = false ) { |
| 6 |
parent::__construct( $atts, $infinite, $isPreview ); |
| 7 |
$this->layout = 'justified'; |
| 8 |
} |
| 9 |
|
| 10 |
function inline_css() { |
| 11 |
$class_id = '#' . $this->class_id; |
| 12 |
$gutter = isset( $this->atts['gutter'] ) ? |
| 13 |
$this->atts['gutter'] : Meow_MGL_Core::get_plugin_option( 'justified_gutter', 10 ); |
| 14 |
$isPreview = $this->isPreview; |
| 15 |
ob_start(); |
| 16 |
include dirname( __FILE__ ) . '/justified.css.php'; |
| 17 |
$html = ob_get_clean(); |
| 18 |
return $html; |
| 19 |
} |
| 20 |
|
| 21 |
function build_next_cell( $id, $data ) { |
| 22 |
$html = parent::build_next_cell( $id, $data ); |
| 23 |
$style_vars = '--w: ' . $data['meta']['width'] . '; --h: ' . $data['meta']['height']; |
| 24 |
$html = str_replace( 'class="mgl-item"', 'class="mgl-item" style="' . $style_vars . '"', $html ); |
| 25 |
return $html; |
| 26 |
} |
| 27 |
|
| 28 |
function build_styles() { |
| 29 |
$row_height = isset( $this->atts['row-height'] ) ? |
| 30 |
$this->atts['row-height'] : Meow_MGL_Core::get_plugin_option( 'justified_row_height', 200 ); |
| 31 |
$styles = '--rh: ' . $row_height . 'px'; |
| 32 |
return $styles; |
| 33 |
} |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
?> |
| 38 |
|