Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(package): drop support of ng v2 and add support of ng v4 and v5 #2602

Merged
merged 29 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9002ed5
feat(package): upgrading ng v4
valorkin Mar 30, 2017
fc323cc
feat(package): dropped support of ng v2
valorkin Mar 30, 2017
dde32a5
chore(datepicker): initial commit
valorkin Jan 26, 2017
29f7177
chore(package): beta.6
valorkin Mar 28, 2017
d21b6f7
fix(datepicker): for ng v4
valorkin Mar 31, 2017
ead1f77
Merge branch 'development' into feat-new-datepicker
valorkin Apr 6, 2017
7c4cd06
chore(core): after merge fix
valorkin Apr 7, 2017
97db6d8
Merge branch 'development' into feat-new-datepicker
valorkin Apr 7, 2017
c2dbde0
Merge branch 'development' into feat-new-datepicker
valorkin Apr 10, 2017
8ac1dd8
Merge branch 'development' into ngv4
IlyaSurmay Jul 28, 2017
ddb0e55
fix(demo): fix carousel demo error
IlyaSurmay Jul 31, 2017
e1dda6a
fix(tests): add matchers, fix fn output type in draggable service
IlyaSurmay Jul 31, 2017
97b12cf
Merge pull request #2315 from valor-software/ngv4-update-to-1.8.1
valorkin Aug 3, 2017
b3a96d4
chore(package): upgraded angular dependencies
valorkin Aug 3, 2017
5c003d1
2.0.0-beta.3
valorkin Aug 3, 2017
a55ce59
chore(changelog): update
valorkin Aug 3, 2017
4cd0e4a
chore(package): fixed missing moment dependecy
valorkin Aug 3, 2017
71ecd3d
fix(index.ts): fix merge issue in root index.ts (#2357)
EvilAlexei Aug 4, 2017
74daa7a
fix(weeks): change calculation of week number (#2368)
Aug 16, 2017
27dec66
Merge branch 'development' into ngv4
valorkin Aug 17, 2017
95026a1
Merge branch 'development' into ngv4
valorkin Aug 18, 2017
1a0268b
Merge branch 'development' into ngv4
valorkin Sep 8, 2017
2297ab2
feat(package): theme switching upgraded
valorkin Sep 10, 2017
f243345
chore(package): version bump
valorkin Sep 11, 2017
dbca6c8
chore(package): we need more dependencies
valorkin Sep 11, 2017
ef6a2a8
chore(package): prettier applied
valorkin Sep 11, 2017
d275c1f
chore(package): splitted html from .ts components
valorkin Sep 11, 2017
3260edb
chore(package): applying tslint
valorkin Sep 12, 2017
2d7f63f
chore(package): tslint apply
valorkin Sep 12, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(package): theme switching upgraded
  • Loading branch information
valorkin committed Sep 10, 2017
commit 2297ab2a894dd6b75d5b244aa6cc6b45ed04de5d
4 changes: 3 additions & 1 deletion .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"mobile": false,
"serviceWorker": true,
"styles": [
"../../src/datepicker/bs-datepicker.scss"
"../../src/datepicker/bs-datepicker.scss",
"assets/css/style.css",
"assets/css/prettify-angulario.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h3>
<a (click)="trackSourceClick()"
href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}"
target="_blank">{{apiDocs.className}}</a>
target="_blank" rel="noopener">{{apiDocs.className}}</a>
</h3>
<p [innerHtml]="apiDocs.description"></p>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div (click)="trackSourceClick()" class="api-doc-component">
<h3>
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}" target="_blank">{{apiDocs.className}}</a>
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}"
target="_blank" rel="noopener">{{apiDocs.className}}</a>
</h3>
<p [innerHtml]="apiDocs.description"></p>

Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/api-docs/api-doc/api-doc.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="api-doc-component">
<h3>
<a (click)="trackSourceClick()" href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}" target="_blank">{{apiDocs.className}}</a>
<a (click)="trackSourceClick()" href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}" target="_blank" rel="noopener">{{apiDocs.className}}</a>
</h3>
<p [innerHtml]="apiDocs.description"></p>
<table class="table table-sm table-hover">
Expand Down
3 changes: 2 additions & 1 deletion demo/src/app/api-docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export { SampleBoxComponent } from './sample-box/sample-box.component';
imports: [CommonModule, TabsModule],
declarations: [NgApiDocComponent, NgApiDocClassComponent,
NgApiDocConfigComponent, SampleBoxComponent],
exports: [NgApiDocComponent, NgApiDocClassComponent, NgApiDocConfigComponent, SampleBoxComponent],
exports: [NgApiDocComponent, NgApiDocClassComponent, NgApiDocConfigComponent,
SampleBoxComponent],
providers: [Analytics]
})
export class NgApiDocModule {
Expand Down
43 changes: 22 additions & 21 deletions demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { AfterContentInit, Component, Inject } from '@angular/core';
import { NavigationEnd, Router, ActivatedRoute } from '@angular/router';
import {
ActivatedRoute, NavigationEnd, Router, UrlSerializer
} from '@angular/router';
import { isBs3 } from 'ngx-bootstrap/utils';

import { PageScrollConfig, PageScrollService, PageScrollInstance } from 'ng2-page-scroll';
import { DOCUMENT } from '@angular/platform-browser';
import {
PageScrollConfig, PageScrollInstance, PageScrollService
} from 'ng2-page-scroll';
import { DOCUMENT } from '@angular/common';
import { Analytics } from './api-docs/analytics/analytics';

PageScrollConfig.defaultDuration = 11;
PageScrollConfig.defaultScrollOffset = 70;

Expand All @@ -16,41 +22,36 @@ export class AppComponent implements AfterContentInit {
return isBs3();
}

private route: ActivatedRoute;
private router: Router;
private pageScrollService: PageScrollService;
private document: any;

public constructor(route: ActivatedRoute, router: Router, pageScrollService: PageScrollService, @Inject(DOCUMENT) document: any) {
this.route = route;
this.router = router;
this.pageScrollService = pageScrollService;
this.document = document;
public constructor(private route: ActivatedRoute,
private router: Router,
private pageScrollService: PageScrollService,
private urlSerializer: UrlSerializer,
private _analytics: Analytics,
@Inject(DOCUMENT) private document: any) {
}

// almost same logic exists in top-menu component
public ngAfterContentInit(): any {
this._analytics.trackPageViews();
const getUrl = (router: Router) => router.routerState.snapshot.url.slice(0, router.routerState.snapshot.url.indexOf('#'));
let _prev = getUrl(this.router);
const justDoIt = (event: any): void => {
if (!(event instanceof NavigationEnd)) {
return;
}

let _cur = getUrl(this.router);
const _cur = getUrl(this.router);
if (typeof PR !== 'undefined' && _prev !== _cur) {
_prev = _cur;
// google code-prettify
PR.prettyPrint();
}

let hash = this.route.snapshot.fragment;
const hash = this.route.snapshot.fragment;
if (hash) {
let pageScrollInstance: PageScrollInstance = PageScrollInstance.simpleDirectionInstance(this.document, `#${hash}`, true);
const pageScrollInstance: PageScrollInstance = PageScrollInstance.simpleDirectionInstance(this.document, `#${hash}`, true);
this.pageScrollService.start(pageScrollInstance);
}
};

this.router.events.subscribe((event: any) => setTimeout(() => justDoIt(event), 50));
this.router.events
.filter(event => event instanceof NavigationEnd)
.subscribe((event: any) => setTimeout(() => justDoIt(event), 50));
}
}
4 changes: 4 additions & 0 deletions demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { MainMenuComponent } from './common/main-menu/main-menu.component';
import { SearchFilterPipe } from './common/main-menu/search-filter.pipe';
import { TopMenuComponent } from './common/top-menu/top-menu.component';
import { GettingStartedComponent } from './getting-started/getting-started.component';
import { ThemeStorage } from './theme/theme-storage';
import { StyleManager } from './theme/style-manager';

@NgModule({
declarations: [
Expand All @@ -36,6 +38,8 @@ import { GettingStartedComponent } from './getting-started/getting-started.compo
BsDropdownModule.forRoot()
],
providers: [
ThemeStorage,
StyleManager,
{provide: NgApiDoc, useValue: ngdoc}
],
bootstrap: [AppComponent]
Expand Down
8 changes: 4 additions & 4 deletions demo/src/app/common/app-footer/app-footer.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<footer class="app-footer col-md-12">
<div class="container">
<p>Designed and built by the <a href="https://github.com/orgs/valor-software/teams/ng-team" target="_blank">ng-team</a>
with the help of our <a href="https://github.com/valor-software/ngx-bootstrap/graphs/contributors" target="_blank">contributors.</a></p>
<p>Code licensed under <a href="https://github.com/valor-software/ngx-bootstrap/blob/development/LICENSE" target="_blank">MIT license conditions</a>, docs <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY 3.0</a></p>
<p>Design and content of the documentation site heavily inspired by the <a target="_blank" href="http://v4-alpha.getbootstrap.com/">original bootstrap.</a> documentation</p>
<p>Designed and built by the <a href="https://github.com/orgs/valor-software/teams/ng-team" target="_blank" rel="noopener">ng-team</a>
with the help of our <a href="https://github.com/valor-software/ngx-bootstrap/graphs/contributors" target="_blank" rel="noopener">contributors.</a></p>
<p>Code licensed under <a href="https://github.com/valor-software/ngx-bootstrap/blob/development/LICENSE" target="_blank" rel="noopener">MIT license conditions</a>, docs <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC BY 3.0</a></p>
<p>Design and content of the documentation site heavily inspired by the <a target="_blank" rel="noopener" href="http://v4-alpha.getbootstrap.com/">original bootstrap.</a> documentation</p>
</div>
</footer>
7 changes: 4 additions & 3 deletions demo/src/app/common/main-menu/main-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<div id="main-menu">
<div class="menu-search">
<input type="text" name="search" placeholder="Search..." [(ngModel)]="search.text"/>
<input type="text" aria-label="Search in docs" name="search"
placeholder="Search..." [(ngModel)]="search.text"/>
</div>
<div class="main-menu-container">
<div class="menu-content" *ngIf="routes && routes.length">
<div class="section">
<h3 *ngIf="isBs3"><a href="./index-bs4.html#{{hash}}">View in Bootstrap 4</a></h3>
<h3 *ngIf="!isBs3"><a href="./#{{hash}}">View in Bootstrap 3</a></h3>
<h3 *ngIf="isBs3"><a (click)="installTheme('bs4')">View in Bootstrap 4</a></h3>
<h3 *ngIf="!isBs3"><a (click)="installTheme('bs3')">View in Bootstrap 3</a></h3>
</div>
<div class="section"
*ngFor="let route of routes | SearchFilter:search.text"
Expand Down
37 changes: 27 additions & 10 deletions demo/src/app/common/main-menu/main-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Component } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { isBs3 } from 'ngx-bootstrap/utils';
import { Router } from '@angular/router';
import { isBs3, setTheme } from 'ngx-bootstrap/utils';
import { routes } from '../../app.routing';
import { StyleManager } from '../../theme/style-manager';
import { ThemeStorage } from '../../theme/theme-storage';

const _bs3Css = 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css';
const _bs4Css = 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css';

@Component({
selector: 'main-menu',
Expand All @@ -14,17 +19,29 @@ export class MainMenuComponent {

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

private router: Router;
currentTheme: 'bs3' | 'bs4';

public constructor(private router: Router,
public styleManager: StyleManager,
private _themeStorage: ThemeStorage) {
const currentTheme = this._themeStorage.getStoredTheme();
if (currentTheme) {
this.installTheme(currentTheme);
}

public constructor(router: Router) {
this.router = router;
this.routes = this.routes.filter((v: any) => v.path !== '**');
this.router.events.subscribe((event: any) => {
if (event instanceof NavigationEnd) {
this.hash = event.url;
}
});
}

installTheme(theme: 'bs3' | 'bs4') {
setTheme(theme);
this.currentTheme = this.isBs3 ? 'bs3' : 'bs4';
this.styleManager.setStyle('theme', this.isBs3 ? _bs3Css : _bs4Css);

if (this.currentTheme) {
this._themeStorage.storeTheme(this.currentTheme);
}
}

}
6 changes: 3 additions & 3 deletions demo/src/app/common/top-menu/top-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ <h2 [routerLink]="['']">ngx-bootstrap {{currentVersion ? 'v' + currentVersion :
</div>

<div id="mobile-main-menu" (click)="toggle()">
<img src="assets/images/menu-left.svg" alt="">
<img src="assets/images/menu-left.svg" alt="left menu">
</div>

<div class="logo">
<a target="_blank" href="https://github.com/valor-software/ngx-bootstrap">
<img src="assets/images/GitHub-Mark-Light-64px.png" alt="">
<a target="_blank" rel="noopener" href="https://github.com/valor-software/ngx-bootstrap">
<img src="assets/images/GitHub-Mark-Light-64px.png" alt="github stars">
</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<carousel [interval]="myInterval" [noWrap]="noWrapSlides" [(activeSlide)]="activeSlideIndex">
<slide *ngFor="let slide of slides; let index=index">
<img [src]="slide.image">
<img [src]="slide.image" alt="image slide">

<div class="carousel-caption">
<h4>Slide {{index}}</h4>
Expand Down
26 changes: 11 additions & 15 deletions demo/src/app/getting-started/getting-started.template.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<!--<div class="content-header">-->
<!--<h1>{{name}}-->
<!--<iframe frameborder="0" scrolling="0" style="height: 20px;"-->
<!--src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ngx-bootstrap&type=star&count=true"></iframe>-->
<!--</h1>-->
<!--</div>-->
<div id="content" class="content-box">

<div class="image-responsive image-fluid">
<img class="mx-auto center-block" src="https://angular.io/assets/images/logos/angular/angular.svg" width="250"
height="250">
<div class="image-responsive img-fluid">
<img class="mx-auto center-block d-block" src="assets/images/logos/angular.svg"
alt="angular logo" width="250" height="250">
</div>

<a href="https://github.com/valor-software/ngx-bootstrap">
Expand All @@ -23,17 +17,19 @@ <h1 align="center">ngx-bootstrap</h1>
<p align="center">
<span style="margin-top: 10px;display: inline-block;width: 120px;">
<iframe frameborder="0" scrolling="0" style="height: 20px;width: 120px;"
title="github stars count"
src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ngx-bootstrap&type=star&count=true"></iframe></span>
<br/>

<a href="https://badge.fury.io/js/ngx-bootstrap"><img src="https://badge.fury.io/js/ngx-bootstrap.svg"
alt="npm version"></a>
<a href="https://npmjs.org/ngx-bootstrap"><img src="https://img.shields.io/npm/dm/ngx-bootstrap.svg"
alt="npm downloads"></a>
<a href="https://badge.fury.io/js/ngx-bootstrap"
><img src="https://badge.fury.io/js/ngx-bootstrap.svg" alt="npm version"></a>

<a href="https://npmjs.org/ngx-bootstrap"
><img src="https://img.shields.io/npm/dm/ngx-bootstrap.svg" alt="npm downloads"></a>

<br/>
<a href="https://travis-ci.org/valor-software/ngx-bootstrap"><img alt=""
src="https://travis-ci.org/valor-software/ngx-bootstrap.svg?branch=development"></a>
<a href="https://travis-ci.org/valor-software/ngx-bootstrap"
><img alt="build status" src="https://travis-ci.org/valor-software/ngx-bootstrap.svg?branch=development"></a>
<a href="https://ngx-slack.herokuapp.com"><img src="https://ngx-slack.herokuapp.com/badge.svg" alt="slack"></a>
</p>

Expand Down
4 changes: 2 additions & 2 deletions demo/src/app/shared/demo-section/demo-section.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="content-header">
<h1>{{name}}
<a [href]="src" target="_blank">
<img src="assets/images/link-doc.png" alt=""/>
<a [href]="src" target="_blank" rel="noopener">
<img src="assets/images/link-doc.png" alt="link to doc"/>
</a>
</h1>
</div>
Expand Down
45 changes: 45 additions & 0 deletions demo/src/app/theme/style-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Injectable } from '@angular/core';

/**
* Class for managing stylesheets. Stylesheets are loaded into named slots so
* that they can be removed or changed later.
*/
@Injectable()
export class StyleManager {
/**
* Set the stylesheet with the specified key.
*/
setStyle(key: string, href: string) {
getLinkElementForKey(key).setAttribute('href', href);
}

/**
* Remove the stylesheet with the specified key.
*/
removeStyle(key: string) {
const existingLinkElement = getExistingLinkElementByKey(key);
if (existingLinkElement) {
document.head.removeChild(existingLinkElement);
}
}
}

function getLinkElementForKey(key: string) {
return getExistingLinkElementByKey(key) || createLinkElementWithKey(key);
}

function getExistingLinkElementByKey(key: string) {
return document.head.querySelector(`link[rel="stylesheet"].${getClassNameForKey(key)}`);
}

function createLinkElementWithKey(key: string) {
const linkEl = document.createElement('link');
linkEl.setAttribute('rel', 'stylesheet');
linkEl.classList.add(getClassNameForKey(key));
document.head.appendChild(linkEl);
return linkEl;
}

function getClassNameForKey(key: string) {
return `style-manager-${key}`;
}
31 changes: 31 additions & 0 deletions demo/src/app/theme/theme-storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2017 Google, Inc.

import { EventEmitter, Injectable } from '@angular/core';

@Injectable()
export class ThemeStorage {
static storageKey = 'bs-theme-storage-current';

public onThemeUpdate: EventEmitter<string> = new EventEmitter<string>();

public storeTheme(theme: 'bs3' | 'bs4') {
try {
window.localStorage[ThemeStorage.storageKey] = theme;
} catch (e) {}
this.onThemeUpdate.emit(theme);
}

public getStoredTheme(): 'bs3' | 'bs4' {
try {
return window.localStorage[ThemeStorage.storageKey] || null;
} catch (e) {
return null;
}
}

public clearStorage() {
try {
window.localStorage.removeItem(ThemeStorage.storageKey);
} catch (e) { }
}
}
Loading