From 4fdb67308b0e095aa76e36581cc4e94357d61f6a Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Thu, 11 Sep 2008 00:07:01 +0000 Subject: Bug 216557: Be able to specify the order of the columns in a bug list - Patch by Pascal Held r=LpSolit r=pyrzak a=LpSolit --- js/change-columns.js | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 js/change-columns.js (limited to 'js') diff --git a/js/change-columns.js b/js/change-columns.js new file mode 100644 index 000000000..5fd5c1085 --- /dev/null +++ b/js/change-columns.js @@ -0,0 +1,145 @@ +/*# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Bug Tracking System. + # + # The Initial Developer of the Original Code is Pascal Held. + # + # Contributor(s): Pascal Held + # +*/ + +function initChangeColumns() { + window.onunload = unload; + var av_select = document.getElementById("available_columns"); + var sel_select = document.getElementById("selected_columns"); + document.getElementById("avail_header").style.display = "inline"; + document.getElementById("available_columns").style.display = "inline"; + document.getElementById("select_button").style.display = "inline"; + document.getElementById("deselect_button").style.display = "inline"; + document.getElementById("up_button").style.display = "inline"; + document.getElementById("down_button").style.display = "inline"; + switch_options(sel_select, av_select, false); + sel_select.selectedIndex = -1; + updateView(); +} + +function switch_options(from_box, to_box, selected) { + for (var i = 0; i= 0; i--) { + var opt = sel_select.options[i]; + if (opt.selected) { + sel_select.options[i] = dummy; + sel_select.options[i + 1] = opt; + sel_select.options[i] = last; + } + else{ + last = opt; + } + } + updateView(); +} + +function updateView() { + var select_button = document.getElementById("select_button"); + var deselect_button = document.getElementById("deselect_button"); + var up_button = document.getElementById("up_button"); + var down_button = document.getElementById("down_button"); + select_button.disabled = true; + deselect_button.disabled = true; + up_button.disabled = true; + down_button.disabled = true; + var av_select = document.getElementById("available_columns"); + var sel_select = document.getElementById("selected_columns"); + for (var i = 0; i < av_select.options.length; i++) { + if (av_select.options[i].selected) { + select_button.disabled = false; + break; + } + } + for (var i = 0; i < sel_select.options.length; i++) { + if (sel_select.options[i].selected) { + deselect_button.disabled = false; + up_button.disabled = false; + down_button.disabled = false; + break; + } + } + if (sel_select.options.length > 0) { + if (sel_select.options[0].selected) { + up_button.disabled = true; + } + if (sel_select.options[sel_select.options.length - 1].selected) { + down_button.disabled = true; + } + } +} + +function change_submit() { + var sel_select = document.getElementById("selected_columns"); + for (var i = 0; i < sel_select.options.length; i++) { + sel_select.options[i].selected = true; + } + return false; +} + +function unload() { + var sel_select = document.getElementById("selected_columns"); + for (var i = 0; i < sel_select.options.length; i++) { + sel_select.options[i].selected = true; + } +} -- cgit v1.2.3-24-g4f1b