PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Document / Models / Elements / Symbol.php

Symbol.php in Depicter — Popup & Slider Builder trunk, at app/src/Document/Models/Elements/Symbol.php

78 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Document\Models\Elements;
3
4 use Depicter\Document\Models;
5 use Depicter\Html\Html;
6
7 class Symbol extends Models\Element
8 {
9
10 public function render() {
11 $symbolContent = '';
12
13 if( ! empty( $this->options->content ) ){
14 $symbolContent = $this->options->content;
15 }
16
17 $args = $this->getDefaultAttributes();
18
19 if ( ! empty( $this->options->disableOnFirst ) ) {
20 $args['data-disable-on-first'] = 'true';
21 }
22
23 if ( ! empty( $this->options->disableOnLast ) ) {
24 $args['data-disable-on-last'] = 'true';
25 }
26
27 $div = Html::div( $args, "\n\t" . $symbolContent . "\n" );
28
29 if ( false !== $a = $this->getLinkTag() ) {
30 return $a->nest( "\n" .$div ) . "\n";
31 }
32
33 return $div . "\n";
34 }
35
36 /**
37 * Get styles of svg
38 *
39 * @return array|array[]
40 */
41 protected function getSymbolCss( $state = 'normal' ) {
42 // Get styles list from styles property
43 $symbolIconStyles = ! empty( $this->styles ) ? $this->styles->generateCssForModulesOfState( ['svg'], $state ) : [];
44
45 if( !empty( $this->options->iconScale->default ) ){
46 $symbolIconStyles['default']['transform'] = "scale( {$this->options->iconScale->default} )";
47 }
48 if( !empty( $this->options->iconScale->tablet ) ){
49 $symbolIconStyles['tablet']['transform'] = "scale( {$this->options->iconScale->tablet} )";
50 }
51 if( !empty( $this->options->iconScale->mobile ) ){
52 $symbolIconStyles['mobile']['transform'] = "scale( {$this->options->iconScale->mobile} )";
53 }
54
55 return $symbolIconStyles;
56 }
57
58 /**
59 * Get list of selector and CSS for element
60 *
61 * @return array
62 * @throws \JsonMapper_Exception
63 */
64 public function getSelectorAndCssList(){
65 parent::getSelectorAndCssList();
66
67 $this->selectorCssList[ '.'. $this->getSelector() .' .depicter-symbol-container' ] = $this->getSymbolCss( 'normal' );
68 $this->selectorCssList[ '.'. $this->getSelector() .':hover .depicter-symbol-container' ] = $this->getSymbolCss( 'hover' );
69
70 $transition = $this->prepare()->styles->getTransitionCss();
71 if ( !empty( $transition ) ) {
72 $this->selectorCssList[ '.'. $this->getSelector() .' .depicter-symbol-container' ] = array_merge_recursive( $this->selectorCssList[ '.'. $this->getSelector() .' .depicter-symbol-container' ], $transition );
73 }
74
75 return $this->selectorCssList;
76 }
77 }
78