Skip to content

Commit

Permalink
fix(aot): removed static variables, should fix #1307
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Dec 17, 2016
1 parent afe4480 commit ce9812a
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 163 deletions.
24 changes: 10 additions & 14 deletions demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { AfterContentInit, Component, ViewContainerRef } from '@angular/core';
import { AfterContentInit, Component } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from 'ng2-bootstrap';

let w:any = window;

if (w && w.__theme === 'bs4') {
Ng2BootstrapConfig.theme = Ng2BootstrapTheme.BS4;
}
import { isBs3 } from 'ng2-bootstrap';

@Component({
selector: 'bs-demo',
templateUrl: './app.component.html'
})
export class AppComponent implements AfterContentInit {
public isBs3:boolean = Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS3;
public get isBs3(): boolean {
return isBs3();
}

private router: Router;

private router:Router;
public constructor(router:Router) {
public constructor(router: Router) {
this.router = router;
}

public ngAfterContentInit():any {
this.router.events.subscribe((event:any) => {
public ngAfterContentInit(): any {
this.router.events.subscribe((event: any) => {
if (event instanceof NavigationEnd) {
if (typeof PR !== 'undefined') {
// google code-prettify
Expand Down
21 changes: 12 additions & 9 deletions demo/src/app/common/main-menu/main-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
import { Component } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from 'ng2-bootstrap';
import { isBs3 } from 'ng2-bootstrap';
import { routes } from '../../app.routing';

@Component({
selector: 'main-menu',
templateUrl: './main-menu.component.html'
})
export class MainMenuComponent {
public isBs3:boolean = Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS3;
public routes:any = routes;
public search:any = {};
public hash:string = '';
public get isBs3(): boolean {
return isBs3();
}

public routes: any = routes;
public search: any = {};
public hash: string = '';

private router: Router;
public constructor(router:Router) {

public constructor(router: Router) {
this.router = router;
this.routes = this.routes.filter((v:any) => v.path !== '**');
this.router.events.subscribe((event:any) => {
this.routes = this.routes.filter((v: any) => v.path !== '**');
this.router.events.subscribe((event: any) => {
if (event instanceof NavigationEnd) {
this.hash = event.url;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from 'ng2-bootstrap';
import { isBs3 } from 'ng2-bootstrap';

@Component({
selector: 'progressbar-demo',
Expand All @@ -13,7 +13,7 @@ export class ProgressbarDemoComponent {
public type: string;
public stacked: any[] = [];
public get isBs3(): boolean {
return Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS3;
return isBs3();
}

public constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { Component } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from 'ng2-bootstrap';
import { isBs3 } from 'ng2-bootstrap';

// webpack html imports
let doc = require('html!markdown!./docs/readme.md');
let titleDoc = require('html!markdown!./docs/title.md');

let ts = require('!!raw?lang=typescript!./demos/progressbar-demo.component.ts');

let templates:any = {
[Ng2BootstrapTheme.BS3]: require('!!raw?lang=markup!./demos/progressbar-demo-bs3.component.html'),
[Ng2BootstrapTheme.BS4]: require('!!raw?lang=markup!./demos/progressbar-demo-bs4.component.html')
let templates: any = {
'bs3': require('!!raw?lang=markup!./demos/progressbar-demo-bs3.component.html'),
'bs4': require('!!raw?lang=markup!./demos/progressbar-demo-bs4.component.html')
};

let html = templates[Ng2BootstrapConfig.theme];

@Component({
selector: 'progressbar-section',
template: `
Expand All @@ -23,10 +20,12 @@ let html = templates[Ng2BootstrapConfig.theme];
</demo-section>`
})
export class ProgressbarSectionComponent {
public name:string = 'Progressbar';
public src:string = 'https://github.com/valor-software/ng2-bootstrap/blob/master/components/progressbar';
public html:string = html;
public ts:string = ts;
public titleDoc:string = titleDoc;
public doc:string = doc;
public name: string = 'Progressbar';
public src: string = 'https://github.com/valor-software/ng2-bootstrap/blob/master/components/progressbar';
public get html(): string {
return isBs3() ? templates.bs3 : templates.bs4;
}
public ts: string = ts;
public titleDoc: string = titleDoc;
public doc: string = doc;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"chokidar-cli": "1.2.0",
"classlist-polyfill": "1.0.3",
"codecov": "1.0.1",
"codelyzer": "^2.0.0-beta.1",
"codelyzer": "^2.0.0-beta.3",
"conventional-changelog-cli": "1.2.0",
"conventional-github-releaser": "1.1.3",
"core-js": "2.4.1",
Expand Down
4 changes: 2 additions & 2 deletions src/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Component, Input, OnDestroy } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from '../utils/ng2-bootstrap-config';
import { isBs3 } from '../utils/ng2-bootstrap-config';
import { SlideComponent } from './slide.component';

export enum Direction {UNKNOWN, NEXT, PREV}
Expand Down Expand Up @@ -58,7 +58,7 @@ export class CarouselComponent implements OnDestroy {
protected _interval:number;

public get isBS4():boolean {
return Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS4;
return !isBs3();
}

public ngOnDestroy():void {
Expand Down
50 changes: 26 additions & 24 deletions src/datepicker/daypicker.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Component, OnInit } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from '../utils/ng2-bootstrap-config';
import { isBs3 } from '../utils/ng2-bootstrap-config';
import { DatePickerInnerComponent } from './datepicker-inner.component';

// write an interface for template options
const TEMPLATE_OPTIONS:any = {
[Ng2BootstrapTheme.BS4]: {
const TEMPLATE_OPTIONS: any = {
'bs4': {
ARROW_LEFT: '&lt;',
ARROW_RIGHT: '&gt;'
},
[Ng2BootstrapTheme.BS3]: {
'bs3': {
ARROW_LEFT: `
<i class="glyphicon glyphicon-chevron-left"></i>
`,
Expand Down Expand Up @@ -81,31 +80,34 @@ const TEMPLATE_OPTIONS:any = {
})
export class DayPickerComponent implements OnInit {

public labels:any[] = [];
public title:string;
public rows:any[] = [];
public weekNumbers:number[] = [];
public datePicker:DatePickerInnerComponent;
public CURRENT_THEME_TEMPLATE:any = TEMPLATE_OPTIONS[Ng2BootstrapConfig.theme || Ng2BootstrapTheme.BS3];

public constructor(datePicker:DatePickerInnerComponent) {
public labels: any[] = [];
public title: string;
public rows: any[] = [];
public weekNumbers: number[] = [];
public datePicker: DatePickerInnerComponent;
public CURRENT_THEME_TEMPLATE: any;

public constructor(datePicker: DatePickerInnerComponent) {
this.CURRENT_THEME_TEMPLATE = isBs3()
? TEMPLATE_OPTIONS.bs3
: TEMPLATE_OPTIONS.bs4;
this.datePicker = datePicker;
}

public get isBS4():boolean {
return Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS4;
public get isBS4(): boolean {
return !isBs3();
}

/*protected getDaysInMonth(year:number, month:number) {
return ((month === 1) && (year % 4 === 0) &&
((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
}*/
public ngOnInit():void {
public ngOnInit(): void {
let self = this;

this.datePicker.stepDay = {months: 1};

this.datePicker.setRefreshViewHandler(function ():void {
this.datePicker.setRefreshViewHandler(function (): void {
let year = this.activeDate.getFullYear();
let month = this.activeDate.getMonth();
let firstDayOfMonth = new Date(year, month, 1);
Expand All @@ -120,8 +122,8 @@ export class DayPickerComponent implements OnInit {
}

// 42 is the number of days on a six-week calendar
let _days:Date[] = self.getDates(firstDate, 42);
let days:any[] = [];
let _days: Date[] = self.getDates(firstDate, 42);
let days: any[] = [];
for (let i = 0; i < 42; i++) {
let _dateObject = this.createDateObject(_days[i], this.formatDay);
_dateObject.secondary = _days[i].getMonth() !== month;
Expand Down Expand Up @@ -149,7 +151,7 @@ export class DayPickerComponent implements OnInit {
}
}, 'day');

this.datePicker.setCompareHandler(function (date1:Date, date2:Date):number {
this.datePicker.setCompareHandler(function (date1: Date, date2: Date): number {
let d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
let d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
return d1.getTime() - d2.getTime();
Expand All @@ -158,11 +160,11 @@ export class DayPickerComponent implements OnInit {
this.datePicker.refreshView();
}

protected getDates(startDate:Date, n:number):Date[] {
let dates:Date[] = new Array(n);
protected getDates(startDate: Date, n: number): Date[] {
let dates: Date[] = new Array(n);
let current = new Date(startDate.getTime());
let i = 0;
let date:Date;
let date: Date;
while (i < n) {
date = new Date(current.getTime());
date = this.datePicker.fixTimeZone(date);
Expand All @@ -172,7 +174,7 @@ export class DayPickerComponent implements OnInit {
return dates;
}

protected getISO8601WeekNumber(date:Date):number {
protected getISO8601WeekNumber(date: Date): number {
let checkDate = new Date(date.getTime());
// Thursday
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
Expand Down
4 changes: 2 additions & 2 deletions src/datepicker/monthpicker.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from '../utils/ng2-bootstrap-config';
import { isBs3 } from '../utils/ng2-bootstrap-config';
import { DatePickerInnerComponent } from './datepicker-inner.component';

@Component({
Expand Down Expand Up @@ -57,7 +57,7 @@ export class MonthPickerComponent implements OnInit {
}

public get isBS4():boolean {
return Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS4;
return !isBs3();
}

public ngOnInit():void {
Expand Down
4 changes: 2 additions & 2 deletions src/datepicker/yearpicker.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from '../utils/ng2-bootstrap-config';
import { isBs3 } from '../utils/ng2-bootstrap-config';
import { DatePickerInnerComponent } from './datepicker-inner.component';

@Component({
Expand Down Expand Up @@ -57,7 +57,7 @@ export class YearPickerComponent implements OnInit {
}

public get isBS4():boolean {
return Ng2BootstrapConfig.theme === Ng2BootstrapTheme.BS4;
return !isBs3();
}

public ngOnInit():void {
Expand Down
Loading

0 comments on commit ce9812a

Please sign in to comment.