FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/src/components/loading/loading-component.ts at master · javascript2016/ionic · GitHub
javascript2016
ionic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
src
/
components
/
loading
/
loading-component.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
113 lines (96 loc) · 3.35 KB
Breadcrumbs
ionic
/
src
/
components
/
loading
/
loading-component.ts
Copy path
File metadata and controls
113 lines (96 loc) · 3.35 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
import
{
Component
,
ElementRef
,
HostListener
,
Renderer
,
ViewEncapsulation
}
from
'@angular/core'
;
import
{
Config
}
from
'../../config/config'
;
import
{
BLOCK_ALL
,
BlockerDelegate
,
GestureController
}
from
'../../gestures/gesture-controller'
;
import
{
assert
,
isDefined
,
isUndefined
}
from
'../../util/util'
;
import
{
KEY_ESCAPE
}
from
'../../platform/key'
;
import
{
LoadingOptions
}
from
'./loading-options'
;
import
{
NavParams
}
from
'../../navigation/nav-params'
;
import
{
ViewController
}
from
'../../navigation/view-controller'
;
/**
*
@hidden
*/
@
Component
(
{
selector
:
'ion-loading'
,
template
:
'<ion-backdrop [hidden]="!d.showBackdrop" (click)="bdClick()" [class.backdrop-no-tappable]="!d.enableBackdropDismiss"></ion-backdrop>'
+
'<div class="loading-wrapper">'
+
'<div *ngIf="showSpinner" class="loading-spinner">'
+
'<ion-spinner [name]="d.spinner"></ion-spinner>'
+
'</div>'
+
'<div *ngIf="d.content" [innerHTML]="d.content" class="loading-content"></div>'
+
'</div>'
,
host
:
{
'role'
:
'dialog'
}
,
encapsulation
:
ViewEncapsulation
.
None
,
}
)
export
class
LoadingCmp
{
d
:
LoadingOptions
;
id
:
number
;
showSpinner
:
boolean
;
durationTimeout
:
any
;
gestureBlocker
:
BlockerDelegate
;
constructor
(
private
_viewCtrl
:
ViewController
,
private
_config
:
Config
,
_elementRef
:
ElementRef
,
gestureCtrl
:
GestureController
,
params
:
NavParams
,
renderer
:
Renderer
)
{
assert
(
params
.
data
,
'params data must be valid'
)
;
this
.
gestureBlocker
=
gestureCtrl
.
createBlocker
(
BLOCK_ALL
)
;
this
.
d
=
params
.
data
;
renderer
.
setElementClass
(
_elementRef
.
nativeElement
,
`loading-
${
_config
.
get
(
'mode'
)
}
`
,
true
)
;
if
(
this
.
d
.
cssClass
)
{
this
.
d
.
cssClass
.
split
(
' '
)
.
forEach
(
cssClass
=>
{
// Make sure the class isn't whitespace, otherwise it throws exceptions
if
(
cssClass
.
trim
(
)
!==
''
)
renderer
.
setElementClass
(
_elementRef
.
nativeElement
,
cssClass
,
true
)
;
}
)
;
}
this
.
id
=
(
++
loadingIds
)
;
}
ngOnInit
(
)
{
// If no spinner was passed in loading options we need to fall back
// to the loadingSpinner in the app's config, then the mode spinner
if
(
isUndefined
(
this
.
d
.
spinner
)
)
{
this
.
d
.
spinner
=
this
.
_config
.
get
(
'loadingSpinner'
,
this
.
_config
.
get
(
'spinner'
,
'ios'
)
)
;
}
// If the user passed hide to the spinner we don't want to show it
this
.
showSpinner
=
isDefined
(
this
.
d
.
spinner
)
&&
this
.
d
.
spinner
!==
'hide'
;
}
ionViewWillEnter
(
)
{
this
.
gestureBlocker
.
block
(
)
;
}
ionViewDidLeave
(
)
{
this
.
gestureBlocker
.
unblock
(
)
;
}
ionViewDidEnter
(
)
{
// If there is a duration, dismiss after that amount of time
if
(
this
.
d
&&
this
.
d
.
duration
)
{
this
.
durationTimeout
=
setTimeout
(
(
)
=>
this
.
dismiss
(
'backdrop'
)
,
this
.
d
.
duration
)
;
}
}
@
HostListener
(
'body:keyup'
,
[
'$event'
]
)
keyUp
(
ev
:
KeyboardEvent
)
{
if
(
this
.
_viewCtrl
.
isLast
(
)
&&
ev
.
keyCode
===
KEY_ESCAPE
)
{
this
.
bdClick
(
)
;
}
}
bdClick
(
)
{
if
(
this
.
d
.
enableBackdropDismiss
)
{
this
.
dismiss
(
'backdrop'
)
;
}
}
dismiss
(
role
:
string
)
:
Promise
<
any
>
{
if
(
this
.
durationTimeout
)
{
clearTimeout
(
this
.
durationTimeout
)
;
}
return
this
.
_viewCtrl
.
dismiss
(
null
,
role
)
;
}
ngOnDestroy
(
)
{
assert
(
this
.
gestureBlocker
.
blocked
===
false
,
'gesture blocker must be already unblocked'
)
;
this
.
gestureBlocker
.
destroy
(
)
;
}
}
let
loadingIds
=
-
1
;
Back
|
FazBrowse Home
|
New Git URL