From fa499e00c89ba127893aa3b876cc47ca22912fdc Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 8 Oct 2015 16:34:50 -0500 Subject: [PATCH 01/15] fix(item-group-title): no content required --- ionic/components/item/item-group.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ionic/components/item/item-group.ts b/ionic/components/item/item-group.ts index 010c49c8f5..29213a26dd 100644 --- a/ionic/components/item/item-group.ts +++ b/ionic/components/item/item-group.ts @@ -38,7 +38,7 @@ export class ItemGroupTitle { * TODO * @param {ElementRef} elementRef TODO */ - constructor(elementRef: ElementRef, config: IonicConfig, @Host() content: Content) { + constructor(elementRef: ElementRef, config: IonicConfig, @Optional() @Host() content: Content) { this.isSticky = true; this.content = content; this.ele = elementRef.nativeElement; @@ -46,6 +46,7 @@ export class ItemGroupTitle { } onInit() { + if(!this.content) { return; } this.scrollContent = this.content.elementRef.nativeElement.children[0]; From 0ef061c2328306ce333a50ef26e2d1e13b3965b5 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 8 Oct 2015 20:08:15 -0500 Subject: [PATCH 02/15] feat(focusOut): ability to blur focused element, close keyboard --- ionic/components/form/form.scss | 24 +++--- ionic/components/form/form.ts | 89 +++++++++++++---------- ionic/components/text-input/text-input.ts | 2 - 3 files changed, 66 insertions(+), 49 deletions(-) diff --git a/ionic/components/form/form.scss b/ionic/components/form/form.scss index 6d63dae9a6..03d613739d 100644 --- a/ionic/components/form/form.scss +++ b/ionic/components/form/form.scss @@ -66,27 +66,33 @@ select[readonly] { // Focus Utils // ------------------------------- -focus-holder input { +focus-ctrl { position: fixed; - top: 1px; - width: 9px; - left: -9999px; - z-index: 9999; + + input, + button { + position: fixed; + top: 1px; + width: 9px; + left: -9999px; + z-index: 9999; + } } -/*focus-holder input[tabindex="999"] { + +/*focus-ctrl input[tabindex="999"] { left: 0px; } -focus-holder input[tabindex="1001"] { +focus-ctrl input[tabindex="1001"] { left: 20px; } -focus-holder input[tabindex="1002"] { +focus-ctrl input[tabindex="1002"] { left: auto; right: 10px; } -focus-holder input:focus { +focus-ctrl input:focus { background: red; }*/ diff --git a/ionic/components/form/form.ts b/ionic/components/form/form.ts index 98f6ff648c..ce0c856933 100644 --- a/ionic/components/form/form.ts +++ b/ionic/components/form/form.ts @@ -28,9 +28,7 @@ export class IonicForm { this._focused = null; zone.runOutsideAngular(() => { - if (this._config.get('keyboardScrollAssist')) { - this.initHolders(document); - } + this.initHolders(document, this._config.get('keyboardScrollAssist')); if (this._config.get('keyboardInputListener') !== false) { this.initKeyInput(document); @@ -78,55 +76,72 @@ export class IonicForm { document.addEventListener('keydown', keyDown); } - initHolders(document) { + initHolders(document, scrollAssist) { // raw DOM fun - this._holder = document.createElement('focus-holder'); + this._ctrl = document.createElement('focus-ctrl'); + this._ctrl.setAttribute('aria-hidden', true); - this._prev = document.createElement('input'); - this._prev.tabIndex = NO_FOCUS_TAB_INDEX; - this._holder.appendChild(this._prev); + if (scrollAssist) { + this._prev = document.createElement('input'); + this._prev.tabIndex = NO_FOCUS_TAB_INDEX; + this._ctrl.appendChild(this._prev); - this._next = document.createElement('input'); - this._next.tabIndex = NO_FOCUS_TAB_INDEX; - this._holder.appendChild(this._next); + this._next = document.createElement('input'); + this._next.tabIndex = NO_FOCUS_TAB_INDEX; + this._ctrl.appendChild(this._next); - this._temp = document.createElement('input'); - this._temp.tabIndex = NO_FOCUS_TAB_INDEX; - this._holder.appendChild(this._temp); + this._temp = document.createElement('input'); + this._temp.tabIndex = NO_FOCUS_TAB_INDEX; + this._ctrl.appendChild(this._temp); + } - document.body.appendChild(this._holder); + this._blur = document.createElement('button'); + this._blur.tabIndex = NO_FOCUS_TAB_INDEX; + this._ctrl.appendChild(this._blur); + + document.body.appendChild(this._ctrl); function preventDefault(ev) { ev.preventDefault(); ev.stopPropagation(); } - this._prev.addEventListener('keydown', preventDefault); - this._next.addEventListener('keydown', preventDefault); - this._temp.addEventListener('keydown', preventDefault); + if (scrollAssist) { + this._prev.addEventListener('keydown', preventDefault); + this._next.addEventListener('keydown', preventDefault); + this._temp.addEventListener('keydown', preventDefault); - this._prev.addEventListener('focus', () => { - this.focusPrevious(); - }); + this._prev.addEventListener('focus', () => { + this.focusPrevious(); + }); - this._next.addEventListener('focus', () => { - this.focusNext(); - }); + this._next.addEventListener('focus', () => { + this.focusNext(); + }); - let self = this; - let resetTimer; - function queueReset() { - clearTimeout(resetTimer); + let self = this; + let resetTimer; + function queueReset() { + clearTimeout(resetTimer); - resetTimer = setTimeout(function() { - self._zone.run(() => { - self.resetInputs(); - }); - }, 100); + resetTimer = setTimeout(function() { + self._zone.run(() => { + self.resetInputs(); + }); + }, 100); + } + + document.addEventListener('focusin', queueReset); + document.addEventListener('focusout', queueReset); } - document.addEventListener('focusin', queueReset); - document.addEventListener('focusout', queueReset); + } + + focusOut() { + console.debug('focusOut') + this._blur.tabIndex = NORMAL_FOCUS_TAB_INDEX; + this._blur.focus(); + this._blur.tabIndex = NO_FOCUS_TAB_INDEX; } setFocusHolder(type) { @@ -216,8 +231,7 @@ export class IonicForm { if (index > -1 && (index + inc) < this._inputs.length) { let siblingInput = this._inputs[index + inc]; if (siblingInput) { - siblingInput.initFocus(); - return; + return siblingInput.initFocus(); } } this._focused.initFocus(); @@ -232,4 +246,3 @@ const PREV_TAB_INDEX = 999; const ACTIVE_FOCUS_TAB_INDEX = 1000; const NEXT_TAB_INDEX = 1001; const TEMP_TAB_INDEX = 2000; - diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index 343552f943..b8b3cdebca 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -322,8 +322,6 @@ export class TextInput { // ensure the body hasn't scrolled down document.body.scrollTop = 0; - - this.form.resetInputs(); }); if (this.scrollAssist && this.scrollView) { From 79185044f39ff4e593f3dce49e24fc6f8af45cec Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 8 Oct 2015 19:17:50 -0500 Subject: [PATCH 03/15] make some NavController methods private --- ionic/components/nav/nav-controller.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index d1e6d52343..cfa26f9497 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -188,7 +188,7 @@ export class NavController extends Ion { let enteringView = new ViewController(this, componentType, params); // add the view to the stack - this.add(enteringView); + this._add(enteringView); if (this.router) { // notify router of the state change @@ -253,12 +253,13 @@ export class NavController extends Ion { } /** + * @private * Pop to a specific view in the history stack * - * @param view {Component} to pop to + * @param view {ViewController} to pop to * @param opts {object} pop options */ - popTo(view, opts = {}) { + _popTo(view, opts = {}) { // Get the target index of the view to pop to let viewIndex = this._views.indexOf(view); @@ -383,7 +384,7 @@ export class NavController extends Ion { viewCtrl.shouldCache = false; // add the item to the stack - this.add(viewCtrl); + this._add(viewCtrl); } } } @@ -749,7 +750,7 @@ export class NavController extends Ion { }); destroys.forEach(view => { - this.remove(view); + this._remove(view); view.destroy(); }); @@ -873,11 +874,12 @@ export class NavController extends Ion { } /** + * @private * TODO * @param {TODO} view TODO * @returns {TODO} TODO */ - add(view) { + _add(view) { this._incrementId(view); this._views.push(view); } @@ -887,11 +889,12 @@ export class NavController extends Ion { } /** + * @private * TODO * @param {TODO} viewOrIndex TODO * @returns {TODO} TODO */ - remove(viewOrIndex) { + _remove(viewOrIndex) { util.array.remove(this._views, viewOrIndex); } From f199e65767a056f78e3a424acfd94c8c9c7fa1b5 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 8 Oct 2015 19:20:52 -0500 Subject: [PATCH 04/15] fix(nav-controller): insert should return a promise --- ionic/components/nav/nav-controller.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index cfa26f9497..05baab9aa9 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -332,6 +332,7 @@ export class NavController extends Ion { this._incrementId(viewCtrl); this._views.splice(index, 0, viewCtrl); + return Promise.resolve(); } /** From 7ccdfed018d3c8695ab3637845dba4bec20e5b89 Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Thu, 8 Oct 2015 20:42:24 -0500 Subject: [PATCH 05/15] feat(nav-controller): remove method --- ionic/components/nav/nav-controller.ts | 20 ++++++++++++++++++++ ionic/components/nav/nav.ts | 4 +--- ionic/components/nav/test/basic/index.ts | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ionic/components/nav/nav-controller.ts b/ionic/components/nav/nav-controller.ts index 05baab9aa9..91edc2d10e 100644 --- a/ionic/components/nav/nav-controller.ts +++ b/ionic/components/nav/nav-controller.ts @@ -335,6 +335,26 @@ export class NavController extends Ion { return Promise.resolve(); } + /** + * Removes a view from the nav stack at the specified index. + * @param {TODO} index TODO + * @returns {Promise} TODO + */ + remove(index) { + 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(); + } else { + this._remove(index); + viewToRemove.destroy(); + return Promise.resolve(); + } + } + /** * Set the view stack to reflect the given component classes. * @param {TODO} components TODO diff --git a/ionic/components/nav/nav.ts b/ionic/components/nav/nav.ts index 5aa2b388a9..ffc10b4000 100644 --- a/ionic/components/nav/nav.ts +++ b/ionic/components/nav/nav.ts @@ -437,9 +437,7 @@ class Pane { showNavbar(hasNavbar) { this.navbar = hasNavbar; - if (!hasNavbar) { - this.renderer.setElementAttribute(this.elementRef, 'no-navbar', ''); - } + this.renderer.setElementAttribute(this.elementRef, 'no-navbar', hasNavbar ? null : '' ); } } diff --git a/ionic/components/nav/test/basic/index.ts b/ionic/components/nav/test/basic/index.ts index 3f6ead453f..d20838f9bf 100644 --- a/ionic/components/nav/test/basic/index.ts +++ b/ionic/components/nav/test/basic/index.ts @@ -104,6 +104,7 @@ class SecondPage {

+

@@ -124,6 +125,10 @@ class ThirdPage { this.nav.insert(FirstPage, 2); } + removeSecond() { + this.nav.remove(1); + } + } From 18519d1576482f3907d0afdccd408da43ea17ecf Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 8 Oct 2015 21:32:14 -0500 Subject: [PATCH 06/15] refactor(cssClass): update/cleanup css class usage --- demos/yerk/main.html | 4 +-- ionic/components/button/button.ts | 11 +++---- ionic/components/checkbox/checkbox.ts | 8 +++-- ionic/components/item/item-sliding.ts | 11 +++---- ionic/components/item/modes/md.scss | 2 +- ionic/components/list/list.ts | 10 +++--- ionic/components/nav-bar/modes/ios.scss | 2 +- ionic/components/nav-bar/modes/md.scss | 34 +++++++++------------ ionic/components/nav-bar/nav-bar.ts | 11 +++---- ionic/components/nav/nav.ts | 7 ++--- ionic/components/radio/radio.ts | 14 ++++++--- ionic/components/search-bar/modes/ios.scss | 4 +-- ionic/components/search-bar/modes/md.scss | 2 +- ionic/components/search-bar/search-bar.scss | 2 +- ionic/components/switch/switch.ts | 5 ++- ionic/components/tabs/tabs.ts | 2 +- ionic/components/text-input/label.scss | 2 +- ionic/components/text-input/label.ts | 1 - ionic/components/text-input/modes/ios.scss | 8 ++--- ionic/components/text-input/modes/md.scss | 8 ++--- ionic/components/text-input/text-input.scss | 4 +-- ionic/components/text-input/text-input.ts | 23 +++++++++----- ionic/components/toolbar/toolbar.ts | 11 +++---- ionic/config/decorators.ts | 3 -- scripts/snapshot/snapshot.config.js | 2 +- 25 files changed, 96 insertions(+), 95 deletions(-) diff --git a/demos/yerk/main.html b/demos/yerk/main.html index 59e85c1e73..47ea1ee8af 100644 --- a/demos/yerk/main.html +++ b/demos/yerk/main.html @@ -1,10 +1,10 @@