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