web/data/cubicweb.preferences.js
author Katia Saurfelt <katia.saurfelt@logilab.fr>
Tue, 19 May 2009 14:31:42 +0200
branchstable
changeset 1868 af1ae863606d
parent 1865 62d3726ad8cb
child 1870 015dfeaf1d89
permissions -rw-r--r--
update handleFormValidationResponse calls
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
604
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     1
/* toggle visibility of an element by its id
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     2
 * & set current visibility status in a cookie
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     3
 * XXX whenever used outside of preferences, don't forget to
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     4
 *     move me in a more appropriate place
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     5
 */
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
     6
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
     7
function togglePrefVisibility(elemId) {
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
     8
    clearPreviousMessages();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
     9
    jQuery('#' + elemId).toggleClass('hidden');
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    10
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    11
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    12
function closeFieldset(fieldsetid){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    13
    var linklabel = _('open all');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    14
    var linkhref = 'javascript:openFieldset("' +fieldsetid + '")'
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    15
    _toggleFieldset(fieldsetid, 1, linklabel, linkhref)
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    16
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    17
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    18
function openFieldset(fieldsetid){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    19
    var linklabel = _('close all');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    20
    var linkhref = 'javascript:closeFieldset("'+ fieldsetid + '")'
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    21
    _toggleFieldset(fieldsetid, 0, linklabel, linkhref)
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    22
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    23
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    24
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    25
function _toggleFieldset(fieldsetid, closeaction, linklabel, linkhref){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    26
    jQuery('#'+fieldsetid).find('div.openlink').each(function(){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    27
	    var link = A({'href' : "javascript:noop();",
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    28
			  'onclick' : linkhref},
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    29
			  linklabel)
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    30
	    jQuery(this).empty().append(link);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    31
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    32
    jQuery('#'+fieldsetid).find('fieldset[id]').each(function(){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    33
	    var fieldset = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    34
	    if(closeaction){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    35
		fieldset.addClass('hidden')
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    36
	    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    37
		fieldset.removeClass('hidden');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    38
		linkLabel = (_('open all'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    39
	    }
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    40
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    41
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    42
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    43
function validatePrefsForm(formid){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    44
    freezeFormButtons(formid);
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    45
    clearPreviousMessages();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    46
    clearPreviousErrors(formid);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    47
    return validateForm(formid, null,  submitSucces, submitFailure);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    48
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    49
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    50
function submitFailure(formid){
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    51
    var form = jQuery('#'+formid);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    52
    var dom = DIV({'class':'critical'},
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    53
		  _("please correct errors below"));
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    54
    jQuery(form).find('div.formsg').empty().append(dom);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    55
    // clearPreviousMessages()
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    56
    jQuery(form).find('span.error').next().focus();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    57
}
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    58
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    59
function submitSucces(url, formid){
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    60
    var form = jQuery('#'+formid);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    61
    setCurrentValues(form);
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    62
    var dom = DIV({'class':'msg'},
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    63
		  _("changes applied"));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    64
    jQuery(form).find('div.formsg').empty().append(dom);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    65
    jQuery(form).find('input').removeClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    66
    checkValues(form, true);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    67
    return;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    68
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    69
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    70
function clearPreviousMessages() {
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    71
    jQuery('div#appMsg').addClass('hidden');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    72
    jQuery('div.formsg').empty();
604
e85042d18b48 [preferences] preferences sections will now remember their collapsed/open status
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    73
}
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    74
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    75
function clearPreviousErrors(formid) {
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    76
    jQuery('#err-value:' + formid).remove();
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    77
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    78
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    79
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    80
function checkValues(form, success){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    81
    var unfreezeButtons = false;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    82
    jQuery(form).find('select').each(function () { 
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    83
	    unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    84
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    85
    jQuery(form).find('[type=text]').each(function () {
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    86
	    unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    87
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    88
    jQuery(form).find('input[type=radio]').each(function () { 
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    89
	    if (jQuery(this).attr('checked')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    90
		unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    91
	    }
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    92
     }); 
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    93
    
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    94
    if (unfreezeButtons){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    95
	unfreezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    96
    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    97
	if (!success){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    98
	    clearPreviousMessages();
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    99
	}
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   100
	clearPreviousErrors(form.attr('id'));
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   101
	freezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   102
    }
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   103
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   104
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   105
function _checkValue(input, unfreezeButtons){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   106
     var currentValueInput = jQuery("input[name=current-" + input.attr('name') + "]");
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   107
     if (currentValueInput.attr('value') != input.attr('value')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   108
	 input.addClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   109
	 unfreezeButtons = true;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   110
     }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   111
	 input.removeClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   112
	 jQuery("span[id=err-" + input.attr('id') + "]").remove();
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   113
     }	
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   114
     input.removeClass('error');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   115
     return unfreezeButtons
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   116
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   117
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   118
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   119
function setCurrentValues(form){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   120
    jQuery(form).find('input[name^=current-value]').each(function () { 
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   121
	    var currentValueInput = jQuery(this);
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   122
	    var name = currentValueInput.attr('name').split('-')[1];
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   123
	    jQuery(form).find("[name=" + name + "]").each(function (){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   124
		    var input = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   125
		    if(input.attr('type')=='radio'){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   126
			if(input.attr('checked')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   127
			    currentValueInput.attr('value', input.attr('value'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   128
			}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   129
		    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   130
			currentValueInput.attr('value', input.attr('value'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   131
		    }
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   132
		});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   133
    });
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   134
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   135
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   136
function initEvents(){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   137
  jQuery('form').each(function() { 
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   138
	  var form = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   139
	  freezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   140
	  form.find('input[type=text]').keyup(function(){  
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   141
		  checkValues(form);	   
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   142
          });
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   143
	  form.find('input[type=radio]').change(function(){  
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   144
		  checkValues(form);	   
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   145
          });
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   146
	  form.find('select').change(function(){  
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   147
		  checkValues(form);	 
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   148
          });
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   149
	  setCurrentValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   150
    });
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   151
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   152
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   153
$(document).ready(function() {
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   154
	initEvents();
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   155
});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   156