mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
1995a96178
Summary: - Fix transparency support on color select - Fix z-index conflicts with color select and right panel - Makes widget's default text color visible to color select Test Plan: - Updates nbrowser/CellColor and browser/Widget.test to support new interface. Should not cause regression. Reviewers: paulfitz, dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2735
38 lines
977 B
JavaScript
38 lines
977 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, {defaultTextColor: '#2CB0AF'});
|
|
}
|
|
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;
|