diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index b9fa5fabe..0a4c96f69 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -1695,6 +1695,45 @@ $(function() { return ''; } /* }}} */ + /** + * Output left-arrow with link which takes over a number of ids into + * a select box. + * + * Clicking in the button will preset the comma seperated list of ids + * in data-ref as options in the select box with name $name + * + * @param string $name id of select box + * @param array $ids list of option values + */ + function printSelectPresetButtonHtml($name, $ids) { /* {{{ */ +?> + " data-ref="" data-ids=""> + +$(document).ready( function() { + $('.selectpreset_btn').click(function(ev){ + ev.preventDefault(); + if (typeof $(ev.currentTarget).data('ids') != 'undefined') { + target = $(ev.currentTarget).data('ref'); + // Use attr() instead of data() because data() converts to int which cannot be split + items = $(ev.currentTarget).attr('data-ids'); + arr = items.split(","); + for(var i in arr) { + $("#"+target+" option[value='"+arr[i]+"']").attr("selected", "selected"); + } + $("#"+target).trigger("chosen:updated"); + } + }); +}); + - "> - -params['strictformcheck']; $dropfolderdir = $this->params['dropfolderdir']; header('Content-Type: application/javascript'); $this->printDropFolderChooserJs("form1"); + $this->printSelectPresetButtonJs(); ?> function checkForm() { @@ -272,7 +254,7 @@ $(document).ready( function() { } } if($tmp) { - $this->__takeOverButton("IndReviewer", $tmp); + $this->printSelectPresetButtonHtml("IndReviewer", $tmp); } /* List all mandatory reviewers */ if($res) { @@ -341,7 +323,7 @@ $(document).ready( function() { } } if($tmp) { - $this->__takeOverButton("GrpReviewer", $tmp); + $this->printSelectPresetButtonHtml("GrpReviewer", $tmp); } /* List all mandatory groups of reviewers */ if($res) { @@ -419,7 +401,7 @@ $(document).ready( function() { } } if($tmp) { - $this->__takeOverButton("IndApprover", $tmp); + $this->printSelectPresetButtonHtml("IndApprover", $tmp); } /* List all mandatory approvers */ if($res) { @@ -489,7 +471,7 @@ $(document).ready( function() { } } if($tmp) { - $this->__takeOverButton("GrpApprover", $tmp); + $this->printSelectPresetButtonHtml("GrpApprover", $tmp); } /* List all mandatory groups of approvers */ if($res) {