2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-09 06:20:38 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backgrid'
|
|
|
|
], function (Backgrid) {
|
|
|
|
return Backgrid.Cell.extend({
|
2013-06-09 06:21:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
className: 'toggle-cell clickable',
|
2013-06-09 06:21:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
events: {
|
|
|
|
'click': '_onClick'
|
|
|
|
},
|
2013-06-09 06:21:32 +00:00
|
|
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
_onClick: function () {
|
|
|
|
var name = this.column.get('name');
|
|
|
|
this.model.set(name, !this.model.get(name));
|
|
|
|
this.render();
|
2013-06-09 06:21:32 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
this.model.save();
|
|
|
|
},
|
2013-06-09 06:20:38 +00:00
|
|
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
render: function () {
|
|
|
|
this.$el.empty();
|
2013-06-09 06:20:38 +00:00
|
|
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
this.$el.html('<i />');
|
2013-06-09 06:20:38 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
var name = this.column.get('name');
|
2013-06-09 06:20:38 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (this.model.get(name)) {
|
|
|
|
this.$('i').addClass(this.column.get('trueClass'));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.$('i').addClass(this.column.get('falseClass'));
|
|
|
|
}
|
|
|
|
return this;
|
2013-06-09 06:21:32 +00:00
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
});
|
2013-06-09 06:20:38 +00:00
|
|
|
});
|