From 7d68d07d0cee9bfdf4f7808c1f6cb609c6fa5ef6 Mon Sep 17 00:00:00 2001 From: Alexey Elizarov Date: Sat, 31 Oct 2015 17:05:45 +0300 Subject: [PATCH 01/20] Fix: SqlStorage _getBackupLocation method argument _getBackupLocation(dbOptions.backupFlag) instead _getBackupLocation(dbOptions) --- ionic/platform/storage/sql.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ionic/platform/storage/sql.ts b/ionic/platform/storage/sql.ts index a219385d9b..3e8d7a3e8b 100644 --- a/ionic/platform/storage/sql.ts +++ b/ionic/platform/storage/sql.ts @@ -50,7 +50,7 @@ export class SqlStorage extends StorageEngine { if(window.sqlitePlugin) { - let location = this._getBackupLocation(dbOptions); + let location = this._getBackupLocation(dbOptions.backupFlag); this._db = window.sqlitePlugin.openDatabase(util.extend({ name: dbOptions.name, From b364017ff24f722a822022b270787d86e9a55bd3 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 31 Oct 2015 14:01:23 -0500 Subject: [PATCH 02/20] fix(zIndex): ion-page dynamic zIndex --- ionic/components/action-sheet/action-sheet.ts | 3 +++ ionic/components/app/structure.scss | 1 + ionic/components/nav/nav-controller.ts | 16 ++++++++++++++ .../nav/test/nav-controller.spec.ts | 22 +++++++++++++++++++ .../components/overlay/overlay-controller.ts | 7 +++--- ionic/components/popup/popup.ts | 3 +++ ionic/config/decorators.ts | 1 + ionic/transitions/md-transition.ts | 15 +++++++------ scripts/e2e/e2e.template.html | 1 - scripts/snapshot/snapshot.config.js | 2 +- 10 files changed, 58 insertions(+), 13 deletions(-) diff --git a/ionic/components/action-sheet/action-sheet.ts b/ionic/components/action-sheet/action-sheet.ts index 187b713f95..6335d7a66f 100644 --- a/ionic/components/action-sheet/action-sheet.ts +++ b/ionic/components/action-sheet/action-sheet.ts @@ -76,6 +76,9 @@ import * as util from 'ionic/util'; '' + '' + '', + host: { + '[style.zIndex]': '_zIndex' + }, directives: [NgFor, NgIf, Icon] }) class ActionSheetCmp { diff --git a/ionic/components/app/structure.scss b/ionic/components/app/structure.scss index acc778ab8c..fbced262d1 100644 --- a/ionic/components/app/structure.scss +++ b/ionic/components/app/structure.scss @@ -88,6 +88,7 @@ ion-tabs { left: 0; width: 100%; height: 100%; + overflow: hidden; } ion-navbar-section { diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index c8a1b27249..774dc8ed65 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -459,6 +459,8 @@ export class NavController extends Ion { return callback(); } + this._setZIndex(enteringView.instance, leavingView.instance, opts.direction); + this._zone.runOutsideAngular(() => { enteringView.shouldDestroy = false; @@ -560,6 +562,20 @@ export class NavController extends Ion { }); } + _setZIndex(enteringInstance, leavingInstance, direction) { + if (!leavingInstance) { + enteringInstance._zIndex = 0; + + } else if (direction === 'back') { + // moving back + enteringInstance._zIndex = leavingInstance._zIndex - 1; + + } else { + // moving forward + enteringInstance._zIndex = leavingInstance._zIndex + 1; + } + } + /** * @private * TODO diff --git a/ionic/components/nav/test/nav-controller.spec.ts b/ionic/components/nav/test/nav-controller.spec.ts index 28336ded55..16c5c807ce 100644 --- a/ionic/components/nav/test/nav-controller.spec.ts +++ b/ionic/components/nav/test/nav-controller.spec.ts @@ -250,5 +250,27 @@ export function run() { }); }); + describe("_setZIndex", () => { + it('should set zIndex 0 on first entering view', () => { + let enteringInstance = {}; + nav._setZIndex(enteringInstance, null, 'forward'); + expect(enteringInstance._zIndex).toEqual(0); + }); + + it('should set zIndex 1 on second entering view', () => { + let leavingInstance = { _zIndex: 0 }; + let enteringInstance = {}; + nav._setZIndex(enteringInstance, leavingInstance, 'forward'); + expect(enteringInstance._zIndex).toEqual(1); + }); + + it('should set zIndex 0 on entering view going back', () => { + let leavingInstance = { _zIndex: 1 }; + let enteringInstance = {}; + nav._setZIndex(enteringInstance, leavingInstance, 'back'); + expect(enteringInstance._zIndex).toEqual(0); + }); + }); + }); } diff --git a/ionic/components/overlay/overlay-controller.ts b/ionic/components/overlay/overlay-controller.ts index a7424483fd..1fbf4e68c6 100644 --- a/ionic/components/overlay/overlay-controller.ts +++ b/ionic/components/overlay/overlay-controller.ts @@ -33,13 +33,12 @@ export class OverlayController { return reject(); } - ref._z = ROOT_Z_INDEX; + instance._zIndex = ROOT_Z_INDEX; for (let i = 0; i < this.refs.length; i++) { - if (this.refs[i]._z >= ref._z) { - ref._z = this.refs[i]._z + 1; + if (this.refs[i].instance._zIndex >= ref.instance._zIndex) { + ref.instance._zIndex = this.refs[i].instance._zIndex + 1; } } - this.renderer.setElementStyle(ref.location, 'zIndex', ref._z); this.renderer.setElementAttribute(ref.location, 'role', 'dialog'); util.extend(instance, opts); diff --git a/ionic/components/popup/popup.ts b/ionic/components/popup/popup.ts index 091a875fcb..f5d152ba7a 100644 --- a/ionic/components/popup/popup.ts +++ b/ionic/components/popup/popup.ts @@ -283,6 +283,9 @@ const OVERLAY_TYPE = 'popup'; '' + '' + '', + host: { + '[style.zIndex]': '_zIndex' + }, directives: [FORM_DIRECTIVES, NgClass, NgIf, NgFor, Button] }) diff --git a/ionic/config/decorators.ts b/ionic/config/decorators.ts index 4299fc3290..dc991505ad 100644 --- a/ionic/config/decorators.ts +++ b/ionic/config/decorators.ts @@ -70,6 +70,7 @@ export function Page(config={}) { config.host = config.host || {}; config.host['[hidden]'] = '_hidden'; config.host['[class.tab-subpage]'] = '_tabSubPage'; + config.host['[style.zIndex]'] = '_zIndex'; var annotations = Reflect.getMetadata('annotations', cls) || []; annotations.push(new Component(config)); Reflect.defineMetadata('annotations', annotations, cls); diff --git a/ionic/transitions/md-transition.ts b/ionic/transitions/md-transition.ts index 8bef0c5a4d..b274f62749 100644 --- a/ionic/transitions/md-transition.ts +++ b/ionic/transitions/md-transition.ts @@ -39,13 +39,14 @@ class MDTransition extends Animation { .fadeIn(); } - let enteringBackButton = new Animation(enteringView.backBtnRef()); - this.add(enteringBackButton); - if (enteringHasNavbar && enteringView.enableBack()) { - enteringBackButton.before.addClass(SHOW_BACK_BTN_CSS); - - } else { - enteringBackButton.before.removeClass(SHOW_BACK_BTN_CSS); + if (enteringHasNavbar) { + let enteringBackButton = new Animation(enteringView.backBtnRef()); + this.add(enteringBackButton); + if (enteringView.enableBack()) { + enteringBackButton.before.addClass(SHOW_BACK_BTN_CSS); + } else { + enteringBackButton.before.removeClass(SHOW_BACK_BTN_CSS); + } } // setup leaving view diff --git a/scripts/e2e/e2e.template.html b/scripts/e2e/e2e.template.html index 5d92e2d6b8..20d03ade09 100644 --- a/scripts/e2e/e2e.template.html +++ b/scripts/e2e/e2e.template.html @@ -30,7 +30,6 @@ -webkit-transition-duration: 0ms !important; transition-duration: 0ms !important; } - .snapshot ion-loading-icon, .snapshot md-ripple { display: none !important; } diff --git a/scripts/snapshot/snapshot.config.js b/scripts/snapshot/snapshot.config.js index f361236d85..be9207c0b9 100644 --- a/scripts/snapshot/snapshot.config.js +++ b/scripts/snapshot/snapshot.config.js @@ -11,7 +11,7 @@ exports.config = { specs: 'dist/e2e/**/*e2e.js', //specs: 'dist/e2e/search-bar/**/*e2e.js', - sleepBetweenSpecs: 250, + sleepBetweenSpecs: 300, platformDefauls: { browser: 'chrome', From 2c270b372226785a8fa10366aa61aaed3b4b43f7 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 31 Oct 2015 14:41:27 -0500 Subject: [PATCH 03/20] feat(menu): enable/disable side menus --- ionic/components/menu/menu-toggle.ts | 3 +- ionic/components/menu/menu.ts | 26 ++++++++++++-- ionic/components/menu/test/multiple/index.ts | 33 +++++++++++++++++ ionic/components/menu/test/multiple/main.html | 36 +++++++++++++++++++ .../components/menu/test/multiple/page1.html | 30 ++++++++++++++++ 5 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 ionic/components/menu/test/multiple/index.ts create mode 100644 ionic/components/menu/test/multiple/main.html create mode 100644 ionic/components/menu/test/multiple/page1.html diff --git a/ionic/components/menu/menu-toggle.ts b/ionic/components/menu/menu-toggle.ts index 2de876178a..48e5da262e 100644 --- a/ionic/components/menu/menu-toggle.ts +++ b/ionic/components/menu/menu-toggle.ts @@ -16,7 +16,8 @@ import {Navbar} from '../nav-bar/nav-bar'; ], host: { '(click)': 'toggle()', - '[hidden]': 'isHidden' + '[hidden]': 'isHidden', + 'menu-toggle': '' //ensures the attr is there for css when using [menu-toggle] } }) export class MenuToggle extends Ion { diff --git a/ionic/components/menu/menu.ts b/ionic/components/menu/menu.ts index 7c59d37a8b..4fbd50fe4d 100644 --- a/ionic/components/menu/menu.ts +++ b/ionic/components/menu/menu.ts @@ -79,6 +79,7 @@ export class Menu extends Ion { this.opening = new EventEmitter('opening'); this.isOpen = false; this._disableTime = 0; + this.isEnabled = true; } /** @@ -107,9 +108,11 @@ export class Menu extends Ion { let self = this; this.onContentClick = function(ev) { - ev.preventDefault(); - ev.stopPropagation(); - self.close(); + if (self.isEnabled) { + ev.preventDefault(); + ev.stopPropagation(); + self.close(); + } }; } @@ -253,6 +256,23 @@ export class Menu extends Ion { return this.setOpen(!this.isOpen); } + enabled(isEnabled) { + if (!this.isEnabled && isEnabled && !this._gesture) { + // was previously disabled, and is being enabled again + // re-add the gestures + this._initGesture(); + + } else if (this.isEnabled && !isEnabled) { + // is currently enabled, and is being disabled + // remove the gestures + this._gesture && this._gesture.destroy(); + this._targetGesture && this._targetGesture.destroy(); + this._gesture = this._targetGesture = null; + } + + this.isEnabled = isEnabled; + } + /** * TODO * @return {Element} The Menu element. diff --git a/ionic/components/menu/test/multiple/index.ts b/ionic/components/menu/test/multiple/index.ts new file mode 100644 index 0000000000..62d167162d --- /dev/null +++ b/ionic/components/menu/test/multiple/index.ts @@ -0,0 +1,33 @@ +import {App, IonicApp, Page, NavController} from 'ionic/ionic'; + + +@Page({ + templateUrl: 'page1.html' +}) +class Page1 { + constructor(app: IonicApp) { + this.app = app; + this.menu1Active(); + } + menu1Active() { + this.activeMenu = 'menu1'; + this.app.getComponent('menu1').enabled(true); + this.app.getComponent('menu2').enabled(false); + } + menu2Active() { + this.activeMenu = 'menu2'; + this.app.getComponent('menu1').enabled(false); + this.app.getComponent('menu2').enabled(true); + } +} + + +@App({ + templateUrl: 'main.html' +}) +class E2EApp { + constructor(app: IonicApp) { + this.app = app; + this.rootPage = Page1; + } +} diff --git a/ionic/components/menu/test/multiple/main.html b/ionic/components/menu/test/multiple/main.html new file mode 100644 index 0000000000..07beb0315e --- /dev/null +++ b/ionic/components/menu/test/multiple/main.html @@ -0,0 +1,36 @@ + + + + + Menu 1 + + + + + + + + + + + + + + + Menu 2 + + + + + + + + + + + + diff --git a/ionic/components/menu/test/multiple/page1.html b/ionic/components/menu/test/multiple/page1.html new file mode 100644 index 0000000000..a8e989f07c --- /dev/null +++ b/ionic/components/menu/test/multiple/page1.html @@ -0,0 +1,30 @@ + + + + + + + Multiple Menus + + + + + + +

Active Menu: {{ activeMenu }}

+ +

+ +

+ +

+ +

+ +

+ +

+ +

This page has two left menus, but only one is active at a time.

+ +
From d3e9980f9c54beef6f029dec19ced0e5d16dcd2d Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 31 Oct 2015 15:02:59 -0500 Subject: [PATCH 04/20] fix(menu): enabling/disabling --- ionic/components/menu/menu-gestures.ts | 2 +- ionic/components/menu/menu.ts | 87 +++++++++----------- ionic/components/menu/test/multiple/index.ts | 8 +- 3 files changed, 46 insertions(+), 51 deletions(-) diff --git a/ionic/components/menu/menu-gestures.ts b/ionic/components/menu/menu-gestures.ts index f2d20ed1f5..43196f05e5 100644 --- a/ionic/components/menu/menu-gestures.ts +++ b/ionic/components/menu/menu-gestures.ts @@ -17,7 +17,7 @@ class MenuContentGesture extends SlideEdgeGesture { } canStart(ev) { - return this.menu.isOpen ? true : super.canStart(ev); + return this.menu.isOpen && this.menu.isEnabled ? true : super.canStart(ev); } // Set CSS, then wait one frame for it to apply before sliding starts diff --git a/ionic/components/menu/menu.ts b/ionic/components/menu/menu.ts index 4fbd50fe4d..60ff6da28a 100644 --- a/ionic/components/menu/menu.ts +++ b/ionic/components/menu/menu.ts @@ -78,7 +78,7 @@ export class Menu extends Ion { this.opening = new EventEmitter('opening'); this.isOpen = false; - this._disableTime = 0; + this._preventTime = 0; this.isEnabled = true; } @@ -154,9 +154,9 @@ export class Menu extends Ion { * @return {Promise} TODO */ setOpen(shouldOpen) { - // _isDisabled is used to prevent unwanted opening/closing after swiping open/close + // _isPrevented is used to prevent unwanted opening/closing after swiping open/close // or swiping open the menu while pressing down on the menu-toggle button - if (shouldOpen === this.isOpen || this._isDisabled()) { + if (shouldOpen === this.isOpen || this._isPrevented()) { return Promise.resolve(); } @@ -169,7 +169,7 @@ export class Menu extends Ion { setProgressStart() { // user started swiping the menu open/close - if (this._isDisabled()) return; + if (this._isPrevented() || !this.isEnabled) return; this._before(); @@ -178,58 +178,66 @@ export class Menu extends Ion { setProgess(value) { // user actively dragging the menu - this._disable(); - this.app.setTransitioning(true); - this._type.setProgess(value); + if (this.isEnabled) { + this._prevent(); + this.app.setTransitioning(true); + this._type.setProgess(value); + } } setProgressEnd(shouldComplete) { // user has finished dragging the menu - this._disable(); - this.app.setTransitioning(true); - this._type.setProgressEnd(shouldComplete).then(isOpen => { - this._after(isOpen); - }); + if (this.isEnabled) { + this._prevent(); + this.app.setTransitioning(true); + this._type.setProgressEnd(shouldComplete).then(isOpen => { + this._after(isOpen); + }); + } } _before() { // this places the menu into the correct location before it animates in // this css class doesn't actually kick off any animations - this.getNativeElement().classList.add('show-menu'); - this.getBackdropElement().classList.add('show-backdrop'); + if (this.isEnabled) { + this.getNativeElement().classList.add('show-menu'); + this.getBackdropElement().classList.add('show-backdrop'); - this._disable(); - this.app.setTransitioning(true); - this.keyboard.close(); + this._prevent(); + this.app.setTransitioning(true); + this.keyboard.close(); + } } _after(isOpen) { // keep opening/closing the menu disabled for a touch more yet - this._disable(); - this.app.setTransitioning(false); + if (this.isEnabled) { + this._prevent(); + this.app.setTransitioning(false); - this.isOpen = isOpen; + this.isOpen = isOpen; - this._cntEle.classList[isOpen ? 'add' : 'remove']('menu-content-open'); + this._cntEle.classList[isOpen ? 'add' : 'remove']('menu-content-open'); - this._cntEle.removeEventListener('click', this.onContentClick); - if (isOpen) { - this._cntEle.addEventListener('click', this.onContentClick); + this._cntEle.removeEventListener('click', this.onContentClick); + if (isOpen) { + this._cntEle.addEventListener('click', this.onContentClick); - } else { - this.getNativeElement().classList.remove('show-menu'); - this.getBackdropElement().classList.remove('show-backdrop'); + } else { + this.getNativeElement().classList.remove('show-menu'); + this.getBackdropElement().classList.remove('show-backdrop'); + } } } - _disable() { + _prevent() { // used to prevent unwanted opening/closing after swiping open/close // or swiping open the menu while pressing down on the menu-toggle - this._disableTime = Date.now() + 20; + this._preventTime = Date.now() + 20; } - _isDisabled() { - return this._disableTime > Date.now(); + _isPrevented() { + return this._preventTime > Date.now(); } /** @@ -256,21 +264,8 @@ export class Menu extends Ion { return this.setOpen(!this.isOpen); } - enabled(isEnabled) { - if (!this.isEnabled && isEnabled && !this._gesture) { - // was previously disabled, and is being enabled again - // re-add the gestures - this._initGesture(); - - } else if (this.isEnabled && !isEnabled) { - // is currently enabled, and is being disabled - // remove the gestures - this._gesture && this._gesture.destroy(); - this._targetGesture && this._targetGesture.destroy(); - this._gesture = this._targetGesture = null; - } - - this.isEnabled = isEnabled; + enable(shouldEnable) { + this.isEnabled = shouldEnable; } /** diff --git a/ionic/components/menu/test/multiple/index.ts b/ionic/components/menu/test/multiple/index.ts index 62d167162d..bf7e01458c 100644 --- a/ionic/components/menu/test/multiple/index.ts +++ b/ionic/components/menu/test/multiple/index.ts @@ -11,13 +11,13 @@ class Page1 { } menu1Active() { this.activeMenu = 'menu1'; - this.app.getComponent('menu1').enabled(true); - this.app.getComponent('menu2').enabled(false); + this.app.getComponent('menu1').enable(true); + this.app.getComponent('menu2').enable(false); } menu2Active() { this.activeMenu = 'menu2'; - this.app.getComponent('menu1').enabled(false); - this.app.getComponent('menu2').enabled(true); + this.app.getComponent('menu1').enable(false); + this.app.getComponent('menu2').enable(true); } } From 71627c327ab0b9f30756110735abf201896c12c3 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 2 Nov 2015 08:37:30 -0600 Subject: [PATCH 05/20] fix(item): sliding item doesn't click if open --- ionic/components/item/item-sliding.ts | 5 +++++ ionic/components/item/test/sliding/index.ts | 3 +++ ionic/components/item/test/sliding/main.html | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ionic/components/item/item-sliding.ts b/ionic/components/item/item-sliding.ts index 4f92478c98..657ed0958e 100644 --- a/ionic/components/item/item-sliding.ts +++ b/ionic/components/item/item-sliding.ts @@ -165,6 +165,11 @@ class ItemSlideGesture extends DragGesture { el.addEventListener('mousedown', touchStart); let touchEnd = (e) => { + // If we have a touch end and the item is closing, + // prevent default to stop a click from triggering + if(this.item.didClose) { + e.preventDefault(); + } this.item.didClose = false; }; el.addEventListener('touchend', touchEnd); diff --git a/ionic/components/item/test/sliding/index.ts b/ionic/components/item/test/sliding/index.ts index 8d0e04110f..23c468db94 100644 --- a/ionic/components/item/test/sliding/index.ts +++ b/ionic/components/item/test/sliding/index.ts @@ -16,4 +16,7 @@ class E2EApp { return [0,1]; } + didClick(e) { + console.log('CLICK', e) + } } diff --git a/ionic/components/item/test/sliding/main.html b/ionic/components/item/test/sliding/main.html index 12f503c03a..ae29dcc1a7 100644 --- a/ionic/components/item/test/sliding/main.html +++ b/ionic/components/item/test/sliding/main.html @@ -2,7 +2,7 @@ - +

Max Lynch

Hey do you want to go to the game tonight? From 70db8e695e08e40ccb5379e72d33b847e91941a3 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 09:30:42 -0600 Subject: [PATCH 06/20] test(tabs): tabs with a side menu example --- ionic/components/tabs/test/basic/index.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ionic/components/tabs/test/basic/index.ts b/ionic/components/tabs/test/basic/index.ts index f142692864..6119d239ec 100644 --- a/ionic/components/tabs/test/basic/index.ts +++ b/ionic/components/tabs/test/basic/index.ts @@ -44,6 +44,9 @@ class Tab2 { @Page({ template: ` + + + Stopwatch @@ -59,12 +62,25 @@ class Tab3 { @App({ template: ` - + + + Menu + + + + + + + + + - ` + ` }) export class TabsPage { constructor() { From 2d27f270dca774babd58e59605215e584113e6a4 Mon Sep 17 00:00:00 2001 From: Drew Rygh Date: Mon, 2 Nov 2015 10:28:22 -0600 Subject: [PATCH 07/20] Update README.md Closes #399 --- scripts/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/README.md b/scripts/README.md index b7f4525bd2..753b018829 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -16,6 +16,13 @@ 4. Run `gulp watch` in this directory 5. A browser should launch at `http://localhost:3000` at which point you can navigate to `http://localhost:3000/docs/v2/components/` + +### Building API Docs +1. `gulp docs` to build the nightly version +2. `gulp docs --doc-version=2.0.0` to build a specific API version + + + ### Running Snapshot 1. Install [Protractor](https://angular.github.io/protractor/#/): `npm install -g protractor` From 61dc17099d98dae719540cf1f1f6d3994273cdd0 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Mon, 2 Nov 2015 10:56:45 -0600 Subject: [PATCH 08/20] fix(item): prevent propagation on item option buttons. Fixes #412 --- ionic/components/item/item-sliding.ts | 20 ++++++++++++++++++-- ionic/components/item/test/sliding/index.ts | 9 ++++++++- ionic/components/item/test/sliding/main.html | 3 ++- ionic/config/directives.ts | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ionic/components/item/item-sliding.ts b/ionic/components/item/item-sliding.ts index 657ed0958e..1497be6926 100644 --- a/ionic/components/item/item-sliding.ts +++ b/ionic/components/item/item-sliding.ts @@ -10,6 +10,23 @@ import * as util from 'ionic/util'; import {CSS, raf} from 'ionic/util/dom'; + +@Directive({ + selector: 'ion-item-options > button,ion-item-options > [button]', + host: { + '(click)': 'clicked($event)' + } +}) +export class ItemSlidingOptionButton { + constructor(elementRef: ElementRef) { + } + clicked(event) { + // Don't allow the click to propagate + event.preventDefault(); + event.stopPropagation(); + } +} + /** * @name ionItem * @description @@ -41,8 +58,7 @@ import {CSS, raf} from 'ionic/util/dom'; '' + ''+ '' + - '', - directives: [NgIf] + '' }) export class ItemSliding { /** diff --git a/ionic/components/item/test/sliding/index.ts b/ionic/components/item/test/sliding/index.ts index 23c468db94..edf8bf5718 100644 --- a/ionic/components/item/test/sliding/index.ts +++ b/ionic/components/item/test/sliding/index.ts @@ -17,6 +17,13 @@ class E2EApp { } didClick(e) { - console.log('CLICK', e) + console.log('CLICK', e.defaultPrevented, e) + } + + archive(e) { + console.log('Accept', e); + } + del(e) { + console.log('Delete', e); } } diff --git a/ionic/components/item/test/sliding/main.html b/ionic/components/item/test/sliding/main.html index ae29dcc1a7..2cce43fbbf 100644 --- a/ionic/components/item/test/sliding/main.html +++ b/ionic/components/item/test/sliding/main.html @@ -8,7 +8,8 @@ Hey do you want to go to the game tonight?

- + +
diff --git a/ionic/config/directives.ts b/ionic/config/directives.ts index e62e298ba2..71595081c7 100644 --- a/ionic/config/directives.ts +++ b/ionic/config/directives.ts @@ -15,7 +15,7 @@ import {Tab} from '../components/tabs/tab'; import {List, ListHeader} from '../components/list/list'; import {Item} from '../components/item/item'; import {ItemGroup, ItemGroupTitle} from '../components/item/item-group'; -import {ItemSliding} from '../components/item/item-sliding'; +import {ItemSliding, ItemSlidingOptionButton} from '../components/item/item-sliding'; import {Toolbar, ToolbarTitle, ToolbarItem} from '../components/toolbar/toolbar'; import {Icon} from '../components/icon/icon'; import {Checkbox} from '../components/checkbox/checkbox'; @@ -60,6 +60,7 @@ export const IONIC_DIRECTIVES = [ ItemGroup, ItemGroupTitle, ItemSliding, + ItemSlidingOptionButton, // Slides Slides, From 0f6d9e5286ebff4ab7b9e696d98209537be8e31e Mon Sep 17 00:00:00 2001 From: Drew Rygh Date: Mon, 2 Nov 2015 11:05:12 -0600 Subject: [PATCH 09/20] docs(demos): no-lines list attribute --- demos/component-docs/lists/dividers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/component-docs/lists/dividers.html b/demos/component-docs/lists/dividers.html index f18fcf032c..dfee7d94ec 100644 --- a/demos/component-docs/lists/dividers.html +++ b/demos/component-docs/lists/dividers.html @@ -4,7 +4,7 @@ - + Pokémon Yellow Super Metroid Mega Man X From 88c24f9d5dcfa2260985642b9d2232a59d813e3a Mon Sep 17 00:00:00 2001 From: Drew Rygh Date: Mon, 2 Nov 2015 11:18:51 -0600 Subject: [PATCH 10/20] docs(components): add no-lines to correct list --- demos/component-docs/lists/basic-lists.html | 2 +- demos/component-docs/lists/dividers.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/component-docs/lists/basic-lists.html b/demos/component-docs/lists/basic-lists.html index 30cfe30c3a..239a855bc8 100644 --- a/demos/component-docs/lists/basic-lists.html +++ b/demos/component-docs/lists/basic-lists.html @@ -4,7 +4,7 @@ - + Pokémon Yellow Super Metroid Mega Man X diff --git a/demos/component-docs/lists/dividers.html b/demos/component-docs/lists/dividers.html index dfee7d94ec..f18fcf032c 100644 --- a/demos/component-docs/lists/dividers.html +++ b/demos/component-docs/lists/dividers.html @@ -4,7 +4,7 @@ - + Pokémon Yellow Super Metroid Mega Man X From f72a0e0f5add9e3c324d243e9631423d7016c454 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 2 Nov 2015 11:29:08 -0600 Subject: [PATCH 11/20] chore(build): update npm package information --- README.md | 58 +++++++++++++++++++++++++++++++++++++++- gulpfile.js | 44 ------------------------------ index.js | 3 --- package.json | 6 ++--- scripts/npm/README.md | 25 ----------------- scripts/npm/package.json | 22 --------------- tooling/index.js | 3 +++ 7 files changed, 63 insertions(+), 98 deletions(-) delete mode 100644 index.js delete mode 100644 scripts/npm/README.md delete mode 100644 scripts/npm/package.json create mode 100644 tooling/index.js diff --git a/README.md b/README.md index c77d4c5f5c..a2f63032bb 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,62 @@ We are also building out a number of starter projects, including the Ionic 2 sta [https://github.com/driftyco/ionic2-starter](https://github.com/driftyco/ionic2-starter) -### Distribution +## Distribution - [npm: ionic-framework](https://www.npmjs.com/package/ionic-framework) + +## Ionic Framework Package + The ionic-framework package comes with both frontend dependencies, located in 'dist', and a Node API, located in 'tooling'. + +### Bundles: + + - `css/` + - the Ionic CSS stylesheet + - `fonts/` + - Ionicons and Roboto fonts + - `js/` + - `ionic.js` the Ionic module, in System register format + - `ionic.bundle.js` the Ionic bundle, contains: + - es6-module-loader.js + - system.js + - angular2.dev.js + - router.dev.js (angular2 router) + - ionic.js + - web-animations.min.js + - `web-animations.min.js` web animations API polyfill + +### Source files: + + - `src/es5` - Ionic ES5 source files in both CommonJS and System module formats + - `src/es6` - Ionic ES6 source files + - `src/ts` - Ionic TypeScript source files (typings still missing) + - `scss` - Ionic Sass source files + +--------- + +### Tooling + + At the moment, ionic-framework exports one function, `generate`, that can be used to scaffold new pages in an Ionic app. It is used by the [Ionic CLI's](https://github.com/driftyco/ionic-cli) `generate` command. + +#### Methods + +`generate(config)` + +Creates the js, html, and scss file for a new page, based on the supplied [Generator](#generators). + +- **config** (Object) Config object, with the following options: + - `appDirectory` - root directory of the Ionic project + - `generator` - which [generator](#generators) to use, default is `page`. + - `name` - + +Example: + ``` + var ionic = require('ionic-framework'); + ionic.generate({ appDirectory: process.cwd(), generator: 'tabs', name: 'MyTabsPage' }) + ``` + +#### Generators +- `page`, a blank page +- `tabs`, a page with tab navigation +- `sidemenu` + diff --git a/gulpfile.js b/gulpfile.js index e730b36a16..c6d7143412 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -497,47 +497,3 @@ gulp.task('demos:docs', ['sass.demos:docs', 'bundle.demos:docs'], function() { gulp.task('demos', ['demos:all']); - -gulp.task('publish', function(done) { - var version = flags.version; - var ngVersion = flags.ngVersion; - var dryRun = flags['dry-run']; - - if (!version || !ngVersion) { - console.error("\nERR: You need to provide a version for Ionic as well as " + - "the version of Angular it depends on.\n\n" + - "gulp publish -v {version} -a {ngVersion}\n"); - return - } - if (version.indexOf("alpha") + version.indexOf("-") > -2 || - ngVersion.indexOf("alpha") + ngVersion.indexOf("-") > -2) - { - console.error("\n ERR: Just provide version number. Instead of 2.0.0-alpha.10, just enter 10\n"); - return - } - - var exec = require('child_process').exec; - var _ = require('lodash'); - var fs = require('fs'); - - runSequence( - 'clean', - ['bundle', 'sass', 'fonts', 'copy.ts', 'copy.scss', 'copy.web-animations'], - 'transpile.common', - function() { - var packageJSONTemplate = _.template(fs.readFileSync('scripts/npm/package.json')); - packageJSONContents = packageJSONTemplate({ 'version': version, 'ngVersion': ngVersion }); - fs.writeFileSync('dist/package.json', packageJSONContents); - fs.writeFileSync('dist/README.md', fs.readFileSync('scripts/npm/README.md')); - - // publish to npm - if (!dryRun) { - exec('cd dist && npm publish', function (err, stdout, stderr) { - console.log(stdout); - console.error(stderr); - done(); - }); - } - } - ) -}) diff --git a/index.js b/index.js deleted file mode 100644 index 4e52b93f40..0000000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - generate: require('./tooling/generate') -}; diff --git a/package.json b/package.json index 05b556514c..af31b1bad2 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { - "name": "ionic2", - "version": "2.0.0-alpha.2", + "name": "ionic-framework", + "version": "2.0.0-alpha.31", "license": "Apache-2.0", "repository": { "type": "git", "url": "https://github.com/driftyco/ionic2.git" }, - "main": "index.js", + "main": "tooling/index.js", "scripts": { "test": "gulp karma", "test:generators": "jasmine-node ./tooling/spec", diff --git a/scripts/npm/README.md b/scripts/npm/README.md deleted file mode 100644 index c83f327b9f..0000000000 --- a/scripts/npm/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Ionic Framework - -### Bundles: - - - `css/` - - the Ionic CSS stylesheet - - `fonts/` - - Ionicons and Roboto fonts - - `js/` - - `ionic.js` the Ionic module, in System register format - - `ionic.bundle.js` the Ionic bundle, contains: - - es6-module-loader.js - - system.js - - angular2.dev.js - - router.dev.js (angular2 router) - - ionic.js - - web-animations.min.js - - `web-animations.min.js` web animations API polyfill - -### Source files: - - - `src/es5` - Ionic ES5 source files in both CommonJS and System module formats - - `src/es6` - Ionic ES6 source files - - `src/ts` - Ionic TypeScript source files (typings still missing) - - `scss` - Ionic Sass source files diff --git a/scripts/npm/package.json b/scripts/npm/package.json deleted file mode 100644 index 42467ffe7c..0000000000 --- a/scripts/npm/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "ionic-framework", - "version": "2.0.0-alpha.<%= version %>", - "license": "Apache-2.0", - "repository": { - "type": "git", - "url": "https://github.com/driftyco/ionic2.git" - }, - "files": [ - "css", - "fonts", - "js", - "src" - ], - "dependencies": { - "angular2": "2.0.0-alpha.<%= ngVersion %>", - "es6-shim": "^0.33.6", - "@reactivex/rxjs": "5.0.0-alpha.4", - "reflect-metadata": "0.1.1", - "zone.js": "0.5.8" - } -} diff --git a/tooling/index.js b/tooling/index.js new file mode 100644 index 0000000000..f3a483486b --- /dev/null +++ b/tooling/index.js @@ -0,0 +1,3 @@ +module.exports = { + generate: require('./generate').generate +}; From b8db33ebb8d8564067d78381258cda8ed91fcec1 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 11:55:51 -0600 Subject: [PATCH 12/20] refactor(nav): move stage to nav-controller --- ionic/components/item/item.ts | 11 +++++--- ionic/components/nav/nav-controller.ts | 27 ++++++++++++++++-- ionic/components/nav/test/basic/index.ts | 35 ++++++++++++++++-------- ionic/components/nav/view-controller.ts | 26 ------------------ 4 files changed, 55 insertions(+), 44 deletions(-) diff --git a/ionic/components/item/item.ts b/ionic/components/item/item.ts index a4c4d0c27a..5b2aa45f2c 100644 --- a/ionic/components/item/item.ts +++ b/ionic/components/item/item.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, Renderer} from 'angular2/angular2'; +import {Component} from 'angular2/angular2'; /** @@ -24,10 +24,13 @@ import {Component, ElementRef, Renderer} from 'angular2/angular2'; '' + '' + ''+ - '' + '', + host: { + '[class.item]': 'isItem' + } }) export class Item { - constructor(elementRef: ElementRef, renderer: Renderer) { - renderer.setElementClass(elementRef, 'item', true); + constructor() { + this.isItem = true; } } diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 774dc8ed65..3a23dfa5a3 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -269,7 +269,6 @@ export class NavController extends Ion { return; } - opts.direction = opts.direction || 'back'; // get the views to auto remove without having to do a transiton for each @@ -452,7 +451,7 @@ export class NavController extends Ion { } // wait for the new view to complete setup - enteringView.stage(() => { + this.stage(enteringView, () => { if (enteringView.shouldDestroy) { // already marked as a view that will be destroyed, don't continue @@ -515,6 +514,30 @@ export class NavController extends Ion { } + /** + * @private + */ + stage(viewCtrl, done) { + if (viewCtrl.instance || viewCtrl.shouldDestroy) { + // already compiled this view + return done(); + } + + // get the pane the NavController wants to use + // the pane is where all this content will be placed into + this.loadPage(viewCtrl, null, () => { + + // this ViewController instance has finished loading + try { + viewCtrl.loaded(); + } catch (e) { + console.error(e); + } + + done(); + }); + } + loadPage(viewCtrl, navbarContainerRef, done) { let providers = this.providers.concat(Injector.resolve([ provide(ViewController, {useValue: viewCtrl}), diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index 6b6dcfa91f..9c2ce6f806 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -14,18 +14,24 @@ import {NavParams, NavController, ViewController} from 'ionic/ionic'; - -

{{title}}

-

-

-

-

-

-

-

-

-

- + + + + {{title}} + + + + + + + + + + + + + + ` }) class FirstPage { @@ -38,6 +44,11 @@ class FirstPage { this.title = 'First Page'; this.pushPage = FullPage; + + this.pages = []; + for (var i = 1; i <= 50; i++) { + this.pages.push(i); + } } setViews() { diff --git a/ionic/components/nav/view-controller.ts b/ionic/components/nav/view-controller.ts index 4fd539c9c2..02470fa1d3 100644 --- a/ionic/components/nav/view-controller.ts +++ b/ionic/components/nav/view-controller.ts @@ -15,32 +15,6 @@ export class ViewController { this._destroys = []; } - /** - * @private - */ - stage(done) { - let navCtrl = this.navCtrl; - - if (this.instance || !navCtrl || this.shouldDestroy) { - // already compiled this view - return done(); - } - - // get the pane the NavController wants to use - // the pane is where all this content will be placed into - navCtrl.loadPage(this, null, () => { - - // this ViewController instance has finished loading - try { - this.loaded(); - } catch (e) { - console.error(e); - } - - done(); - }); - } - /** * TODO * @returns {boolean} TODO From ef19d7ca61ccf65d0c02cab01fdb5380448a080e Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 12:01:35 -0600 Subject: [PATCH 13/20] chore(nav): return transition promises --- ionic/components/nav/nav-controller.ts | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 3a23dfa5a3..fddecfd059 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -236,10 +236,7 @@ export class NavController extends Ion { } // start the transition - this.transition(enteringView, leavingView, opts, () => { - // transition completed, destroy the leaving view - resolve(); - }); + this.transition(enteringView, leavingView, opts, resolve); } else { this._transComplete(); @@ -261,14 +258,14 @@ export class NavController extends Ion { // Get the target index of the view to pop to let viewIndex = this._views.indexOf(view); let targetIndex = viewIndex + 1; - let resolve; - let promise = new Promise(res => { resolve = res; }); + // Don't pop to the view if it wasn't found, or the target is beyond the view list - if(viewIndex < 0 || targetIndex > this._views.length - 1) { - resolve(); - return; + if (viewIndex < 0 || targetIndex > this._views.length - 1) { + return Promise.resolve(); } + let resolve; + let promise = new Promise(res => { resolve = res; }); opts.direction = opts.direction || 'back'; // get the views to auto remove without having to do a transiton for each @@ -289,9 +286,7 @@ export class NavController extends Ion { this.router.stateChange('pop', enteringView); } - this.transition(enteringView, leavingView, opts, () => { - resolve(); - }); + this.transition(enteringView, leavingView, opts, resolve); return promise; } @@ -301,7 +296,7 @@ export class NavController extends Ion { * @param opts extra animation options */ popToRoot(opts = {}) { - this._popTo(this.first()); + return this._popTo(this.first(), opts); } /** From d38fff878c88f8eae0dbf5c83b054615567381bb Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 12:05:39 -0600 Subject: [PATCH 14/20] feat(nav): make popTo public --- ionic/components/nav/nav-controller.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index fddecfd059..00a054efd8 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -253,10 +253,10 @@ export class NavController extends Ion { * @param view {ViewController} to pop to * @param opts {object} pop options */ - _popTo(view, opts = {}) { + popTo(viewCtrl, opts = {}) { // Get the target index of the view to pop to - let viewIndex = this._views.indexOf(view); + let viewIndex = this._views.indexOf(viewCtrl); let targetIndex = viewIndex + 1; // Don't pop to the view if it wasn't found, or the target is beyond the view list @@ -279,14 +279,13 @@ export class NavController extends Ion { } } - let leavingView = this._views[this._views.length - 1]; - let enteringView = view; + let leavingView = this.getPrevious(viewCtrl); if (this.router) { - this.router.stateChange('pop', enteringView); + this.router.stateChange('pop', viewCtrl); } - this.transition(enteringView, leavingView, opts, resolve); + this.transition(viewCtrl, leavingView, opts, resolve); return promise; } From b336c280b94af23ae29885515f3519f5f0ce7172 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 12:13:00 -0600 Subject: [PATCH 15/20] feat(nav): pass opts in insert/remove --- ionic/components/nav/nav-controller.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 00a054efd8..fae3ec1ed2 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -304,14 +304,14 @@ export class NavController extends Ion { * @param {TODO} index TODO * @returns {Promise} TODO */ - insert(componentType, index) { + insert(componentType, index, params = {}, opts = {}) { if (!componentType || index < 0) { return Promise.reject(); } // push it onto the end if (index >= this._views.length) { - return this.push(componentType); + return this.push(componentType, params, opts); } // create new ViewController, but don't render yet @@ -330,14 +330,14 @@ export class NavController extends Ion { * @param {TODO} index TODO * @returns {Promise} TODO */ - remove(index) { + remove(index, opts = {}) { if (index < 0 || index >= this._views.length) { return Promise.reject("Index out of range"); } let viewToRemove = this._views[index]; if (this.isActive(viewToRemove)){ - return this.pop(); + return this.pop(opts); } viewToRemove.shouldDestroy = true; @@ -429,12 +429,12 @@ export class NavController extends Ion { * @param {TODO} enteringView TODO * @param {TODO} leavingView TODO * @param {TODO} opts TODO - * @param {Function} callback TODO + * @param {Function} done TODO * @returns {any} TODO */ - transition(enteringView, leavingView, opts, callback) { + transition(enteringView, leavingView, opts, done) { if (!enteringView || enteringView === leavingView) { - return callback(); + return done(); } if (!opts.animation) { @@ -449,7 +449,7 @@ export class NavController extends Ion { if (enteringView.shouldDestroy) { // already marked as a view that will be destroyed, don't continue - return callback(); + return done(); } this._setZIndex(enteringView.instance, leavingView.instance, opts.direction); @@ -498,7 +498,7 @@ export class NavController extends Ion { // all done! this._zone.run(() => { this._transComplete(); - callback(); + done(); }); }); From 0edc60eefc82fb851c1d9f88a82c856449c670c0 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 2 Nov 2015 12:20:26 -0600 Subject: [PATCH 16/20] chore(nav): make transition/stage private --- ionic/components/nav/nav-controller.ts | 16 +++++++--------- ionic/components/nav/test/nav-controller.spec.ts | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index fae3ec1ed2..bae12c2640 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -193,9 +193,7 @@ export class NavController extends Ion { } // start the transition - this.transition(enteringView, leavingView, opts, () => { - resolve(); - }); + this._transition(enteringView, leavingView, opts, resolve); return promise; } @@ -236,7 +234,7 @@ export class NavController extends Ion { } // start the transition - this.transition(enteringView, leavingView, opts, resolve); + this._transition(enteringView, leavingView, opts, resolve); } else { this._transComplete(); @@ -285,7 +283,7 @@ export class NavController extends Ion { this.router.stateChange('pop', viewCtrl); } - this.transition(viewCtrl, leavingView, opts, resolve); + this._transition(viewCtrl, leavingView, opts, resolve); return promise; } @@ -432,7 +430,7 @@ export class NavController extends Ion { * @param {Function} done TODO * @returns {any} TODO */ - transition(enteringView, leavingView, opts, done) { + _transition(enteringView, leavingView, opts, done) { if (!enteringView || enteringView === leavingView) { return done(); } @@ -445,7 +443,7 @@ export class NavController extends Ion { } // wait for the new view to complete setup - this.stage(enteringView, () => { + this._stage(enteringView, () => { if (enteringView.shouldDestroy) { // already marked as a view that will be destroyed, don't continue @@ -511,7 +509,7 @@ export class NavController extends Ion { /** * @private */ - stage(viewCtrl, done) { + _stage(viewCtrl, done) { if (viewCtrl.instance || viewCtrl.shouldDestroy) { // already compiled this view return done(); @@ -627,7 +625,7 @@ export class NavController extends Ion { enteringView.willEnter(); // wait for the new view to complete setup - enteringView.stage(() => { + enteringView._stage(() => { this._zone.runOutsideAngular(() => { // set that the new view pushed on the stack is staged to be entering/leaving diff --git a/ionic/components/nav/test/nav-controller.spec.ts b/ionic/components/nav/test/nav-controller.spec.ts index 16c5c807ce..84e5d546da 100644 --- a/ionic/components/nav/test/nav-controller.spec.ts +++ b/ionic/components/nav/test/nav-controller.spec.ts @@ -133,7 +133,7 @@ export function run() { spyOn(nav, '_add').and.callThrough(); - nav.transition = mockTransitionFn; + nav._transition = mockTransitionFn; nav.push(FirstPage, {}, {}).then(() => { expect(nav._add).toHaveBeenCalled(); expect(nav._views.length).toBe(1); @@ -163,7 +163,7 @@ export function run() { nav._views = [vc1, vc2, vc3]; let arr = [FirstPage, SecondPage, ThirdPage]; - nav.transition = mockTransitionFn; + nav._transition = mockTransitionFn; nav.setViews(arr); //_views[0] will be transitioned out of @@ -188,7 +188,7 @@ export function run() { nav.insert(FirstPage, 2); expect(nav.push).not.toHaveBeenCalled(); - nav.transition = mockTransitionFn; + nav._transition = mockTransitionFn; nav.insert(FirstPage, 4); expect(nav._views[4].componentType).toBe(FirstPage); expect(nav.push).toHaveBeenCalled(); @@ -208,7 +208,7 @@ export function run() { nav._views = [vc1, vc2, vc3]; expect(nav._views.length).toBe(3); - nav.transition = mockTransitionFn; + nav._transition = mockTransitionFn; nav.setRoot(FirstPage); //_views[0] will be transitioned out of expect(nav._views.length).toBe(2); From 9de07d93d4da254e006a6311653101aabb54120b Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 2 Nov 2015 12:59:01 -0600 Subject: [PATCH 17/20] chore(tooling): add inquirer as generator dependency --- package.json | 1 + tooling/generate.js | 5 ----- tooling/generators/page-tabs/index.js | 13 +++++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index af31b1bad2..5b2c34d4be 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@reactivex/rxjs": "5.0.0-alpha.4", "angular2": "2.0.0-alpha.44", "es6-shim": "^0.33.6", + "inquirer": "^0.11.0", "lodash": "^3.10.1", "reflect-metadata": "0.1.1", "shelljs": "^0.5.3", diff --git a/tooling/generate.js b/tooling/generate.js index 82ce487028..4d5abd2a4c 100644 --- a/tooling/generate.js +++ b/tooling/generate.js @@ -30,10 +30,6 @@ Generate.generate = function generate(options) { Generate.log = options.log; } - if (options.inquirer) { - Generate.inquirer = options.inquirer; - } - if (options.q) { Generate.q = options.q; } @@ -44,7 +40,6 @@ Generate.generate = function generate(options) { var generateOptions = { appDirectory: options.appDirectory, - inquirer: options.inquirer, fileAndClassName: Generate.fileAndClassName(options.name), javascriptClassName: Generate.javascriptClassName(options.name), name: options.name diff --git a/tooling/generators/page-tabs/index.js b/tooling/generators/page-tabs/index.js index 04092f4548..b159cb0e45 100644 --- a/tooling/generators/page-tabs/index.js +++ b/tooling/generators/page-tabs/index.js @@ -1,7 +1,8 @@ var fs = require('fs'), + path = require('path'), + inquirer = require('inquirer'), Generator = module.exports, - Generate = require('../../generate'), - path = require('path'); + Generate = require('../../generate'); Generator.validate = function(input) { // console.log(typeof parseInt(input)); @@ -17,7 +18,7 @@ Generator.numberNames = ['first', 'second', 'third', 'fourth', 'fifth']; Generator.promptForTabCount = function promptForTabCount() { var q = Generate.q.defer(); - Generate.inquirer.prompt({choices: ['1', '2', '3', '4', '5'], message: 'How many tabs will you have?', name: 'count', type: 'list', validate: Generator.validate}, function(result) { + inquirer.prompt({choices: ['1', '2', '3', '4', '5'], message: 'How many tabs will you have?', name: 'count', type: 'list', validate: Generator.validate}, function(result) { q.resolve(result.count); }); @@ -27,7 +28,7 @@ Generator.promptForTabCount = function promptForTabCount() { Generator.promptForTabName = function promptForTabName(tabIndex, options) { var q = Generate.q.defer(); - Generate.inquirer.prompt({message: 'Enter the ' + Generator.numberNames[tabIndex] + ' tab name:', name: 'name', type: 'input'}, function(nameResult) { + inquirer.prompt({message: 'Enter the ' + Generator.numberNames[tabIndex] + ' tab name:', name: 'name', type: 'input'}, function(nameResult) { Generator.tabs.push({ appDirectory: options.appDirectory, fileAndClassName: Generate.fileAndClassName(nameResult.name), javascriptClassName: Generate.javascriptClassName(nameResult.name), name: nameResult.name }); q.resolve(); }); @@ -63,9 +64,9 @@ Generator.run = function run(options) { // console.log('Using tabs:', Generator.tabs); // }); }) - .then(function() { + .then(function() { var templates = Generate.loadGeneratorTemplates(__dirname); - + //Generate the tabs container page templates templates.forEach(function(template) { var templatePath = path.join(__dirname, template.file); From b8aec7011382c06e8ef2bcda2819fbce8532b164 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 2 Nov 2015 12:59:30 -0600 Subject: [PATCH 18/20] test(tooling): remove unused require --- tooling/spec/generate.spec.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tooling/spec/generate.spec.js b/tooling/spec/generate.spec.js index 5a46329de5..4a312c3d39 100644 --- a/tooling/spec/generate.spec.js +++ b/tooling/spec/generate.spec.js @@ -1,5 +1,4 @@ -var colors = require('colors'), - fs = require('fs'), +var fs = require('fs'), path = require('path'), Generate = require('../generate'), _ = require('lodash'), @@ -48,7 +47,7 @@ describe('#Generate', function() { var genOpts = { fileAndClassName: 'about', javascriptClassName: 'About', - name: 'About', + name: 'About', } expect(generatorSpy.run).toHaveBeenCalledWith(genOpts); @@ -62,7 +61,7 @@ describe('#Generate', function() { var genOpts = { fileAndClassName: 'about', javascriptClassName: 'About', - name: 'About', + name: 'About', }; spyOn(fs, 'writeFileSync'); @@ -71,12 +70,12 @@ describe('#Generate', function() { Generate.generate(generatorOptions); expect(fs.writeFileSync.calls.length).toBe(3); - + }); }); }); - xdescribe('#page', function() { + xdescribe('#page', function() { it('should generate a page at a directory', function() { //ionic g page about @@ -144,7 +143,7 @@ describe('#Generate', function() { }); }); //#page - xdescribe('#directories', function() { + xdescribe('#directories', function() { it('should create directories for scaffolding', function() { // pwd = /ionic/app // ionic g page about From 9c9895b0af4167ef255cdefb4490ea273b2a8f6a Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 2 Nov 2015 13:27:53 -0600 Subject: [PATCH 19/20] chore(tooling): add q as generator dependency --- package.json | 2 +- tooling/generate.js | 14 +++++--------- tooling/generators/page-tabs/index.js | 8 ++++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 5b2c34d4be..de2a5ef46a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "es6-shim": "^0.33.6", "inquirer": "^0.11.0", "lodash": "^3.10.1", + "q": "^1.4.1", "reflect-metadata": "0.1.1", "shelljs": "^0.5.3", "zone.js": "0.5.8" @@ -57,7 +58,6 @@ "minimist": "^1.1.3", "node-html-encoder": "0.0.2", "node-libs-browser": "^0.5.2", - "q": "^1.4.1", "request": "2.53.0", "run-sequence": "^1.1.0", "semver": "^5.0.1", diff --git a/tooling/generate.js b/tooling/generate.js index 4d5abd2a4c..313b89d1f4 100644 --- a/tooling/generate.js +++ b/tooling/generate.js @@ -10,7 +10,7 @@ Generate.__defineGetter__('generators', function() { if (!Generate._generators) { Generate._generators = Generate.loadGenerators(); } - + return Generate._generators; }); @@ -24,21 +24,17 @@ Generate.generate = function generate(options) { if (!options) { throw new Error('No options passed to generator'); } - + //add optional logger for CLI or other tools if (options.log) { Generate.log = options.log; } - if (options.q) { - Generate.q = options.q; - } - if (!options.generatorName) { options.generatorName = 'page'; } - var generateOptions = { + var generateOptions = { appDirectory: options.appDirectory, fileAndClassName: Generate.fileAndClassName(options.name), javascriptClassName: Generate.javascriptClassName(options.name), @@ -78,7 +74,7 @@ Generate.loadGenerator = function loadGenerator(file) { } return generateModule; }; - + Generate.loadGenerators = function loadGenerators() { var generators = {}; fs.readdirSync(path.join(__dirname, 'generators')) @@ -92,7 +88,7 @@ Generate.loadGenerators = function loadGenerators() { return generators; }; -/* +/* Will take options to render an html, js, or scss template. options: they differ based on what is needed in template diff --git a/tooling/generators/page-tabs/index.js b/tooling/generators/page-tabs/index.js index b159cb0e45..c6b1d6798b 100644 --- a/tooling/generators/page-tabs/index.js +++ b/tooling/generators/page-tabs/index.js @@ -1,6 +1,7 @@ var fs = require('fs'), path = require('path'), inquirer = require('inquirer'), + Q = require('q'), Generator = module.exports, Generate = require('../../generate'); @@ -16,7 +17,7 @@ Generator.validate = function(input) { Generator.numberNames = ['first', 'second', 'third', 'fourth', 'fifth']; Generator.promptForTabCount = function promptForTabCount() { - var q = Generate.q.defer(); + var q = Q.defer(); inquirer.prompt({choices: ['1', '2', '3', '4', '5'], message: 'How many tabs will you have?', name: 'count', type: 'list', validate: Generator.validate}, function(result) { q.resolve(result.count); @@ -26,7 +27,7 @@ Generator.promptForTabCount = function promptForTabCount() { }; Generator.promptForTabName = function promptForTabName(tabIndex, options) { - var q = Generate.q.defer(); + var q = Q.defer(); inquirer.prompt({message: 'Enter the ' + Generator.numberNames[tabIndex] + ' tab name:', name: 'name', type: 'input'}, function(nameResult) { Generator.tabs.push({ appDirectory: options.appDirectory, fileAndClassName: Generate.fileAndClassName(nameResult.name), javascriptClassName: Generate.javascriptClassName(nameResult.name), name: nameResult.name }); @@ -39,7 +40,6 @@ Generator.promptForTabName = function promptForTabName(tabIndex, options) { Generator.run = function run(options) { // console.log('got options!', options); - // Generator.q = Generate.q; //Need to query user for tabs: options.rootDirectory = options.rootDirectory || path.join('www', 'app'); var savePath = path.join(options.appDirectory, options.rootDirectory, options.fileAndClassName); @@ -49,7 +49,7 @@ Generator.run = function run(options) { return Generator.promptForTabCount() .then(function(count) { console.log('count', count); - var promise = Generate.q(); + var promise = Q(); for(var i = 0, j = parseInt(count); i < j; i++) { (function(index) { promise = promise.then(function() { From df4b5f04b189f51669902da86bf47e38eee51bde Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Mon, 2 Nov 2015 13:29:12 -0600 Subject: [PATCH 20/20] chore(build): use specific dependency versions --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index de2a5ef46a..0b52132bed 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,12 @@ "dependencies": { "@reactivex/rxjs": "5.0.0-alpha.4", "angular2": "2.0.0-alpha.44", - "es6-shim": "^0.33.6", - "inquirer": "^0.11.0", - "lodash": "^3.10.1", - "q": "^1.4.1", + "es6-shim": "0.33.6", + "inquirer": "0.11.0", + "lodash": "3.10.1", + "q": "1.4.1", "reflect-metadata": "0.1.1", - "shelljs": "^0.5.3", + "shelljs": "0.5.3", "zone.js": "0.5.8" }, "devDependencies": {