| 1 |
<?php |
| 2 |
defined('ABSPATH') or die('No direct access permitted'); |
| 3 |
$blockClass["dimension"] = "dimensionBlock"; |
| 4 |
$blockOrder[20][] = "dimension"; |
| 5 |
|
| 6 |
class dimensionBlock extends maxBlock |
| 7 |
{ |
| 8 |
protected $blockname = "dimension"; |
| 9 |
protected $fields = array("button_width" => array("default" => '160px', |
| 10 |
"css" => "width", |
| 11 |
), |
| 12 |
"button_height" => array("default" => '50px', |
| 13 |
"css" => "height") |
| 14 |
); |
| 15 |
|
| 16 |
public function parse_css($css, $mode = 'normal') |
| 17 |
{ |
| 18 |
$css = parent::parse_css($css, $mode); |
| 19 |
|
| 20 |
if (! isset($css["maxbutton"]["normal"]["width"])) return $css; |
| 21 |
|
| 22 |
// do not allow zero's. |
| 23 |
if (isset($css["maxbutton"]["normal"]["width"]) && ($css["maxbutton"]["normal"]["width"] == 0 || $css["maxbutton"]["normal"]["width"] == '') ) |
| 24 |
unset($css["maxbutton"]["normal"]["width"]); |
| 25 |
|
| 26 |
if (isset($css["maxbutton"]["normal"]["height"]) && ($css["maxbutton"]["normal"]["height"] == 0 || $css["maxbutton"]["normal"]["height"] == '') ) |
| 27 |
unset($css["maxbutton"]["normal"]["height"]); |
| 28 |
|
| 29 |
|
| 30 |
/* if ($css["normal"]["width"] > maxbuttons_strip_px(0) || $css["normal"]["height"] > maxbuttons_strip_px(0)) |
| 31 |
{ |
| 32 |
$css["normal"]["display"] = "inline-block"; |
| 33 |
} |
| 34 |
*/ |
| 35 |
|
| 36 |
return $css; |
| 37 |
} |
| 38 |
|
| 39 |
public function map_fields($map) |
| 40 |
{ |
| 41 |
$map = parent::map_fields($map); |
| 42 |
|
| 43 |
$map["button_width"]["func"] = "updateDimension"; |
| 44 |
$map["button_height"]["func"] = "updateDimension"; |
| 45 |
|
| 46 |
return $map; |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
public function admin_fields() |
| 52 |
{ |
| 53 |
return; |
| 54 |
|
| 55 |
$data = $this->data[$this->blockname]; |
| 56 |
|
| 57 |
foreach($this->fields as $field => $options) |
| 58 |
{ |
| 59 |
$default = (isset($options["default"])) ? $options["default"] : ''; |
| 60 |
${$field} = (isset($data[$field])) ? $data[$field] : $default; |
| 61 |
${$field . "_default"} = $default; |
| 62 |
} |
| 63 |
?> |
| 64 |
<div class="mb_tab option-container"> |
| 65 |
<div class="title"><?php _e('Dimensions', 'maxbuttons') ?></div> |
| 66 |
<div class="inside"> |
| 67 |
<div class="option-design"> |
| 68 |
<div class="label"><?php _e('Button Width', 'maxbuttons') ?></div> |
| 69 |
<div class="input"><input class="tiny-nopad" type="text" id="button_width" name="button_width" value="<?php echo maxUtils::strip_px($button_width) ?>" />px</div> |
| 70 |
<div class="clear"></div> |
| 71 |
</div> |
| 72 |
<div class="option-design"> |
| 73 |
<div class="label"><?php _e('Button Height', 'maxbuttons') ?></div> |
| 74 |
<div class="input"><input class="tiny-nopad" type="text" id="button_height" name="button_height" value="<?php echo maxUtils::strip_px($button_height) ?>" />px</div> |
| 75 |
<div class="clear"></div> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
<?php |
| 80 |
} // admin_fields |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
} // class |
| 85 |
|
| 86 |
?> |
| 87 |
|