Skip to content

Commit 6b7a8c4

Browse files
committed
fix(modals): fix modals crash, remove glyphicons, disable service worker
1 parent d8d2803 commit 6b7a8c4

File tree

17 files changed

+38
-69
lines changed

17 files changed

+38
-69
lines changed

.angular-cli.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"testTsconfig": "../../src/tsconfig.spec.json",
2020
"prefix": "",
2121
"mobile": false,
22-
"serviceWorker": true,
22+
"serviceWorker": false,
2323
"styles": [
2424
"../../src/datepicker/bs-datepicker.scss",
2525
"assets/css/style.css",

demo/src/app/components/+accordion/demos/basic/basic.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
<accordion-group #group>
66
<div accordion-heading>
77
I can have markup, too!
8-
<i class="pull-right float-xs-right glyphicon"
9-
[ngClass]="{'glyphicon-chevron-down': group?.isOpen, 'glyphicon-chevron-right': !group?.isOpen}"></i>
8+
<span class="badge badge-secondary float-right pull-right">Some HTML here</span>
109
</div>
1110
This is just some content to illustrate fancy headings.
1211
</accordion-group>

demo/src/app/components/+accordion/demos/dymanic/dynamic.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
<accordion-group #group [isOpen]="status.isOpen">
2323
<div accordion-heading>
2424
I can have markup, too!
25-
<i class="pull-right float-xs-right glyphicon"
26-
[ngClass]="{'glyphicon-chevron-down': group?.isOpen, 'glyphicon-chevron-right': !group?.isOpen}"></i>
25+
<span class="badge badge-secondary float-right pull-right">Some HTML here</span>
2726
</div>
2827
This is just some content to illustrate fancy headings.
2928
</accordion-group>

demo/src/app/components/+rating/demos/custom/custom.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,4 @@ import { Component } from '@angular/core';
77
export class DemoRatingCustomComponent {
88
public x: number = 5;
99
public y: number = 2;
10-
11-
public ratingStates: any = [
12-
{ stateOn: 'glyphicon-ok-sign', stateOff: 'glyphicon-ok-circle' },
13-
{ stateOn: 'glyphicon-star', stateOff: 'glyphicon-star-empty' },
14-
{ stateOn: 'glyphicon-heart', stateOff: 'glyphicon-ban-circle' },
15-
{ stateOn: 'glyphicon-heart' },
16-
{ stateOff: 'glyphicon-off' }
17-
];
1810
}

demo/src/app/components/+rating/rating-section.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ let titleDoc = require('html-loader!markdown-loader!./docs/title.md');
88
template: `
99
<demo-section [name]="name" [src]="src">
1010
<p>Rating component that will take care of visualising a star rating bar</p>
11-
<p><em>Note</em>: Bootstrap 4 do not include glyphicons anymore, so if you want to continue use this font, you will need to add a link to <a href="https://github.com/valor-software/ngx-bootstrap/blob/master/demo/assets/css/glyphicons.css"><code>glyphicons.css</code></a></p>
1211
1312
<h2>Contents</h2>
1413
<ul>

demo/src/app/components/+tabs/demos/basic/basic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<tab heading="Static Title 2">Static content 2</tab>
66
<tab (select)="alertMe()">
77
<ng-template tabHeading>
8-
<i class="glyphicon glyphicon-bell"></i> Alert!
8+
<span class="badge badge-secondary">Click here!</span>
99
</ng-template>
1010
I've got an HTML heading, and a select callback. Pretty cool!
1111
</tab>

demo/src/app/components/+typeahead/demos/async/async.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@
88
typeaheadOptionField="name"
99
placeholder="Locations loaded with timeout"
1010
class="form-control">
11-
<div *ngIf="typeaheadLoading===true">
12-
<i class="glyphicon glyphicon-refresh ng-hide" style=""></i>
13-
</div>
14-
<div *ngIf="typeaheadNoResults===true" class="" style="">
15-
<i class="glyphicon glyphicon-remove"></i> No Results Found
16-
</div>
11+
<div *ngIf="typeaheadLoading===true">Loading</div>
12+
<div *ngIf="typeaheadNoResults===true">&#10060; No Results Found</div>

demo/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<!--<link rel="stylesheet" href="assets/css/style.css">-->
2222
<!--<link rel="stylesheet" href="assets/css/prettify-angulario.css">-->
2323

24-
<link rel="manifest" href="ngsw-manifest.json">
24+
<!--<link rel="manifest" href="ngsw-manifest.json">-->
2525

2626
<meta name="mobile-web-app-capable" content="yes">
2727
<meta name="apple-mobile-web-app-capable" content="yes">

scripts/bs-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
port: 4200,
2+
port: 4400,
33
server: {
44
baseDir: './gh-pages',
55
middleware : { 1 : require('compression')()}

src/component-loader/component-loader.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export class ComponentLoader<T> {
359359
content
360360
);
361361
const modalContentInjector = ReflectiveInjector.resolveAndCreate(
362-
[...this._providers, content],
362+
[...this._providers],
363363
this._injector
364364
);
365365
const componentRef = contentCmptFactory.create(modalContentInjector);

src/datepicker/daypicker.component.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ import { DatePickerInnerComponent } from './datepicker-inner.component';
1515
type="button"
1616
class="btn btn-default btn-secondary btn-sm pull-left float-left"
1717
(click)="datePicker.move(-1)"
18-
tabindex="-1">
19-
<i class="glyphicon glyphicon-chevron-left"></i>
20-
</button>
18+
tabindex="-1">‹</button>
2119
<button *ngIf="isBs4"
2220
type="button"
2321
class="btn btn-default btn-secondary btn-sm pull-left float-left"
2422
(click)="datePicker.move(-1)"
25-
tabindex="-1">&lt;
26-
</button>
23+
tabindex="-1">&lt;</button>
2724
</th>
2825
<th [attr.colspan]="5 + (datePicker.showWeeks ? 1 : 0)">
2926
<button [id]="datePicker.uniqueId + '-title'"
@@ -39,9 +36,7 @@ import { DatePickerInnerComponent } from './datepicker-inner.component';
3936
type="button"
4037
class="btn btn-default btn-secondary btn-sm pull-right float-right"
4138
(click)="datePicker.move(1)"
42-
tabindex="-1">
43-
<i class="glyphicon glyphicon-chevron-right"></i>
44-
</button>
39+
tabindex="-1">›</button>
4540
<button *ngIf="isBs4"
4641
type="button"
4742
class="btn btn-default btn-secondary btn-sm pull-right float-right"

src/datepicker/monthpicker.component.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@ import { DatePickerInnerComponent } from './datepicker-inner.component';
1313
<tr>
1414
<th>
1515
<button type="button" class="btn btn-default btn-sm pull-left float-left"
16-
(click)="datePicker.move(-1)" tabindex="-1">
17-
<i class="glyphicon glyphicon-chevron-left"></i>
18-
</button></th>
16+
(click)="datePicker.move(-1)" tabindex="-1">‹</button></th>
1917
<th [attr.colspan]="((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2">
2018
<button [id]="datePicker.uniqueId + '-title'"
2119
type="button" class="btn btn-default btn-sm"
2220
(click)="datePicker.toggleMode()"
2321
[disabled]="datePicker.datepickerMode === maxMode"
2422
[ngClass]="{disabled: datePicker.datepickerMode === maxMode}" tabindex="-1" style="width:100%;">
25-
<strong>{{ title }}</strong>
23+
<strong>{{ title }}</strong>
2624
</button>
2725
</th>
2826
<th>
2927
<button type="button" class="btn btn-default btn-sm pull-right float-right"
30-
(click)="datePicker.move(1)" tabindex="-1">
31-
<i class="glyphicon glyphicon-chevron-right"></i>
32-
</button>
28+
(click)="datePicker.move(1)" tabindex="-1">›</button>
3329
</th>
3430
</tr>
3531
</thead>

src/datepicker/yearpicker.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import { DatePickerInnerComponent } from './datepicker-inner.component';
1313
<tr>
1414
<th>
1515
<button type="button" class="btn btn-default btn-sm pull-left float-left"
16-
(click)="datePicker.move(-1)" tabindex="-1">
17-
<i class="glyphicon glyphicon-chevron-left"></i>
18-
</button>
16+
(click)="datePicker.move(-1)" tabindex="-1">‹</button>
1917
</th>
2018
<th [attr.colspan]="((datePicker.yearColLimit - 2) <= 0) ? 1 : datePicker.yearColLimit - 2">
2119
<button [id]="datePicker.uniqueId + '-title'" role="heading"
@@ -28,9 +26,7 @@ import { DatePickerInnerComponent } from './datepicker-inner.component';
2826
</th>
2927
<th>
3028
<button type="button" class="btn btn-default btn-sm pull-right float-right"
31-
(click)="datePicker.move(1)" tabindex="-1">
32-
<i class="glyphicon glyphicon-chevron-right"></i>
33-
</button>
29+
(click)="datePicker.move(1)" tabindex="-1">›</button>
3430
</th>
3531
</tr>
3632
</thead>

src/modal/bs-modal.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
ComponentRef,
33
Injectable,
44
TemplateRef,
5-
EventEmitter, Renderer2, Injector
5+
EventEmitter, Renderer2, RendererFactory2
66
} from '@angular/core';
77

88
import { ComponentLoader } from '../component-loader/component-loader.class';
@@ -41,12 +41,13 @@ export class BsModalService {
4141

4242
private _renderer: Renderer2;
4343

44-
constructor(private _injector: Injector, private clf: ComponentLoaderFactory) {
44+
constructor(rendererFactory: RendererFactory2, private clf: ComponentLoaderFactory) {
4545
this._backdropLoader = this.clf.createLoader<ModalBackdropComponent>(
4646
null,
4747
null,
4848
null
4949
);
50+
this._renderer = rendererFactory.createRenderer(null, null);
5051
}
5152

5253
/** Shows a modal */
@@ -170,12 +171,11 @@ export class BsModalService {
170171

171172
// thx d.walsh
172173
private getScrollbarWidth(): number {
173-
this._renderer = this._renderer || this._injector.get(Renderer2);
174174
const scrollDiv = this._renderer.createElement('div');
175175
this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER);
176-
this._renderer.appendChild('body', scrollDiv);
176+
this._renderer.appendChild(document.body, scrollDiv);
177177
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
178-
this._renderer.removeChild('body', scrollDiv);
178+
this._renderer.removeChild(document.body, scrollDiv);
179179

180180
return scrollbarWidth;
181181
}

src/modal/modal.directive.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import {
77
ComponentRef, Directive, ElementRef, EventEmitter, HostListener, Input,
8-
OnDestroy, Output, Renderer2, ViewContainerRef
8+
OnDestroy, OnInit, Output, Renderer2, ViewContainerRef
99
} from '@angular/core';
1010

1111
import { document, window } from '../utils/facade/browser';
@@ -27,7 +27,7 @@ const BACKDROP_TRANSITION_DURATION = 150;
2727
selector: '[bsModal]',
2828
exportAs: 'bs-modal'
2929
})
30-
export class ModalDirective implements OnDestroy {
30+
export class ModalDirective implements OnDestroy, OnInit {
3131
/** allows to set modal configuration via element property */
3232
@Input()
3333
set config(conf: ModalOptions) {
@@ -127,14 +127,14 @@ export class ModalDirective implements OnDestroy {
127127
}
128128
}
129129

130-
// ngAfterViewInit(): any {
131-
// this._config = this._config || this.getConfig();
132-
// setTimeout(() => {
133-
// if (this._config.show) {
134-
// this.show();
135-
// }
136-
// }, 0);
137-
// }
130+
ngOnInit(): any {
131+
this._config = this._config || this.getConfig();
132+
setTimeout(() => {
133+
if (this._config.show) {
134+
this.show();
135+
}
136+
}, 0);
137+
}
138138

139139
/* Public methods */
140140

@@ -427,9 +427,9 @@ export class ModalDirective implements OnDestroy {
427427
protected getScrollbarWidth(): number {
428428
const scrollDiv = this._renderer.createElement('div');
429429
this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER);
430-
this._renderer.appendChild('body', scrollDiv);
430+
this._renderer.appendChild(document.body, scrollDiv);
431431
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
432-
this._renderer.removeChild('body', scrollDiv);
432+
this._renderer.removeChild(document.body, scrollDiv);
433433

434434
return scrollbarWidth;
435435
}

src/spec/tabset.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('Component: Tabs', () => {
148148
const tabTitles = getTabTitles(element);
149149
expect(
150150
(tabTitles[3] as HTMLAnchorElement).querySelectorAll(
151-
'span span.glyphicon-remove-circle'
151+
'span.bs-remove-tab'
152152
).length
153153
).toEqual(1);
154154
});
@@ -157,7 +157,7 @@ describe('Component: Tabs', () => {
157157
const tabTitlesBefore = getTabTitles(element);
158158
expect(tabTitlesBefore.length).toEqual(4);
159159
const el = (tabTitlesBefore[3] as HTMLAnchorElement).querySelectorAll(
160-
'span span.glyphicon-remove-circle'
160+
'span.bs-remove-tab'
161161
)[0];
162162
(el as HTMLSpanElement).click();
163163

@@ -238,7 +238,7 @@ describe('Component: Tabs', () => {
238238
it('should emit remove on remove tab', () => {
239239
const tabTitles = getTabTitles(element);
240240
const el = (tabTitles[3] as HTMLAnchorElement).querySelectorAll(
241-
'span span.glyphicon-remove-circle'
241+
'span.bs-remove-tab'
242242
)[0];
243243
(el as HTMLSpanElement).click();
244244
fixture.detectChanges();

src/tabs/tabset.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
[class.active]="tabz.active" [class.disabled]="tabz.disabled"
66
(click)="tabz.active = true">
77
<span [ngTransclude]="tabz.headingRef">{{ tabz.heading }}</span>
8-
<span *ngIf="tabz.removable">
9-
<span (click)="$event.preventDefault(); removeTab(tabz);"
10-
class="glyphicon glyphicon-remove-circle"></span>
11-
</span>
8+
<span *ngIf="tabz.removable" (click)="$event.preventDefault(); removeTab(tabz);" class="bs-remove-tab"> &#10060;</span>
129
</a>
1310
</li>
1411
</ul>

0 commit comments

Comments
 (0)