| 1 |
<?php |
| 2 |
namespace MBSocial; |
| 3 |
defined('ABSPATH') or die('No direct access permitted'); |
| 4 |
|
| 5 |
use \MaxButtons\maxField as maxField; |
| 6 |
use \MaxButtons\maxBlocks as maxBlocks; |
| 7 |
use \MaxButtons\maxButton as maxButton; |
| 8 |
|
| 9 |
$collectionBlock["effect"] = array('class' => "effectBlock", |
| 10 |
'order' => 55); |
| 11 |
|
| 12 |
class effectBlock extends block |
| 13 |
{ |
| 14 |
|
| 15 |
protected $blockname = "effect"; |
| 16 |
protected $fields = array( |
| 17 |
'effect_type' => array('default' => 'none'), |
| 18 |
'scale' => array('default' => '120'), |
| 19 |
); |
| 20 |
|
| 21 |
|
| 22 |
public function parseCSS($css,$args) |
| 23 |
{ |
| 24 |
$blockdata = $this->data[$this->blockname]; |
| 25 |
//$is_active = isset($blockdata['use_effect']) && $blockdata['use_effect'] == 1 ? true : false; |
| 26 |
|
| 27 |
//if (! $is_active) |
| 28 |
// return $css; |
| 29 |
|
| 30 |
$effect = $this->getValue('effect_type'); |
| 31 |
$style = $this->collection->getStyle(); |
| 32 |
|
| 33 |
// maybe this should be moved to style object in time(?) |
| 34 |
switch($effect) |
| 35 |
{ |
| 36 |
case 'transform': |
| 37 |
$scale = $this->getvalue('scale'); |
| 38 |
$scale = $scale / 10; |
| 39 |
$css = $style->addEffect($css, $effect, array('scale' => $scale)); |
| 40 |
|
| 41 |
break; |
| 42 |
|
| 43 |
case 'drop': |
| 44 |
case 'shift': |
| 45 |
case 'lift' : |
| 46 |
|
| 47 |
$layoutBlock = $this->collection->getBlock('layoutBlock'); |
| 48 |
$labelsize = $layoutBlock->getValue('font_label_size'); |
| 49 |
|
| 50 |
$css = $style->addEffect($css, $effect, array('line_height' => $labelsize)); |
| 51 |
break; |
| 52 |
default: |
| 53 |
$css = $style->addEffect($css, $effect); |
| 54 |
break; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
$css['mb-social']['normal']['transition'] = 'all 0.4s linear'; |
| 59 |
|
| 60 |
|
| 61 |
return $css; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
public function admin() |
| 66 |
{ |
| 67 |
$admin = mbSocial()->admin(); |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
$types = array('none' => __('None', 'mbsocial'), |
| 72 |
'hover' => __('Hover', 'mbsocial'), |
| 73 |
'transform' => __('Enlarge', 'mbsocial'), |
| 74 |
'drop' => __('Drop', 'mbsocial'), |
| 75 |
'lift' => __('Lift from down', 'mbsocial'), |
| 76 |
'shift' => __('Shift from left', 'mbsocial'), |
| 77 |
'flip' => __('Flip', 'mbsocial'), |
| 78 |
'stretch' => __('Stretch', 'mbsocial'), |
| 79 |
); |
| 80 |
|
| 81 |
$shape_icons = array(); |
| 82 |
|
| 83 |
?> |
| 84 |
|
| 85 |
<div class='options option-container style' id='effectBlock' data-refresh='previewBlock' > |
| 86 |
<?php if (! Install::isPRO() ) : ?> |
| 87 |
<div class='forpro overlay'><div><?php echo $admin->getProMessage(); ?></div></div> |
| 88 |
<?php endif; ?> |
| 89 |
<div class='title'><?php _e('Effects', 'mbsocial'); ?></div> |
| 90 |
<div class='inside'> |
| 91 |
<?php |
| 92 |
|
| 93 |
$etype = new maxField('option_select'); |
| 94 |
$etype->id = 'effect_type'; |
| 95 |
$etype->name = $etype->id; |
| 96 |
$etype->label = __('Type', 'mbsocial'); |
| 97 |
$etype->options = $types; |
| 98 |
$etype->selected = $this->getValue($etype->id); |
| 99 |
|
| 100 |
|
| 101 |
$admin->addField($etype, 'start','end'); |
| 102 |
|
| 103 |
$scale = new maxField('number'); |
| 104 |
$scale->id = 'scale'; |
| 105 |
$scale->name = $scale->id; |
| 106 |
$scale->label = __('Scale', 'mbsocial'); |
| 107 |
$scale->inputclass = 'tiny'; |
| 108 |
$scale->min = '100'; |
| 109 |
$scale->default = 'Enlarge in %. 100% is same size'; |
| 110 |
$scale->value = $this->getValue('scale'); |
| 111 |
$scale->start_conditional = htmlentities(json_encode(array('target' => $etype->id, 'values' => array('transform') ))); |
| 112 |
|
| 113 |
$admin->addField($scale, 'start','end'); |
| 114 |
|
| 115 |
$admin->display_fields(); |
| 116 |
?> |
| 117 |
</div> |
| 118 |
</div> |
| 119 |
<?php |
| 120 |
} // admin |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
} |
| 126 |
|