unit FMXTee.Editor.Export.JavaScript;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMX.Edit, FMXTee.Canvas.JavaScript;

type
  TTeeJScriptOptions = class(TForm)
    CBFullPage: TCheckBox;
    Label1: TLabel;
    ECanvas: TEdit;
    Label2: TLabel;
    CBPath: TComboEdit;
    CBMinify: TCheckBox;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    IFormat : TJavascriptExportFormat;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

procedure TTeeJScriptOptions.FormActivate(Sender: TObject);
begin
  if not Assigned(IFormat) then
  begin
    IFormat:=TJavaScriptExportFormat(TagObject);

    if Assigned(IFormat) then
    begin
      CBFullPage.IsChecked:=IFormat.DoFullPage;
      ECanvas.Text:=IFormat.CanvasName;
      CBPath.Text:=IFormat.SourceScriptPath;
      CBMinify.IsChecked:=IFormat.Minify;
    end;
  end;
end;

procedure TTeeJScriptOptions.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  if Assigned(IFormat) then
  begin
    IFormat.DoFullPage:=CBFullPage.IsChecked;
    IFormat.CanvasName:=ECanvas.Text;
    IFormat.SourceScriptPath:=CBPath.Text;
    IFormat.Minify:=CBMinify.IsChecked;
  end;

  CanClose:=True;
end;

initialization
  RegisterClass(TTeeJScriptOptions);
finalization
  UnRegisterClass(TTeeJScriptOptions);
end.
