mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1654a2681f
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
38 lines
946 B
JavaScript
38 lines
946 B
JavaScript
var dom = require('../lib/dom');
|
|
var dispose = require('../lib/dispose');
|
|
var _ = require('underscore');
|
|
var kd = require('../lib/koDom');
|
|
var AbstractWidget = require('./AbstractWidget');
|
|
|
|
/**
|
|
* Switch - A bi-state Switch widget
|
|
*/
|
|
function Switch(field) {
|
|
AbstractWidget.call(this, field);
|
|
}
|
|
dispose.makeDisposable(Switch);
|
|
_.extend(Switch.prototype, AbstractWidget.prototype);
|
|
|
|
Switch.prototype.buildConfigDom = function() {
|
|
return null;
|
|
};
|
|
|
|
Switch.prototype.buildDom = function(row) {
|
|
var value = row[this.field.colId()];
|
|
return dom('div.field_clip',
|
|
dom('div.widget_switch',
|
|
kd.toggleClass('switch_on', value),
|
|
kd.toggleClass('switch_transition', row._isRealChange),
|
|
dom('div.switch_slider'),
|
|
dom('div.switch_circle'),
|
|
dom.on('click', () => {
|
|
if (!this.field.column().isRealFormula()) {
|
|
value.setAndSave(!value.peek());
|
|
}
|
|
})
|
|
)
|
|
);
|
|
};
|
|
|
|
module.exports = Switch;
|