| 1 |
<?php |
| 2 |
namespace MaxButtons; |
| 3 |
defined('ABSPATH') or die('No direct access permitted'); |
| 4 |
$blockClass["border"] = "borderBlock"; |
| 5 |
$blockOrder[30][] = "border"; |
| 6 |
|
| 7 |
class borderBlock extends maxBlock |
| 8 |
{ |
| 9 |
protected $blockname = "border"; |
| 10 |
protected $fields = array("radius_top_left" => |
| 11 |
array("default" => "4px", |
| 12 |
"css" => "border-top-left-radius" |
| 13 |
), |
| 14 |
"radius_top_right" => array("default" => "4px", |
| 15 |
"css" => "border-top-right-radius" |
| 16 |
), |
| 17 |
"radius_bottom_left" => array("default" => "4px", |
| 18 |
"css" => "border-bottom-left-radius" |
| 19 |
), |
| 20 |
"radius_bottom_right" => array("default" => "4px", |
| 21 |
"css" => "border-bottom-right-radius" |
| 22 |
), |
| 23 |
"border_style" => array("default" => "solid", |
| 24 |
"css" => "border-style" |
| 25 |
), |
| 26 |
"border_width" => array("default" => "2px", |
| 27 |
"css" => "border-width" |
| 28 |
), |
| 29 |
"box_shadow_offset_left" => array("default" => "0px", |
| 30 |
"css" => "box-shadow-offset-left", |
| 31 |
"csspseudo" => "normal,hover" |
| 32 |
), |
| 33 |
"box_shadow_offset_top" => array("default" => "0px", |
| 34 |
"css" => "box-shadow-offset-top", |
| 35 |
"csspseudo" => "normal,hover"), |
| 36 |
"box_shadow_width" => array("default" => "2px", |
| 37 |
"css" => "box-shadow-width", |
| 38 |
"csspseudo" => "normal,hover"), |
| 39 |
'box_shadow_spread' => array('default' => '0px', |
| 40 |
'css' => 'box-shadow-spread', |
| 41 |
'csspseudo' => 'normal,hover'), |
| 42 |
|
| 43 |
); |
| 44 |
|
| 45 |
|
| 46 |
public function map_fields($map) |
| 47 |
{ |
| 48 |
$map = parent::map_fields($map); |
| 49 |
$map["box_shadow_offset_left"]["func"] = "updateBoxShadow"; |
| 50 |
$map["box_shadow_offset_top"]["func"] = "updateBoxShadow"; |
| 51 |
$map["box_shadow_width"]["func"] = "updateBoxShadow"; |
| 52 |
$map["box_shadow_spread"]["func"] = "updateBoxShadow"; |
| 53 |
|
| 54 |
$map["radius_top_left"]["func"] = "updateRadius"; |
| 55 |
$map["radius_top_right"]["func"] = "updateRadius"; |
| 56 |
$map["radius_bottom_left"]["func"] = "updateRadius"; |
| 57 |
$map["radius_bottom_right"]["func"] = "updateRadius"; |
| 58 |
|
| 59 |
return $map; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
public function parse_css($css, $mode = 'normal') |
| 64 |
{ |
| 65 |
$css = parent::parse_css($css); |
| 66 |
$data = $this->data[$this->blockname]; |
| 67 |
|
| 68 |
$border_width = maxBlocks::getValue('border_width'); |
| 69 |
if ( intval($border_width) == 0) // if no border, then don't output other border properties. |
| 70 |
{ |
| 71 |
unset($css['maxbutton']['normal']['border-style']); |
| 72 |
} |
| 73 |
|
| 74 |
return $css; |
| 75 |
} |
| 76 |
|
| 77 |
public function admin_fields() |
| 78 |
{ |
| 79 |
|
| 80 |
$data = $this->data[$this->blockname]; |
| 81 |
foreach($this->fields as $field => $options) |
| 82 |
{ |
| 83 |
$default = (isset($options["default"])) ? $options["default"] : ''; |
| 84 |
$$field = (isset($data[$field])) ? $data[$field] : $default; |
| 85 |
${$field . "_default"} = $default; |
| 86 |
} |
| 87 |
|
| 88 |
$maxbuttons_border_styles = array( |
| 89 |
'' => '', |
| 90 |
'dashed' => __('dashed','maxbuttons'), |
| 91 |
'dotted' => __('dotted','maxbuttons'), |
| 92 |
'double' => __('double','maxbuttons'), |
| 93 |
'groove' => __('groove','maxbuttons'), |
| 94 |
'inset' => __('inset','maxbuttons'), |
| 95 |
'outset' => __('outset','maxbuttons'), |
| 96 |
'ridge' => __('ridge','maxbuttons'), |
| 97 |
'solid' => __('solid','maxbuttons') |
| 98 |
); |
| 99 |
|
| 100 |
$color_copy_self = __("Replace color from other field", "maxbuttons"); |
| 101 |
$color_copy_move = __("Copy Color to other field", "maxbuttons"); |
| 102 |
|
| 103 |
$admin = MB()->getClass('admin'); |
| 104 |
|
| 105 |
$start_block = new maxField('block_start'); |
| 106 |
$start_block->name = __('border', 'maxbuttons'); |
| 107 |
$start_block->label = __('Border', 'maxbuttons'); |
| 108 |
$admin->addField($start_block); |
| 109 |
|
| 110 |
|
| 111 |
// Spacer |
| 112 |
$fspacer = new maxField('spacer'); |
| 113 |
$fspacer->label = __('Radius','maxbuttons'); |
| 114 |
$fspacer->name = 'radius'; |
| 115 |
// $fspacer->output('start'); |
| 116 |
|
| 117 |
$admin->addField($fspacer, 'start'); |
| 118 |
|
| 119 |
// Radius left top |
| 120 |
$radius_tleft = new maxField('number'); |
| 121 |
$radius_tleft->value = maxUtils::strip_px(maxBlocks::getValue('radius_top_left')); |
| 122 |
$radius_tleft->id = 'radius_top_left'; |
| 123 |
$radius_tleft->name = $radius_tleft->id; |
| 124 |
$radius_tleft->min = 0; |
| 125 |
$radius_tleft->inputclass = 'tiny'; |
| 126 |
$radius_tleft->publish = false; |
| 127 |
$rtl = $radius_tleft->output(''); |
| 128 |
|
| 129 |
// Radius right top |
| 130 |
$radius_tright = new maxField('number'); |
| 131 |
$radius_tright->value = maxUtils::strip_px(maxBlocks::getValue('radius_top_right')); |
| 132 |
$radius_tright->id = 'radius_top_right'; |
| 133 |
$radius_tright->name = $radius_tright->id; |
| 134 |
$radius_tright->min = 0; |
| 135 |
$radius_tright->inputclass = 'tiny'; |
| 136 |
$radius_tright->publish = false; |
| 137 |
$rtr = $radius_tright->output('', ''); |
| 138 |
|
| 139 |
|
| 140 |
// Radius bottom left |
| 141 |
$radius_bleft = new maxField('number'); |
| 142 |
$radius_bleft->value = maxUtils::strip_px(maxBlocks::getValue('radius_bottom_left')); |
| 143 |
$radius_bleft->id = 'radius_bottom_left'; |
| 144 |
$radius_bleft->name = $radius_bleft->id; |
| 145 |
$radius_bleft->min = 0; |
| 146 |
$radius_bleft->inputclass = 'tiny'; |
| 147 |
$radius_bleft->publish = false; |
| 148 |
$rbl = $radius_bleft->output(''); |
| 149 |
|
| 150 |
// Radius bottom right |
| 151 |
$radius_bright = new maxField('number'); |
| 152 |
|
| 153 |
$radius_bright->value = maxUtils::strip_px(maxBlocks::getValue('radius_bottom_right')); |
| 154 |
$radius_bright->id = 'radius_bottom_right'; |
| 155 |
$radius_bright->name = $radius_bright->id; |
| 156 |
$radius_bright->min = 0; |
| 157 |
$radius_bright->inputclass = 'tiny'; |
| 158 |
$radius_bright->publish = false; |
| 159 |
$rbr = $radius_bright->output('', ''); |
| 160 |
|
| 161 |
// If all same, lock the corners for simultanious change. |
| 162 |
if ($radius_tleft->value == $radius_tright->value && |
| 163 |
$radius_tright->value == $radius_bleft->value && |
| 164 |
$radius_bleft->value = $radius_bright->value) |
| 165 |
{ |
| 166 |
$lock = 'lock'; |
| 167 |
} |
| 168 |
else |
| 169 |
$lock = 'unlock'; |
| 170 |
|
| 171 |
$radius = new maxField('radius'); |
| 172 |
$radius->radius_tl = $rtl; |
| 173 |
$radius->label_tl = __('Top Left','maxbuttons'); |
| 174 |
$radius->radius_tr = $rtr; |
| 175 |
$radius->label_tr = __('Top Right','maxbuttons'); |
| 176 |
$radius->radius_bl = $rbl; |
| 177 |
$radius->label_bl = __('Bottom Left','maxbuttons'); |
| 178 |
$radius->radius_br = $rbr; |
| 179 |
$radius->label_br = __('Bottom Right','maxbuttons'); |
| 180 |
$radius->lock = $lock; |
| 181 |
$admin->addField($radius, '', 'end'); |
| 182 |
|
| 183 |
// Border style |
| 184 |
$bstyle = new maxField('generic'); |
| 185 |
$bstyle->label = __('Style','maxbuttons'); |
| 186 |
$bstyle->name = 'border_style'; |
| 187 |
$bstyle->id = $bstyle->name; |
| 188 |
$bstyle->value= maxBlocks::getValue('border_style'); |
| 189 |
$bstyle->setDefault(maxBlocks::getDefault('border_style')); |
| 190 |
$bstyle->content = maxUtils::selectify($bstyle->name, $maxbuttons_border_styles, $bstyle->value); |
| 191 |
$admin->addField($bstyle, 'start', 'end'); |
| 192 |
|
| 193 |
// Border width |
| 194 |
$bwidth = new maxField('number'); |
| 195 |
$bwidth->label = __('Width', 'maxbuttons'); |
| 196 |
$bwidth->name = 'border_width'; |
| 197 |
$bwidth->id = $bwidth->name; |
| 198 |
$bwidth->value = maxUtils::strip_px( maxBlocks::getValue('border_width') ); |
| 199 |
$bwidth->min = 0; |
| 200 |
$bwidth->after_input = __('px', 'maxbuttons'); |
| 201 |
$bwidth->inputclass = 'tiny'; |
| 202 |
$admin->addField($bwidth, 'start', 'end'); |
| 203 |
|
| 204 |
// Border Color |
| 205 |
$bcolor = new maxField('color'); |
| 206 |
$bcolor->id = 'border_color'; |
| 207 |
$bcolor->name = $bcolor->id; |
| 208 |
$bcolor->value = maxBlocks::getColorValue('border_color'); |
| 209 |
$bcolor->label = __('Border Color','maxbuttons'); |
| 210 |
$bcolor->copycolor = true; |
| 211 |
$bcolor->bindto = 'border_color_hover'; |
| 212 |
$bcolor->copypos = 'right'; |
| 213 |
$bcolor->left_title = $color_copy_self; |
| 214 |
$bcolor->right_title = $color_copy_move; |
| 215 |
$admin->addField($bcolor ,'start'); |
| 216 |
|
| 217 |
// Border Color Hover |
| 218 |
$bcolor_hover = new maxField('color'); |
| 219 |
$bcolor_hover->id = 'border_color_hover'; |
| 220 |
$bcolor_hover->name = $bcolor_hover->id; |
| 221 |
$bcolor_hover->value = maxBlocks::getColorValue('border_color_hover'); |
| 222 |
$bcolor_hover->label = __('Hover','maxbuttons'); |
| 223 |
$bcolor_hover->copycolor = true; |
| 224 |
$bcolor_hover->bindto = 'border_color'; |
| 225 |
$bcolor_hover->copypos = 'left'; |
| 226 |
$bcolor_hover->left_title = $color_copy_move; |
| 227 |
$bcolor_hover->right_title = $color_copy_self; |
| 228 |
$admin->addField($bcolor_hover, '', 'end'); |
| 229 |
|
| 230 |
// Shadow offset left |
| 231 |
$bshadow = new maxField('number'); |
| 232 |
$bshadow->label = __('Shadow Offset Left','maxbuttons'); |
| 233 |
$bshadow->name = 'box_shadow_offset_left'; |
| 234 |
$bshadow->id = $bshadow->name; |
| 235 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_offset_left') ); |
| 236 |
$bshadow->inputclass = 'tiny'; |
| 237 |
$admin->addField($bshadow, 'start'); |
| 238 |
|
| 239 |
// Shadow offset top |
| 240 |
$bshadow = new maxField('number'); |
| 241 |
$bshadow->label = __('Shadow Offset Top','maxbuttons'); |
| 242 |
$bshadow->name = 'box_shadow_offset_top'; |
| 243 |
$bshadow->id = $bshadow->name; |
| 244 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_offset_top') ); |
| 245 |
$bshadow->inputclass = 'tiny'; |
| 246 |
$admin->addField($bshadow, '', 'end'); |
| 247 |
|
| 248 |
// Shadow width |
| 249 |
$bshadow = new maxField('number'); |
| 250 |
$bshadow->label = __('Shadow Blur','maxbuttons'); |
| 251 |
$bshadow->name = 'box_shadow_width'; |
| 252 |
$bshadow->id = $bshadow->name; |
| 253 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_width') ); |
| 254 |
$bshadow->inputclass = 'tiny'; |
| 255 |
$bshadow->min = 0; |
| 256 |
$admin->addField($bshadow, 'start', ''); |
| 257 |
|
| 258 |
$bspread = new maxField('number'); |
| 259 |
$bspread->label = __('Shadow Spread', 'maxbuttons'); |
| 260 |
$bspread->value = maxUtils::strip_px(maxBlocks::getValue('box_shadow_spread')); |
| 261 |
$bspread->id = 'box_shadow_spread'; |
| 262 |
$bspread->name = $bspread->id; |
| 263 |
$bspread->inputclass = 'tiny'; |
| 264 |
$admin->addField($bspread, '', 'end'); |
| 265 |
|
| 266 |
// Border Shadow Color |
| 267 |
$scolor = new maxField('color'); |
| 268 |
$scolor->id = 'box_shadow_color'; |
| 269 |
$scolor->name = $scolor->id; |
| 270 |
$scolor->value = maxBlocks::getColorValue('box_shadow_color'); |
| 271 |
$scolor->label = __('Border Shadow Color','maxbuttons'); |
| 272 |
$scolor->copycolor = true; |
| 273 |
$scolor->bindto = 'box_shadow_color_hover'; |
| 274 |
$scolor->copypos = 'right'; |
| 275 |
$scolor->left_title = $color_copy_self; |
| 276 |
$scolor->right_title = $color_copy_move; |
| 277 |
$admin->addField($scolor, 'start'); |
| 278 |
|
| 279 |
// Border Shadow Color Hover |
| 280 |
$scolor_hover = new maxField('color'); |
| 281 |
$scolor_hover->id = 'box_shadow_color_hover'; |
| 282 |
$scolor_hover->name = $scolor_hover->id; |
| 283 |
$scolor_hover->value = maxBlocks::getColorValue('box_shadow_color_hover'); |
| 284 |
$scolor_hover->label = __('Hover','maxbuttons'); |
| 285 |
$scolor_hover->copycolor = true; |
| 286 |
$scolor_hover->bindto = 'box_shadow_color'; |
| 287 |
$scolor_hover->copypos = 'left'; |
| 288 |
$scolor_hover->left_title = $color_copy_self; |
| 289 |
$scolor_hover->right_title = $color_copy_move; |
| 290 |
$admin->addField($scolor_hover, '','end'); |
| 291 |
|
| 292 |
$this->sidebar(); |
| 293 |
$endblock = new maxField('block_end'); |
| 294 |
$admin->addField($endblock); |
| 295 |
|
| 296 |
} // admin fields |
| 297 |
|
| 298 |
} // class |
| 299 |
|
| 300 |
?> |
| 301 |
|