• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 13416627295

19 Feb 2025 03:46PM CUT coverage: 91.615% (+0.02%) from 91.595%
13416627295

Pull #15246

github

web-flow
Merge 2a114cdda into 10ddb05cf
Pull Request #15246: fix(excel-export): Get correct grid column collection from row island…

12987 of 15218 branches covered (85.34%)

3 of 3 new or added lines in 1 file covered. (100.0%)

380 existing lines in 31 files now uncovered.

26385 of 28800 relevant lines covered (91.61%)

34358.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/projects/igniteui-angular/src/lib/banner/banner.component.ts
1
import {
2
    Component,
3
    ContentChild,
4
    ElementRef,
5
    EventEmitter,
6
    HostBinding,
7
    Input,
8
    Output,
9
    ViewChild
10
} from '@angular/core';
11

12
import { IgxIconComponent } from '../icon/icon.component';
13
import { IToggleView } from '../core/navigation';
14
import { IgxButtonDirective } from '../directives/button/button.directive';
15
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
16
import { IgxBannerActionsDirective } from './banner.directives';
17
import { NgIf } from '@angular/common';
18
import { CancelableEventArgs, IBaseEventArgs } from '../core/utils';
19
import { ToggleAnimationSettings } from '../expansion-panel/toggle-animation-component';
20
import { IgxExpansionPanelBodyComponent } from '../expansion-panel/expansion-panel-body.component';
21
import { IgxExpansionPanelComponent } from '../expansion-panel/expansion-panel.component';
22
import { BannerResourceStringsEN, IBannerResourceStrings } from '../core/i18n/banner-resources';
23
import { getCurrentResourceStrings } from '../core/i18n/resources';
24

25
export interface BannerEventArgs extends IBaseEventArgs {
26
    event?: Event;
27
}
28

29
export interface BannerCancelEventArgs extends BannerEventArgs, CancelableEventArgs {
30
}
31
/**
32
 * **Ignite UI for Angular Banner** -
33
 * [Documentation](https://www.infragistics.com/products/ignite-ui-angular/angular/components/banner.html)
34
 *
35
 * The Ignite UI Banner provides a highly template-able and easy to use banner that can be shown in your application.
36
 *
37
 * Usage:
38
 *
39
 * ```html
40
 * <igx-banner #banner>
41
 *   Our privacy settings have changed.
42
 *  <igx-banner-actions>
43
 *      <button type="button" igxButton="contained">Read More</button>
44
 *      <button type="button" igxButton="contained">Accept and Continue</button>
45
 *  </igx-banner-actions>
46
 * </igx-banner>
47
 * ```
48
 */
49
@Component({
50
    selector: 'igx-banner',
51
    templateUrl: 'banner.component.html',
52
    imports: [IgxExpansionPanelComponent, IgxExpansionPanelBodyComponent, NgIf, IgxButtonDirective, IgxRippleDirective]
53
})
54
export class IgxBannerComponent implements IToggleView {
2✔
55
    /**
56
     * @hidden
57
     */
58
    @ContentChild(IgxIconComponent)
59
    public bannerIcon: IgxIconComponent;
60

61
    /**
62
     * Fires after the banner shows up
63
     * ```typescript
64
     * public handleOpened(event) {
65
     *  ...
66
     * }
67
     * ```
68
     * ```html
69
     * <igx-banner (opened)="handleOpened($event)"></igx-banner>
70
     * ```
71
     */
72
    @Output()
73
    public opened = new EventEmitter<BannerEventArgs>();
19✔
74

75
    /**
76
     * Fires before the banner shows up
77
     * ```typescript
78
     * public handleOpening(event) {
79
     *  ...
80
     * }
81
     * ```
82
     * ```html
83
     * <igx-banner (opening)="handleOpening($event)"></igx-banner>
84
     * ```
85
     */
86
    @Output()
87
    public opening = new EventEmitter<BannerCancelEventArgs>();
19✔
88

89
    /**
90
     * Fires after the banner hides
91
     * ```typescript
92
     * public handleClosed(event) {
93
     *  ...
94
     * }
95
     * ```
96
     * ```html
97
     * <igx-banner (closed)="handleClosed($event)"></igx-banner>
98
     * ```
99
     */
100
    @Output()
101
    public closed = new EventEmitter<BannerEventArgs>();
19✔
102

103
    /**
104
     * Fires before the banner hides
105
     * ```typescript
106
     * public handleClosing(event) {
107
     *  ...
108
     * }
109
     * ```
110
     * ```html
111
     * <igx-banner (closing)="handleClosing($event)"></igx-banner>
112
     * ```
113
     */
114
    @Output()
115
    public closing = new EventEmitter<BannerCancelEventArgs>();
19✔
116

117
    /** @hidden */
118
    public get useDefaultTemplate(): boolean {
119
        return !this._bannerActionTemplate;
184✔
120
    }
121

122
    /**
123
     * Set the animation settings used by the banner open/close methods
124
     * ```typescript
125
     * import { slideInLeft, slideOutRight } from 'igniteui-angular';
126
     * ...
127
     * banner.animationSettings: ToggleAnimationSettings = { openAnimation: slideInLeft, closeAnimation: slideOutRight };
128
     * ```
129
     */
130
    public set animationSettings(settings: ToggleAnimationSettings) {
131
        this._animationSettings = settings;
×
132
    }
133

134
    /**
135
     * Get the animation settings used by the banner open/close methods
136
     * ```typescript
137
     * let currentAnimations: ToggleAnimationSettings = banner.animationSettings
138
     * ```
139
     */
140
    @Input()
141
    public get animationSettings(): ToggleAnimationSettings {
142
        return this._animationSettings ? this._animationSettings : this._expansionPanel.animationSettings;
90!
143
    }
144

145
    /**
146
     * Gets/Sets the resource strings.
147
     *
148
     * @remarks
149
     * By default it uses EN resources.
150
     */
151
    @Input()
152
    public set resourceStrings(value: IBannerResourceStrings) {
UNCOV
153
        this._resourceStrings = Object.assign({}, this._resourceStrings, value);
×
154
    }
155

156
    public get resourceStrings(): IBannerResourceStrings {
157
        return this._resourceStrings;
18✔
158
    }
159

160
    /**
161
     * Gets/Sets whether the banner is expanded (visible) or collapsed (hidden).
162
     * Defaults to `false`.
163
     * Setting to `true` opens the banner, while `false` closes it.
164
     *
165
     * @example
166
     * // Expand the banner
167
     * banner.expanded = true;
168
     *
169
     * @example
170
     * // Collapse the banner
171
     * banner.expanded = false;
172
     *
173
     * @example
174
     * // Check if the banner is expanded
175
     * const isExpanded = banner.expanded;
176
     */
177
    @Input()
178
    public get expanded(): boolean {
179
        return this._expanded;
5✔
180
    }
181

182
    public set expanded(value: boolean) {
183
        if (value === this._expanded) {
6!
UNCOV
184
            return;
×
185
        }
186

187
        this._expanded = value;
6✔
188
        this._shouldFireEvent = true;
6✔
189

190
        if (value) {
6✔
191
            this._expansionPanel.open();
4✔
192
        } else {
193
            this._expansionPanel.close();
2✔
194
        }
195
    }
196

197
    /**
198
     * Gets whether the banner is collapsed.
199
     *
200
     * ```typescript
201
     * const isCollapsed: boolean = banner.collapsed;
202
     * ```
203
     */
204
    public get collapsed(): boolean {
205
        return this._expansionPanel.collapsed;
307✔
206
    }
207

208
    /**
209
     * Returns the native element of the banner component
210
     * ```typescript
211
     *  const myBannerElement: HTMLElement = banner.element;
212
     * ```
213
     */
214
    public get element() {
215
        return this.elementRef.nativeElement;
5✔
216
    }
217

218
    @HostBinding('class')
219
    public cssClass = 'igx-banner-host';
19✔
220

221
    /**
222
     * @hidden
223
     */
224
    @HostBinding('style.display')
225
    public get displayStyle(): string {
226
        return this.collapsed ? '' : 'block';
90✔
227
    }
228

229
    @ViewChild('expansionPanel', { static: true })
230
    private _expansionPanel: IgxExpansionPanelComponent;
231

232
    @ContentChild(IgxBannerActionsDirective)
233
    private _bannerActionTemplate: IgxBannerActionsDirective;
234

235
    private _expanded: boolean = false;
19✔
236
    private _shouldFireEvent: boolean = false;
19✔
237
    private _bannerEvent: BannerEventArgs;
238
    private _animationSettings: ToggleAnimationSettings;
239
    private _resourceStrings = getCurrentResourceStrings(BannerResourceStringsEN);
19✔
240

241
    constructor(public elementRef: ElementRef<HTMLElement>) { }
19✔
242

243
    /**
244
     * Opens the banner
245
     *
246
     * ```typescript
247
     *  myBanner.open();
248
     * ```
249
     *
250
     * ```html
251
     * <igx-banner #banner>
252
     * ...
253
     * </igx-banner>
254
     * <button type="button" (click)="banner.open()">Open Banner</button>
255
     * ```
256
     */
257
    public open(event?: Event) {
258
        this._bannerEvent = { owner: this, event };
17✔
259
        const openingArgs: BannerCancelEventArgs = {
17✔
260
            owner: this,
261
            event,
262
            cancel: false
263
        };
264
        this.opening.emit(openingArgs);
17✔
265
        if (openingArgs.cancel) {
17✔
266
            return;
1✔
267
        }
268
        this._expansionPanel.open(event);
16✔
269
        this._expanded = true;
16✔
270
        this._shouldFireEvent = false;
16✔
271
    }
272

273
    /**
274
     * Closes the banner
275
     *
276
     * ```typescript
277
     *  myBanner.close();
278
     * ```
279
     *
280
     * ```html
281
     * <igx-banner #banner>
282
     * ...
283
     * </igx-banner>
284
     * <button type="button" (click)="banner.close()">Close Banner</button>
285
     * ```
286
     */
287
    public close(event?: Event) {
288
        this._bannerEvent = { owner: this, event};
9✔
289
        const closingArgs: BannerCancelEventArgs = {
9✔
290
            owner: this,
291
            event,
292
            cancel: false
293
        };
294
        this.closing.emit(closingArgs);
9✔
295
        if (closingArgs.cancel) {
9✔
296
            return;
1✔
297
        }
298
        this._expansionPanel.close(event);
8✔
299
        this._expanded = false;
8✔
300
        this._shouldFireEvent = false;
8✔
301
    }
302

303
    /**
304
     * Toggles the banner
305
     *
306
     * ```typescript
307
     *  myBanner.toggle();
308
     * ```
309
     *
310
     * ```html
311
     * <igx-banner #banner>
312
     * ...
313
     * </igx-banner>
314
     * <button type="button" (click)="banner.toggle()">Toggle Banner</button>
315
     * ```
316
     */
317
    public toggle(event?: Event) {
318
        if (this.collapsed) {
13✔
319
            this.open(event);
8✔
320
        } else {
321
            this.close(event);
5✔
322
        }
323
    }
324

325
    /** @hidden */
326
    public onExpansionPanelOpen() {
327
        if (this._shouldFireEvent) {
14✔
328
            return;
2✔
329
        }
330
        this.opened.emit(this._bannerEvent);
12✔
331
    }
332

333
    /** @hidden */
334
    public onExpansionPanelClose() {
335
        if (this._shouldFireEvent) {
10✔
336
            return;
2✔
337
        }
338
        this.closed.emit(this._bannerEvent);
8✔
339
    }
340
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc