web/data/cubicweb.preferences.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 28 May 2009 18:32:51 +0200
changeset 1987 d495e9ce9367
parent 1870 015dfeaf1d89
child 1992 b073057c2756
permissions -rw-r--r--
basic views for python values (eg without any result set)
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');
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    14
    var linkhref = 'javascript:openFieldset("' +fieldsetid + '")';
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    15
    _toggleFieldset(fieldsetid, 1, linklabel, linkhref);
1612
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');
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    20
    var linkhref = 'javascript:closeFieldset("'+ fieldsetid + '")';
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    21
    _toggleFieldset(fieldsetid, 0, linklabel, linkhref);
1612
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},
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    29
			  linklabel);
1612
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){
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    35
		fieldset.addClass('hidden');
1612
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){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    44
    clearPreviousMessages();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    45
    clearPreviousErrors(formid);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    46
    return validateForm(formid, null,  submitSucces, submitFailure);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    47
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    48
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    49
function submitFailure(formid){
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    50
    var form = jQuery('#'+formid);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    51
    var dom = DIV({'class':'critical'},
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    52
		  _("please correct errors below"));
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    53
    jQuery(form).find('div.formsg').empty().append(dom);
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    54
    // clearPreviousMessages()
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    55
    jQuery(form).find('span.error').next().focus();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    56
}
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
function submitSucces(url, formid){
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    59
    var form = jQuery('#'+formid);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    60
    setCurrentValues(form);
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    61
    var dom = DIV({'class':'msg'},
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    62
		  _("changes applied"));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    63
    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
    64
    jQuery(form).find('input').removeClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    65
    checkValues(form, true);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    66
    return;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    67
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    68
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    69
function clearPreviousMessages() {
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    70
    jQuery('div#appMsg').addClass('hidden');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    71
    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
    72
}
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    73
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    74
function clearPreviousErrors(formid) {
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    75
    jQuery('#err-value:' + formid).remove();
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    76
}
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
function checkValues(form, success){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    80
    var unfreezeButtons = false;
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    81
    jQuery(form).find('select').each(function () {
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    82
	    unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    83
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    84
    jQuery(form).find('[type=text]').each(function () {
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    85
	    unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    86
	});
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    87
    jQuery(form).find('input[type=radio]').each(function () {
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    88
	    if (jQuery(this).attr('checked')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    89
		unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    90
	    }
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    91
     });
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    92
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    93
    if (unfreezeButtons){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    94
	unfreezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    95
    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    96
	if (!success){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    97
	    clearPreviousMessages();
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    98
	}
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    99
	clearPreviousErrors(form.attr('id'));
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   100
	freezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   101
    }
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
function _checkValue(input, unfreezeButtons){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   105
     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
   106
     if (currentValueInput.attr('value') != input.attr('value')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   107
	 input.addClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   108
	 unfreezeButtons = true;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   109
     }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   110
	 input.removeClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   111
	 jQuery("span[id=err-" + input.attr('id') + "]").remove();
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   112
     }
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   113
     input.removeClass('error');
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   114
     return unfreezeButtons;
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   115
}
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
function setCurrentValues(form){
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   119
    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
   120
	    var currentValueInput = jQuery(this);
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   121
	    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
   122
	    jQuery(form).find("[name=" + name + "]").each(function (){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   123
		    var input = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   124
		    if(input.attr('type')=='radio'){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   125
			if(input.attr('checked')){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   126
			    currentValueInput.attr('value', input.attr('value'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   127
			}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   128
		    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   129
			currentValueInput.attr('value', input.attr('value'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   130
		    }
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
function initEvents(){
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   136
  jQuery('form').each(function() {
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   137
	  var form = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   138
	  freezeFormButtons(form.attr('id'));
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   139
	  form.find('input[type=text]').keyup(function(){
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   140
		  checkValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   141
          });
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   142
	  form.find('input[type=radio]').change(function(){
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   143
		  checkValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   144
          });
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   145
	  form.find('select').change(function(){
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
   146
		  checkValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   147
          });
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
   148
	  setCurrentValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   149
    });
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
$(document).ready(function() {
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   153
	initEvents();
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   154
});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   155