File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 38
38
</ script >
39
39
40
40
< script src ="assets/js/prettify.min.js "> </ script >
41
- <!-- Enable bootstrap 4 theme -->
42
- < script > window . __theme = 'bs4' ; </ script >
43
41
<!-- script files will be inserted by html-webpack-plugin -->
44
42
</ body >
45
43
</ html >
Original file line number Diff line number Diff line change 18
18
<!--<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">-->
19
19
20
20
<!--link to bootstrap.css-->
21
- <!--<script>window.__theme = 'bs4';</script>-->
22
21
<!--<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet">-->
23
22
< link rel ="stylesheet " href ="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css ">
24
23
< link rel ="stylesheet " href ="assets/css/style.css ">
Original file line number Diff line number Diff line change 1
1
import { window } from './facade/browser' ;
2
2
3
+ let guessedVersion : 'bs3' | 'bs4' ;
4
+
5
+ function _guessBsVersion ( ) : 'bs3' | 'bs4' {
6
+ if ( typeof document === 'undefined' ) {
7
+ return null ;
8
+ }
9
+ const spanEl = document . createElement ( 'span' ) ;
10
+ spanEl . innerText = 'test bs version' ;
11
+ document . body . appendChild ( spanEl ) ;
12
+ spanEl . classList . add ( 'd-none' ) ;
13
+ const rect = spanEl . getBoundingClientRect ( ) ;
14
+ document . body . removeChild ( spanEl ) ;
15
+ if ( ! rect ) {
16
+ return 'bs3' ;
17
+ }
18
+
19
+ return rect . top === 0 ? 'bs4' : 'bs3' ;
20
+ }
21
+
22
+ // todo: in ngx-bootstrap, bs4 will became a default one
3
23
export function isBs3 ( ) : boolean {
24
+ if ( typeof window === 'undefined' ) {
25
+ return true ;
26
+ }
27
+
28
+ if ( typeof window . __theme === 'undefined' ) {
29
+ if ( guessedVersion ) {
30
+ return guessedVersion === 'bs3' ;
31
+ }
32
+ guessedVersion = _guessBsVersion ( ) ;
33
+
34
+ return guessedVersion === 'bs3' ;
35
+ }
36
+
4
37
return window . __theme !== 'bs4' ;
5
38
}
You can’t perform that action at this time.
0 commit comments