Revision 95f1d53f
Added by Marek Hulán about 9 years ago
app/assets/javascripts/hidden_values.js | ||
---|---|---|
function turn_text_switch() {
|
||
$('.hidden_value_text_switch').each(function (index, switch_field) {
|
||
if ($(switch_field).attr('data-switch-active') != 'true') {
|
||
$(switch_field).change(function () {
|
||
value = $("#common_parameter_value")[0];
|
||
value.type = (this.checked ? 'password' : 'text');
|
||
});
|
||
$(this).attr('data-switch-active', 'true');
|
||
}
|
||
})
|
||
}
|
||
|
||
function turn_textarea_switch() {
|
||
$('.hidden_value_textarea_switch').each(function (index, switch_field) {
|
||
if ($(switch_field).attr('data-switch-active') != 'true') {
|
||
$(switch_field).change(function () {
|
||
var source = $(this).closest('tr').children('td.value').children()[0];
|
||
if (source === undefined) {
|
||
source = $(this).closest('div.form-group').parent().prev().children().children('div.col-md-4').children()[0];
|
||
}
|
||
if (this.checked) {
|
||
var target = '<input class="form-control" type="password" id="' + source.id + '" name="' + source.name + '" value ="' + source.value + '"></input>'
|
||
} else {
|
||
... | ... | |
});
|
||
}
|
||
|
||
// normal page load trigger
|
||
$(document).ready(turn_text_switch);
|
||
|
||
// two-pane ajax trigger
|
||
$(document).ajaxComplete(turn_text_switch);
|
||
|
||
// normal page load trigger
|
||
$(document).ready(turn_textarea_switch);
|
||
|
app/views/common_parameters/_form.html.erb | ||
---|---|---|
<% if @common_parameter.hidden_value? %>
|
||
<%= password_f f, :value, :size => "col-md-8", :value => @common_parameter.value %>
|
||
<% else %>
|
||
<%= text_f f, :value, :size => "col-md-8" %>
|
||
<%= textarea_f(f, :value,
|
||
:class => "form-control value col-md-8",
|
||
:rows => line_count(f, :value),
|
||
:placeholder => _("Value")) %>
|
||
<% end %>
|
||
<%= checkbox_f f, :hidden_value, :class => 'hidden_value_text_switch', :checked => f.object.hidden_value? %>
|
||
<%= checkbox_f f, :hidden_value, :class => 'hidden_value_textarea_switch', :checked => f.object.hidden_value? %>
|
||
<%= submit_or_cancel f %>
|
||
<% end %>
|
Also available in: Unified diff
Fixes #9650 - use textarea for global parameters