diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-15 16:52:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-15 18:20:56 +0200 |
commit | bbe0f0645ca958d33a3f409b15166609733b663f (patch) | |
tree | edcd5d702c73cda74a2177c4bdc08c616334337d /client/src/app/shared/misc | |
parent | 2baea0c77cc765f7cbca9c9a2f4272268892a35c (diff) | |
download | PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.gz PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.zst PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.zip |
Add ability to schedule video publication
Diffstat (limited to 'client/src/app/shared/misc')
-rw-r--r-- | client/src/app/shared/misc/screen.service.ts | 23 | ||||
-rw-r--r-- | client/src/app/shared/misc/utils.ts | 14 |
2 files changed, 23 insertions, 14 deletions
diff --git a/client/src/app/shared/misc/screen.service.ts b/client/src/app/shared/misc/screen.service.ts new file mode 100644 index 000000000..5b17a914a --- /dev/null +++ b/client/src/app/shared/misc/screen.service.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { Injectable, NgZone } from '@angular/core' | ||
2 | |||
3 | @Injectable() | ||
4 | export class ScreenService { | ||
5 | private windowInnerWidth: number | ||
6 | |||
7 | constructor (private zone: NgZone) { | ||
8 | this.windowInnerWidth = window.innerWidth | ||
9 | |||
10 | // Try to cache a little bit window.innerWidth | ||
11 | this.zone.runOutsideAngular(() => { | ||
12 | setInterval(() => this.windowInnerWidth = window.innerWidth, 500) | ||
13 | }) | ||
14 | } | ||
15 | |||
16 | isInSmallView () { | ||
17 | return this.windowInnerWidth < 600 | ||
18 | } | ||
19 | |||
20 | isInMobileView () { | ||
21 | return this.windowInnerWidth < 500 | ||
22 | } | ||
23 | } | ||
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts index 2219ac802..53aff1b24 100644 --- a/client/src/app/shared/misc/utils.ts +++ b/client/src/app/shared/misc/utils.ts | |||
@@ -96,26 +96,12 @@ function lineFeedToHtml (obj: object, keyToNormalize: string) { | |||
96 | }) | 96 | }) |
97 | } | 97 | } |
98 | 98 | ||
99 | // Try to cache a little bit window.innerWidth | ||
100 | let windowInnerWidth = window.innerWidth | ||
101 | setInterval(() => windowInnerWidth = window.innerWidth, 500) | ||
102 | |||
103 | function isInSmallView () { | ||
104 | return windowInnerWidth < 600 | ||
105 | } | ||
106 | |||
107 | function isInMobileView () { | ||
108 | return windowInnerWidth < 500 | ||
109 | } | ||
110 | |||
111 | export { | 99 | export { |
112 | objectToUrlEncoded, | 100 | objectToUrlEncoded, |
113 | getParameterByName, | 101 | getParameterByName, |
114 | populateAsyncUserVideoChannels, | 102 | populateAsyncUserVideoChannels, |
115 | getAbsoluteAPIUrl, | 103 | getAbsoluteAPIUrl, |
116 | dateToHuman, | 104 | dateToHuman, |
117 | isInSmallView, | ||
118 | isInMobileView, | ||
119 | immutableAssign, | 105 | immutableAssign, |
120 | objectToFormData, | 106 | objectToFormData, |
121 | lineFeedToHtml | 107 | lineFeedToHtml |