1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return function (d, b) {
|
7 | extendStatics(d, b);
|
8 | function __() { this.constructor = d; }
|
9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10 | };
|
11 | })();
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | var Graphic_1 = require("./../Graphic");
|
14 | var Tool_1 = require("./../Tool");
|
15 |
|
16 |
|
17 |
|
18 | var Button = (function (_super) {
|
19 | __extends(Button, _super);
|
20 |
|
21 | |
22 |
|
23 |
|
24 | function Button() {
|
25 | var _this = _super.call(this) || this;
|
26 | _this.setProps({
|
27 | label: "",
|
28 | labelCentered: false,
|
29 | paddingLeft: 0,
|
30 | paddingRight: 0,
|
31 | paddingTop: 0,
|
32 | paddingBottom: 0
|
33 | });
|
34 | return _this;
|
35 | }
|
36 | |
37 |
|
38 |
|
39 |
|
40 | Button.prototype.initialize = function (props) {
|
41 | _super.prototype.initialize.call(this, props);
|
42 | this.shape("shape", {
|
43 | stroke: this.context.theme.primaryColor,
|
44 | strokeThickness: 2,
|
45 | fill: Tool_1.Color.black,
|
46 | fillAlpha: 0.5,
|
47 | radius: 5
|
48 | }, {
|
49 | hover: {
|
50 | fill: Tool_1.Color.cyan900,
|
51 | fillAlpha: 1
|
52 | },
|
53 | disabled: {
|
54 | fill: Tool_1.Color.grey900,
|
55 | fillAlpha: 0.7,
|
56 | stroke: Tool_1.Color.grey400
|
57 | }
|
58 | }).text("label", {
|
59 | text: this.props.label,
|
60 | fill: Tool_1.Color.white,
|
61 | dropShadow: true,
|
62 | dropShadowColor: Tool_1.Color.black,
|
63 | dropShadowAngle: 80,
|
64 | dropShadowBlur: 30,
|
65 | dropShadowDistance: 1
|
66 | }, {
|
67 | disabled: {
|
68 | fill: Tool_1.Color.grey400
|
69 | }
|
70 | });
|
71 | this.connect(this.signals.propChange, ["label", "labelCentered"], this.onSizeChange.bind(this))
|
72 | .connect(this.getGraphicItem("label").signals.propChange, ["width", "height"], this.onSizeChange.bind(this));
|
73 | };
|
74 |
|
75 | |
76 |
|
77 |
|
78 | Button.prototype.onSizeChange = function () {
|
79 | var label = this.getGraphicItem("label"), _a = label && label.props, width = _a.width, height = _a.height;
|
80 | this.shape("shape", {
|
81 | width: (this.props.width || width) + this.props.paddingLeft + this.props.paddingRight,
|
82 | height: (this.props.height || height) + this.props.paddingTop + this.props.paddingBottom
|
83 | }).text("label", {
|
84 | text: this.props.label,
|
85 | x: this.props.labelCentered ? ((this.props.width + this.props.paddingLeft + this.props.paddingRight) / 2) - (width / 2) : this.props.paddingLeft,
|
86 | y: this.props.labelCentered ? ((this.props.height + this.props.paddingTop + this.props.paddingBottom) / 2) - (height / 2) : this.props.paddingTop
|
87 | });
|
88 | _super.prototype.onSizeChange.call(this);
|
89 | };
|
90 | return Button;
|
91 | }(Graphic_1.Graphic));
|
92 | exports.Button = Button;
|