/** * add all styles from an element to queue */ public function add_element_css($settings, $element_class) { //check if element_class already set, only proceed if it is not set if (isset($this->layers_css[$this->id]['idle'][$element_class])) { return true; } $idle = array(); $hover = array(); $do_hover = false; $do_important = ''; if (isset($settings['enable-hover']) && $settings['enable-hover'] == 'on') { $do_hover = true; } if (isset($settings['force-important']) && $settings['force-important'] == 'true') { $do_important = ' !important'; } if (!empty($settings)) { $attributes = Essential_Grid_Item_Element::get_existing_elements(true); foreach ($attributes as $style => $attr) { if ($attr['style'] == 'hover' && !$do_hover) { continue; } if (!isset($settings[$style]) || empty($settings[$style]) || $settings[$style] == '') { continue; } if ($attr['style'] != 'idle' && $attr['style'] != 'hover') { continue; } $set_style = $attr['style'] == 'idle' ? $style : str_replace('-hover', '', $style); if ($attr['type'] == 'multi-text') { if (!isset($settings[$style . '-unit'])) { $settings[$style . '-unit'] = 'px'; } $set_unit = $settings[$style . '-unit']; if ($set_style == 'box-shadow' || $set_style == 'background-color') { $multi_string = ''; foreach ($settings[$style] as $val) { $multi_string .= $val . $set_unit . ' '; } //get box shadow color $shadow_color = $attr['style'] == 'idle' ? $settings['shadow-color'] : $settings['shadow-color-hover']; //get box shadow transaprency $shadow_transparency = $attr['style'] == 'idle' ? $settings['shadow-alpha'] : $settings['shadow-alpha-hover']; $shadow_color = Essential_Grid_Base::hex2rgba($shadow_color, $shadow_transparency); $multi_string .= ' ' . $shadow_color; if ($attr['style'] == 'idle') { $idle['-moz-' . $set_style] = $multi_string; $idle['-webkit-' . $set_style] = $multi_string; $idle[$set_style] = $multi_string; } else { $hover['-moz-' . $set_style] = $multi_string; $hover['-webkit-' . $set_style] = $multi_string; $hover[$set_style] = $multi_string; } } elseif ($set_style == 'border') { if ($attr['style'] == 'idle') { $idle['border-top-width'] = isset($settings[$style][0]) ? $settings[$style][0] . $set_unit : '0' . $set_unit; $idle['border-right-width'] = isset($settings[$style][1]) ? $settings[$style][1] . $set_unit : '0' . $set_unit; $idle['border-bottom-width'] = isset($settings[$style][2]) ? $settings[$style][2] . $set_unit : '0' . $set_unit; $idle['border-left-width'] = isset($settings[$style][3]) ? $settings[$style][3] . $set_unit : '0' . $set_unit; } else { $hover['border-top-width'] = isset($settings[$style][0]) ? $settings[$style][0] . $set_unit : '0' . $set_unit; $hover['border-right-width'] = isset($settings[$style][1]) ? $settings[$style][1] . $set_unit : '0' . $set_unit; $hover['border-bottom-width'] = isset($settings[$style][2]) ? $settings[$style][2] . $set_unit : '0' . $set_unit; $hover['border-left-width'] = isset($settings[$style][3]) ? $settings[$style][3] . $set_unit : '0' . $set_unit; } } else { $multi_string = ''; foreach ($settings[$style] as $val) { $multi_string .= $val . $set_unit . ' '; } if ($attr['style'] == 'idle') { $idle[$set_style] = $multi_string; } else { $hover[$set_style] = $multi_string; } } } else { if ($set_style == 'background-color') { //get bg color transaprency $bg_color_transparency = $attr['style'] == 'idle' ? $settings['bg-alpha'] : $settings['bg-alpha-hover']; $bg_color_rgba = Essential_Grid_Base::hex2rgba($settings[$style], $bg_color_transparency); // we only need rgba in backend if ($attr['style'] == 'idle') { $idle[$set_style] = $bg_color_rgba; } else { $hover[$set_style] = $bg_color_rgba; } } else { if ($set_style == 'border') { if ($attr['style'] == 'idle') { $idle['border-style'] = 'solid'; } else { $hover['border-style'] = 'solid'; } } if ($set_style == 'font-style' && $settings[$style] == 'true') { $settings[$style] = 'italic'; } $set_unit = @$attributes[$style]['unit']; if ($attr['style'] == 'idle') { $idle[$set_style] = $settings[$style] . $set_unit; if ($set_style == 'position' && $settings[$style] == 'absolute') { $idle['height'] = 'auto'; $idle['width'] = 'auto'; switch ($settings['align']) { case 't_l': $idle['top'] = $settings['top-bottom'] . $settings['absolute-unit']; $idle['left'] = $settings['left-right'] . $settings['absolute-unit']; break; case 't_r': $idle['top'] = $settings['top-bottom'] . $settings['absolute-unit']; $idle['right'] = $settings['left-right'] . $settings['absolute-unit']; break; case 'b_l': $idle['bottom'] = $settings['top-bottom'] . $settings['absolute-unit']; $idle['left'] = $settings['left-right'] . $settings['absolute-unit']; break; case 'b_r': $idle['bottom'] = $settings['top-bottom'] . $settings['absolute-unit']; $idle['right'] = $settings['left-right'] . $settings['absolute-unit']; break; } } } else { $hover[$set_style] = $settings[$style] . $set_unit; } } } } } $this->layers_css[$this->id]['idle'][$element_class] = $idle; $this->layers_css[$this->id]['hover'][$element_class] = $hover; $this->layers_css[$this->id]['settings'][$element_class]['important'] = $do_important; }