| @@ -1,62 +1,62 @@ | ||
| 1 | -<?php | |
| 2 | -class AccuaForm_Element_Checkbox extends AccuaForm_OptionElement { | |
| 3 | - protected $attributes = array("type" => "checkbox"); | |
| 4 | - protected $inline; | |
| 5 | - protected $maxheight; | |
| 6 | - | |
| 7 | - public function jQueryDocumentReady() { | |
| 8 | - if(!empty($this->inline)) | |
| 9 | - echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css("margin-right", "0");'; | |
| 10 | - else | |
| 11 | - echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css({ "padding-bottom": "0", "border-bottom": "none" });'; | |
| 12 | - | |
| 13 | - if(!empty($this->maxheight) && is_numeric($this->maxheight)) { | |
| 14 | - echo <<<JS | |
| 15 | -var checkboxes = jQuery("#{$this->attributes["id"]} .pfbc-checkboxes"); | |
| 16 | -if(checkboxes.outerHeight() > {$this->maxheight}) { | |
| 17 | - checkboxes.css({ | |
| 18 | - "height": "{$this->maxheight}px", | |
| 19 | - "overflow": "auto", | |
| 20 | - "overflow-x": "hidden" | |
| 21 | - }); | |
| 22 | -} | |
| 23 | -JS; | |
| 24 | - } | |
| 25 | - } | |
| 26 | - | |
| 27 | - public function render() { | |
| 28 | - if(isset($this->attributes["value"])) { | |
| 29 | - if(!is_array($this->attributes["value"])) | |
| 30 | - $this->attributes["value"] = array($this->attributes["value"]); | |
| 31 | - } | |
| 32 | - else | |
| 33 | - $this->attributes["value"] = array(); | |
| 34 | - | |
| 35 | - if(substr($this->attributes["name"], -2) != "[]") | |
| 36 | - $this->attributes["name"] .= "[]"; | |
| 37 | - | |
| 38 | - $count = 0; | |
| 39 | - echo '<div id="', $this->attributes["id"], '"><div class="pfbc-checkboxes">'; | |
| 40 | - foreach($this->options as $value => $text) { | |
| 41 | - $value = $this->getOptionValue($value); | |
| 42 | - echo '<div class="pfbc-checkbox"><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), '"'; | |
| 43 | - if(in_array($value, $this->attributes["value"])) | |
| 44 | - echo ' checked="checked"'; | |
| 45 | - echo '/></td><td><label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></td></tr></table></div>'; | |
| 46 | - ++$count; | |
| 47 | - } | |
| 48 | - echo '</div>'; | |
| 49 | - | |
| 50 | - if(!empty($this->inline)) | |
| 51 | - echo '<div style="clear: both;"></div>'; | |
| 52 | - | |
| 53 | - echo '</div>'; | |
| 54 | - } | |
| 55 | - | |
| 56 | - public function renderCSS() { | |
| 57 | - if(!empty($this->inline)) | |
| 58 | - echo '#', $this->attributes["id"], ' .pfbc-checkbox { float: left; margin-right: 0.5em; }'; | |
| 59 | - else | |
| 60 | - echo '#', $this->attributes["id"], ' .pfbc-checkbox { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }'; | |
| 61 | - } | |
| 62 | -} | |
| 1 | +<?php | |
| 2 | +class AccuaForm_Element_Checkbox extends AccuaForm_OptionElement { | |
| 3 | + protected $attributes = array("type" => "checkbox"); | |
| 4 | + protected $inline; | |
| 5 | + protected $maxheight; | |
| 6 | + | |
| 7 | + public function jQueryDocumentReady() { | |
| 8 | + if(!empty($this->inline)) | |
| 9 | + echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css("margin-right", "0");'; | |
| 10 | + else | |
| 11 | + echo 'jQuery("#', $this->attributes["id"], ' .pfbc-checkbox:last").css({ "padding-bottom": "0", "border-bottom": "none" });'; | |
| 12 | + | |
| 13 | + if(!empty($this->maxheight) && is_numeric($this->maxheight)) { | |
| 14 | + echo <<<JS | |
| 15 | +var checkboxes = jQuery("#{$this->attributes["id"]} .pfbc-checkboxes"); | |
| 16 | +if(checkboxes.outerHeight() > {$this->maxheight}) { | |
| 17 | + checkboxes.css({ | |
| 18 | + "height": "{$this->maxheight}px", | |
| 19 | + "overflow": "auto", | |
| 20 | + "overflow-x": "hidden" | |
| 21 | + }); | |
| 22 | +} | |
| 23 | +JS; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 27 | + public function render() { | |
| 28 | + if(isset($this->attributes["value"])) { | |
| 29 | + if(!is_array($this->attributes["value"])) | |
| 30 | + $this->attributes["value"] = array($this->attributes["value"]); | |
| 31 | + } | |
| 32 | + else | |
| 33 | + $this->attributes["value"] = array(); | |
| 34 | + | |
| 35 | + if(substr($this->attributes["name"], -2) != "[]") | |
| 36 | + $this->attributes["name"] .= "[]"; | |
| 37 | + | |
| 38 | + $count = 0; | |
| 39 | + echo '<div id="', $this->attributes["id"], '"><div class="pfbc-checkboxes">'; | |
| 40 | + foreach($this->options as $value => $text) { | |
| 41 | + $value = $this->getOptionValue($value); | |
| 42 | + echo '<div class="pfbc-checkbox"><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(array("id", "value", "checked")), ' value="', $this->filter($value), '"'; | |
| 43 | + if(in_array($value, $this->attributes["value"])) | |
| 44 | + echo ' checked="checked"'; | |
| 45 | + echo '/> <label for="', $this->attributes["id"], "-", $count, '">', $text, '</label></div>'; | |
| 46 | + ++$count; | |
| 47 | + } | |
| 48 | + echo '</div>'; | |
| 49 | + | |
| 50 | + if(!empty($this->inline)) | |
| 51 | + echo '<div style="clear: both;"></div>'; | |
| 52 | + | |
| 53 | + echo '</div>'; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public function renderCSS() { | |
| 57 | + if(!empty($this->inline)) | |
| 58 | + echo '#', $this->attributes["id"], ' .pfbc-checkbox { float: left; margin-right: 0.5em; }'; | |
| 59 | + else | |
| 60 | + echo '#', $this->attributes["id"], ' .pfbc-checkbox { padding: 0.5em 0; border-bottom: 1px solid #f4f4f4; }'; | |
| 61 | + } | |
| 62 | +} | |