PluginProbe
Contact Forms by Cimatti / trunk
Contact Forms by Cimatti vtrunk
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / PFBC / Element / Radio.php

Radio.php in Contact Forms by Cimatti trunk, at PFBC/Element/Radio.php

62 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PFBC (PHP Form Builder Class) - Third-party library
4 * @package PFBC
5 */
6
7 // phpcs:disable WordPress.Security.EscapeOutput, WordPress.NamingConventions.PrefixAllGlobals, PluginCheck.CodeAnalysis.Heredoc -- Third-party library
8
9 class Element_Radio extends OptionElement {
10 protected $attributes = array("type" => "radio");
11 protected $inline;
12 protected $maxheight;
13
14 public function jQueryDocumentReady() {
15 if(!empty($this->inline))
16 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-radio:last").css("margin-right", "0");';
17 else
18 echo 'jQuery("#', $this->attributes["id"], ' .pfbc-radio:last").css({ "padding-bottom": "0", "border-bottom": "none" });';
19
20 if(!empty($this->maxheight) && is_numeric($this->maxheight)) {
21 echo <<<JS
22 var radiobuttons = jQuery("#{$this->attributes["id"]} .pfbc-radio-buttons");
23 if(radiobuttons.outerHeight() > {$this->maxheight}) {
24 radiobuttons.css({
25 "height": "{$this->maxheight}px",
26 "overflow": "auto",
27 "overflow-x": "hidden"
28 });
29 }
30 JS;
31 }
32 }
33
34 public function render() {
35 $this->applyAriaAttributes();
36 $count = 0;
37 $checked = false;
38 echo '<div id="', $this->attributes["id"], '"><div class="pfbc-radio-buttons">';
39 foreach($this->options as $value => $text) {
40 $value = $this->getOptionValue($value);
41 echo '<div class="pfbc-radio"><table cellpadding="0" cellspacing="0"><tr><td valign="top"><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(array("id", "value", "checked")), ' value="', $this->filter($value), '"';
42 if(isset($this->attributes["value"]) && $this->attributes["value"] == $value)
43 echo ' checked="checked"';
44 echo '/></td><td><label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></td></tr></table></div>';
45 ++$count;
46 }
47 echo '</div>';
48
49 if(!empty($this->inline))
50 echo '<div style="clear: both;"></div>';
51
52 echo '</div>';
53 }
54
55 public function renderCSS() {
56 if(!empty($this->inline))
57 echo '#', $this->attributes["id"], ' .pfbc-radio { float: left; margin-right: 0.5em; }';
58 else
59 echo '#', $this->attributes["id"], ' .pfbc-radio { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }';
60 }
61 }
62