mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
3ee8f505b7
The main benefit of this is so that authors who make use of .editorconfig don't end up with whitespace changes in their PRs. Spaces vs. tabs has been left alone, although that could do with a tidy-up in SS4 after the switch to PSR-1/2. The command used was this: for match in '*.ss' '*.css' '*.scss' '*.html' '*.yml' '*.php' '*.js' '*.csv' '*.inc' '*.php5'; do find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" -exec sed -E -i '' 's/[[:space:]]+$//' {} \+ find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" | xargs perl -pi -e 's/ +$//' done
128 lines
4.5 KiB
JavaScript
128 lines
4.5 KiB
JavaScript
describe 'ChangeTracker'
|
|
describe 'Basics'
|
|
before_each
|
|
$('body').append(
|
|
'<form method="GET" id="form_test" action="#"></form>'
|
|
);
|
|
end
|
|
after_each
|
|
$('#form_test').remove()
|
|
end
|
|
|
|
it 'doesnt mark unaltered forms as changed'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text" value="origval" />'
|
|
);
|
|
|
|
$('#form_test').changetracker();
|
|
|
|
$('#form_test').is('.changed').should.be_false
|
|
end
|
|
|
|
it 'can track changes on input type=text fields with existing values'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text" value="origval" />'
|
|
);
|
|
|
|
$('#form_test').changetracker();
|
|
|
|
$(':input[name=field_text]').val('newval').trigger('change');
|
|
$('#form_test').is('.changed').should.be_true
|
|
$(':input[name=field_text]').is('.changed').should.be_true
|
|
end
|
|
|
|
it 'can track changes on input type=radio fields with existing values'
|
|
$('#form_test').append(
|
|
'<input type="radio" id="field_radio1" name="field_radio" value="1" checked="checked" />'
|
|
+ '<input type="radio" id="field_radio2" name="field_radio" value="2" />'
|
|
);
|
|
$('#form_test').changetracker();
|
|
$('#field_radio2').attr('checked', 'checked').trigger('click');
|
|
$('#form_test').is('.changed').should.be_true
|
|
// $('#field_radio1').is('.changed').should.be_true
|
|
$('#field_radio2').is('.changed').should.be_true
|
|
end
|
|
|
|
it 'can track changes on select fields with existing values'
|
|
$('#form_test').append(
|
|
'<select name="field_select">'
|
|
+ '<option value="1" selected="selected" />'
|
|
+ '<option value="2" />'
|
|
+ '</select>'
|
|
);
|
|
|
|
$('#form_test').changetracker();
|
|
|
|
$(':input[name=field_select]').val(2).trigger('change');
|
|
$('#form_test').is('.changed').should.be_true
|
|
$(':input[name=field_select]').is('.changed').should.be_true
|
|
end
|
|
|
|
it 'can exclude certain fields via an optional selector'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text" value="origval" />'
|
|
+ '<input type="text" name="field_text_ignored" value="origval" />'
|
|
);
|
|
|
|
$('#form_test').changetracker({
|
|
ignoreFieldSelector: ':input[name=field_text_ignored]'
|
|
});
|
|
|
|
$(':input[name=field_text_ignored]').val('newval').trigger('change');
|
|
$('#form_test').is('.changed').should.be_false
|
|
$(':input[name=field_text_ignored]').is('.changed').should.be_false
|
|
|
|
$(':input[name=field_text]').val('newval').trigger('change');
|
|
$('#form_test').is('.changed').should.be_true
|
|
$(':input[name=field_text]').is('.changed').should.be_true
|
|
end
|
|
|
|
it 'can attach custom CSS classes for tracking changed state'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text" value="origval" />'
|
|
);
|
|
|
|
$('#form_test').changetracker({
|
|
changedCssClass: 'customchanged'
|
|
});
|
|
|
|
$(':input[name=field_text]').val('newval').trigger('change');
|
|
$('#form_test').hasClass('changed').should.be_false
|
|
$('#form_test').hasClass('customchanged').should.be_true
|
|
$(':input[name=field_text]').hasClass('changed').should.be_false
|
|
$(':input[name=field_text]').hasClass('customchanged').should.be_true
|
|
end
|
|
|
|
it 'can reset changed state of individual fields'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text1" value="origval" />'
|
|
+ '<input type="text" name="field_text2" value="origval" />'
|
|
);
|
|
$('#form_test').changetracker();
|
|
|
|
$(':input[name=field_text1]').val('newval').trigger('change');
|
|
$(':input[name=field_text2]').val('newval').trigger('change');
|
|
$('#form_test').changetracker('resetField', $(':input[name=field_text1]'));
|
|
$(':input[name=field_text1]').is('.changed').should.be_false
|
|
$(':input[name=field_text2]').is('.changed').should.be_true
|
|
$('#form_test').is('.changed').should.be_true
|
|
end
|
|
|
|
it 'can reset all fields in the form'
|
|
$('#form_test').append(
|
|
'<input type="text" name="field_text1" value="origval" />'
|
|
+ '<input type="text" name="field_text2" value="origval" />'
|
|
);
|
|
$('#form_test').changetracker();
|
|
|
|
$(':input[name=field_text1]').val('newval').trigger('change');
|
|
$(':input[name=field_text2]').val('newval').trigger('change');
|
|
$('#form_test').changetracker('reset');
|
|
$(':input[name=field_text1]').is('.changed').should.be_false
|
|
$(':input[name=field_text2]').is('.changed').should.be_false
|
|
$('#form_test').is('.changed').should.be_false
|
|
end
|
|
|
|
end
|
|
end
|