Advertisement
Guest User

can I die yet

a guest
Feb 9th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { IOColorPicker } from "../io/color-picker";
  2. import { IOCheckbox } from "../io/checkbox";
  3. import { FormGroup } from "./form-group";
  4.  
  5. export class ColorPickerFormGroup extends FormGroup {
  6.     public _Outline: IOColorPicker;
  7.     public _Color: IOColorPicker;
  8.     public _ColorCheckbox: IOCheckbox;
  9.     public _OutlineCheckbox: IOCheckbox;
  10.  
  11.     public CheckElements(): void {
  12.         if (this.Node.children.length >= 2) {
  13.             let color_checkbox: HTMLElement = this.Node.children[0].querySelector("CHECK-BOX");
  14.             let color_picker: HTMLElement = this.Node.children[1].querySelector("COLOR-PICKER");
  15.  
  16.             if (!color_checkbox) {
  17.                 this._ColorCheckbox = null;
  18.             } else if (!this._ColorCheckbox || this._ColorCheckbox.Node !== color_checkbox) {
  19.                 this._ColorCheckbox = new IOCheckbox(color_checkbox);
  20.             }
  21.  
  22.             if (!color_picker) {
  23.                 this._Color = null;
  24.             } else if (!this._Color || this._Color.Node !== color_picker)  {
  25.                 this._Color = new IOColorPicker(color_picker, "FFFFFF");
  26.             }
  27.         } else {
  28.             this._Color = null;
  29.             this._ColorCheckbox = null;
  30.         }
  31.  
  32.         if (this.Node.children.length >= 4) {
  33.             let outline_checkbox: HTMLElement = this.Node.children[2].querySelector("CHECK-BOX");
  34.             let outline_picker: HTMLElement = this.Node.children[3].querySelector("COLOR-PICKER");
  35.  
  36.             if (!outline_checkbox) {
  37.                 this._OutlineCheckbox = null;
  38.             } else if (!this._OutlineCheckbox || this._OutlineCheckbox.Node !== outline_checkbox) {
  39.                 this._OutlineCheckbox = new IOCheckbox(outline_checkbox);
  40.             }
  41.  
  42.             if (!outline_picker) {
  43.                 this._Outline = null;
  44.             } else if (!this._Outline || this._Outline.Node !== outline_picker)  {
  45.                 this._Outline = new IOColorPicker(outline_picker, "000000");
  46.             }
  47.         } else {
  48.             this._Outline = null;
  49.             this._OutlineCheckbox = null;
  50.         }
  51.     }
  52.  
  53.     public get Color(): string {
  54.         this.CheckElements();
  55.  
  56.         if (this._ColorCheckbox && this._ColorCheckbox.get()) {
  57.             return null;
  58.         }
  59.  
  60.         if (this._Color) {
  61.             return this._Color.Color;
  62.         }
  63.     }
  64.  
  65.     public set Color(value: string) {
  66.         this.CheckElements();
  67.  
  68.         if (this._ColorCheckbox) {
  69.             this._ColorCheckbox.set(!!value);
  70.  
  71.             if (!value) {
  72.                 return;
  73.             }
  74.         }
  75.  
  76.         if (this._Color) {
  77.             this._Color.Color = value;
  78.         }
  79.     }
  80.  
  81.     public get Outline(): string {
  82.         this.CheckElements();
  83.  
  84.         if (this._OutlineCheckbox && this._OutlineCheckbox.get()) {
  85.             return null;
  86.         }
  87.  
  88.         if (this._Outline) {
  89.             return this._Outline.Color;
  90.         }
  91.     }
  92.  
  93.     public set Outline(value: string) {
  94.         this.CheckElements();
  95.  
  96.         if (this._OutlineCheckbox) {
  97.             this._OutlineCheckbox.set(!!value);
  98.  
  99.             if (!value) {
  100.                 return;
  101.             }
  102.         }
  103.  
  104.         if (this._Outline) {
  105.             this._Outline.Color = value;
  106.         }
  107.     }
  108.  
  109.     constructor(Node: HTMLElement) {
  110.         super(Node);
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement