/',$key)) eval("\$x = \$d->$key;"); elseif (preg_match('/^__VALUE__$/',$key)) $x = $d; else $x = $d->display($key); return $x; } public static function display($data,$rows,array $cols,array $option) { if (! (array)$data) return ''; $pag = NULL; $view = $output = $button = ''; if (isset($option['type']) AND $option['type']) switch ($option['type']) { case 'select': $view = 'table/select'; if (! empty($option['button'])) $button = implode('',$option['button']); else $button = Form::button('Submit','View/Edit',array('class'=>'form_button','type'=>'submit')); Script::add(array( 'type'=>'stdin', 'data'=>' (function($) { // Enable Range Selection $.fn.enableCheckboxRangeSelection = function() { var lastCheckbox = null; var followOn = 0; var $spec = this; $spec.bind("click", function(e) { if (lastCheckbox != null && e.shiftKey) { x = y = 0; if (followOn != 0) { if ($spec.index(lastCheckbox) < $spec.index(e.target)) { x = 1 - ((followOn == 1) ? 1 : 0); } else { y = 1 - ((followOn == -1) ? 1 : 0); } } $spec.slice( Math.min($spec.index(lastCheckbox) - x, $spec.index(e.target)) + 1, Math.max($spec.index(lastCheckbox), $spec.index(e.target)) + y ).attr("checked",function() { return ! this.checked; }) .parent().parent().toggleClass("selected"); followOn = ($spec.index(lastCheckbox) < $spec.index(e.target)) ? 1 : -1; } else { followOn = 0; } lastCheckbox = e.target; }); return $spec; }; // Enable Toggle, (De)Select All $.fn.check = function(mode) { // if mode is undefined, use "on" as default var mode = mode || "on"; switch(mode) { case "on": $("#select-table tr:not(.head)") .filter(":has(:checkbox:not(checked))") .toggleClass("selected") break; case "off": $("#select-table tr:not(.head)") .filter(":has(:checkbox:checked)") .toggleClass("selected") break; case "toggle": $("#select-table tr:not(.head)") .toggleClass("selected"); break; } return this.each(function(e) { switch(mode) { case "on": this.checked = true; break; case "off": this.checked = false; break; case "toggle": this.checked = !this.checked; break; } }); }; })(jQuery); // Bind our actions $(document).ready(function() { $("#select-table :checkbox").enableCheckboxRangeSelection(); $("#select-menu > #toggle").bind("click",function() { $("#select-table :checkbox").check("toggle"); }); $("#select-menu > #all_on").bind("click",function() { $("#select-table :checkbox").check("on"); }); $("#select-menu > #all_off").bind("click",function() { $("#select-table :checkbox").check("off"); }); // Our mouse over row highlight $("#select-table tr:not(.head)").hover(function() { $(this).children().toggleClass("highlight"); }, function() { $(this).children().toggleClass("highlight"); }); // Click to select Row $("#select-table tr:not(.head)") .filter(":has(:checkbox:checked)") .addClass("selected") .end() .click(function(e) { $(this).toggleClass("selected"); if (e.target.type !== "checkbox") { $(":checkbox", this).attr("checked", function() { return !this.checked; }); } }); // Double click to select a row $("#select-table tr:not(.head)") .dblclick(function(e) { window.location = $("a", this).attr("href"); }); }); ')); $output .= Form::open((isset($option['form']) ? $option['form'] : '')); if (! empty($option['hidden'])) $output .= '