-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path$Component.html
159 lines (144 loc) · 6.67 KB
/
$Component.html
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html>
<head>
<title>Material</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css"></style>
</head>
<body>
<div data-role="page" data-theme="a">
<div data-role="header" data-position="fixed">
<a
href="#"
class="ui-btn-left"
data-icon="arrow-l"
data-theme="c"
onclick="history.back(); return false"
>Back</a
>
<h1>$component</h1>
</div>
<div data-role="content">
<style>
.jump {
line-height: 1.5em;
}
</style>
<script>
function OpenUrl(url, type, choose) {
if (navigator.userAgent.indexOf("Android") > -1) {
prompt(
"#",
"App.OpenUrl(\f" +
url +
"\f" +
type +
"\f" +
choose
);
return false;
} else return true;
}
</script>
<p>
The <b>`$component`</b> function lets you author your own
components without having to write verbose class code.
</p>
<p>
After that you will be exposed to the batch and css methods.
</p>
<div class="samp">
$component(parent, tag, width, height, properties,
options)
</div>
<p>
The properties param is an object that contains the
properties of the html element and use direct dom access. So
you can use DOM Api's like textContent.
</p>
<p>Here is an example:</p>
<div
data-role="collapsible"
data-collapsed="true"
data-mini="true"
data-theme="a"
data-content-theme="b"
>
<h3>Example - $component</h3>
<div id="main" class="code-js" style="font-size: 70%">
<br />app.LoadPlugin('Metro')<br />
<b id="cfg">cfg.Portrait</b><br /><br />
class Main extends App {<br />
constructor() {<br />
super();<br />
this.layMain =
ui.addLayout("main", "linear", "fillxy,vcenter");<br />
this.txt =
ui.addText(this.layMain, "My Hybrid app");<br />
}<br /><br />
onStart() {<br />
this.layMain.setChildMargins(0.02,
0.02, 0.02, 0.02);<br /><br />
let btn =
ui.addButton(this.layMain, "My Button", "primary");<br /><br />
let outlinebtn =
$component(this.layMain, "button", -1, -1, {<br />
textContent: "Hello
World",<br />
}).css`<br />
border: 2px solid #6200ea;<br />
color: #6200ea;<br />
background-color:
transparent;<br />
font-family: "Archivo",
sans-serif;<br />
font-weight: 500;<br />
font-size: 1rem;<br />
text-align: center;<br />
cursor: pointer;<br />
padding: 0.5rem 1rem;<br />
transition: background-color
0.3s, color 0.3s;<br />
<br />
&:hover {<br />
background-color:
#6200ea;<br />
color:
white;<br />
}<br /><br />
&:active {<br />
background-color:
#3700b3;<br />
border-color:
#3700b3;<br />
}`.on("click", function (e) {<br />
e.stopPropagation();<br />
ui.showPopup("Clicked
Custom Button");<br />
});<br /><br />
}<br />
}<br />
</div>
<div name="divCopy" align="right">
<a
href="#"
data-role="button"
data-mini="true"
data-inline="true"
onclick="copy('main')"
>Copy All</a
>
<a
href="#"
data-role="button"
data-mini="true"
data-inline="true"
onclick="demo('main')"
> Run </a
>
</div>
</div>
</div>
</div>
</body>
</html>