FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/ionic/components/menu/menu-toggle.ts at loading · Java1024/ionic · GitHub
Java1024
ionic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
ionic
/
components
/
menu
/
menu-toggle.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
86 lines (77 loc) · 1.86 KB
Breadcrumbs
ionic
/
ionic
/
components
/
menu
/
menu-toggle.ts
Copy path
File metadata and controls
86 lines (77 loc) · 1.86 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
import
{
Directive
,
ElementRef
,
Optional
,
Input
,
HostListener
}
from
'angular2/core'
;
import
{
ViewController
}
from
'../nav/view-controller'
;
import
{
Navbar
}
from
'../navbar/navbar'
;
import
{
MenuController
}
from
'./menu-controller'
;
/**
*
@name
MenuToggle
*
@description
* The `menuToggle` directive can be placed on any button to
* automatically close an open menu.
*
*
@usage
* ```html
* <button menuToggle>Toggle Menu</button>
* ```
*
* To toggle a certain menu by its id or side, give the `menuToggle`
* directive a value.
*
* ```html
* <button menuToggle="right">Toggle Right Menu</button>
* ```
*
*
@demo
/docs/v2/demos/menu/
*
@see
{
@link /docs/v2/components#menus Menu Component Docs
}
*
@see
{
@link ../../menu/Menu Menu API Docs
}
*/
@
Directive
(
{
selector
:
'[menuToggle]'
,
host
:
{
'[hidden]'
:
'isHidden'
,
'menuToggle'
:
''
//ensures the attr is there for css when using [menuToggle]
}
}
)
export
class
MenuToggle
{
/**
*
@private
*/
@
Input
(
)
menuToggle
;
/**
*
@private
*/
private
_inNavbar
:
boolean
;
constructor
(
private
_menu
:
MenuController
,
elementRef
:
ElementRef
,
@
Optional
(
)
private
_viewCtrl
:
ViewController
,
@
Optional
(
)
private
_navbar
:
Navbar
)
{
this
.
_inNavbar
=
!
!
_navbar
;
}
/**
*
@private
*/
@
HostListener
(
'click'
)
toggle
(
)
{
let
menu
=
this
.
_menu
.
get
(
this
.
menuToggle
)
;
menu
&&
menu
.
toggle
(
)
;
}
/**
*
@private
*/
get
isHidden
(
)
{
if
(
this
.
_inNavbar
&&
this
.
_viewCtrl
)
{
if
(
this
.
_viewCtrl
.
isFirst
(
)
)
{
// this is the first view, so it should always show
return
false
;
}
let
menu
=
this
.
_menu
.
get
(
this
.
menuToggle
)
;
if
(
menu
)
{
// this is not the root view, so see if this menu
// is configured to still be enabled if it's not the root view
return
!
menu
.
persistent
;
}
}
return
false
;
}
}
Back
|
FazBrowse Home
|
New Git URL