@intuitionrobotics/thunderstorm
Version:
74 lines • 2.78 kB
JavaScript
;
/*
* Thunderstorm is a full web app framework!
*
* Typescript & Express backend infrastructure that natively runs on firebase function
* Typescript & React frontend infrastructure
*
* Copyright (C) 2020 Intuition Robotics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TooltipBuilder = exports.TooltipModule = exports.TooltipModule_Class = void 0;
const ts_common_1 = require("@intuitionrobotics/ts-common");
const thunder_dispatcher_1 = require("../../core/thunder-dispatcher");
const Stylable_1 = require("../../tools/Stylable");
const dispatch_showTooltip = new thunder_dispatcher_1.ThunderDispatcher("__showTooltip");
const Interval_DefaultTooltip = 6 * ts_common_1.Second;
class TooltipModule_Class extends ts_common_1.Module {
constructor() {
super("TooltipModule");
this.show = (tooltip, e) => {
if (!tooltip.location && e)
tooltip.location = { x: e.pageX + 10, y: e.pageY + 15 };
dispatch_showTooltip.dispatchUI(tooltip);
};
this.hide = () => dispatch_showTooltip.dispatchUI();
}
}
exports.TooltipModule_Class = TooltipModule_Class;
exports.TooltipModule = new TooltipModule_Class();
class TooltipBuilder extends Stylable_1.StylableBuilder {
constructor(content, e) {
super();
this.location = { x: 0, y: 0 };
this.duration = Interval_DefaultTooltip;
this.setLocation = (x, y) => {
this.location = { x, y };
return this;
};
this.setDuration = (duration) => {
this.duration = duration;
return this;
};
this.show = () => {
const model = {
content: this.content,
location: this.location,
style: this.style,
className: this.className,
duration: this.duration,
};
exports.TooltipModule.show(model);
};
this.content = content;
if (e)
this.location = {
x: e.pageX + 10,
y: e.pageY + 15
};
}
}
exports.TooltipBuilder = TooltipBuilder;
//# sourceMappingURL=TooltipModule.js.map