Replaced the use of the jQuery 'attr' function with the 'prop' function when using the 'selected' property.

The 'attr' function is going to be deprecated an may cause errors in Firefox.
This commit is contained in:
Alejandro Gallardo Escobar 2015-07-14 11:48:30 +02:00
parent e6e640524c
commit 289bcefbe2
14 changed files with 45 additions and 45 deletions

View File

@ -1039,7 +1039,7 @@ $(document).ready (function () {
return false;
}
$('#module option').map(function(){
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});
});

View File

@ -508,11 +508,11 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
if (c == 0) {
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -521,7 +521,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
}

View File

@ -491,7 +491,7 @@ $(document).ready (function () {
return false;
}
$('#module option').map(function(){
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});
});

View File

@ -704,13 +704,13 @@ $(document).ready (function () {
$("#submit-updbutton").click(function () {
$('#id_tag_selected option').map(function(){
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});
$("#submit-crtbutton").click(function () {
$('#id_tag_selected option').map(function(){
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});

View File

@ -221,7 +221,7 @@ $(document).ready (function () {
$("#submit-upd_button").click(function () {
$('#fields_selected option').map(function() {
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});
});

View File

@ -142,7 +142,7 @@ $('#type').change(function() {
switch ($(this).val()) {
case 'command':
$('#new_window option[value="0"]')
.attr('selected','selected');
.prop('selected', true);
$('#new_window').attr('disabled','disabled');
break;
case 'url':

View File

@ -586,7 +586,7 @@ function loadAgents(agent_list) {
function setFieldsFormLayer(layer_name,layer_group, layer_visible_form, agent_list) {
$("#text-layer_name_form").val(layer_name);
$("#layer_group_form [value="+layer_group+"]").attr("selected",true);
$("#layer_group_form [value="+layer_group+"]").prop("selected", true);
$("#text_id_agent").val('<?php echo __('Select'); ?>');
if (layer_visible_form == '0') {
$("#checkbox-layer_visible_form").removeAttr("checked");

View File

@ -397,7 +397,7 @@ $(document).ready (function () {
jQuery.each ($(this).fieldValue (), function () {
if (module_alerts[this] != undefined)
$("#target_modules option[value="+module_alerts[this]+"]")
.attr ("selected", "selected");
.prop ("selected", true);
});
});

View File

@ -456,13 +456,13 @@ $(document).ready (function () {
$("#submit-crt").click(function () {
$('#id_tag_selected option').map(function() {
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});
$("#submit-upd").click(function () {
$('#id_tag_selected option').map(function() {
$(this).attr('selected','selected');
$(this).prop('selected', true);
});
});

View File

@ -541,16 +541,16 @@ function loadFieldsFromDB(item) {
.each(function() {
if($(this).val() == val) {
$(this).attr('selected',true);
$(this).prop('selected', true);
$(this).trigger('change');
anySelected = true;
}
});
if (anySelected == false) {
$('#' + periodId + '_select option')
.eq(0).attr('selected',true);
.eq(0).prop('selected', true);
$('#' + periodId + '_units option')
.eq(0).attr('selected',true);
.eq(0).prop('selected', true);
$('#hidden-period').val(val);
$('#text-' + periodId + '_text').val(val);
adjustTextUnits(periodId);

View File

@ -346,7 +346,7 @@ $(document).ready (function () {
$('#id_agents')
.append($('<option></option>')
.html(noneText).attr ("None", "")
.attr('value', -1).attr('selected', true));
.attr('value', -1).prop('selected', true));
}
else {
jQuery.each (data, function (i, val) {
@ -470,7 +470,7 @@ function item_per_agent_change(itemPerAgent) {
$('#module').append ($('<option></option>').html (<?php echo "'" . __('None') . "'"; ?>).attr("value", -1));
$('#module').attr('disabled', true);
$('#label_type').empty();
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Agent') . "'"; ?>).attr('value', 'agent').attr('selected', true));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Agent') . "'"; ?>).attr('value', 'agent').prop('selected', true));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('None') . "'"; ?>).attr('value', 'none'));
$('#hidden-item_per_agent_test').val(1);
@ -488,7 +488,7 @@ function item_per_agent_change(itemPerAgent) {
$('#hidden-item_per_agent_test').val(0);
$('#label_type').empty();
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Agent') . "'"; ?>).attr('value', 'agent'));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Agent - Module') . "'"; ?>).attr('value', 'agent_module').attr('selected', true));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Agent - Module') . "'"; ?>).attr('value', 'agent_module').prop('selected', true));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('Module') . "'"; ?>).attr('value', 'module'));
$('#label_type').append ($('<option></option>').html (<?php echo "'" . __('None') . "'"; ?>).attr('value', 'none'));

View File

@ -121,7 +121,7 @@
selected = $('#hidden-'+config.moduleSelect.attr('id')+'_selected').val();
if (selected == i) {
option = $("<option></option>")
.attr ("selected", "selected")
.prop ("selected", true)
.attr ("value", value['id_agente_modulo'])
.html (js_html_entity_decode (value['nombre']));
}

View File

@ -88,11 +88,11 @@ function agent_changed (event, id_agent, selected) {
$('#module').empty ();
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -101,7 +101,7 @@ function agent_changed (event, id_agent, selected) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
jQuery.each (data, function (i, val) {
@ -223,7 +223,7 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
.append ($('<option></option>')
.html(noneText)
.attr ("None", "")
.attr('selected', true));
.prop('selected', true));
return;
}
@ -234,7 +234,7 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
.html ($(document)
.data('text_for_module'))
.attr("value", 0)
.attr('selected', true));
.prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
@ -242,7 +242,7 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
.append ($('<option></option>')
.html (data['any_text'])
.attr ("value", 0)
.attr('selected', true));
.prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -255,7 +255,7 @@ function agent_changed_by_multiple_agents (event, id_agent, selected) {
.append ($('<option></option>')
.html (anyText)
.attr ("value", 0)
.attr('selected', true));
.prop('selected', true));
}
}
jQuery.each (data, function (i, val) {
@ -321,11 +321,11 @@ function agent_changed_by_multiple_agents_with_alerts (event, id_agent, selected
$('#module').empty ();
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -334,7 +334,7 @@ function agent_changed_by_multiple_agents_with_alerts (event, id_agent, selected
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
jQuery.each (data, function (i, val) {
@ -394,19 +394,19 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
}
$('#agents')
.append($('<option></option>').html (noneText).attr ("None", "").attr('selected', true));
.append($('<option></option>').html (noneText).attr ("None", "").prop('selected', true));
return;
}
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#agents')
.append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
.append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#agents')
.append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
.append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -416,7 +416,7 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
}
$('#agents')
.append($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
.append($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
jQuery.each (data, function (i, val) {
@ -461,11 +461,11 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
$('#module').empty ();
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
}
else {
if (typeof(data['any_text']) != 'undefined') {
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
@ -474,7 +474,7 @@ function agent_changed_by_multiple_agents_id (event, id_agent, selected) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).attr('selected', true));
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
@ -511,15 +511,15 @@ function period_select_init(name) {
$('.' + name).val(300);
if ($('#' + name + '_select option:eq(0)').val() == 0) {
$('#' + name + '_select option:eq(2)')
.attr('selected', 'selected');
.prop('selected', true);
}
else {
$('#' + name + '_select option:eq(1)')
.attr('selected', 'selected');
.prop('selected', true);
}
}
else if ($('#text-' + name + '_text').val() == 0) {
$('#' + name + '_units option:last').removeAttr('selected');
$('#' + name + '_units option:last').prop('selected', false);
$('#' + name + '_manual').show();
$('#' + name + '_default').hide();
}
@ -595,10 +595,10 @@ function period_set_value(name, value) {
*/
function selectFirst(name) {
if ($('#'+name+' option:eq(0)').val() == 0) {
$('#'+name+' option:eq(1)').attr('selected', 'selected');
$('#'+name+' option:eq(1)').prop('selected', true);
}
else {
$('#'+name+' option:eq(0)').attr('selected', 'selected');
$('#'+name+' option:eq(0)').prop('selected', true);
}
}
@ -666,7 +666,7 @@ function adjustTextUnits(name) {
var restInt = parseInt(rest).toString();
if(rest != restInt && unitsSelected == false) {
$('#'+name+'_units option:eq('+($(this).index()-1)+')').attr('selected', true);
$('#'+name+'_units option:eq('+($(this).index()-1)+')').prop('selected', true);
$('#text-'+name+'_text').val(restPrev);
unitsSelected = true;
}
@ -675,7 +675,7 @@ function adjustTextUnits(name) {
});
if(unitsSelected == false) {
$('#'+name+'_units option:last').attr('selected', true);
$('#'+name+'_units option:last').prop('selected', true);
$('#text-'+name+'_text').val(restPrev);
}

View File

@ -780,7 +780,7 @@ function toggleCommentForm(id_event) {
$('.event_form_' + id_event).css('display', 'none');
// Hide All showed rows
$('.event_form').css('display', 'none');
$(".select_validate").find('option:first').attr('selected', 'selected').parent('select');
$(".select_validate").find('option:first').prop('selected', false).parent('select');
}
else {
$('.event_form_' + id_event).css('display', '');