FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/ionic/components/toolbar/toolbar.ts at ion-datetime · Java1024/ionic · GitHub
Java1024
ionic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
ionic
/
components
/
toolbar
/
toolbar.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
217 lines (194 loc) · 5.45 KB
Breadcrumbs
ionic
/
ionic
/
components
/
toolbar
/
toolbar.ts
Copy path
File metadata and controls
217 lines (194 loc) · 5.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import
{
Component
,
Directive
,
Host
,
ElementRef
,
Optional
,
forwardRef
,
Inject
,
ContentChildren
,
ContentChild
,
QueryList
,
ChangeDetectionStrategy
,
ViewEncapsulation
}
from
'angular2/core'
;
import
{
Button
}
from
'../button/button'
;
import
{
Config
}
from
'../../config/config'
;
import
{
Ion
}
from
'../ion'
;
import
{
MenuToggle
}
from
'../menu/menu-toggle'
;
import
{
Navbar
}
from
'../navbar/navbar'
;
/**
*
@private
*/
export
class
ToolbarBase
extends
Ion
{
itemRefs
=
[
]
;
titleRef
=
null
;
titleCmp
:
any
;
constructor
(
elementRef
:
ElementRef
)
{
super
(
elementRef
)
;
}
/**
*
@private
*/
setTitleCmp
(
titleCmp
)
{
this
.
titleCmp
=
titleCmp
;
}
/**
*
@private
* Returns the toolbar title text if it exists or an empty string
*/
getTitleText
(
)
{
return
(
this
.
titleCmp
&&
this
.
titleCmp
.
getTitleText
(
)
)
||
''
;
}
/**
*
@private
*/
getTitleRef
(
)
{
return
this
.
titleCmp
&&
this
.
titleCmp
.
elementRef
;
}
/**
*
@private
* A toolbar items include the left and right side `ion-buttons`,
* and every `menu-toggle`. It does not include the `ion-title`.
*
@returns
{
TODO
} Array of this toolbar's item ElementRefs.
*/
getItemRefs
(
)
{
return
this
.
itemRefs
;
}
/**
*
@private
*/
addItemRef
(
itemElementRef
)
{
this
.
itemRefs
.
push
(
itemElementRef
)
;
}
}
/**
*
@name
Toolbar
*
@description
* The toolbar is generic bar that sits above or below content.
* Unlike an `Navbar`, `Toolbar` can be used for a subheader as well.
* Since it's based on flexbox, you can place the toolbar where you
* need it and flexbox will handle everything else. Toolbars will automatically
* assume they should be placed before an `ion-content`, so to specify that you want it
* below, you can add the property `position="bottom"`. This will change the flex order
* property.
*
*
@usage
* ```html
* <ion-toolbar>
* <ion-title>My Toolbar Title</ion-title>
* </ion-toolbar>
*
* <ion-toolbar>
* <ion-title>I'm a subheader</ion-title>
* </ion-toolbar>
*
* <ion-content></ion-content>
*
* <ion-toolbar position="bottom">
* <ion-title>I'm a subfooter</ion-title>
* </ion-toolbar>
*
* <ion-toolbar position="bottom">
* <ion-title>I'm a footer</ion-title>
* </ion-toolbar>
*
* ```
*
*
@property
{
any
} [position] - set position of the toolbar, `top` or `bottom`.
* Default `top`.
*
@demo
/docs/v2/demos/toolbar/
*
@see
{
@link ../../navbar/Navbar/ Navbar API Docs
}
*/
@
Component
(
{
selector
:
'ion-toolbar'
,
template
:
'<div class="toolbar-background"></div>'
+
'<ng-content select="[menuToggle],ion-buttons[left]"></ng-content>'
+
'<ng-content select="ion-buttons[start]"></ng-content>'
+
'<ng-content select="ion-buttons[end],ion-buttons[right]"></ng-content>'
+
'<div class="toolbar-content">'
+
'<ng-content></ng-content>'
+
'</div>'
,
host
:
{
'class'
:
'toolbar'
,
'[class.statusbar-padding]'
:
'_sbPadding'
}
,
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
}
)
export
class
Toolbar
extends
ToolbarBase
{
private
_sbPadding
:
boolean
;
constructor
(
elementRef
:
ElementRef
,
config
:
Config
)
{
super
(
elementRef
)
;
this
.
_sbPadding
=
config
.
getBoolean
(
'statusbarPadding'
,
false
)
;
}
}
/**
*
@name
Title
*
@description
* `ion-title` is a component that sets the title of the `Toolbar` or `Navbar`
*
@usage
* ```html
* <ion-navbar *navbar>
* <ion-title>Tab 1</ion-title>
* </ion-navbar>
*
*<!-- or if you wanted to create a subheader title-->
* <ion-navbar *navbar>
* <ion-title>Tab 1</ion-title>
* </ion-navbar>
* <ion-toolbar>
* <ion-title>SubHeader</ion-title>
* </ion-toolbar>
* ```
*
@demo
/docs/v2/demos/title/
*/
@
Component
(
{
selector
:
'ion-title'
,
template
:
'<div class="toolbar-title">'
+
'<ng-content></ng-content>'
+
'</div>'
,
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
encapsulation
:
ViewEncapsulation
.
None
,
}
)
export
class
ToolbarTitle
extends
Ion
{
constructor
(
elementRef
:
ElementRef
,
@
Optional
(
)
toolbar
:
Toolbar
,
@
Optional
(
)
@
Inject
(
forwardRef
(
(
)
=>
Navbar
)
)
navbar
:
Navbar
)
{
super
(
elementRef
)
;
toolbar
&&
toolbar
.
setTitleCmp
(
this
)
;
navbar
&&
navbar
.
setTitleCmp
(
this
)
;
}
/**
*
@private
*/
getTitleText
(
)
{
return
this
.
getNativeElement
(
)
.
textContent
;
}
}
/**
*
@private
*/
@
Directive
(
{
selector
:
'ion-buttons,[menuToggle],ion-nav-items'
}
)
export
class
ToolbarItem
{
inToolbar
:
boolean
;
constructor
(
elementRef
:
ElementRef
,
@
Optional
(
)
toolbar
:
Toolbar
,
@
Optional
(
)
@
Inject
(
forwardRef
(
(
)
=>
Navbar
)
)
navbar
:
Navbar
)
{
toolbar
&&
toolbar
.
addItemRef
(
elementRef
)
;
navbar
&&
navbar
.
addItemRef
(
elementRef
)
;
this
.
inToolbar
=
!
!
(
toolbar
||
navbar
)
;
// Deprecation warning
if
(
elementRef
.
nativeElement
.
tagName
===
'ION-NAV-ITEMS'
)
{
if
(
elementRef
.
nativeElement
.
hasAttribute
(
'primary'
)
)
{
console
.
warn
(
'<ion-nav-items primary> has been renamed to <ion-buttons start>, please update your HTML'
)
;
elementRef
.
nativeElement
.
setAttribute
(
'start'
,
''
)
;
}
else
if
(
elementRef
.
nativeElement
.
hasAttribute
(
'secondary'
)
)
{
console
.
warn
(
'<ion-nav-items secondary> has been renamed to <ion-buttons end>, please update your HTML'
)
;
elementRef
.
nativeElement
.
setAttribute
(
'end'
,
''
)
;
}
else
{
console
.
warn
(
'<ion-nav-items> has been renamed to <ion-buttons>, please update your HTML'
)
;
}
}
}
@
ContentChildren
(
Button
)
set
_buttons
(
buttons
)
{
if
(
this
.
inToolbar
)
{
Button
.
setRoles
(
buttons
,
'bar-button'
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL