From 523ea043c7d1338e602f0e8bc965b4fba9348197 Mon Sep 17 00:00:00 2001 From: YevheniiaMazur Date: Tue, 24 Apr 2018 17:31:57 +0300 Subject: [PATCH] docs(dropdown): decompose manual triggering demo (#4116) * docs(dropdown): decompose manual triggering demo * Update dropdown-section.list.ts --- .../app/components/+dropdown/demos/index.ts | 2 ++ .../trigger-by-isopen-property.html | 13 +++++++++++ .../trigger-by-isopen-property.ts | 8 +++++++ .../triggers-manual/triggers-manual.html | 13 +++++------ .../demos/triggers-manual/triggers-manual.ts | 11 ---------- .../+dropdown/dropdown-section.list.ts | 22 ++++++++++++++----- demo/src/ng-api-doc.ts | 2 +- src/dropdown/bs-dropdown.directive.ts | 3 ++- 8 files changed, 47 insertions(+), 27 deletions(-) create mode 100644 demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.html create mode 100644 demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.ts diff --git a/demo/src/app/components/+dropdown/demos/index.ts b/demo/src/app/components/+dropdown/demos/index.ts index ecc147c298..02ab140d8e 100644 --- a/demo/src/app/components/+dropdown/demos/index.ts +++ b/demo/src/app/components/+dropdown/demos/index.ts @@ -16,6 +16,7 @@ import { DemoDropdownStateChangeEventComponent } from './state-change-event/stat import { DemoDropdownAutoCloseComponent } from './autoclose/autoclose'; import { DemoDropdownCustomHtmlComponent } from './custom-html/custom-html'; import { DemoAccessibilityComponent } from './accessibility/accessibility'; +import { DemoDropdownByIsOpenPropComponent } from './trigger-by-isopen-property/trigger-by-isopen-property'; export const DEMO_COMPONENTS = [ DemoDropdownBasicComponent, @@ -27,6 +28,7 @@ export const DEMO_COMPONENTS = [ DemoDropdownDropupComponent, DemoDropdownMenuDividersComponent, DemoDropdownTriggersManualComponent, + DemoDropdownByIsOpenPropComponent, DemoDropdownDisabledComponent, DemoDropdownDisabledItemComponent, DemoDropdownAlignmentComponent, diff --git a/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.html b/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.html new file mode 100644 index 0000000000..de89e420d6 --- /dev/null +++ b/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.html @@ -0,0 +1,13 @@ +
+ + +
+ diff --git a/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.ts b/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.ts new file mode 100644 index 0000000000..2dab8d2746 --- /dev/null +++ b/demo/src/app/components/+dropdown/demos/trigger-by-isopen-property/trigger-by-isopen-property.ts @@ -0,0 +1,8 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'demo-dropdown-trigger-by-isopen', + templateUrl: './trigger-by-isopen-property.html' +}) +export class DemoDropdownByIsOpenPropComponent { +} diff --git a/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.html b/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.html index 2e043e1bcc..92b5c17271 100644 --- a/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.html +++ b/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.html @@ -1,6 +1,5 @@ -
-
- - - + + + diff --git a/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.ts b/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.ts index 0d31818e27..39b7b07dca 100644 --- a/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.ts +++ b/demo/src/app/components/+dropdown/demos/triggers-manual/triggers-manual.ts @@ -5,15 +5,4 @@ import { Component } from '@angular/core'; templateUrl: './triggers-manual.html' }) export class DemoDropdownTriggersManualComponent { - status: { isopen: boolean } = { isopen: false }; - - toggleDropdown($event: MouseEvent): void { - $event.preventDefault(); - $event.stopPropagation(); - this.status.isopen = !this.status.isopen; - } - - change(value: boolean): void { - this.status.isopen = value; - } } diff --git a/demo/src/app/components/+dropdown/dropdown-section.list.ts b/demo/src/app/components/+dropdown/dropdown-section.list.ts index 0c508cbd03..ad05f6f1fe 100644 --- a/demo/src/app/components/+dropdown/dropdown-section.list.ts +++ b/demo/src/app/components/+dropdown/dropdown-section.list.ts @@ -2,6 +2,7 @@ import { DemoDropdownBasicComponent } from './demos/basic/basic'; import { DemoDropdownBasicLinkComponent } from './demos/basic/basic-link'; import { DemoDropdownSplitComponent } from './demos/split/split'; import { DemoDropdownTriggersManualComponent } from './demos/triggers-manual/triggers-manual'; +import { DemoDropdownByIsOpenPropComponent } from './demos/trigger-by-isopen-property/trigger-by-isopen-property'; import { DemoDropdownDisabledComponent } from './demos/disabled-menu/disabled-menu'; import { DemoDropdownDisabledItemComponent } from './demos/disabled-item/disabled-item'; import { DemoDropdownAlignmentComponent } from './demos/alignment/menu-alignment'; @@ -72,17 +73,26 @@ export const demoComponentContent: ContentSection[] = [ outlet: DemoDropdownSplitComponent }, { - title: 'Manual triggers', + title: 'Manual triggering', anchor: 'triggers-manual', component: require('!!raw-loader?lang=typescript!./demos/triggers-manual/triggers-manual.ts'), html: require('!!raw-loader?lang=markup!./demos/triggers-manual/triggers-manual.html'), - description: `

Dropdown can be triggered in two ways: -

`, + description: `

Dropdown can be triggered by show, hide and + toggle methods from directive +
+ Use method toggle(true) if you want to toggle the dropdown or toggle(false) + if you want to only close opened dropdown. +

`, outlet: DemoDropdownTriggersManualComponent }, + { + title: 'Trigger by isOpen property', + anchor: 'trigger-by-isopen-property', + component: require('!!raw-loader?lang=typescript!./demos/trigger-by-isopen-property/trigger-by-isopen-property.ts'), + html: require('!!raw-loader?lang=markup!./demos/trigger-by-isopen-property/trigger-by-isopen-property.html'), + description: `

Dropdown can be shown or hidden by changing isOpen input property

`, + outlet: DemoDropdownByIsOpenPropComponent + }, { title: 'Disabled menu', anchor: 'disabled-menu', diff --git a/demo/src/ng-api-doc.ts b/demo/src/ng-api-doc.ts index 70a6e7fa31..84860602d3 100644 --- a/demo/src/ng-api-doc.ts +++ b/demo/src/ng-api-doc.ts @@ -1802,7 +1802,7 @@ export const ngdoc: any = { }, { "name": "toggle", - "description": "

Toggles an element’s popover. This is considered a “manual” triggering of\nthe popover.

\n", + "description": "

Toggles an element’s popover. This is considered a “manual” triggering of\nthe popover. With parameter true allows toggling, with parameter false\nonly hides opened dropdown. Parameter usage will be removed in ngx-bootstrap v3

\n", "args": [ { "name": "value", diff --git a/src/dropdown/bs-dropdown.directive.ts b/src/dropdown/bs-dropdown.directive.ts index 6d6347bda7..a2aebf7d2c 100644 --- a/src/dropdown/bs-dropdown.directive.ts +++ b/src/dropdown/bs-dropdown.directive.ts @@ -260,7 +260,8 @@ export class BsDropdownDirective implements OnInit, OnDestroy { /** * Toggles an element’s popover. This is considered a “manual” triggering of - * the popover. + * the popover. With parameter true allows toggling, with parameter false + * only hides opened dropdown. Parameter usage will be removed in ngx-bootstrap v3 */ toggle(value?: boolean): void { if (this.isOpen || !value) {