Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { IOColorPicker } from "../io/color-picker";
- import { IOCheckbox } from "../io/checkbox";
- import { FormGroup } from "./form-group";
- export class ColorPickerFormGroup extends FormGroup {
- public _Outline: IOColorPicker;
- public _Color: IOColorPicker;
- public _ColorCheckbox: IOCheckbox;
- public _OutlineCheckbox: IOCheckbox;
- public CheckElements(): void {
- if (this.Node.children.length >= 2) {
- let color_checkbox: HTMLElement = this.Node.children[0].querySelector("CHECK-BOX");
- let color_picker: HTMLElement = this.Node.children[1].querySelector("COLOR-PICKER");
- if (!color_checkbox) {
- this._ColorCheckbox = null;
- } else if (!this._ColorCheckbox || this._ColorCheckbox.Node !== color_checkbox) {
- this._ColorCheckbox = new IOCheckbox(color_checkbox);
- }
- if (!color_picker) {
- this._Color = null;
- } else if (!this._Color || this._Color.Node !== color_picker) {
- this._Color = new IOColorPicker(color_picker, "FFFFFF");
- }
- } else {
- this._Color = null;
- this._ColorCheckbox = null;
- }
- if (this.Node.children.length >= 4) {
- let outline_checkbox: HTMLElement = this.Node.children[2].querySelector("CHECK-BOX");
- let outline_picker: HTMLElement = this.Node.children[3].querySelector("COLOR-PICKER");
- if (!outline_checkbox) {
- this._OutlineCheckbox = null;
- } else if (!this._OutlineCheckbox || this._OutlineCheckbox.Node !== outline_checkbox) {
- this._OutlineCheckbox = new IOCheckbox(outline_checkbox);
- }
- if (!outline_picker) {
- this._Outline = null;
- } else if (!this._Outline || this._Outline.Node !== outline_picker) {
- this._Outline = new IOColorPicker(outline_picker, "000000");
- }
- } else {
- this._Outline = null;
- this._OutlineCheckbox = null;
- }
- }
- public get Color(): string {
- this.CheckElements();
- if (this._ColorCheckbox && this._ColorCheckbox.get()) {
- return null;
- }
- if (this._Color) {
- return this._Color.Color;
- }
- }
- public set Color(value: string) {
- this.CheckElements();
- if (this._ColorCheckbox) {
- this._ColorCheckbox.set(!!value);
- if (!value) {
- return;
- }
- }
- if (this._Color) {
- this._Color.Color = value;
- }
- }
- public get Outline(): string {
- this.CheckElements();
- if (this._OutlineCheckbox && this._OutlineCheckbox.get()) {
- return null;
- }
- if (this._Outline) {
- return this._Outline.Color;
- }
- }
- public set Outline(value: string) {
- this.CheckElements();
- if (this._OutlineCheckbox) {
- this._OutlineCheckbox.set(!!value);
- if (!value) {
- return;
- }
- }
- if (this._Outline) {
- this._Outline.Color = value;
- }
- }
- constructor(Node: HTMLElement) {
- super(Node);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement