Skip to content

Commit

Permalink
refactor(item-options): simplify getSides()
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Apr 19, 2017
1 parent 4525f75 commit 9732883
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/components/item/item-options.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Directive, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';

import { Platform } from '../../platform/platform';
import { isPresent} from '../../util/util';
import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-sliding';

/**
Expand Down Expand Up @@ -29,6 +28,7 @@ import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-s
selector: 'ion-item-options',
})
export class ItemOptions {

/**
* @input {string} The side the option button should be on. Defaults to `"right"`.
* If you have multiple `ion-item-options`, a side must be provided for each.
Expand All @@ -40,25 +40,26 @@ export class ItemOptions {
*/
@Output() ionSwipe: EventEmitter<ItemSliding> = new EventEmitter<ItemSliding>();

constructor(private _elementRef: ElementRef, private _renderer: Renderer, private _plt: Platform) {}
constructor(
private _elementRef: ElementRef,
private _renderer: Renderer,
private _plt: Platform
) { }

/**
* @hidden
*/
getSides(): number {
if (isPresent(this.side)) {
switch (this.side) {
case 'left':
return ITEM_SIDE_FLAG_LEFT;
case 'right':
return ITEM_SIDE_FLAG_RIGHT;
case 'start':
return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT;
case 'end':
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
}
switch (this.side) {
case 'left':
return ITEM_SIDE_FLAG_LEFT;
case 'right':
return ITEM_SIDE_FLAG_RIGHT;
case 'start':
return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT;
default: // end
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
}
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
}

/**
Expand Down

0 comments on commit 9732883

Please sign in to comment.