diff --git a/ionic/components/app/structure.scss b/ionic/components/app/structure.scss index c57ee0fc69..ed04f4f4f2 100644 --- a/ionic/components/app/structure.scss +++ b/ionic/components/app/structure.scss @@ -131,7 +131,7 @@ ion-view { } } -.no-navbar > .navbar-container { +[no-navbar] > .navbar-container { display: none; } diff --git a/ionic/components/card/card.ts b/ionic/components/card/card.ts index 238898e144..437ec3626f 100644 --- a/ionic/components/card/card.ts +++ b/ionic/components/card/card.ts @@ -1,24 +1,12 @@ -import {ElementRef} from 'angular2/angular2'; - -import {Ion} from '../ion'; -import {IonicConfig} from '../../config/config'; -import {IonicDirective} from '../../config/decorators'; -import {ListVirtualScroll} from './virtual'; -import * as util from 'ionic/util'; +import {Directive} from 'angular2/angular2'; /** * TODO */ -@IonicDirective({ - selector: 'ion-card' -}) -export class Card extends Ion { - /** - * TODO - * @param {ElementeRef} elementRef TODO - * @param {IonicConfig} ionicConfig TODO - */ - constructor(elementRef: ElementRef, ionicConfig: IonicConfig) { - super(elementRef, ionicConfig); +@Directive({ + selector: 'ion-card', + host: { + 'class': 'card' } -} +}) +export class Card {} diff --git a/ionic/components/checkbox/checkbox.ts b/ionic/components/checkbox/checkbox.ts index ec6219214e..d9814214d5 100644 --- a/ionic/components/checkbox/checkbox.ts +++ b/ionic/components/checkbox/checkbox.ts @@ -1,15 +1,8 @@ -import { - View, - Directive, - ElementRef, - Optional, - NgControl -} from 'angular2/angular2'; +import {Component, View, Directive, ElementRef, Optional, NgControl} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonInput} from '../form/input'; import {IonicConfig} from '../../config/config'; -import {IonicComponent} from '../../config/decorators'; /** * The checkbox is no different than the HTML checkbox input, except it's styled differently @@ -23,7 +16,7 @@ import {IonicComponent} from '../../config/decorators'; * * ``` */ -@IonicComponent({ +@Component({ selector: 'ion-checkbox', inputs: [ 'value', diff --git a/ionic/components/content/content.ts b/ionic/components/content/content.ts index 029445429f..198cb6ba0d 100644 --- a/ionic/components/content/content.ts +++ b/ionic/components/content/content.ts @@ -3,7 +3,6 @@ import {Component, View, ElementRef, Optional, Host} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; import {IonicPlatform} from '../../platform/platform'; -import {IonicComponent} from '../../config/decorators'; import {ViewController} from '../nav/view-controller'; import {Tab} from '../tabs/tab'; import {ScrollTo} from '../../animations/scroll-to'; diff --git a/ionic/components/item/item.ts b/ionic/components/item/item.ts index 53750e6e93..8863eb0539 100644 --- a/ionic/components/item/item.ts +++ b/ionic/components/item/item.ts @@ -1,6 +1,4 @@ -import {Component, Directive, View, ElementRef, NgIf, ViewQuery, QueryList} from 'angular2/angular2'; - -import * as util from 'ionic/util'; +import {Component, View} from 'angular2/angular2'; /** @@ -31,25 +29,6 @@ import * as util from 'ionic/util'; '' + ''+ '' + - '' + - '', - directives: [NgIf] + '' }) -export class Item { - /** - * TODO - * @param {ElementRef} elementRef A reference to the component's DOM element. - */ - constructor(elementRef: ElementRef) { - this._isOpen = false; - this._isSlideActive = false; - this._isTransitioning = false; - this._transform = ''; - - this.ele = elementRef.nativeElement; - this.swipeButtons = {}; - this.optionButtons = {}; - - } - -} +export class Item {} diff --git a/ionic/components/list/list.ts b/ionic/components/list/list.ts index 2ceeef3a97..14d2a8b72c 100644 --- a/ionic/components/list/list.ts +++ b/ionic/components/list/list.ts @@ -2,7 +2,6 @@ import {Directive, ElementRef} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; -import {IonicDirective} from '../../config/decorators'; import {ListVirtualScroll} from './virtual'; import * as util from 'ionic/util'; @@ -17,13 +16,16 @@ import * as util from 'ionic/util'; * interaction modes such as swipe to edit, drag to reorder, and removing items. * */ -@IonicDirective({ +@Directive({ selector: 'ion-list', inputs: [ 'items', 'virtual', 'content' - ] + ], + host: { + 'class': 'list' + } }) export class List extends Ion { /** diff --git a/ionic/components/menu/test/basic/e2e.ts b/ionic/components/menu/test/basic/e2e.ts index 0a67f84760..063470be1e 100644 --- a/ionic/components/menu/test/basic/e2e.ts +++ b/ionic/components/menu/test/basic/e2e.ts @@ -5,5 +5,5 @@ it('should toggle open menu', function() { it('should close menu', function() { - element(by.css('.e2eCloseMenu')).click(); + element(by.css('[menu-close=leftMenu]')).click(); }); diff --git a/ionic/components/menu/test/basic/main.html b/ionic/components/menu/test/basic/main.html index 0d6f204fd3..0c4af2d548 100644 --- a/ionic/components/menu/test/basic/main.html +++ b/ionic/components/menu/test/basic/main.html @@ -12,7 +12,7 @@ {{p.title}} - diff --git a/ionic/components/nav/nav.ts b/ionic/components/nav/nav.ts index 67aba08cb8..8d48e54727 100644 --- a/ionic/components/nav/nav.ts +++ b/ionic/components/nav/nav.ts @@ -430,7 +430,7 @@ class Pane { showNavbar(hasNavbar) { this.navbar = hasNavbar; if (!hasNavbar) { - this.renderer.setElementClass(this.elementRef, 'no-navbar', true); + this.renderer.setElementAttribute(this.elementRef, 'no-navbar', ''); } } diff --git a/ionic/components/radio/radio.ts b/ionic/components/radio/radio.ts index 2fb3ca116a..dcdebc3a05 100644 --- a/ionic/components/radio/radio.ts +++ b/ionic/components/radio/radio.ts @@ -1,6 +1,5 @@ -import {ElementRef, Host, Optional, NgControl, Query, QueryList, View} from 'angular2/angular2'; +import {Component, Directive, ElementRef, Host, Optional, NgControl, Query, QueryList, View} from 'angular2/angular2'; -import {IonicDirective, IonicComponent} from '../../config/decorators'; import {IonicConfig} from '../../config/config'; import {Ion} from '../ion'; import {ListHeader} from '../list/list'; @@ -43,7 +42,7 @@ import {ListHeader} from '../list/list'; * ``` */ -@IonicDirective({ +@Directive({ selector: 'ion-radio-group', host: { 'class': 'list', @@ -162,7 +161,7 @@ export class RadioGroup extends Ion { * ``` * */ -@IonicComponent({ +@Component({ selector: 'ion-radio', inputs: [ 'value', diff --git a/ionic/components/scroll/scroll.ts b/ionic/components/scroll/scroll.ts index 9089483a7d..51a0be4736 100644 --- a/ionic/components/scroll/scroll.ts +++ b/ionic/components/scroll/scroll.ts @@ -1,8 +1,7 @@ -import {View, ElementRef, onInit} from 'angular2/angular2'; +import {Component, View, ElementRef, onInit} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; -import {IonicComponent} from '../../config/decorators'; import {Gesture} from '../../gestures/gesture'; import {CSS} from '../../util/dom'; import {Animation} from '../../animations/animation'; @@ -13,7 +12,7 @@ import * as util from 'ionic/util'; * Scroll is a non-flexboxed scroll area that can scroll horizontally or * vertically. */ -@IonicComponent({ +@Component({ selector: 'ion-scroll', inputs: [ 'scrollX', 'scrollY', 'zoom', 'maxZoom' diff --git a/ionic/components/search-bar/search-bar.ts b/ionic/components/search-bar/search-bar.ts index a5b8400e14..add71fab53 100644 --- a/ionic/components/search-bar/search-bar.ts +++ b/ionic/components/search-bar/search-bar.ts @@ -1,5 +1,4 @@ import {ElementRef, Pipe, NgControl, Renderer, View} from 'angular2/angular2'; -//import {ControlGroup} from 'angular2/forms' import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; @@ -22,7 +21,6 @@ import {IonicComponent} from '../../config/decorators'; 'query' ], defaultInputs: { - 'showCancel': false, 'cancelText': 'Cancel', 'placeholder': 'Search', @@ -30,7 +28,7 @@ import {IonicComponent} from '../../config/decorators'; console.log('Default Cancel'); this.isFocused = false; this.shouldLeftAlign = this.value.trim() != ''; - // TODO input blur + // TODO input blur } } }) diff --git a/ionic/components/search-bar/search-bar.ts.orig b/ionic/components/search-bar/search-bar.ts.orig deleted file mode 100644 index f250b7d108..0000000000 --- a/ionic/components/search-bar/search-bar.ts.orig +++ /dev/null @@ -1,135 +0,0 @@ -import {ElementRef, Pipe, NgControl, Renderer, View} from 'angular2/angular2'; -//import {ControlGroup} from 'angular2/forms' - -import {Ion} from '../ion'; -import {IonicConfig} from '../../config/config'; -import {IonicComponent} from '../../config/decorators'; - -/** - * @name Search Bar - * @description - * The Search Bar service adds an input field which can be used to search or filter items. - * - * @usage - * ```html - * - * ``` - */ -@IonicComponent({ - selector: 'ion-search-bar', - inputs: [ - 'list', - 'query' - ], -<<<<<<< HEAD - defaultInputs: { -======= - defaultProperties: { - 'showCancel': false, ->>>>>>> master - 'cancelText': 'Cancel', - 'placeholder': 'Search', - 'cancelAction': function() { - console.log('Default Cancel'); - this.isFocused = false; - this.shouldLeftAlign = this.value.trim() != ''; - // TODO input blur - } - } -}) -@View({ - template: ` -
-
- -
-
- ` -}) - -export class SearchBar extends Ion { - /** - * TODO - * @param {ElementRef} elementRef TODO - * @param {IonicConfig} config TODO - */ - constructor( - elementRef: ElementRef, - config: IonicConfig, - ngControl: NgControl, - renderer: Renderer - ) { - super(elementRef, config); - this.renderer = renderer; - this.elementRef = elementRef; - if(!ngControl) { - // They don't want to do anything that works, so we won't do anything that breaks - return; - } - - this.ngControl = ngControl; - - ngControl.valueAccessor = this; - - this.query = ''; - } - - /** - * Much like ngModel, this is called from our valueAccessor for the attached - * ControlDirective to update the value internally. - */ - writeValue(value) { - this.value = value; - this.renderer.setElementProperty(this.elementRef, 'value', this.value); - - } - - registerOnChange(val) { - } - - registerOnTouched(val) { - } - - inputChanged(event) { - this.value = event.target.value; - this.ngControl.valueAccessor.writeValue(this.value); - this.ngControl.control.updateValue(this.value); - } - - inputFocused() { - this.isFocused = true; - this.shouldLeftAlign = true; - } - inputBlurred() { - this.isFocused = false; - this.shouldLeftAlign = this.value.trim() != ''; - } - - clearInput() { - this.value = ''; - this.ngControl.control.updateValue(''); - } -} - -/* -export class SearchPipe extends Pipe { - constructor() { - super(); - this.state = 0; - } - - supports(newValue) { - return true; - } - - transform(value, ...args) { - return value; - //return `${value} state:${this.state ++}`; - } - - create(cdRef) { - return new SearchPipe(cdRef); - } -} -*/ diff --git a/ionic/components/search-bar/test/floating/index.ts b/ionic/components/search-bar/test/floating/index.ts index f04c84767f..74a7a381c0 100644 --- a/ionic/components/search-bar/test/floating/index.ts +++ b/ionic/components/search-bar/test/floating/index.ts @@ -1,5 +1,4 @@ -import {NgControl} from 'angular2/angular2'; -import {FORM_DIRECTIVES, FormBuilder, Validators, Control, ControlGroup} from 'angular2/forms'; +import {NgControl, FORM_DIRECTIVES, FormBuilder, Validators, Control, ControlGroup} from 'angular2/angular2'; import {App} from 'ionic/ionic'; import {SearchPipe} from 'ionic/components/search-bar/search-bar'; diff --git a/ionic/components/segment/segment.ts b/ionic/components/segment/segment.ts index f337f8d2c8..6c05834be1 100644 --- a/ionic/components/segment/segment.ts +++ b/ionic/components/segment/segment.ts @@ -1,17 +1,15 @@ -import {View, Renderer, ElementRef, EventEmitter, Host, forwardRef, Optional} from 'angular2/angular2'; +import {Component, Directive, View, Renderer, ElementRef, EventEmitter, Host, forwardRef, Optional} from 'angular2/angular2'; import {Control, NgControl, NgFormControl, ControlGroup, ControlDirective} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; -import {IonicDirective, IonicComponent} from '../../config/decorators' import {dom} from 'ionic/util'; /** * TODO */ -@IonicComponent({ +@Component({ selector: 'ion-segment', - appInjector: [ NgControl ], inputs: [ 'value' ], @@ -123,7 +121,7 @@ export class Segment extends Ion { /** * TODO */ -@IonicDirective({ +@Directive({ selector: 'ion-segment', //inputs: ['value'], host: { @@ -190,7 +188,7 @@ export class SegmentControlValueAccessor { /** * TODO */ -@IonicDirective({ +@Directive({ selector: 'ion-segment-button', inputs: [ 'value' diff --git a/ionic/components/slides/slides.ts b/ionic/components/slides/slides.ts index 6d85eb9db0..f51879d3a0 100644 --- a/ionic/components/slides/slides.ts +++ b/ionic/components/slides/slides.ts @@ -1,11 +1,9 @@ -import {Component, View, QueryList, ElementRef, EventEmitter, onInit, - Host, forwardRef, NgFor, NgIf, NgClass} from 'angular2/angular2'; +import {Directive, Component, View, ElementRef, Host, NgIf, NgClass} from 'angular2/angular2'; import {Ion} from '../ion'; import {Animation} from 'ionic/animations/animation'; import {Gesture} from 'ionic/gestures/gesture'; import {DragGesture} from 'ionic/gestures/drag-gesture'; -import {IonicComponent, IonicDirective} from '../../config/decorators'; import {IonicConfig} from '../../config/config'; import {dom} from 'ionic/util'; import {CSS} from '../../util/dom'; @@ -14,6 +12,7 @@ import * as util from 'ionic/util'; import {Swiper} from './swiper-widget'; import {Scroll} from '../scroll/scroll'; + /** * Slides is a slide box implementation based on Swiper.js * @@ -29,7 +28,7 @@ import {Scroll} from '../scroll/scroll'; * Licensed under MIT * */ -@IonicComponent({ +@Component({ selector: 'ion-slides', inputs: [ 'loop', @@ -447,7 +446,7 @@ export class Slides extends Ion { /** * TODO */ -@IonicComponent({ +@Component({ selector: 'ion-slide', inputs: ['zoom'] }) @@ -471,7 +470,7 @@ export class Slide { } } -@IonicDirective({ +@Directive({ selector: 'slide-lazy', }) export class SlideLazy { diff --git a/ionic/components/switch/switch.ts b/ionic/components/switch/switch.ts index 9c6d3cf95c..306f57622a 100644 --- a/ionic/components/switch/switch.ts +++ b/ionic/components/switch/switch.ts @@ -1,11 +1,11 @@ import { + Component, View, Directive, ElementRef, Host, Optional, NgControl, - Renderer, Inject, forwardRef } from 'angular2/angular2'; @@ -13,7 +13,6 @@ import { import {Ion} from '../ion'; import {IonInput} from '../form/input'; import {IonicConfig} from '../../config/config'; -import {IonicComponent} from '../../config/decorators'; import {pointerCoord} from '../../util/dom'; /** @@ -77,7 +76,7 @@ class MediaSwitch { * ``` * */ -@IonicComponent({ +@Component({ selector: 'ion-switch', inputs: [ 'value', diff --git a/ionic/components/tabs/test/tab-bar-scenarios/main.html b/ionic/components/tabs/test/tab-bar-scenarios/main.html index 116754739c..3db2d1f21c 100644 --- a/ionic/components/tabs/test/tab-bar-scenarios/main.html +++ b/ionic/components/tabs/test/tab-bar-scenarios/main.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -24,7 +24,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -40,21 +40,21 @@ - + - + - + diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index 74b83b8299..3db3e6bfb4 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -1,6 +1,5 @@ import {Directive, View, Host, Optional, ElementRef, Attribute, Query, QueryList, NgZone} from 'angular2/angular2'; -import {IonicDirective} from '../../config/decorators'; import {IonicConfig} from '../../config/config'; import {IonInput} from '../form/input'; import {Label} from './label'; @@ -14,9 +13,8 @@ import {IonicPlatform} from '../../platform/platform'; /** * TODO */ -@IonicDirective({ +@Directive({ selector: 'ion-input', - classId: 'item-input', inputs: [ 'tabIndex' ], diff --git a/ionic/config/decorators.ts b/ionic/config/decorators.ts index 5269924526..1cb4831669 100644 --- a/ionic/config/decorators.ts +++ b/ionic/config/decorators.ts @@ -78,18 +78,6 @@ export function IonicView(args) { } } -/** - * TODO - */ -export function IonicDirective(config) { - return function(cls) { - var annotations = Reflect.getMetadata('annotations', cls) || []; - annotations.push(new Directive(appendConfig(cls, config))); - Reflect.defineMetadata('annotations', annotations, cls); - return cls; - } -} - /** * TODO */ @@ -109,22 +97,22 @@ export function makeComponent(cls, config) { function appendConfig(cls, config) { config.host = config.host || {}; - cls.defaultProperties = config.defaultProperties || {}; + cls.defaultInputs = config.defaultInputs || {}; - config.properties = config.properties || []; + config.inputs = config.inputs || []; - for (let prop in cls.defaultProperties) { - // add the property to the component "properties" - config.properties.push(prop); + for (let prop in cls.defaultInputs) { + // add the property to the component "inputs" + config.inputs.push(prop); // set the component "hostProperties", so the instance's - // property value will be used to set the element's attribute + // input value will be used to set the element's attribute config.host['[attr.' + util.pascalCaseToDashCase(prop) + ']'] = prop; } cls.delegates = config.delegates; - let componentId = config.classId || (config.selector && config.selector.replace('ion-', '')); + let componentId = (config.selector && config.selector.replace('ion-', '')); config.host['class'] = ((config.host['class'] || '') + ' ' + componentId).trim(); return config;