| 1 |
<?php |
| 2 |
class AccuaForm_Element_Sort extends AccuaForm_OptionElement { |
| 3 |
protected $jQueryOptions; |
| 4 |
|
| 5 |
public function jQueryDocumentReady() { |
| 6 |
echo 'jQuery("#', $this->attributes["id"], ' ul").sortable(', $this->jQueryOptions(), ');'; |
| 7 |
echo 'jQuery("#', $this->attributes["id"], ' ul").disableSelection();'; |
| 8 |
} |
| 9 |
|
| 10 |
public function render() { |
| 11 |
if(substr($this->attributes["name"], -2) != "[]") |
| 12 |
$this->attributes["name"] .= "[]"; |
| 13 |
|
| 14 |
echo '<div id="', $this->attributes["id"], '"><ul>'; |
| 15 |
foreach($this->options as $value => $text) { |
| 16 |
$value = $this->getOptionValue($value); |
| 17 |
echo '<li class="ui-state-default"><input type="hidden" name="', $this->attributes["name"], '" value="', $value, '"/>', $text, '</li>'; |
| 18 |
} |
| 19 |
echo "</ul></div>"; |
| 20 |
} |
| 21 |
|
| 22 |
public function renderCSS() { |
| 23 |
echo '#', $this->attributes["id"], ' ul { list-style-type: none; margin: 0; padding: 0; cursor: pointer; }'; |
| 24 |
echo '#', $this->attributes["id"], ' ul li { margin: 0.25em 0; padding: 0.5em; font-size: 1em; }'; |
| 25 |
} |
| 26 |
} |
| 27 |
|