mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
BUGFIX Fixed fieldSelector logic in jquery.changetracker
MINOR Fixed removeData() invocation in jquery.changetracker MINOR Removed debug code in jquery.changetracker git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92683 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6514dc35d4
commit
54a7beb5e7
@ -34,13 +34,17 @@
|
|||||||
* @license BSD License
|
* @license BSD License
|
||||||
*/
|
*/
|
||||||
$.fn.changetracker = function(_options) {
|
$.fn.changetracker = function(_options) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
if(this.length > 1){
|
if(this.length > 1){
|
||||||
this.each(function() { $(this).changetracker(_options); });
|
this.each(function(i, item) {
|
||||||
|
this.changetracker(_options);
|
||||||
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
fieldSelector: ':input:not(:submit),:select:not(:submit)',
|
fieldSelector: ':input:not(:submit)',
|
||||||
ignoreFieldSelector: "",
|
ignoreFieldSelector: "",
|
||||||
changedCssClass: 'changed'
|
changedCssClass: 'changed'
|
||||||
};
|
};
|
||||||
@ -48,15 +52,11 @@
|
|||||||
var options = $.extend({}, this.defaults, _options);
|
var options = $.extend({}, this.defaults, _options);
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
// optional metadata plugin support
|
// optional metadata plugin support
|
||||||
if ($.meta) options = $.extend({}, options, this.data());
|
if ($.meta) options = $.extend({}, options, this.data());
|
||||||
|
|
||||||
// setup original values
|
// setup original values
|
||||||
this.getFields().each(function() {
|
this.getFields()
|
||||||
$(this).data('changetracker.origVal', $(this).val());
|
|
||||||
})
|
|
||||||
.bind('change', function(e) {
|
.bind('change', function(e) {
|
||||||
var $field = $(e.target);
|
var $field = $(e.target);
|
||||||
var origVal = $field.data('changetracker.origVal');
|
var origVal = $field.data('changetracker.origVal');
|
||||||
@ -64,6 +64,9 @@
|
|||||||
$field.addClass(options.changedCssClass);
|
$field.addClass(options.changedCssClass);
|
||||||
self.addClass(options.changedCssClass);
|
self.addClass(options.changedCssClass);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.each(function() {
|
||||||
|
$(this).data('changetracker.origVal', $(this).val());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,9 +74,6 @@
|
|||||||
* Reset change state of all form fields and the form itself.
|
* Reset change state of all form fields and the form itself.
|
||||||
*/
|
*/
|
||||||
this.reset = function() {
|
this.reset = function() {
|
||||||
console.debug('reset called');
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.getFields().each(function() {
|
this.getFields().each(function() {
|
||||||
self.resetField(this);
|
self.resetField(this);
|
||||||
});
|
});
|
||||||
@ -88,7 +88,7 @@
|
|||||||
* @param DOMElement field
|
* @param DOMElement field
|
||||||
*/
|
*/
|
||||||
this.resetField = function(field) {
|
this.resetField = function(field) {
|
||||||
return $(field).data('changetracker', null);
|
return $(field).removeData('changetracker.origVal');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user