From 9732883165ec3121f81d622a001d037531ea498d Mon Sep 17 00:00:00 2001 From: Manuel Mtz-Almeida Date: Thu, 20 Apr 2017 01:01:14 +0200 Subject: [PATCH] refactor(item-options): simplify getSides() --- src/components/item/item-options.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/item/item-options.ts b/src/components/item/item-options.ts index 3d9646a6a3..6d7cb85a19 100644 --- a/src/components/item/item-options.ts +++ b/src/components/item/item-options.ts @@ -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'; /** @@ -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. @@ -40,25 +40,26 @@ export class ItemOptions { */ @Output() ionSwipe: EventEmitter = new EventEmitter(); - 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; } /**