web/data/cubicweb.preferences.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 02 Jul 2009 10:30:44 +0200
branchstable
changeset 2233 bf3603caaf0d
parent 2162 14088bb1a103
child 4280 15d541321a8c
permissions -rw-r--r--
merge
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
2133
c3beb65d884d simplify js
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1992
diff changeset
     7
var prefsValues = {};
c3beb65d884d simplify js
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1992
diff changeset
     8
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
     9
function togglePrefVisibility(elemId) {
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    10
    clearPreviousMessages();
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    11
    jQuery('#' + elemId).toggleClass('hidden');
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    12
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    13
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    14
function closeFieldset(fieldsetid){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    15
    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
    16
    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
    17
    _toggleFieldset(fieldsetid, 1, linklabel, linkhref);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    18
}
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    19
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    20
function openFieldset(fieldsetid){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    21
    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
    22
    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
    23
    _toggleFieldset(fieldsetid, 0, linklabel, linkhref);
1612
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
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    26
function _toggleFieldset(fieldsetid, closeaction, linklabel, linkhref){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    27
    jQuery('#'+fieldsetid).find('div.openlink').each(function(){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    28
	    var link = A({'href' : "javascript:noop();",
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    29
			  '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
    30
			  linklabel);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    31
	    jQuery(this).empty().append(link);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    32
	});
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    33
    jQuery('#'+fieldsetid).find('fieldset[id]').each(function(){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    34
	    var fieldset = jQuery(this);
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    35
	    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
    36
		fieldset.addClass('hidden');
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    37
	    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    38
		fieldset.removeClass('hidden');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    39
		linkLabel = (_('open all'));
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
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    44
function validatePrefsForm(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
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
	});
1992
b073057c2756 [javascript] fix AJAX user preference validation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1870
diff changeset
    87
    jQuery(form).find('input[type=radio]:checked').each(function () {
b073057c2756 [javascript] fix AJAX user preference validation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1870
diff changeset
    88
            unfreezeButtons = _checkValue(jQuery(this), unfreezeButtons);
1870
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    89
     });
015dfeaf1d89 trailing space cleanup, js lint, a small indent for preference sections
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1865
diff changeset
    90
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    91
    if (unfreezeButtons){
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    92
	unfreezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    93
    }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    94
	if (!success){
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    95
	    clearPreviousMessages();
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    96
	}
1865
62d3726ad8cb restore ajax validation cwpreferencies
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1671
diff changeset
    97
	clearPreviousErrors(form.attr('id'));
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    98
	freezeFormButtons(form.attr('id'));
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
    99
    }
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   100
}
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
function _checkValue(input, unfreezeButtons){
2133
c3beb65d884d simplify js
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1992
diff changeset
   103
    var currentValue = prefsValues[input.attr('name')];
c3beb65d884d simplify js
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1992
diff changeset
   104
     if (currentValue != input.val()){
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   105
	 input.addClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   106
	 unfreezeButtons = true;
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   107
     }else{
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   108
	 input.removeClass('changed');
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   109
	 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
   110
     }
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   111
     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
   112
     return unfreezeButtons;
1612
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
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   115
function setCurrentValues(form){
2154
558079860667 [javascript][preferences] fix setCurrentValues to consider all kind of widgets (textarea, select, etc.) not just inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2133
diff changeset
   116
    jQuery(form).find('[name^=value]').each(function () {
2162
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   117
	var input = jQuery(this);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   118
	var name = input.attr('name');
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   119
	if(input.attr('type') == 'radio'){
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   120
	    // NOTE: there seems to be a bug with jQuery(input).attr('checked')
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   121
	    //       in our case, we can't rely on its value, we use
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   122
	    //       the DOM API instead.
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   123
	    if(input[0].checked){
2155
1dd3dfc6fd76 change values in "edits-value" input
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 2154
diff changeset
   124
		prefsValues[name] = input.val();
2133
c3beb65d884d simplify js
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 1992
diff changeset
   125
	    }
2162
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   126
	}else{
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   127
	    prefsValues[name] = input.val();
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   128
	}
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   129
	jQuery(form).find('input[name=edits-'+ name + ']').val(prefsValues[name]);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   130
    });
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   131
}
2154
558079860667 [javascript][preferences] fix setCurrentValues to consider all kind of widgets (textarea, select, etc.) not just inputs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2133
diff changeset
   132
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   133
function initEvents(){
2162
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   134
    jQuery('form').each(function() {
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   135
	var form = jQuery(this);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   136
	//freezeFormButtons(form.attr('id'));
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   137
	form.find('input.validateButton').attr('disabled', 'disabled');
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   138
	form.find('input[type=text]').keyup(function(){
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   139
	    checkValues(form);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   140
	});
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   141
	form.find('input[type=radio]').change(function(){
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   142
	    checkValues(form);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   143
	});
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   144
	form.find('select').change(function(){
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   145
	    checkValues(form);
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   146
	});
14088bb1a103 reindent, fix obscur perf pb w/ ff 3.0.11 by performing search on the form instead of the whole document
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2155
diff changeset
   147
	setCurrentValues(form);
1612
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   148
    });
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
$(document).ready(function() {
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   152
	initEvents();
0be8605c411a validation of preferencies done by ajax
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 604
diff changeset
   153
});