| @@ -1,13 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | +namespace MaxButtons; | |
| 2 | 3 | defined('ABSPATH') or die('No direct access permitted'); |
| 3 | 4 | $blockClass["responsive"] = "responsiveBlock"; |
| 4 | 5 | $blockOrder[90][] = "responsive"; |
| 5 | 6 | |
| 6 | -use MaxButtons\maxBlocks as maxBlocks; | |
| 7 | -use MaxButtons\maxField as maxField; | |
| 8 | - | |
| 9 | - | |
| 10 | 7 | class responsiveBlock extends maxBlock |
| 11 | 8 | { |
| 12 | 9 | protected $blockname = 'responsive'; |
| 13 | 10 | protected $fields = array("options" => '', |
| @@ -216,8 +213,12 @@ | ||
| 216 | 213 | $names_used = array_intersect_key($media_names,$fk); |
| 217 | 214 | $media_query = array_merge($names_used,$media_query); |
| 218 | 215 | |
| 219 | 216 | ?> |
| 217 | + <script type='text/javascript'> | |
| 218 | + var responsiveMap = '<?php echo json_encode($this->multi_fields); ?>'; | |
| 219 | + </script> | |
| 220 | + | |
| 220 | 221 | <div class="mb_tab option-container"> |
| 221 | 222 | <div class="title"><?php _e('Responsive Settings', 'maxbuttons') ?></div> |
| 222 | 223 | <div class="inside responsive"> |
| 223 | 224 | |
| @@ -269,13 +270,13 @@ | ||
| 269 | 270 | |
| 270 | 271 | if (! isset($fields['mq_hide'])) |
| 271 | 272 | $fields['mq_hide'] = 0; |
| 272 | 273 | |
| 273 | - $condition = array('target' => 'mq_hide[' . $i . ']', 'values' => 'checked'); | |
| 274 | + $condition = array('target' => 'mq_hide[' . $i . ']', 'values' => 'unchecked'); | |
| 274 | 275 | $show_conditional = htmlentities(json_encode($condition)); |
| 275 | 276 | |
| 276 | 277 | ?> |
| 277 | - <div class='media_query' data-query="<?php echo $item ?>"> | |
| 278 | + <div class='media_query' data-query="<?php echo $item ?>" data-id="<?php echo $i ?>"> | |
| 278 | 279 | <span class='removebutton dashicons dashicons-no'></span> |
| 279 | 280 | |
| 280 | 281 | <input type="hidden" name="media_query[<?php echo $i ?>]" value="<?php echo $item ?>"> |
| 281 | 282 | <label class='title'><?php echo $media_names[$item] ?></label> |
| @@ -280,9 +281,9 @@ | ||
| 280 | 281 | <input type="hidden" name="media_query[<?php echo $i ?>]" value="<?php echo $item ?>"> |
| 281 | 282 | <label class='title'><?php echo $media_names[$item] ?></label> |
| 282 | 283 | <p class='description'><?php echo $media_desc[$item] ?></p> |
| 283 | 284 | <?php |
| 284 | - if ($item == "custom") { $custom_class = ''; } else { $custom_class = ' hidden '; } | |
| 285 | + if ($item == "custom") { $custom_class = 'option custom'; } else { $custom_class = 'option custom hidden '; } | |
| 285 | 286 | |
| 286 | 287 | $min_width = new maxField('number'); |
| 287 | 288 | $min_width->id = 'mq_custom_minwidth[' . $i . ']'; |
| 288 | 289 | $min_width->name= $min_width->id; |
| @@ -287,11 +288,12 @@ | ||
| 287 | 288 | $min_width->id = 'mq_custom_minwidth[' . $i . ']'; |
| 288 | 289 | $min_width->name= $min_width->id; |
| 289 | 290 | $min_width->label = __('Min Width', 'maxbuttons'); |
| 290 | 291 | $min_width->value = $fields['mq_custom_minwidth']; |
| 291 | - $min_width->inputclass = 'small' . $custom_class; | |
| 292 | + $min_width->inputclass = 'small'; | |
| 292 | 293 | $min_width->main_class = $custom_class; // hide label |
| 293 | 294 | $min_width->output('start', ''); |
| 295 | + | |
| 294 | 296 | |
| 295 | 297 | $max_width = new maxField('number'); |
| 296 | 298 | $max_width->id = 'mq_custom_maxwidth[' . $i . ']'; |
| 297 | 299 | $max_width->name = $max_width->id; |
| @@ -296,9 +298,9 @@ | ||
| 296 | 298 | $max_width->id = 'mq_custom_maxwidth[' . $i . ']'; |
| 297 | 299 | $max_width->name = $max_width->id; |
| 298 | 300 | $max_width->label = __('Max Width','maxbuttons'); |
| 299 | 301 | $max_width->value = $fields['mq_custom_maxwidth']; |
| 300 | - $max_width->inputclass = 'small' . $custom_class; | |
| 302 | + $max_width->inputclass = 'small'; | |
| 301 | 303 | $max_width->mainclass = $custom_class; |
| 302 | 304 | $max_width->output('','end'); |
| 303 | 305 | |
| 304 | 306 | |
| @@ -308,9 +310,9 @@ | ||
| 308 | 310 | $font_size->value = $fields['mq_font_size']; |
| 309 | 311 | $font_size->label = __('Font Size', 'maxbuttons'); |
| 310 | 312 | $font_size->min = 0; |
| 311 | 313 | $font_size->inputclass = 'tiny'; |
| 312 | - // $font_size->conditional = $show_conditional; | |
| 314 | + $font_size->start_conditional = $show_conditional; | |
| 313 | 315 | $font_size->output('start', ''); |
| 314 | 316 | |
| 315 | 317 | $fsize_unit = new maxField('generic'); |
| 316 | 318 | $fsize_unit->id = 'mq_font_size_unit[' . $i . ']'; |
| @@ -327,9 +329,9 @@ | ||
| 327 | 329 | $width->value = $fields['mq_button_width']; |
| 328 | 330 | $width->label = __('Button Width', 'maxbuttons'); |
| 329 | 331 | $width->min = 0; |
| 330 | 332 | $width->inputclass = 'tiny'; |
| 331 | - // $width->conditional = $show_conditional; | |
| 333 | + $width->start_conditional = $show_conditional; | |
| 332 | 334 | $width->output('start',''); |
| 333 | 335 | |
| 334 | 336 | $width_unit = new maxField('generic'); |
| 335 | 337 | $width_unit->id = 'mq_button_width_unit[' . $i . ']'; |
| @@ -364,9 +366,9 @@ | ||
| 364 | 366 | $cwidth->label = __('Container Width', 'maxbuttons'); |
| 365 | 367 | $cwidth->value = $fields['mq_container_width']; |
| 366 | 368 | $cwidth->min = '0'; |
| 367 | 369 | $cwidth->inputclass = 'tiny'; |
| 368 | - // $cwidth->conditional = $show_conditional; | |
| 370 | + $cwidth->start_conditional = $show_conditional; | |
| 369 | 371 | $cwidth->output('start', ''); |
| 370 | 372 | |
| 371 | 373 | $cwidth_unit = new maxField('generic'); |
| 372 | 374 | $cwidth_unit->id = 'mq_container_width_unit[' . $i . ']'; |
| @@ -381,9 +383,9 @@ | ||
| 381 | 383 | $cfloat->name = $cfloat->id; |
| 382 | 384 | $cfloat->label = __('Container Float','maxbuttons'); |
| 383 | 385 | $cfloat->value = $fields['mq_container_float']; |
| 384 | 386 | $cfloat->content = maxUtils::selectify($cfloat->id, $container_floats, $cfloat->value); |
| 385 | - // $cfloat->conditional = $show_conditional; | |
| 387 | + $cfloat->start_conditional = $show_conditional; | |
| 386 | 388 | $cfloat->output('start','end'); |
| 387 | 389 | |
| 388 | 390 | $hide = new maxField('switch'); |
| 389 | 391 | $hide->id = 'mq_hide[' . $i . ']'; |
| @@ -392,8 +394,16 @@ | ||
| 392 | 394 | $hide->checked = checked($fields['mq_hide'], $hide->value, false); |
| 393 | 395 | $hide->label = __('Hide button in this view','maxbuttons'); |
| 394 | 396 | $hide->output('start','end'); |
| 395 | 397 | |
| 398 | + /* | |
| 399 | + $preview = new maxField('button'); | |
| 400 | + $preview->id = 'mq_preview[' . $i . ']'; | |
| 401 | + $preview->inputclass = 'responsive_preview'; | |
| 402 | + $preview->button_label = __('Show in preview','maxbuttons'); | |
| 403 | + $preview->output('', 'end'); | |
| 404 | + */ | |
| 405 | + | |
| 396 | 406 | $i++; |
| 397 | 407 | //if ($item != 'custom') |
| 398 | 408 | // unset($media_names[$item]); // remove existing queries from new query selection |
| 399 | 409 | ?> |
| @@ -408,8 +418,9 @@ | ||
| 408 | 418 | <div class="new_query_space"></div> |
| 409 | 419 | </div> <!-- inside --> |
| 410 | 420 | |
| 411 | 421 | <input type="hidden" name="next_media_index" value="<?php echo $i ?>" > |
| 422 | + | |
| 412 | 423 | <div class='media_option_prot'> |
| 413 | 424 | |
| 414 | 425 | <div class='media_query' data-query=''> |
| 415 | 426 | <span class='removebutton dashicons dashicons-no'></span> |
| @@ -416,32 +427,44 @@ | ||
| 416 | 427 | |
| 417 | 428 | <input type="hidden" name="media_query[]" value=""> |
| 418 | 429 | <label class='title'></label> |
| 419 | 430 | <p class='description'> </p> |
| 431 | + <?php | |
| 432 | + $custom_class = 'option hidden custom'; | |
| 433 | + $condition = array('target' => 'mq_hide[]', 'values' => 'unchecked'); | |
| 434 | + $show_conditional = htmlentities(json_encode($condition)); | |
| 435 | + | |
| 436 | + $min_width = new maxField('number'); | |
| 437 | + $min_width->id = 'mq_custom_minwidth[]'; | |
| 438 | + $min_width->name= $min_width->id; | |
| 439 | + $min_width->label = __('Min Width', 'maxbuttons'); | |
| 440 | + // $min_width->value = $fields['mq_custom_minwidth']; | |
| 441 | + $min_width->inputclass = 'small'; | |
| 442 | + $min_width->main_class = $custom_class; // hide label | |
| 443 | + $min_width->output('start', ''); | |
| 444 | + | |
| 445 | + $max_width = new maxField('number'); | |
| 446 | + $max_width->id = 'mq_custom_maxwidth[]'; | |
| 447 | + $max_width->name = $max_width->id; | |
| 448 | + $max_width->label = __('Max Width','maxbuttons'); | |
| 449 | + // $max_width->value = $fields['mq_custom_maxwidth']; | |
| 450 | + $max_width->inputclass = 'small'; | |
| 451 | + $max_width->mainclass = $custom_class; | |
| 452 | + $max_width->output('','end'); | |
| 420 | 453 | |
| 421 | - <div class="custom"> | |
| 422 | - <div class="label"><?php _e("Min width","maxbuttons") ?></div> | |
| 423 | - <div class="input"><input type="text" class="tiny" name="mq_custom_minwidth[]" value="0" />px</div> | |
| 424 | - | |
| 425 | - <div class="label max"> <?php _e("Max width","maxbuttons"); ?></div> | |
| 426 | - <div class="input max"><input type="text" class="tiny" name="mq_custom_maxwidth[]" value="0" />px</div> | |
| 427 | 454 | |
| 428 | - | |
| 429 | - </div> | |
| 430 | - | |
| 431 | - | |
| 432 | - <?php | |
| 433 | 455 | $font_size = new maxField('number'); |
| 434 | - $font_size->id = 'mq_font_size[' . $i . ']'; | |
| 456 | + $font_size->id = 'mq_font_size[]'; | |
| 435 | 457 | $font_size->name = $font_size->id; |
| 436 | 458 | //$font_size->value = $fields['mq_font_size']; |
| 437 | 459 | $font_size->label = __('Font Size', 'maxbuttons'); |
| 438 | 460 | $font_size->min = 0; |
| 439 | 461 | $font_size->inputclass = 'tiny'; |
| 462 | + $font_size->start_conditional = $show_conditional; | |
| 440 | 463 | $font_size->output('start', ''); |
| 441 | 464 | |
| 442 | 465 | $fsize_unit = new maxField('generic'); |
| 443 | - $fsize_unit->id = 'mq_font_size_unit[' . $i . ']'; | |
| 466 | + $fsize_unit->id = 'mq_font_size_unit[]'; | |
| 444 | 467 | $fsize_unit->name = $fsize_unit->id; |
| 445 | 468 | //$fsize_unit->value = $fields['mq_font_size_unit']; |
| 446 | 469 | $fsize_unit->content = maxUtils::selectify($fsize_unit->id, $units, $fsize_unit->value) ; |
| 447 | 470 | $fsize_unit->output('','end'); |
| @@ -447,18 +470,19 @@ | ||
| 447 | 470 | $fsize_unit->output('','end'); |
| 448 | 471 | |
| 449 | 472 | // width |
| 450 | 473 | $width = new maxField('number'); |
| 451 | - $width->id = 'mq_button_width[' . $i . ']'; | |
| 474 | + $width->id = 'mq_button_width[]'; | |
| 452 | 475 | $width->name = $width->id; |
| 453 | 476 | //$width->value = $fields['mq_button_width']; |
| 454 | 477 | $width->label = __('Button Width', 'maxbuttons'); |
| 455 | 478 | $width->min = 0; |
| 456 | 479 | $width->inputclass = 'tiny'; |
| 480 | + $width->start_conditional = $show_conditional; | |
| 457 | 481 | $width->output('start',''); |
| 458 | 482 | |
| 459 | 483 | $width_unit = new maxField('generic'); |
| 460 | - $width_unit->id = 'mq_button_width_unit[' . $i . ']'; | |
| 484 | + $width_unit->id = 'mq_button_width_unit[]'; | |
| 461 | 485 | $width_unit->name = $width_unit->id; |
| 462 | 486 | //$width_unit->value = $fields['mq_button_width_unit']; |
| 463 | 487 | $width_unit->content = maxUtils::selectify($width_unit->id, $units, $width_unit->value); |
| 464 | 488 | $width_unit->output('',''); |
| @@ -464,9 +488,9 @@ | ||
| 464 | 488 | $width_unit->output('',''); |
| 465 | 489 | |
| 466 | 490 | // height |
| 467 | 491 | $height = new maxField('number'); |
| 468 | - $height->id = 'mq_button_height[' . $i . ']'; | |
| 492 | + $height->id = 'mq_button_height[]'; | |
| 469 | 493 | $height->name = $height->id; |
| 470 | 494 | //$height->value = $fields['mq_button_height']; |
| 471 | 495 | $height->label = __("Button Height", "maxbuttons"); |
| 472 | 496 | $height->min = 0; |
| @@ -473,25 +497,26 @@ | ||
| 473 | 497 | $height->inputclass = 'tiny'; |
| 474 | 498 | $height->output('',''); |
| 475 | 499 | |
| 476 | 500 | $height_unit = new maxField('generic'); |
| 477 | - $height_unit->id = 'mq_button_height_unit[' . $i . ']'; | |
| 501 | + $height_unit->id = 'mq_button_height_unit[]'; | |
| 478 | 502 | $height_unit->name = $height_unit->id; |
| 479 | - $height_unit->value = $fields['mq_button_height_unit']; | |
| 503 | + // $height_unit->value = $fields['mq_button_height_unit']; | |
| 480 | 504 | $height_unit->content = maxUtils::selectify($height_unit->id, $units, $height_unit->value) ; |
| 481 | 505 | $height_unit->output('','end'); |
| 482 | 506 | |
| 483 | 507 | $cwidth = new maxField('number'); |
| 484 | - $cwidth->id = 'mq_container_width[' . $i . ']'; | |
| 508 | + $cwidth->id = 'mq_container_width[]'; | |
| 485 | 509 | $cwidth->name = $cwidth->id; |
| 486 | 510 | $cwidth->label = __('Container Width', 'maxbuttons'); |
| 487 | 511 | //$cwidth->value = $fields['mq_container_width']; |
| 488 | 512 | $cwidth->min = '1'; |
| 489 | 513 | $cwidth->inputclass = 'tiny'; |
| 514 | + $cwidth->start_conditional = $show_conditional; | |
| 490 | 515 | $cwidth->output('start', ''); |
| 491 | 516 | |
| 492 | 517 | $cwidth_unit = new maxField('generic'); |
| 493 | - $cwidth_unit->id = 'mq_container_width_unit[' . $i . ']'; | |
| 518 | + $cwidth_unit->id = 'mq_container_width_unit[]'; | |
| 494 | 519 | $cwidth_unit->name = $cwidth_unit->id; |
| 495 | 520 | //$cwidth_unit->value = $fields['mq_container_width_unit']; |
| 496 | 521 | $cwidth_unit->content = maxUtils::selectify($cwidth_unit->id, $units, $cwidth_unit->value); |
| 497 | 522 | $cwidth_unit->output('','end'); |
| @@ -496,13 +521,14 @@ | ||
| 496 | 521 | $cwidth_unit->content = maxUtils::selectify($cwidth_unit->id, $units, $cwidth_unit->value); |
| 497 | 522 | $cwidth_unit->output('','end'); |
| 498 | 523 | |
| 499 | 524 | $cfloat = new maxField('generic'); |
| 500 | - $cfloat->id = 'mq_container_float[' . $i . ']'; | |
| 525 | + $cfloat->id = 'mq_container_float[]'; | |
| 501 | 526 | $cfloat->name = $cfloat->id; |
| 502 | 527 | $cfloat->label = __('Container Float','maxbuttons'); |
| 503 | 528 | // $cfloat->value = $fields['mq_container_float']; |
| 504 | 529 | $cfloat->content = maxUtils::selectify($cfloat->id, $container_floats, $cfloat->value); |
| 530 | + $cfloat->start_conditional = $show_conditional; | |
| 505 | 531 | $cfloat->output('start','end'); |
| 506 | 532 | |
| 507 | 533 | if (! isset($fields['mq_hide'])) |
| 508 | 534 | $fields['mq_hide'] = 0; |
| @@ -507,18 +533,24 @@ | ||
| 507 | 533 | if (! isset($fields['mq_hide'])) |
| 508 | 534 | $fields['mq_hide'] = 0; |
| 509 | 535 | |
| 510 | 536 | $hide = new maxField('switch'); |
| 511 | - $hide->id = 'mq_hide[' . $i . ']'; | |
| 537 | + $hide->id = 'mq_hide[]'; | |
| 512 | 538 | $hide->name = $hide->id; |
| 513 | 539 | $hide->value = 'none'; |
| 514 | 540 | //$hide->checked = checked($fields['mq_hide'], $hide->value, false); |
| 515 | 541 | $hide->label = __('Hide button in this view','maxbuttons'); |
| 516 | - $hide->output('start','end'); | |
| 542 | + $hide->output('start','end'); | |
| 543 | + | |
| 544 | + /*$preview = new maxField('button'); | |
| 545 | + $preview->id = 'mq_preview[]'; | |
| 546 | + $preview->button_label = __('Show in preview','maxbuttons'); | |
| 547 | + $preview->output('', 'end'); | |
| 548 | + */ | |
| 517 | 549 | ?> |
| 518 | - </div> | |
| 550 | + </div> <!-- /media-query --> | |
| 519 | 551 | |
| 520 | - </div> | |
| 552 | + </div> <!-- /media-query-prot --> | |
| 521 | 553 | <div id="media_desc"> |
| 522 | 554 | <?php foreach($media_desc as $key => $desc) |
| 523 | 555 | { |
| 524 | 556 | echo "<span id='$key'>$desc</span>"; |
| @@ -528,12 +560,9 @@ | ||
| 528 | 560 | </div> |
| 529 | 561 | |
| 530 | 562 | |
| 531 | 563 | </div> <!-- container --> |
| 532 | - | |
| 533 | - | |
| 534 | - | |
| 535 | - | |
| 564 | + | |
| 536 | 565 | <?php |
| 537 | 566 | } |
| 538 | 567 | |
| 539 | 568 | } // class |