-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
1 parent
57eda7f
commit 421f637
Showing
2 changed files
with
58 additions
and
0 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,55 @@ | ||
import { Directive, ElementRef, Renderer, Attribute } from '@angular/core'; | ||
|
||
import { Config } from '../../config/config'; | ||
|
||
/** | ||
* @name Chip | ||
* @module ionic | ||
* @description | ||
* Chips represent complex entities in small blocks, such as a contact. | ||
* @see {@link /docs/v2/components/#chips Chips Component Docs} | ||
**/ | ||
|
||
@Directive({ | ||
selector: 'ion-chip' | ||
}) | ||
export class Chip { | ||
|
||
constructor( | ||
config: Config, | ||
private _elementRef: ElementRef, | ||
private _renderer: Renderer | ||
) { | ||
let element = _elementRef.nativeElement; | ||
|
||
this._readAttrs(element); | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
private _readAttrs(element: HTMLElement) { | ||
let elementAttrs = element.attributes; | ||
let attrName: string; | ||
|
||
console.info("mushroom"); | ||
|
||
for (let i = 0, l = elementAttrs.length; i < l; i++) { | ||
if (elementAttrs[i].value !== '') continue; | ||
|
||
attrName = elementAttrs[i].name; | ||
|
||
// Ignore attributes item-left, item-right | ||
if (attrName.indexOf('item') === -1) { | ||
this._setClass(attrName); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
private _setClass(color: string) { | ||
this._renderer.setElementClass(this._elementRef.nativeElement, 'chip-' + color, true); | ||
} | ||
} |
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