1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-31 16:02:29 +01:00
Sonarr/UI/Cells/ToggleCell.js

40 lines
855 B
JavaScript
Raw Normal View History

2013-06-09 08:20:38 +02:00
"use strict";
define(['app', 'Episode/Layout'], function () {
NzbDrone.Cells.ToggleCell = Backgrid.Cell.extend({
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 08:20:38 +02:00
render: function () {
this.$el.empty();
this.$el.html('<i />');
2013-06-09 08:20:38 +02:00
var name = this.column.get('name');
2013-06-09 08:20:38 +02:00
if (this.model.get(name)) {
this.$('i').addClass(this.column.get('trueClass'));
}
else {
this.$('i').addClass(this.column.get('falseClass'));
2013-06-09 08:20:38 +02:00
}
return this;
}
});
});