diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-24 18:02:22 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-24 18:02:22 +0000 |
commit | 858bd8dc40215486198aa73ab701a17262064b0b (patch) | |
tree | fcc3ec8bcbe0efb4cb52a69b3d1164f22f85d68b /public | |
parent | 669a8c68a7b23f1979a510627425d7aa9a2b1fb9 (diff) | |
download | redmine-858bd8dc40215486198aa73ab701a17262064b0b.tar.gz redmine-858bd8dc40215486198aa73ab701a17262064b0b.zip |
Moved javascript filters functions to application.js.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8698 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public')
-rw-r--r-- | public/javascripts/application.js | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 9d27c0463..9aa996e3e 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -83,6 +83,104 @@ function hideFieldset(el) { fieldset.down('div').hide(); } +function add_filter() { + select = $('add_filter_select'); + field = select.value + Element.show('tr_' + field); + check_box = $('cb_' + field); + check_box.checked = true; + toggle_filter(field); + select.selectedIndex = 0; + + for (i=0; i<select.options.length; i++) { + if (select.options[i].value == field) { + select.options[i].disabled = true; + } + } +} + +function toggle_filter(field) { + check_box = $('cb_' + field); + if (check_box.checked) { + Element.show("operators_" + field); + Form.Element.enable("operators_" + field); + toggle_operator(field); + } else { + Element.hide("operators_" + field); + Form.Element.disable("operators_" + field); + enableValues(field, []); + } +} + +function enableValues(field, indexes) { + var f = $$(".values_" + field); + for(var i=0;i<f.length;i++) { + if (indexes.include(i)) { + Form.Element.enable(f[i]); + f[i].up('span').show(); + } else { + f[i].value = ''; + Form.Element.disable(f[i]); + f[i].up('span').hide(); + } + } + if (indexes.length > 0) { + Element.show("div_values_" + field); + } else { + Element.hide("div_values_" + field); + } +} + +function toggle_operator(field) { + operator = $("operators_" + field); + switch (operator.value) { + case "!*": + case "*": + case "t": + case "w": + case "o": + case "c": + enableValues(field, []); + break; + case "><": + enableValues(field, [0,1]); + break; + case "<t+": + case ">t+": + case "t+": + case ">t-": + case "<t-": + case "t-": + enableValues(field, [2]); + break; + default: + enableValues(field, [0]); + break; + } +} + +function toggle_multi_select(el) { + var select = $(el); + if (select.multiple == true) { + select.multiple = false; + } else { + select.multiple = true; + } +} + +function submit_query_form(id) { + selectAllOptions("selected_columns"); + $(id).submit(); +} + +function apply_filters_observer() { + $$("#query_form input[type=text]").invoke("observe", "keypress", function(e){ + if(e.keyCode == Event.KEY_RETURN) { + submit_query_form("query_form"); + } + }); +} + var fileFieldCount = 1; function addFileField() { |