mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-21 13:59:21 +02:00
* Checked and IsDisabled
This commit is contained in:
parent
a89aeae608
commit
34e96dd494
@ -43,10 +43,14 @@ Type
|
||||
FStopPropagation: Boolean;
|
||||
FBeforeBind : TNotifyEvent;
|
||||
FAfterBind : TNotifyEvent;
|
||||
function GetChecked: Boolean;
|
||||
function GetDisabled: Boolean;
|
||||
function GetIndex: Integer;
|
||||
procedure SetActionList(AValue: THTMLCustomElementActionList);
|
||||
procedure SetChecked(AValue: Boolean);
|
||||
procedure SetCSSSelector(AValue: String);
|
||||
procedure SetCustomEvents(AValue: String);
|
||||
procedure SetDisabled(AValue: Boolean);
|
||||
procedure SetElementID(AValue: String);
|
||||
procedure SetIndex(AValue: Integer);
|
||||
Protected
|
||||
@ -61,8 +65,12 @@ Type
|
||||
|
||||
Public
|
||||
Destructor Destroy; override;
|
||||
Class Function GetElementChecked(aElement : TJSHTMLElement) : boolean; virtual;
|
||||
Class Function GetElementDisabled(aElement : TJSHTMLElement) : boolean; virtual;
|
||||
Class Function GetElementValue(aElement : TJSHTMLElement) : String; virtual;
|
||||
Class Procedure SetElementValue(aElement : TJSHTMLElement; const aValue : String; asHTML : Boolean = false); virtual;
|
||||
Class Procedure SetElementChecked(aElement : TJSHTMLElement; const aValue : Boolean); virtual;
|
||||
Class Procedure SetElementDisabled(aElement : TJSHTMLElement; const aValue : Boolean); virtual;
|
||||
function GetParentComponent: TComponent; override;
|
||||
function HasParent: Boolean; override;
|
||||
Procedure Bind;
|
||||
@ -82,6 +90,8 @@ Type
|
||||
// When reading, only the first value is returned in case of multiple elements.
|
||||
// When writing, the value is set on all elements.
|
||||
Property Value : String Read GetValue Write SetValue;
|
||||
property checked : Boolean Read GetChecked write SetChecked;
|
||||
property Disabled : Boolean Read GetDisabled Write SetDisabled;
|
||||
Public
|
||||
// These can be published in descendents
|
||||
Property Events : THTMLEvents Read FEvents Write FEvents;
|
||||
@ -380,6 +390,17 @@ begin
|
||||
FActionList.AddAction(Self);
|
||||
end;
|
||||
|
||||
procedure THTMLCustomElementAction.SetChecked(AValue: Boolean);
|
||||
|
||||
procedure DoSetChecked(aElement: TJSHTMLElement);
|
||||
begin
|
||||
SetElementChecked(aElement,aValue);
|
||||
end;
|
||||
|
||||
begin
|
||||
ForEach(@DoSetChecked);
|
||||
end;
|
||||
|
||||
function THTMLCustomElementAction.GetIndex: Integer;
|
||||
begin
|
||||
if Assigned(FActionList) then
|
||||
@ -388,6 +409,18 @@ begin
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
function THTMLCustomElementAction.GetChecked: Boolean;
|
||||
begin
|
||||
if (Length(FElements)>0) and Assigned (FElements[0]) then
|
||||
Result:=GetElementChecked(FElements[0]);
|
||||
end;
|
||||
|
||||
function THTMLCustomElementAction.GetDisabled: Boolean;
|
||||
begin
|
||||
if (Length(FElements)>0) and Assigned (FElements[0]) then
|
||||
Result:=GetElementDisabled(FElements[0]);
|
||||
end;
|
||||
|
||||
function THTMLCustomElementAction.GetValue: String;
|
||||
begin
|
||||
if (Length(FElements)>0) and Assigned (FElements[0]) then
|
||||
@ -425,6 +458,18 @@ begin
|
||||
Inherited;
|
||||
end;
|
||||
|
||||
class function THTMLCustomElementAction.GetElementChecked(
|
||||
aElement: TJSHTMLElement): boolean;
|
||||
begin
|
||||
Result:=aElement.IsChecked;
|
||||
end;
|
||||
|
||||
class function THTMLCustomElementAction.GetElementDisabled(
|
||||
aElement: TJSHTMLElement): boolean;
|
||||
begin
|
||||
Result:=aElement.IsDisabled;
|
||||
end;
|
||||
|
||||
class function THTMLCustomElementAction.GetElementValue(aElement: TJSHTMLElement
|
||||
): String;
|
||||
begin
|
||||
@ -455,6 +500,18 @@ begin
|
||||
aElement.InputValue:=aValue;
|
||||
end;
|
||||
|
||||
class procedure THTMLCustomElementAction.SetElementChecked(
|
||||
aElement: TJSHTMLElement; const aValue: Boolean);
|
||||
begin
|
||||
aElement.IsChecked:=aValue;
|
||||
end;
|
||||
|
||||
class procedure THTMLCustomElementAction.SetElementDisabled(
|
||||
aElement: TJSHTMLElement; const aValue: Boolean);
|
||||
begin
|
||||
aElement.IsDisabled:=aValue;
|
||||
end;
|
||||
|
||||
procedure THTMLCustomElementAction.SetCSSSelector(AValue: String);
|
||||
begin
|
||||
if (FCSSSelector=aValue) then exit;
|
||||
@ -471,6 +528,16 @@ begin
|
||||
BindElementEvents;
|
||||
end;
|
||||
|
||||
procedure THTMLCustomElementAction.SetDisabled(AValue: Boolean);
|
||||
procedure DoSetChecked(aElement: TJSHTMLElement);
|
||||
begin
|
||||
SetElementDisabled(aElement,aValue);
|
||||
end;
|
||||
|
||||
begin
|
||||
ForEach(@DoSetChecked);
|
||||
end;
|
||||
|
||||
procedure THTMLCustomElementAction.SetElementID(AValue: String);
|
||||
begin
|
||||
if (FElementID=aValue) then exit;
|
||||
|
@ -83,8 +83,12 @@ Type
|
||||
private
|
||||
Function GetData(aName: String): String;
|
||||
function GetInputValue: String;
|
||||
function GetIsChecked: Boolean;
|
||||
function GetIsDisabled: Boolean;
|
||||
procedure SetData(Index: String; AValue: String);
|
||||
procedure SetInputValue(const aValue: String);
|
||||
procedure SetIsChecked(AValue: Boolean);
|
||||
procedure SetIsDisabled(AValue: Boolean);
|
||||
Public
|
||||
Function ParentHTMLElement : TJSHTMLElement;
|
||||
Function FindParent(aMatch : TJSHTMLElementMatcher) : TJSHTMLElement;
|
||||
@ -95,6 +99,8 @@ Type
|
||||
procedure AddRemoveClass(Const aAddClass, aRemoveClass: String); overload;
|
||||
function HasClass(const aClass: String): Boolean;
|
||||
Property InputValue: String Read GetInputValue Write SetInputValue;
|
||||
Property IsChecked : Boolean Read GetIsChecked Write SetIsChecked;
|
||||
Property IsDisabled: Boolean Read GetIsDisabled Write SetIsDisabled;
|
||||
Property Data[Index: String]: String Read GetData Write SetData;
|
||||
end;
|
||||
|
||||
@ -376,6 +382,19 @@ begin
|
||||
Result:=GetElementValue(Self)
|
||||
end;
|
||||
|
||||
function TJSHTMLElementHelper.GetIsChecked: Boolean;
|
||||
begin
|
||||
if Self is TJSHTMLInputElement then
|
||||
Result:=TJSHTMLInputElement(Self).Checked
|
||||
else
|
||||
Result:=False;
|
||||
end;
|
||||
|
||||
function TJSHTMLElementHelper.GetIsDisabled: Boolean;
|
||||
begin
|
||||
Result:=Assigned(Self) and (hasOwnProperty('disabled'))
|
||||
end;
|
||||
|
||||
procedure TJSHTMLElementHelper.SetData(Index: String; AValue: String);
|
||||
begin
|
||||
Dataset.Map[Index]:=aValue;
|
||||
@ -400,6 +419,20 @@ begin
|
||||
SetElementValue(Self,aValue)
|
||||
end;
|
||||
|
||||
procedure TJSHTMLElementHelper.SetIsChecked(AValue: Boolean);
|
||||
begin
|
||||
if (Self is TJSHTMLInputElement) then
|
||||
TJSHTMLInputElement(Self).Checked:=aValue;
|
||||
end;
|
||||
|
||||
procedure TJSHTMLElementHelper.SetIsDisabled(AValue: Boolean);
|
||||
begin
|
||||
if aValue then
|
||||
Self.Properties['disabled']:=True
|
||||
else
|
||||
Self.Properties['disabled']:=Undefined;
|
||||
end;
|
||||
|
||||
function TJSHTMLElementHelper.ParentHTMLElement: TJSHTMLElement;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user