| 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 |
if (false === Install::isPRO() ) { |
| 30 |
return $css; |
| 31 |
} |
| 32 |
|
| 33 |
$effect = $this->getValue('effect_type'); |
| 34 |
$style = $this->collection->getStyle(); |
| 35 |
|
| 36 |
// maybe this should be moved to style object in time(?) |
| 37 |
switch($effect) |
| 38 |
{ |
| 39 |
case 'transform': |
| 40 |
$scale = $this->getvalue('scale'); |
| 41 |
$scale = $scale / 10; |
| 42 |
$css = $style->addEffect($css, $effect, array('scale' => $scale)); |
| 43 |
|
| 44 |
break; |
| 45 |
|
| 46 |
case 'drop': |
| 47 |
case 'shift': |
| 48 |
case 'lift' : |
| 49 |
|
| 50 |
$layoutBlock = $this->collection->getBlock('layoutBlock'); |
| 51 |
$labelsize = $layoutBlock->getValue('font_label_size'); |
| 52 |
|
| 53 |
$css = $style->addEffect($css, $effect, array('line_height' => $labelsize)); |
| 54 |
break; |
| 55 |
case 'stretch': |
| 56 |
$css = $style->addEffect($css, $effect, array('orientation' => $this->collection->orientation, 'is_static' => $this->collection->is_static)); |
| 57 |
break; |
| 58 |
default: |
| 59 |
$css = $style->addEffect($css, $effect); |
| 60 |
break; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
$css['mb-social']['normal']['transition'] = 'all 0.4s linear'; |
| 65 |
|
| 66 |
|
| 67 |
return $css; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
public function admin() |
| 72 |
{ |
| 73 |
$admin = mbSocial()->admin(); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
$types = array('none' => __('None', 'mbsocial'), |
| 78 |
'hover' => __('Hover', 'mbsocial'), |
| 79 |
'transform' => __('Enlarge', 'mbsocial'), |
| 80 |
'drop' => __('Drop', 'mbsocial'), |
| 81 |
'lift' => __('Lift from down', 'mbsocial'), |
| 82 |
'shift' => __('Shift from left', 'mbsocial'), |
| 83 |
'flip' => __('Flip', 'mbsocial'), |
| 84 |
'stretch' => __('Stretch', 'mbsocial'), |
| 85 |
); |
| 86 |
|
| 87 |
$shape_icons = array(); |
| 88 |
|
| 89 |
?> |
| 90 |
<div class='help-side'> |
| 91 |
<h3><?php _e('Effect Options', 'mbsocial'); ?></h3> |
| 92 |
|
| 93 |
<p><?php _e('These will modify the behavior when a user hovers the mouse cursor over the share buttons', 'mbsocial') ?></p> |
| 94 |
|
| 95 |
</div> |
| 96 |
|
| 97 |
<div class='options option-container style' id='effectBlock' data-refresh='previewBlock' > |
| 98 |
<?php if (! Install::isPRO() ) : ?> |
| 99 |
<div class='forpro overlay'><div><?php echo $admin->getProMessage(); ?></div></div> |
| 100 |
<?php endif; ?> |
| 101 |
<div class='title'><?php _e('Hover Effects', 'mbsocial'); ?></div> |
| 102 |
<div class='inside'> |
| 103 |
<?php |
| 104 |
|
| 105 |
$etype = new maxField('option_select'); |
| 106 |
$etype->id = 'effect_type'; |
| 107 |
$etype->name = $etype->id; |
| 108 |
$etype->label = __('Type', 'mbsocial'); |
| 109 |
$etype->options = $types; |
| 110 |
$etype->selected = $this->getValue($etype->id); |
| 111 |
|
| 112 |
|
| 113 |
$admin->addField($etype, 'start','end'); |
| 114 |
|
| 115 |
$scale = new maxField('number'); |
| 116 |
$scale->id = 'scale'; |
| 117 |
$scale->name = $scale->id; |
| 118 |
$scale->label = __('Scale', 'mbsocial'); |
| 119 |
$scale->inputclass = 'tiny'; |
| 120 |
$scale->min = '100'; |
| 121 |
$scale->default = 'Enlarge in %. 100% is same size'; |
| 122 |
$scale->value = $this->getValue('scale'); |
| 123 |
$scale->start_conditional = htmlentities(json_encode(array('target' => $etype->id, 'values' => array('transform') ))); |
| 124 |
|
| 125 |
$admin->addField($scale, 'start','end'); |
| 126 |
|
| 127 |
$admin->display_fields(); |
| 128 |
?> |
| 129 |
</div> |
| 130 |
</div> |
| 131 |
<?php |
| 132 |
} // admin |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
} |
| 138 |
|