diff --git a/demo/src/app/app.module.ts b/demo/src/app/app.module.ts index b0268a1f76..437503825d 100644 --- a/demo/src/app/app.module.ts +++ b/demo/src/app/app.module.ts @@ -20,6 +20,7 @@ import { DemoDatepickerModule } from './components/datepicker'; import { DemoDropdownModule } from './components/dropdown'; import { DemoModalModule } from './components/modal'; import { DemoPaginationModule } from './components/pagination'; +import { DemoPopoverModule } from './components/popover/index'; import { DemoProgressbarModule } from './components/progressbar'; import { DemoRatingModule } from './components/rating'; import { DemoTabsModule } from './components/tabs'; @@ -55,6 +56,7 @@ import { ngdoc } from '../ng-api-doc'; DemoDropdownModule, DemoModalModule, DemoPaginationModule, + DemoPopoverModule, DemoProgressbarModule, DemoRatingModule, DemoTabsModule, diff --git a/demo/src/app/app.routing.ts b/demo/src/app/app.routing.ts index a3ea93f306..5c9b66e696 100644 --- a/demo/src/app/app.routing.ts +++ b/demo/src/app/app.routing.ts @@ -14,6 +14,7 @@ import { TabsSectionComponent } from './components/tabs/tabs-section.component'; import { TimepickerSectionComponent } from './components/timepicker/timepicker-section.component'; import { TooltipSectionComponent } from './components/tooltip/tooltip-section.component'; import { TypeaheadSectionComponent } from './components/typeahead/typeahead-section.component'; +import { PopoverSectionComponent } from './components/popover/popover-section.component'; export const routes = [ { @@ -66,6 +67,11 @@ export const routes = [ data: ['Pagination'], component: PaginationSectionComponent }, + { + path: 'popover', + data: ['Popover'], + component: PopoverSectionComponent + }, { path: 'progressbar', data: ['Progressbar'], diff --git a/demo/src/app/components/popover/demos/basic/basic.html b/demo/src/app/components/popover/demos/basic/basic.html new file mode 100644 index 0000000000..44745424d5 --- /dev/null +++ b/demo/src/app/components/popover/demos/basic/basic.html @@ -0,0 +1,5 @@ + + diff --git a/demo/src/app/components/popover/demos/basic/basic.ts b/demo/src/app/components/popover/demos/basic/basic.ts new file mode 100644 index 0000000000..5cad47c7c2 --- /dev/null +++ b/demo/src/app/components/popover/demos/basic/basic.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-basic', + templateUrl: './basic.html' +}) +export class DemoPopoverBasicComponent { +} diff --git a/demo/src/app/components/popover/demos/config/config.html b/demo/src/app/components/popover/demos/config/config.html new file mode 100644 index 0000000000..2beb90485a --- /dev/null +++ b/demo/src/app/components/popover/demos/config/config.html @@ -0,0 +1,4 @@ + diff --git a/demo/src/app/components/popover/demos/config/config.ts b/demo/src/app/components/popover/demos/config/config.ts new file mode 100644 index 0000000000..c976e9e586 --- /dev/null +++ b/demo/src/app/components/popover/demos/config/config.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; +import { PopoverConfig } from 'ng2-bootstrap'; + +// such override allows to keep some initial values + +export function getAlertConfig(): PopoverConfig { + return Object.assign(new PopoverConfig(), {placement: 'right', container: 'body', triggers: 'focus'}); +} + +@Component({ + selector: 'demo-popover-config', + templateUrl: './config.html', + providers: [{provide: PopoverConfig, useFactory: getAlertConfig}] +}) +export class DemoPopoverConfigComponent { +} diff --git a/demo/src/app/components/popover/demos/container/container.html b/demo/src/app/components/popover/demos/container/container.html new file mode 100644 index 0000000000..ea31a92817 --- /dev/null +++ b/demo/src/app/components/popover/demos/container/container.html @@ -0,0 +1,13 @@ +
+
+ + +
+
diff --git a/demo/src/app/components/popover/demos/container/container.ts b/demo/src/app/components/popover/demos/container/container.ts new file mode 100644 index 0000000000..c333dab876 --- /dev/null +++ b/demo/src/app/components/popover/demos/container/container.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-container', + templateUrl: './container.html' +}) +export class DemoPopoverContainerComponent { +} diff --git a/demo/src/app/components/popover/demos/dismiss/dismiss.html b/demo/src/app/components/popover/demos/dismiss/dismiss.html new file mode 100644 index 0000000000..cd23716e5b --- /dev/null +++ b/demo/src/app/components/popover/demos/dismiss/dismiss.html @@ -0,0 +1,7 @@ + + diff --git a/demo/src/app/components/popover/demos/dismiss/dismiss.ts b/demo/src/app/components/popover/demos/dismiss/dismiss.ts new file mode 100644 index 0000000000..290f8e6226 --- /dev/null +++ b/demo/src/app/components/popover/demos/dismiss/dismiss.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-dismiss', + templateUrl: './dismiss.html' +}) +export class DemoPopoverDismissComponent { +} diff --git a/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.html b/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.html new file mode 100644 index 0000000000..39e77290c9 --- /dev/null +++ b/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.html @@ -0,0 +1,5 @@ + + diff --git a/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.ts b/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.ts new file mode 100644 index 0000000000..5c7ec1d670 --- /dev/null +++ b/demo/src/app/components/popover/demos/dynamic-html/dynamic-html.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-dynamic-html', + templateUrl: './dynamic-html.html' +}) +export class DemoPopoverDynamicHtmlComponent { + public html:string = ` +Never trust not sanitized HTML!!!`; +} diff --git a/demo/src/app/components/popover/demos/dynamic/dynamic.html b/demo/src/app/components/popover/demos/dynamic/dynamic.html new file mode 100644 index 0000000000..2055488dc6 --- /dev/null +++ b/demo/src/app/components/popover/demos/dynamic/dynamic.html @@ -0,0 +1,10 @@ + + + + diff --git a/demo/src/app/components/popover/demos/dynamic/dynamic.ts b/demo/src/app/components/popover/demos/dynamic/dynamic.ts new file mode 100644 index 0000000000..0f16e18d90 --- /dev/null +++ b/demo/src/app/components/popover/demos/dynamic/dynamic.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-dynamic', + templateUrl: './dynamic.html' +}) +export class DemoPopoverDynamicComponent { + public title:string = 'Welcome word'; + public content: string = 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus.'; +} diff --git a/demo/src/app/components/popover/demos/four-directions/four-directions.html b/demo/src/app/components/popover/demos/four-directions/four-directions.html new file mode 100644 index 0000000000..20131853d9 --- /dev/null +++ b/demo/src/app/components/popover/demos/four-directions/four-directions.html @@ -0,0 +1,27 @@ + + + + + + + diff --git a/demo/src/app/components/popover/demos/four-directions/four-directions.ts b/demo/src/app/components/popover/demos/four-directions/four-directions.ts new file mode 100644 index 0000000000..26ca5d1d79 --- /dev/null +++ b/demo/src/app/components/popover/demos/four-directions/four-directions.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-four-directions', + templateUrl: './four-directions.html' +}) +export class DemoPopoverFourDirectionsComponent { +} diff --git a/demo/src/app/components/popover/demos/index.ts b/demo/src/app/components/popover/demos/index.ts new file mode 100644 index 0000000000..d1080911ca --- /dev/null +++ b/demo/src/app/components/popover/demos/index.ts @@ -0,0 +1,48 @@ +import { DemoPopoverBasicComponent } from './basic/basic'; +import { DemoPopoverFourDirectionsComponent } from './four-directions/four-directions'; +import { DemoPopoverDismissComponent } from './dismiss/dismiss'; +import { DemoPopoverDynamicComponent } from './dynamic/dynamic'; +import { DemoPopoverDynamicHtmlComponent } from './dynamic-html/dynamic-html'; +import { DemoPopoverContainerComponent } from './container/container'; +import { DemoPopoverConfigComponent } from './config/config'; + +export const DEMO_COMPONENTS = [ + DemoPopoverBasicComponent, + DemoPopoverFourDirectionsComponent, + DemoPopoverDismissComponent, + DemoPopoverDynamicComponent, + DemoPopoverDynamicHtmlComponent, + DemoPopoverContainerComponent, + DemoPopoverConfigComponent +]; + +export const DEMOS = { + basic: { + component: require('!!raw?lang=typescript!./basic/basic.ts'), + html: require('!!raw?lang=markup!./basic/basic.html') + }, + forDirections: { + component: require('!!raw?lang=typescript!./four-directions/four-directions.ts'), + html: require('!!raw?lang=markup!./four-directions/four-directions.html') + }, + dismiss: { + component: require('!!raw?lang=typescript!./dismiss/dismiss.ts'), + html: require('!!raw?lang=markup!./dismiss/dismiss.html') + }, + dynamic: { + component: require('!!raw?lang=typescript!./dynamic/dynamic.ts'), + html: require('!!raw?lang=markup!./dynamic/dynamic.html') + }, + dynamicHtml: { + component: require('!!raw?lang=typescript!./dynamic-html/dynamic-html.ts'), + html: require('!!raw?lang=markup!./dynamic-html/dynamic-html.html') + }, + container: { + component: require('!!raw?lang=typescript!./container/container.ts'), + html: require('!!raw?lang=markup!./container/container.html') + }, + config: { + component: require('!!raw?lang=typescript!./config/config.ts'), + html: require('!!raw?lang=markup!./config/config.html') + } +}; diff --git a/demo/src/app/components/popover/demos/styling-global/styling-global.html b/demo/src/app/components/popover/demos/styling-global/styling-global.html new file mode 100644 index 0000000000..94be687165 --- /dev/null +++ b/demo/src/app/components/popover/demos/styling-global/styling-global.html @@ -0,0 +1,10 @@ + + + Well done! You successfully read this important alert message. + diff --git a/demo/src/app/components/popover/demos/styling-global/styling-global.ts b/demo/src/app/components/popover/demos/styling-global/styling-global.ts new file mode 100644 index 0000000000..3add4485f6 --- /dev/null +++ b/demo/src/app/components/popover/demos/styling-global/styling-global.ts @@ -0,0 +1,9 @@ +import { Component, ViewEncapsulation } from '@angular/core'; + +@Component({ + selector: 'demo-alert-styling-global', + templateUrl: './styling-global.html', + encapsulation: ViewEncapsulation.None +}) +export class DemoAlertStylingGlobalComponent { +} diff --git a/demo/src/app/components/popover/demos/styling-local/styling-local.html b/demo/src/app/components/popover/demos/styling-local/styling-local.html new file mode 100644 index 0000000000..28c72a0d24 --- /dev/null +++ b/demo/src/app/components/popover/demos/styling-local/styling-local.html @@ -0,0 +1,3 @@ + + Well done! You successfully read this important alert message. + diff --git a/demo/src/app/components/popover/demos/styling-local/styling-local.ts b/demo/src/app/components/popover/demos/styling-local/styling-local.ts new file mode 100644 index 0000000000..955d4ae292 --- /dev/null +++ b/demo/src/app/components/popover/demos/styling-local/styling-local.ts @@ -0,0 +1,16 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-alert-styling-local', + templateUrl: './styling-local.html', + /* tslint:disable no-unused-css*/ + styles: [` + :host >>> .alert-md-local { + background-color: #009688; + border-color: #00695C; + color: #fff; + } + `] +}) +export class DemoAlertStylingLocalComponent { +} diff --git a/demo/src/app/components/popover/demos/triggers/basic.html b/demo/src/app/components/popover/demos/triggers/basic.html new file mode 100644 index 0000000000..44745424d5 --- /dev/null +++ b/demo/src/app/components/popover/demos/triggers/basic.html @@ -0,0 +1,5 @@ + + diff --git a/demo/src/app/components/popover/demos/triggers/basic.ts b/demo/src/app/components/popover/demos/triggers/basic.ts new file mode 100644 index 0000000000..5cad47c7c2 --- /dev/null +++ b/demo/src/app/components/popover/demos/triggers/basic.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-popover-basic', + templateUrl: './basic.html' +}) +export class DemoPopoverBasicComponent { +} diff --git a/demo/src/app/components/popover/docs/title.md b/demo/src/app/components/popover/docs/title.md new file mode 100644 index 0000000000..49ffab739f --- /dev/null +++ b/demo/src/app/components/popover/docs/title.md @@ -0,0 +1,11 @@ +```typescript +// RECOMMENDED +import { PopoverModule } from 'ng2-bootstrap/popover'; +// or +import { PopoverModule } from 'ng2-bootstrap'; + +@NgModule({ + imports: [PopoverModule.forRoot(),...] +}) +export class AppModule(){} +``` diff --git a/demo/src/app/components/popover/index.ts b/demo/src/app/components/popover/index.ts new file mode 100644 index 0000000000..7744cc7ed2 --- /dev/null +++ b/demo/src/app/components/popover/index.ts @@ -0,0 +1,22 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { PopoverModule } from 'ng2-bootstrap'; +import { SharedModule } from '../../shared'; +import { DEMO_COMPONENTS } from './demos/index'; +import { PopoverSectionComponent } from './popover-section.component'; + +@NgModule({ + declarations: [ + PopoverSectionComponent, + ...DEMO_COMPONENTS + ], + imports: [ + CommonModule, + FormsModule, + SharedModule, + PopoverModule.forRoot() + ], + exports: [PopoverSectionComponent] +}) +export class DemoPopoverModule {} diff --git a/demo/src/app/components/popover/popover-section.component.ts b/demo/src/app/components/popover/popover-section.component.ts new file mode 100644 index 0000000000..456bf9b392 --- /dev/null +++ b/demo/src/app/components/popover/popover-section.component.ts @@ -0,0 +1,91 @@ +import { Component } from '@angular/core'; +import { DEMOS } from './demos'; +// webpack html imports +let titleDoc = require('html!markdown!./docs/title.md'); + +@Component({ + selector: 'tooltip-section', + template: ` + +

Add small overlay content, like those found in iOS, to any element for housing secondary information.

+ +

Contents

+ + +

Usage

+ +

+ +

Examples

+ + + + + + + +

Four directions

+ Four positioning options are available: top, right, bottom, and left aligned. + + + + +

Dismiss on next click

+

Use the focus trigger to dismiss popovers on the next click that the user makes.

+ + + + +

Dynamic Content

+

Popover content can contain any html template. Just create <template #myId> with any + html allowed by Angular, and provide template ref (#myId) as popover content.

+ + + + +

Dynamic Html

+

By using small trick you can display any dynamic html, which you got from ajax request for example.

+ + + + +

Append to body

+

When you have some styles on a parent element that interfere with a popover, you’ll want to specify a container="body" so that the popover’s HTML will be appended to body. This will help to avoid rendering problems in more complex components (like our input groups, button groups, etc) or inside elements with overflow: hidden

+ + + + +

Configuring defaults

+ + + + +

API Reference

+ + + +
` +}) +export class PopoverSectionComponent { + public name:string = 'Popover'; + public src:string = 'https://github.com/valor-software/ng2-bootstrap/tree/development/src/popover'; + public demos: any = DEMOS; + public titleDoc:string = titleDoc; +} diff --git a/demo/src/app/components/popover/todo.md b/demo/src/app/components/popover/todo.md index b092534e39..a315ef8f9f 100644 --- a/demo/src/app/components/popover/todo.md +++ b/demo/src/app/components/popover/todo.md @@ -4,8 +4,11 @@ - dismissible popovers (like tooltips) - templateRef content - html content -- triggers - container: body + +todo: +- triggers +- styling - config + add doc base diff --git a/demo/src/app/getting-started/getting-started.template.html b/demo/src/app/getting-started/getting-started.template.html index 13c35ba463..e20bfb6893 100644 --- a/demo/src/app/getting-started/getting-started.template.html +++ b/demo/src/app/getting-started/getting-started.template.html @@ -1,5 +1,5 @@
-

{{name}}

diff --git a/src/index.ts b/src/index.ts index 79d02ad539..15759db93b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import { NgModule } from '@angular/core'; - +/* tslint:disable: max-classes-per-file */ +import { NgModule, ModuleWithProviders } from '@angular/core'; import { AccordionModule } from './accordion/accordion.module'; import { AlertModule } from './alert/alert.module'; import { ButtonsModule } from './buttons/buttons.module'; @@ -15,15 +15,36 @@ import { TabsModule } from './tabs/tabs.module'; import { TimepickerModule } from './timepicker/timepicker.module'; import { TooltipModule } from './tooltip/tooltip.module'; import { TypeaheadModule } from './typeahead/typeahead.module'; +import { PopoverModule } from './popover/popover.module'; + +const MODULES = [ + AccordionModule, AlertModule, ButtonsModule, + CarouselModule, CollapseModule, DatepickerModule, + DropdownModule, ModalModule, PaginationModule, + ProgressbarModule, PopoverModule, RatingModule, + TabsModule, TimepickerModule, TooltipModule, + TypeaheadModule +]; @NgModule({ - exports: [ - AccordionModule, AlertModule, ButtonsModule, CarouselModule, CollapseModule, DatepickerModule, DropdownModule, - ModalModule, PaginationModule, ProgressbarModule, RatingModule, TabsModule, TimepickerModule, TooltipModule, - TypeaheadModule - ] + imports: [ + AccordionModule.forRoot(), AlertModule.forRoot(), ButtonsModule.forRoot(), + CarouselModule.forRoot(), CollapseModule.forRoot(), DatepickerModule.forRoot(), + DropdownModule.forRoot(), ModalModule.forRoot(), PaginationModule.forRoot(), + ProgressbarModule.forRoot(), PopoverModule.forRoot(), RatingModule.forRoot(), + TabsModule.forRoot(), TimepickerModule.forRoot(), TooltipModule.forRoot(), + TypeaheadModule.forRoot() + ], + exports: MODULES }) +export class BsRootModule { +} + +@NgModule({exports: MODULES}) export class Ng2BootstrapModule { + public static forRoot(): ModuleWithProviders { + return {ngModule: BsRootModule}; + } } export * from './accordion'; @@ -41,6 +62,6 @@ export * from './tabs'; export * from './timepicker'; export * from './tooltip'; export * from './typeahead'; - +export * from './popover'; export * from './utils/ng2-bootstrap-config'; export * from './utils/decorators'; diff --git a/src/popover/popover-container.component.ts b/src/popover/popover-container.component.ts index 1758b73d92..119079da31 100644 --- a/src/popover/popover-container.component.ts +++ b/src/popover/popover-container.component.ts @@ -5,10 +5,14 @@ import { PopoverConfig } from './popover-config'; selector: 'popover-container', changeDetection: ChangeDetectionStrategy.OnPush, // tslint:disable-next-line - host: {'[class]': '"popover in popover-" + placement', role: 'tooltip'}, + host: { + '[class]': '"popover in popover-" + placement + " " + placement', + role: 'tooltip', + style: 'display:block;' + }, template: ` -
-

{{title}}

+
+

{{title}}

` }) export class PopoverContainerComponent { diff --git a/src/popover/popover.module.ts b/src/popover/popover.module.ts index 7f807fd800..73b284f392 100644 --- a/src/popover/popover.module.ts +++ b/src/popover/popover.module.ts @@ -1,4 +1,6 @@ import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CommonModule } from '@angular/common'; + import { PopoverConfig } from './popover-config'; import { ComponentLoaderFactory } from '../component-loader'; import { PositioningService } from '../positioning'; @@ -6,6 +8,7 @@ import { PopoverDirective } from './popover.directive'; import { PopoverContainerComponent } from './popover-container.component'; @NgModule({ + imports: [CommonModule], declarations: [PopoverDirective, PopoverContainerComponent], exports: [PopoverDirective], entryComponents: [PopoverContainerComponent]