-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDW.VCL.Iframe.pas
101 lines (81 loc) · 2.26 KB
/
DW.VCL.Iframe.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit DW.VCL.Iframe;
interface
uses Classes, DWElementTag, DW.VCL.CustomRegion;
type
TDWIFrame = class(TDWCustomRegion)
private
FSrc: string;
procedure SetSrc(const Value: string);
protected
FOldSrc: string;
function RenderAsync: TDWElementXHTMLTag; override;
function RenderHTML: TDWElementTag; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Src: string read FSrc write SetSrc;
end;
implementation
uses
DW.VCL.Common;
{ TDWIFrame }
constructor TDWIFrame.Create(AOwner: TComponent);
begin
inherited;
FTagName := 'iframe'
end;
destructor TDWIFrame.Destroy;
begin
inherited;
end;
function TDWIFrame.RenderAsync: TDWElementXHTMLTag;
var
xHTMLName: string;
begin
Result := nil;
xHTMLName := HTMLName;
if (FAsyncRefreshControl) or (not FRendered) or (FOldSrc <> FSrc) then
begin
TDWRegionCommon.CancelChildAsyncRender(Self);
TDWBSCommon.RenderAsync(xHTMLName, Self);
end
else
begin
TDWBSCommon.SetAsyncClass(xHTMLName, RenderCSSClass, FOldCss);
TDWBSCommon.SetAsyncStyle(xHTMLName, RenderStyle, FOldStyle);
TDWBSCommon.SetAsyncVisible(FMainID, Visible, FOldVisible);
if Assigned(OnAfterAsyncChange) then
OnAfterAsyncChange(Self);
{ TODO 1 -oDELCIO -cIMPLEMENT : Global event OnAfterAsyncChange }
{ if Assigned(gIWBSOnAfterAsyncChange) then
gIWBSOnAfterAsyncChange(Self, xHTMLName); }
end;
end;
function TDWIFrame.RenderHTML: TDWElementTag;
begin
FOldCss := RenderCSSClass;
FOldStyle := RenderStyle;
FOldVisible := Visible;
FOldSrc := FSrc;
FRegionDiv := TDWElementTag.CreateHTMLTag(FTagName);
FRegionDiv.AddStringParam('id', HTMLName);
FRegionDiv.AddClassParam(FOldCss);
FRegionDiv.AddStringParam('src', FOldSrc);
// FRegionDiv.AddStringParam('role',GetRoleString);
FRegionDiv.AddStringParam('style', RenderStyle);
TDWBSCommon.RenderScript(Self, FRegionDiv);
FMainID := FRegionDiv.Params.Values['id'];
Result := FRegionDiv;
FAsyncRefreshControl := False;
FRendered := True;
end;
procedure TDWIFrame.SetSrc(const Value: string);
begin
if FSrc <> Value then
begin
FSrc := Value;
AsyncRefreshControl;
end;
end;
end.