-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
408 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/// <reference path="../../typedefinition/primeui.d.ts" /> | ||
|
||
import {Component, ElementRef, AfterViewInit, OnDestroy, OnChanges, Input, Output, SimpleChange, EventEmitter} from 'angular2/core'; | ||
import {SelectItem} from '../api/selectitem'; | ||
|
||
@Component({ | ||
selector: 'p-selectbutton', | ||
template: ` | ||
<div class="pui-selectbutton pui-buttonset ui-widget ui-corner-all pui-buttonset-3"> | ||
<div *ngFor="#choice of choices;" class="pui-button ui-widget ui-state-default pui-button-text-only" [attr.data-value]="choice.value"> | ||
<span class="pui-button-text ui-c">{{choice.label}}</span> | ||
</div> | ||
</div> | ||
` | ||
}) | ||
export class Selectbutton { | ||
|
||
initialized: boolean; | ||
|
||
@Input() choices: SelectItem[]; | ||
|
||
@Input() formfield: string; | ||
|
||
@Input() unselectable: boolean; | ||
|
||
@Input() tabindex: number; | ||
|
||
@Input() multiple: boolean; | ||
|
||
@Input() style: string; | ||
|
||
@Input() styleClass: string; | ||
|
||
@Input() value: any; | ||
|
||
@Output() valueChange: EventEmitter<any> = new EventEmitter(); | ||
|
||
@Output() onChange: EventEmitter<any> = new EventEmitter(); | ||
|
||
constructor(private el: ElementRef) { | ||
this.initialized = false; | ||
} | ||
|
||
ngAfterViewInit() { | ||
jQuery(this.el.nativeElement.children[0]).puiselectbutton({ | ||
value: this.value, | ||
unselectable: this.unselectable, | ||
tabindex : this.tabindex, | ||
formfield: this.formfield, | ||
multiple: this.multiple, | ||
enhanced: true, | ||
style: this.style, | ||
styleClass: this.styleClass, | ||
change: (event: Event, ui: PrimeUI.SelectbuttonEventParams) => { | ||
this.onChange.next({ originalEvent: event, value: ui.value }); | ||
if (this.multiple) { | ||
var values: any = []; | ||
for (var i = 0; i < ui.index.length; i++) { | ||
values.push(this.choices[ui.index[i]].value); | ||
this.valueChange.next(values); | ||
} | ||
|
||
} | ||
else { | ||
this.valueChange.next(this.choices[ui.index].value); | ||
} | ||
} | ||
}); | ||
this.initialized = true; | ||
} | ||
|
||
ngOnChanges(changes: { [key: string]: SimpleChange }) { | ||
if (this.initialized) { | ||
for (var key in changes) { | ||
jQuery(this.el.nativeElement.children[0]).puiselectbutton('option', key, changes[key].currentValue); | ||
} | ||
} | ||
} | ||
|
||
ngOnDestroy() { | ||
jQuery(this.el.nativeElement.children[0]).puiselectbutton('destroy'); | ||
this.initialized = false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
showcase/demo/selectbutton/selectbuttondemo.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<div class="ContentSideSections"> | ||
<div class="Content100 overHidden TextShadow"> | ||
<span class="fontSize30 TextShadow orange mediumFont marginBottom20 dispBlock">SelectButton</span> | ||
<span class="defaultText dispTable">SelectButton is used to choose single or multiple items from a list using buttons.</span> | ||
</div> | ||
</div> | ||
|
||
<div class="ContentSideSections Implementation"> | ||
<h3 class="first">Single</h3> | ||
<p-selectbutton [choices]="teams" [(value)]="selectedTeam"></p-selectbutton> | ||
|
||
<p>Selected Team: {{selectedTeam}}</p> | ||
|
||
<h3>Multiple</h3> | ||
<p-selectbutton [choices]="teams" [(value)]="selectedTeams" multiple="multiple"></p-selectbutton> | ||
|
||
<p>Selected Teams: {{selectedTeams}} </p> | ||
|
||
<h3>Preselect</h3> | ||
<p-selectbutton [choices]="cars" [(value)]="selectedCar" style="width:190px"></p-selectbutton> | ||
<p>Select Car: {{selectedCar}}</p> | ||
|
||
<button type="button" (click)="selectedCar=null" pButton icon="fa-close">Clear Selected Car</button> | ||
</div> | ||
|
||
<div class="ContentSideSections Source"> | ||
<p-tabView effect="fade"> | ||
<p-tabPanel header="Documentation"> | ||
<h3>Import</h3> | ||
<pre> | ||
import {Panel} from 'primeng/primeng'; | ||
</pre> | ||
|
||
<h3>Getting Started</h3> | ||
<p>Panel is defined with p-panel element.</p> | ||
<pre> | ||
<p-panel header="Title"> | ||
Content | ||
</p-panel> | ||
</pre> | ||
<h3>Toggleable</h3> | ||
<p>Content of the panel can be expanded and collapsed using toggleable option. Duration of the toggle effect | ||
is customized with toggleDuration and default state is defined with collapsed option. Orientation is "vertical" by default | ||
and other possible value is "horizontal".</p> | ||
<pre> | ||
<p-panel header="Title" toggleable="true"> | ||
Content | ||
</p-panel> | ||
</pre> | ||
|
||
<h3>Attributes</h3> | ||
<div class="doc-tablewrapper"> | ||
<table class="doc-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Default</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>header</td> | ||
<td>string</td> | ||
<td>null</td> | ||
<td>Header text of the panel.</td> | ||
</tr> | ||
<tr> | ||
<td>toggleable</td> | ||
<td>boolean</td> | ||
<td>false</td> | ||
<td>Defines if content of panel can be expanded and collapsed.</td> | ||
</tr> | ||
<tr> | ||
<td>toggleDuration</td> | ||
<td>any</td> | ||
<td>normal</td> | ||
<td>Duration of the effect in milliseconds or pre-defined values like "slow","normal" and "fast".</td> | ||
</tr> | ||
<tr> | ||
<td>toggleOrientation</td> | ||
<td>string</td> | ||
<td>vertical</td> | ||
<td>Defines orientation of toggle direction, valid values are "vertical" and "horizontal".</td> | ||
</tr> | ||
<tr> | ||
<td>collapsed</td> | ||
<td>boolean</td> | ||
<td>false</td> | ||
<td>When specified, displays the panel as collapsed initially.</td> | ||
</tr> | ||
<tr> | ||
<td>closable</td> | ||
<td>boolean</td> | ||
<td>false</td> | ||
<td>Defines if panel can be hidden using close option.</td> | ||
</tr> | ||
<tr> | ||
<td>closeDuration</td> | ||
<td>any</td> | ||
<td>normal</td> | ||
<td>Duration of the effect in milliseconds or pre-defined values like "slow","normal" and "fast".</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<h3>Events</h3> | ||
<div class="doc-tablewrapper"> | ||
<table class="doc-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Parameters</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>onBeforeCollapse</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke before content is collapsed.</td> | ||
</tr> | ||
<tr> | ||
<td>onAfterCollapse</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke after content is collapsed.</td> | ||
</tr> | ||
<tr> | ||
<td>onBeforeExpand</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke before content is expanded.</td> | ||
</tr> | ||
<tr> | ||
<td>onAfterExpand</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke after content is expanded.</td> | ||
</tr> | ||
<tr> | ||
<td>onBeforeClose</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke before panel is closed.</td> | ||
</tr> | ||
<tr> | ||
<td>onAfterClose</td> | ||
<td>event: Toggle event</td> | ||
<td>Callback to invoke after panel is closed.</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<h3>Dependencies</h3> | ||
<p>jQuery, jQuery UI WidgetFactory API, PrimeUI Panel.</p> | ||
</p-tabPanel> | ||
|
||
<p-tabPanel header="Source"> | ||
<pre> | ||
<p-panel header="Godfather I" toggleable="true"> | ||
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. | ||
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business. | ||
Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, | ||
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family. | ||
</p-panel> | ||
</pre> | ||
</p-tabPanel> | ||
</p-tabView> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {Component} from 'angular2/core'; | ||
import {Selectbutton} from '../../../components/selectbutton/selectbutton'; | ||
import {TabView} from '../../../components/tabview/tabview'; | ||
import {TabPanel} from '../../../components/tabview/tabpanel'; | ||
import {Button} from '../../../components/button/button'; | ||
import {SelectItem} from '../../../components/api/selectitem'; | ||
import {ROUTER_DIRECTIVES} from 'angular2/router'; | ||
|
||
@Component({ | ||
templateUrl: 'showcase/demo/selectbutton/selectbuttondemo.component.html', | ||
directives: [Selectbutton, TabPanel, TabView, Button, ROUTER_DIRECTIVES] | ||
}) | ||
export class SelectbuttonDemoComponent { | ||
|
||
teams: SelectItem[]; | ||
|
||
selectedTeam: string; | ||
|
||
selectedTeams: string[]; | ||
|
||
cars: SelectItem[]; | ||
|
||
selectedCar: string = 'BMW'; | ||
|
||
constructor() { | ||
this.teams = []; | ||
this.teams.push({label: 'Barcelona', value: 'Barcelona'}); | ||
this.teams.push({label: 'Real Madrid', value: 'Real Madrid'}); | ||
this.teams.push({label: 'Bayern Munich', value: 'Bayern Munich'}); | ||
|
||
this.cars = []; | ||
this.cars.push({ label: 'Audi', value: 'Audi' }); | ||
this.cars.push({ label: 'BMW', value: 'BMW' }); | ||
this.cars.push({ label: 'Fiat', value: 'Fiat' }); | ||
this.cars.push({ label: 'Ford', value: 'Ford' }); | ||
this.cars.push({ label: 'Honda', value: 'Honda' }); | ||
this.cars.push({ label: 'Jaguar', value: 'Jaguar' }); | ||
this.cars.push({ label: 'Mercedes', value: 'Mercedes' }); | ||
this.cars.push({ label: 'Renault', value: 'Renault' }); | ||
this.cars.push({ label: 'Volkswagen', value: 'Volkswagen' }); | ||
this.cars.push({ label: 'Volvo', value: 'Volvo' }); | ||
} | ||
} |
Oops, something went wrong.