mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Compare commits
26 Commits
ionic-modu
...
v3.4.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b5b6b5e5 | ||
|
|
5094feec89 | ||
|
|
1ca7df75ed | ||
|
|
877d8211d5 | ||
|
|
a8731dfc98 | ||
|
|
7803998542 | ||
|
|
8bd2f24d06 | ||
|
|
63f728f517 | ||
|
|
61935602a1 | ||
|
|
1a4aacf8be | ||
|
|
5a5da39a1e | ||
|
|
c7645ee59d | ||
|
|
2743c63537 | ||
|
|
7a1342caa1 | ||
|
|
3564bcfe1b | ||
|
|
f149c5ee95 | ||
|
|
2791c40c29 | ||
|
|
54ac2e393f | ||
|
|
dc958c3e2c | ||
|
|
9f86e10f46 | ||
|
|
8041eedf22 | ||
|
|
ef85ba6c1f | ||
|
|
6dee17b89b | ||
|
|
c10f72b1e2 | ||
|
|
47e3c70bf3 | ||
|
|
a91a68e198 |
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -19,7 +19,7 @@
|
||||
|
||||
For Ionic V1 issues - http://plnkr.co/edit/Xo1QyAUx35ny1Xf9ODHx?p=preview
|
||||
|
||||
For Ionic issues - http://plnkr.co/edit/z0DzVL?p=preview
|
||||
For Ionic issues - http://plnkr.co/edit/cpeRJs?p=preview
|
||||
-->
|
||||
|
||||
**Related code:**
|
||||
|
||||
88
CHANGELOG.md
88
CHANGELOG.md
@@ -1,3 +1,91 @@
|
||||
<a name="3.4.1"></a>
|
||||
## [3.4.1](https://github.com/ionic-team/ionic/compare/v3.4.0...v3.4.1) (2017-06-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **themes:** change default app-direction ([ce92be0](https://github.com/ionic-team/ionic/commit/ce92be0))
|
||||
|
||||
|
||||
|
||||
<a name="3.4.0"></a>
|
||||
# [3.4.0](https://github.com/ionic-team/ionic/compare/v3.3.0...v3.4.0) (2017-06-15)
|
||||
|
||||
### Steps to Upgrade
|
||||
|
||||
`ionic-angular` should be set to version `3.4.0` in the package.json dependency list. The latest `@angular` release `4.1.3` is also supported. Feel free to update apps by updating the `package.json` dependencies to match below.
|
||||
|
||||
```
|
||||
"dependencies": {
|
||||
"@angular/common": "4.1.3",
|
||||
"@angular/compiler": "4.1.3",
|
||||
"@angular/compiler-cli": "4.1.3",
|
||||
"@angular/core": "4.1.3",
|
||||
"@angular/forms": "4.1.3",
|
||||
"@angular/http": "4.1.3",
|
||||
"@angular/platform-browser": "4.1.3",
|
||||
"@angular/platform-browser-dynamic": "4.1.3",
|
||||
"@ionic-native/core": "3.12.1",
|
||||
"@ionic-native/splash-screen": "3.12.1",
|
||||
"@ionic-native/status-bar": "3.12.1",
|
||||
"@ionic/storage": "2.0.1",
|
||||
"ionic-angular": "3.4.1",
|
||||
"ionicons": "3.0.0",
|
||||
"rxjs": "5.4.0",
|
||||
"sw-toolbox": "3.6.0",
|
||||
"zone.js": "0.8.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ionic/app-scripts": "1.3.7",
|
||||
"typescript": "2.3.4"
|
||||
}
|
||||
```
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **button:** rtl fix for md ripple effect ([#11842](https://github.com/ionic-team/ionic/issues/11842)) ([bb966e5](https://github.com/ionic-team/ionic/commit/bb966e5))
|
||||
* **content:** scroll content should inherit background ([#11467](https://github.com/ionic-team/ionic/issues/11467)) ([6256b0f](https://github.com/ionic-team/ionic/commit/6256b0f))
|
||||
* **datetime:** set datetime direction the same on ltr and rtl ([#11992](https://github.com/ionic-team/ionic/issues/11992)) ([20c9dd7](https://github.com/ionic-team/ionic/commit/20c9dd7))
|
||||
* **gesture:** RTL fix for slide-gesture ([#11822](https://github.com/ionic-team/ionic/issues/11822)) ([59a1e3d](https://github.com/ionic-team/ionic/commit/59a1e3d))
|
||||
* **input:** add correct translate3d for rtl ([ef85ba6](https://github.com/ionic-team/ionic/commit/ef85ba6)), closes [#11745](https://github.com/ionic-team/ionic/issues/11745) [#11211](https://github.com/ionic-team/ionic/issues/11211)
|
||||
* **input:** better handling of attributes ([9f86e10](https://github.com/ionic-team/ionic/commit/9f86e10))
|
||||
* **input:** slightly longer delay for autofocus ([#12037](https://github.com/ionic-team/ionic/issues/12037)) ([54ac2e3](https://github.com/ionic-team/ionic/commit/54ac2e3))
|
||||
* **input:** use all supported attributes on both textareas and inputs ([#12028](https://github.com/ionic-team/ionic/issues/12028)) ([8041eed](https://github.com/ionic-team/ionic/commit/8041eed))
|
||||
* **item-sliding:** RTL fix for item sliding ([#11825](https://github.com/ionic-team/ionic/issues/11825)) ([10f4df4](https://github.com/ionic-team/ionic/commit/10f4df4))
|
||||
* **keyboard:** big keyboard/input refactor ([c10f72b](https://github.com/ionic-team/ionic/commit/c10f72b)), closes [#9699](https://github.com/ionic-team/ionic/issues/9699) [#11484](https://github.com/ionic-team/ionic/issues/11484) [#11389](https://github.com/ionic-team/ionic/issues/11389) [#11325](https://github.com/ionic-team/ionic/issues/11325) [#11291](https://github.com/ionic-team/ionic/issues/11291) [#10828](https://github.com/ionic-team/ionic/issues/10828) [#11291](https://github.com/ionic-team/ionic/issues/11291) [#10393](https://github.com/ionic-team/ionic/issues/10393) [#10257](https://github.com/ionic-team/ionic/issues/10257) [#9434](https://github.com/ionic-team/ionic/issues/9434) [#8933](https://github.com/ionic-team/ionic/issues/8933) [#7178](https://github.com/ionic-team/ionic/issues/7178) [#7047](https://github.com/ionic-team/ionic/issues/7047) [#10552](https://github.com/ionic-team/ionic/issues/10552) [#10393](https://github.com/ionic-team/ionic/issues/10393) [#10183](https://github.com/ionic-team/ionic/issues/10183) [#10187](https://github.com/ionic-team/ionic/issues/10187) [#10852](https://github.com/ionic-team/ionic/issues/10852) [#11578](https://github.com/ionic-team/ionic/issues/11578)
|
||||
* **menu:** rtl gesture for menu ([#11830](https://github.com/ionic-team/ionic/issues/11830)) ([30047f0](https://github.com/ionic-team/ionic/commit/30047f0))
|
||||
* **refresher:** border should only show when pulled ([#12015](https://github.com/ionic-team/ionic/issues/12015)) ([47e3c70](https://github.com/ionic-team/ionic/commit/47e3c70)), closes [#10994](https://github.com/ionic-team/ionic/issues/10994)
|
||||
* **rtl:** add icon-start and icon-end attributes ([#11737](https://github.com/ionic-team/ionic/issues/11737)) ([a40b872](https://github.com/ionic-team/ionic/commit/a40b872))
|
||||
* **sass:** add default flag to variables ([#11779](https://github.com/ionic-team/ionic/issues/11779)) ([f14d7d6](https://github.com/ionic-team/ionic/commit/f14d7d6))
|
||||
* **searchbar:** caret moving to the end when typing ([261bc4d](https://github.com/ionic-team/ionic/commit/261bc4d))
|
||||
* **segment:** fix border-radius logic for RTL ([#11981](https://github.com/ionic-team/ionic/issues/11981)) ([6db8c14](https://github.com/ionic-team/ionic/commit/6db8c14))
|
||||
* **select:** add cssClass for popover interface ([#11769](https://github.com/ionic-team/ionic/issues/11769)) ([1c25acb](https://github.com/ionic-team/ionic/commit/1c25acb))
|
||||
* **select:** return undefined when there are no options ([#11968](https://github.com/ionic-team/ionic/issues/11968)) ([dc6c586](https://github.com/ionic-team/ionic/commit/dc6c586)), closes [#10435](https://github.com/ionic-team/ionic/issues/10435)
|
||||
* **split-pane:** correct split-pane menu side order ([30dc247](https://github.com/ionic-team/ionic/commit/30dc247))
|
||||
* **textarea:** apply classes properly ([dc958c3](https://github.com/ionic-team/ionic/commit/dc958c3))
|
||||
* **toggle:** RTL fix for toggle ([2afb936](https://github.com/ionic-team/ionic/commit/2afb936))
|
||||
* **toolbar:** get the correct contrast color for md mode ([0f4ed1c](https://github.com/ionic-team/ionic/commit/0f4ed1c)), closes [#11848](https://github.com/ionic-team/ionic/issues/11848)
|
||||
* **toolbar:** use the correct contrast color for MD toolbar ([041689b](https://github.com/ionic-team/ionic/commit/041689b)), closes [#11848](https://github.com/ionic-team/ionic/issues/11848)
|
||||
* **transition:** RTL fix for transition on ios ([#11820](https://github.com/ionic-team/ionic/issues/11820)) ([6322134](https://github.com/ionic-team/ionic/commit/6322134))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **background-position:** add background position support for rtl ([#11946](https://github.com/ionic-team/ionic/issues/11946)) ([305c306](https://github.com/ionic-team/ionic/commit/305c306))
|
||||
* **loading:** add enableBackdropDismiss to Loading ([#11937](https://github.com/ionic-team/ionic/issues/11937)) ([d0ae810](https://github.com/ionic-team/ionic/commit/d0ae810)), closes [#7975](https://github.com/ionic-team/ionic/issues/7975)
|
||||
* **loading:** add margin start variable ([#11980](https://github.com/ionic-team/ionic/issues/11980)) ([3e0d43e](https://github.com/ionic-team/ionic/commit/3e0d43e))
|
||||
* **rtl:** add transform and transform-origin support for rtl ([#11649](https://github.com/ionic-team/ionic/issues/11649)) ([2273fb5](https://github.com/ionic-team/ionic/commit/2273fb5))
|
||||
* **rtl:** optimize the new mixins for smaller bundle, ltr separation ([#11635](https://github.com/ionic-team/ionic/issues/11635)) ([f0c6948](https://github.com/ionic-team/ionic/commit/f0c6948))
|
||||
* **rtl:** support flipped svg background images on rtl ([#11945](https://github.com/ionic-team/ionic/issues/11945)) ([f4452b5](https://github.com/ionic-team/ionic/commit/f4452b5))
|
||||
* **slides:** support centering slides and using decimal numbers ([e3c60c5](https://github.com/ionic-team/ionic/commit/e3c60c5)), closes [#10361](https://github.com/ionic-team/ionic/issues/10361)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **item-sliding:** remove duplicate class ([#11829](https://github.com/ionic-team/ionic/issues/11829)) ([c9cb9ae](https://github.com/ionic-team/ionic/commit/c9cb9ae))
|
||||
|
||||
|
||||
|
||||
<a name="3.3.0"></a>
|
||||
# [3.3.0](https://github.com/ionic-team/ionic/compare/v3.2.1...v3.3.0) (2017-05-24)
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Hair Color</ion-label>
|
||||
<ion-select [(ngModel)]="hairColor" okText="Okay" cancelText="Dismiss" [compareWith]="compareFn">
|
||||
<ion-option *ngFor="let o of hairColorData" [value]="o">{{o.text}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Gaming</ion-label>
|
||||
<ion-select [(ngModel)]="gaming" okText="Okay" cancelText="Dismiss">
|
||||
@@ -147,6 +154,13 @@
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Skittles</ion-label>
|
||||
<ion-select [(ngModel)]="skittles" multiple="true" okText="Okay" cancelText="Dismiss" [compareWith]="compareFn">
|
||||
<ion-option *ngFor="let o of skittlesData" [value]="o">{{o.text}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Disabled</ion-label>
|
||||
<ion-select multiple disabled="true">
|
||||
|
||||
@@ -10,6 +10,10 @@ export class PageOne {
|
||||
petAlertOpts: any;
|
||||
petData: any;
|
||||
pets: Array<string>;
|
||||
hairColorData: any;
|
||||
hairColor: any;
|
||||
skittlesData: any;
|
||||
skittles: Array<any>;
|
||||
notifications: string = 'mute_1';
|
||||
rating: number = 2;
|
||||
|
||||
@@ -31,9 +35,37 @@ export class PageOne {
|
||||
{ text: 'Honey Badger', value: 'honeybadger' },
|
||||
];
|
||||
|
||||
this.hairColorData = [
|
||||
{ text: 'Brown', value: 'brown' },
|
||||
{ text: 'Blonde', value: 'blonde' },
|
||||
{ text: 'Black', value: 'black' },
|
||||
{ text: 'Red', value: 'red' }
|
||||
];
|
||||
|
||||
// Pre-selected object with different object reference
|
||||
this.hairColor = { text: 'Brown', value: 'brown' };
|
||||
|
||||
this.skittlesData = [
|
||||
{ text: 'Red', value: 'red' },
|
||||
{ text: 'Orange', value: 'orange' },
|
||||
{ text: 'Yellow', value: 'yellow' },
|
||||
{ text: 'Green', value: 'green' },
|
||||
{ text: 'Purple', value: 'purple' }
|
||||
];
|
||||
|
||||
// Pre-selected object with different object reference
|
||||
this.skittles = [
|
||||
{ text: 'Red', value: 'red' },
|
||||
{ text: 'Purple', value: 'purple' }
|
||||
];
|
||||
|
||||
this.pets = ['cat', 'dog'];
|
||||
}
|
||||
|
||||
compareFn(option1: any, option2: any) {
|
||||
return option1.value === option2.value;
|
||||
}
|
||||
|
||||
monthChange(val: any) {
|
||||
console.log('Month Change:', val);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "ionic2",
|
||||
"version": "3.3.0",
|
||||
"version": "3.4.1",
|
||||
"description": "A powerful framework for building mobile and progressive web apps with JavaScript and Angular",
|
||||
"keywords": [
|
||||
"ionic",
|
||||
@@ -146,4 +146,4 @@
|
||||
"pre-push#master": [
|
||||
"test"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -11,14 +11,14 @@ task('demos.watch', ['demos.prepare'], (done: Function) => {
|
||||
done(new Error(`Usage: gulp e2e.watch --folder modal`));
|
||||
}
|
||||
|
||||
serveDemo(folderInfo.componentName).then(() => {
|
||||
serveDemo(folderInfo.componentName, folderInfo.devApp).then(() => {
|
||||
done();
|
||||
}).catch((err: Error) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
function serveDemo(folderName: any) {
|
||||
function serveDemo(folderName: any, devApp: boolean) {
|
||||
|
||||
const ionicAngularDir = join(PROJECT_ROOT, 'src');
|
||||
const srcTestRoot = join(DEMOS_ROOT, 'src', folderName);
|
||||
@@ -40,5 +40,5 @@ function serveDemo(folderName: any) {
|
||||
const appNgModulePath = join(srcTestRoot, 'app', 'app.module.ts');
|
||||
const distDir = join(distDemoRoot, 'www');
|
||||
|
||||
return runAppScriptsServe(folderName, appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, watchConfigPath);
|
||||
return runAppScriptsServe(folderName, appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, watchConfigPath, devApp);
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ task('e2e.watch', ['e2e.prepare'], (done: Function) => {
|
||||
return;
|
||||
}
|
||||
|
||||
serveTest(folderInfo).then(() => {
|
||||
serveTest(folderInfo, folderInfo.devApp).then(() => {
|
||||
done();
|
||||
}).catch((err: Error) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
function serveTest(folderInfo: any) {
|
||||
function serveTest(folderInfo: any, devApp: boolean) {
|
||||
|
||||
const ionicAngularDir = join(PROJECT_ROOT, 'src');
|
||||
const srcTestRoot = join(PROJECT_ROOT, 'src', 'components', folderInfo.componentName, 'test', folderInfo.componentTest);
|
||||
@@ -47,5 +47,5 @@ function serveTest(folderInfo: any) {
|
||||
const appNgModulePath = join(dirname(appEntryPoint), 'app.module.ts');
|
||||
const distDir = join(distTestRoot, 'www');
|
||||
|
||||
return runAppScriptsServe(join(folderInfo.componentName, folderInfo.componentTest), appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, null);
|
||||
return runAppScriptsServe(join(folderInfo.componentName, folderInfo.componentTest), appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, null, devApp);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ export function runWebpack(pathToWebpackConfig: string, done: Function) {
|
||||
});
|
||||
}
|
||||
|
||||
export function runAppScriptsServe(testOrDemoName: string, appEntryPoint: string, appNgModulePath: string, srcDir: string, distDir: string, tsConfig: string, ionicAngularDir: string, sassConfigPath: string, copyConfigPath: string, watchConfigPath: string) {
|
||||
export function runAppScriptsServe(testOrDemoName: string, appEntryPoint: string, appNgModulePath: string, srcDir: string, distDir: string, tsConfig: string, ionicAngularDir: string, sassConfigPath: string, copyConfigPath: string, watchConfigPath: string, devApp: boolean) {
|
||||
console.log('Running ionic-app-scripts serve with', testOrDemoName);
|
||||
const deepLinksDir = dirname(dirname(appNgModulePath));
|
||||
let scriptArgs = [
|
||||
@@ -207,6 +207,9 @@ export function runAppScriptsServe(testOrDemoName: string, appEntryPoint: string
|
||||
'--copy', copyConfigPath,
|
||||
'--enableLint', 'false'
|
||||
];
|
||||
if (devApp) {
|
||||
scriptArgs.push('--bonjour');
|
||||
}
|
||||
|
||||
if (watchConfigPath) {
|
||||
scriptArgs.push('--watch');
|
||||
@@ -349,9 +352,11 @@ export function getFolderInfo() {
|
||||
componentName = folderSplit[0];
|
||||
componentTest = (folderSplit.length > 1 ? folderSplit[1] : 'basic');
|
||||
}
|
||||
const devApp = argv.devapp !== undefined;
|
||||
return {
|
||||
componentName: componentName,
|
||||
componentTest: componentTest
|
||||
componentTest: componentTest,
|
||||
devApp: devApp
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -117,8 +117,6 @@ export class ActionSheetCmp {
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
this._plt.focusOutActiveElement();
|
||||
|
||||
const focusableEle = this._elementRef.nativeElement.querySelector('button');
|
||||
if (focusableEle) {
|
||||
focusableEle.focus();
|
||||
|
||||
@@ -84,6 +84,7 @@ export class AlertCmp {
|
||||
msgId: string;
|
||||
subHdrId: string;
|
||||
mode: string;
|
||||
keyboardResizes: boolean;
|
||||
gestureBlocker: BlockerDelegate;
|
||||
|
||||
constructor(
|
||||
@@ -99,6 +100,7 @@ export class AlertCmp {
|
||||
this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
|
||||
this.d = params.data;
|
||||
this.mode = this.d.mode || config.get('mode');
|
||||
this.keyboardResizes = config.getBoolean('keyboardResizes', false);
|
||||
_renderer.setElementClass(_elementRef.nativeElement, `alert-${this.mode}`, true);
|
||||
|
||||
if (this.d.cssClass) {
|
||||
@@ -178,7 +180,7 @@ export class AlertCmp {
|
||||
}
|
||||
|
||||
const hasTextInput = (this.d.inputs.length && this.d.inputs.some(i => !(NON_TEXT_INPUT_REGEX.test(i.type))));
|
||||
if (hasTextInput && this._plt.is('mobile')) {
|
||||
if (!this.keyboardResizes && hasTextInput && this._plt.is('mobile')) {
|
||||
// this alert has a text input and it's on a mobile device so we should align
|
||||
// the alert up high because we need to leave space for the virtual keboard
|
||||
// this also helps prevent the layout getting all messed up from
|
||||
@@ -192,18 +194,10 @@ export class AlertCmp {
|
||||
}
|
||||
|
||||
ionViewDidLeave() {
|
||||
this._plt.focusOutActiveElement();
|
||||
this.gestureBlocker.unblock();
|
||||
}
|
||||
|
||||
ionViewWillLeave() {
|
||||
this._plt.focusOutActiveElement();
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
// focus out of the active element
|
||||
this._plt.focusOutActiveElement();
|
||||
|
||||
// set focus on the first input or button in the alert
|
||||
// note that this does not always work and bring up the keyboard on
|
||||
// devices since the focus command must come from the user's touch event
|
||||
|
||||
@@ -30,6 +30,7 @@ export class App {
|
||||
private _titleSrv: Title = new Title(DOCUMENT);
|
||||
private _rootNav: NavController = null;
|
||||
private _disableScrollAssist: boolean;
|
||||
private _didScroll = false;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
@@ -87,6 +88,11 @@ export class App {
|
||||
_plt.registerBackButtonAction(this.goBack.bind(this));
|
||||
this._disableScrollAssist = _config.getBoolean('disableScrollAssist', false);
|
||||
|
||||
const blurring = _config.getBoolean('inputBlurring', false);
|
||||
if (blurring) {
|
||||
this._enableInputBlurring();
|
||||
}
|
||||
|
||||
runInDev(() => {
|
||||
// During developement, navPop can be triggered by calling
|
||||
const win = <any>_plt.win();
|
||||
@@ -179,6 +185,7 @@ export class App {
|
||||
*/
|
||||
setScrolling() {
|
||||
this._scrollTime = Date.now() + ACTIVE_SCROLLING_TIME;
|
||||
this._didScroll = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +241,6 @@ export class App {
|
||||
// TODO: move _setNav() to the earlier stages of NavController. _queueTrns()
|
||||
enteringView._setNav(portal);
|
||||
|
||||
opts.keyboardClose = false;
|
||||
opts.direction = DIRECTION_FORWARD;
|
||||
|
||||
if (!opts.animation) {
|
||||
@@ -242,7 +248,7 @@ export class App {
|
||||
}
|
||||
|
||||
enteringView.setLeavingOpts({
|
||||
keyboardClose: false,
|
||||
keyboardClose: opts.keyboardClose,
|
||||
direction: DIRECTION_BACK,
|
||||
animation: enteringView.getTransitionName(DIRECTION_BACK),
|
||||
ev: opts.ev
|
||||
@@ -289,6 +295,60 @@ export class App {
|
||||
return recursivePop(this.getActiveNav());
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
_enableInputBlurring() {
|
||||
console.debug('App: _enableInputBlurring');
|
||||
let focused = true;
|
||||
const self = this;
|
||||
const platform = this._plt;
|
||||
|
||||
platform.registerListener(platform.doc(), 'focusin', onFocusin, { capture: true, zone: false, passive: true });
|
||||
platform.registerListener(platform.doc(), 'touchend', onTouchend, { capture: false, zone: false, passive: true });
|
||||
|
||||
function onFocusin(ev: any) {
|
||||
focused = true;
|
||||
}
|
||||
function onTouchend(ev: any) {
|
||||
// if app did scroll return early
|
||||
if (self._didScroll) {
|
||||
self._didScroll = false;
|
||||
return;
|
||||
}
|
||||
const active = <HTMLElement> self._plt.getActiveElement();
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
// only blur if the active element is a text-input or a textarea
|
||||
if (SKIP_BLURRING.indexOf(active.tagName) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if the selected target is the active element, do not blur
|
||||
const tapped = ev.target;
|
||||
if (tapped === active) {
|
||||
return;
|
||||
}
|
||||
if (SKIP_BLURRING.indexOf(tapped.tagName) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// skip if div is a cover
|
||||
if (tapped.classList.contains('input-cover')) {
|
||||
return;
|
||||
}
|
||||
|
||||
focused = false;
|
||||
// TODO: find a better way, why 50ms?
|
||||
platform.timeout(() => {
|
||||
if (!focused) {
|
||||
active.blur();
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function recursivePop(nav: any): Promise<any> {
|
||||
@@ -322,5 +382,6 @@ function findTopNav(nav: NavController) {
|
||||
return nav;
|
||||
}
|
||||
|
||||
const SKIP_BLURRING = ['INPUT', 'TEXTAREA', 'ION-INPUT', 'ION-TEXTAREA'];
|
||||
const ACTIVE_SCROLLING_TIME = 100;
|
||||
const CLICK_BLOCK_BUFFER_IN_MILLIS = 64;
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Config } from '../../config/config';
|
||||
import { DeepLinker } from '../../navigation/deep-linker';
|
||||
import { DomController } from '../../platform/dom-controller';
|
||||
import { GestureController } from '../../gestures/gesture-controller';
|
||||
import { Keyboard } from '../../platform/keyboard';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
import { Platform } from '../../platform/platform';
|
||||
import { TransitionController } from '../../transitions/transition-controller';
|
||||
@@ -22,7 +21,6 @@ export class OverlayPortal extends NavControllerBase {
|
||||
@Inject(forwardRef(() => App)) app: App,
|
||||
config: Config,
|
||||
plt: Platform,
|
||||
keyboard: Keyboard,
|
||||
elementRef: ElementRef,
|
||||
zone: NgZone,
|
||||
renderer: Renderer,
|
||||
@@ -34,7 +32,7 @@ export class OverlayPortal extends NavControllerBase {
|
||||
domCtrl: DomController,
|
||||
errHandler: ErrorHandler
|
||||
) {
|
||||
super(null, app, config, plt, keyboard, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler);
|
||||
super(null, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler);
|
||||
this._isPortal = true;
|
||||
this._init = true;
|
||||
this.setViewport(viewPort);
|
||||
|
||||
@@ -492,7 +492,7 @@ $button-md-strong-font-weight: bold !default;
|
||||
}
|
||||
}
|
||||
|
||||
.md .button-effect {
|
||||
.md button .button-effect {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,13 +118,6 @@ export class Checkbox extends BaseInput<boolean> implements IonicTapInput, OnDes
|
||||
super(config, elementRef, renderer, 'checkbox', false, form, item, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
initFocus() {
|
||||
this._elementRef.nativeElement.querySelector('button').focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@@ -145,8 +138,8 @@ export class Checkbox extends BaseInput<boolean> implements IonicTapInput, OnDes
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
_inputCheckHasValue(val: boolean) {
|
||||
this._item && this._item.setElementClass('item-checkbox-checked', val);
|
||||
_inputUpdated() {
|
||||
this._item && this._item.setElementClass('item-checkbox-checked', this._value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,7 +167,8 @@ export class EventEmitterProxy<T> extends EventEmitter<T> {
|
||||
'</div>' +
|
||||
'<ng-content select="ion-refresher"></ng-content>',
|
||||
host: {
|
||||
'[class.statusbar-padding]': 'statusbarPadding'
|
||||
'[class.statusbar-padding]': 'statusbarPadding',
|
||||
'[class.has-refresher]': '_hasRefresher'
|
||||
},
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
@@ -212,6 +213,8 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
|
||||
/** @internal */
|
||||
_fullscreen: boolean;
|
||||
/** @internal */
|
||||
_hasRefresher: boolean = false;
|
||||
/** @internal */
|
||||
_footerEle: HTMLElement;
|
||||
/** @internal */
|
||||
_dirty: boolean;
|
||||
@@ -782,6 +785,11 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
|
||||
this._cBottom += this._tabbarHeight;
|
||||
}
|
||||
|
||||
// Refresher uses a border which should be hidden unless pulled
|
||||
if (this._hasRefresher) {
|
||||
this._cTop -= 1;
|
||||
}
|
||||
|
||||
// Fixed content shouldn't include content padding
|
||||
this._fTop = this._cTop;
|
||||
this._fBottom = this._cBottom;
|
||||
|
||||
@@ -448,6 +448,7 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni
|
||||
* @hidden
|
||||
*/
|
||||
_inputUpdated() {
|
||||
super._inputUpdated();
|
||||
this.updateText();
|
||||
}
|
||||
|
||||
@@ -475,10 +476,6 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni
|
||||
|
||||
@HostListener('click', ['$event'])
|
||||
_click(ev: UIEvent) {
|
||||
// do not continue if the click event came from a form submit
|
||||
if (ev.detail === 0) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.open();
|
||||
|
||||
@@ -93,6 +93,8 @@ input.text-input:-webkit-autofill {
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.input[disabled] .input-cover {
|
||||
@@ -127,27 +129,6 @@ input.text-input:-webkit-autofill {
|
||||
}
|
||||
|
||||
|
||||
// Scroll Assist Input
|
||||
// --------------------------------------------------
|
||||
// This input is used to help the app handle
|
||||
// Next and Previous input tabbing
|
||||
|
||||
[next-input] {
|
||||
@include padding(0);
|
||||
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
|
||||
border: 0;
|
||||
background: transparent;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
// Clear Input Icon
|
||||
// --------------------------------------------------
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,242 +0,0 @@
|
||||
import { Directive, ElementRef, EventEmitter, HostListener, Output, Renderer } from '@angular/core';
|
||||
import { NgControl } from '@angular/forms';
|
||||
|
||||
import { Config } from '../../config/config';
|
||||
import { Platform } from '../../platform/platform';
|
||||
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@Directive({
|
||||
selector: '.text-input'
|
||||
})
|
||||
export class NativeInput {
|
||||
_relocated: boolean;
|
||||
_clone: boolean;
|
||||
_blurring: boolean;
|
||||
_unrefBlur: Function;
|
||||
|
||||
@Output() focusChange: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
@Output() valueChange: EventEmitter<string> = new EventEmitter<string>();
|
||||
@Output() keydown: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
||||
constructor(
|
||||
public _elementRef: ElementRef,
|
||||
public _renderer: Renderer,
|
||||
config: Config,
|
||||
private _plt: Platform,
|
||||
public ngControl: NgControl
|
||||
) {
|
||||
this._clone = config.getBoolean('inputCloning', false);
|
||||
this._blurring = config.getBoolean('inputBlurring', false);
|
||||
}
|
||||
|
||||
@HostListener('input', ['$event'])
|
||||
_change(ev: any) {
|
||||
this.valueChange.emit(ev.target.value);
|
||||
}
|
||||
|
||||
@HostListener('keydown', ['$event'])
|
||||
_keyDown(ev: any) {
|
||||
if (ev) {
|
||||
ev.target && this.keydown.emit(ev.target.value);
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('focus')
|
||||
_focus() {
|
||||
var self = this;
|
||||
|
||||
self.focusChange.emit(true);
|
||||
|
||||
if (self._blurring) {
|
||||
// automatically blur input if:
|
||||
// 1) this input has focus
|
||||
// 2) the newly tapped document element is not an input
|
||||
console.debug(`native-input, blurring enabled`);
|
||||
|
||||
var unregTouchEnd = this._plt.registerListener(this._plt.doc(), 'touchend', (ev: TouchEvent) => {
|
||||
var tapped = <HTMLElement>ev.target;
|
||||
if (tapped && self.element()) {
|
||||
if (tapped.tagName !== 'INPUT' && tapped.tagName !== 'TEXTAREA' && !tapped.classList.contains('input-cover')) {
|
||||
self.element().blur();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
capture: true,
|
||||
zone: false
|
||||
});
|
||||
|
||||
self._unrefBlur = function() {
|
||||
console.debug(`native-input, blurring disabled`);
|
||||
unregTouchEnd();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('blur')
|
||||
_blur() {
|
||||
this.focusChange.emit(false);
|
||||
this.hideFocus(false);
|
||||
|
||||
this._unrefBlur && this._unrefBlur();
|
||||
this._unrefBlur = null;
|
||||
}
|
||||
|
||||
labelledBy(val: string) {
|
||||
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-labelledby', val);
|
||||
}
|
||||
|
||||
isDisabled(val: boolean) {
|
||||
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'disabled', val ? '' : null);
|
||||
}
|
||||
|
||||
setFocus() {
|
||||
// let's set focus to the element
|
||||
// but only if it does not already have focus
|
||||
if (this._plt.getActiveElement() !== this.element()) {
|
||||
this.element().focus();
|
||||
}
|
||||
}
|
||||
|
||||
beginFocus(shouldFocus: boolean, inputRelativeY: number) {
|
||||
if (this._relocated !== shouldFocus) {
|
||||
const focusedInputEle = this.element();
|
||||
if (shouldFocus) {
|
||||
// we should focus into this element
|
||||
|
||||
if (this._clone) {
|
||||
// this platform needs the input to be cloned
|
||||
// this allows for the actual input to receive the focus from
|
||||
// the user's touch event, but before it receives focus, it
|
||||
// moves the actual input to a location that will not screw
|
||||
// up the app's layout, and does not allow the native browser
|
||||
// to attempt to scroll the input into place (messing up headers/footers)
|
||||
// the cloned input fills the area of where native input should be
|
||||
// while the native input fakes out the browser by relocating itself
|
||||
// before it receives the actual focus event
|
||||
cloneInputComponent(this._plt, focusedInputEle);
|
||||
|
||||
// move the native input to a location safe to receive focus
|
||||
// according to the browser, the native input receives focus in an
|
||||
// area which doesn't require the browser to scroll the input into place
|
||||
(<any>focusedInputEle.style)[this._plt.Css.transform] = `translate3d(-9999px,${inputRelativeY}px,0)`;
|
||||
focusedInputEle.style.opacity = '0';
|
||||
}
|
||||
|
||||
// let's now set focus to the actual native element
|
||||
// at this point it is safe to assume the browser will not attempt
|
||||
// to scroll the input into view itself (screwing up headers/footers)
|
||||
this.setFocus();
|
||||
|
||||
} else {
|
||||
// should remove the focus
|
||||
if (this._clone) {
|
||||
// should remove the cloned node
|
||||
removeClone(this._plt, focusedInputEle);
|
||||
}
|
||||
}
|
||||
|
||||
this._relocated = shouldFocus;
|
||||
}
|
||||
}
|
||||
|
||||
hideFocus(shouldHideFocus: boolean) {
|
||||
let focusedInputEle = this.element();
|
||||
|
||||
console.debug(`native-input, hideFocus, shouldHideFocus: ${shouldHideFocus}, input value: ${focusedInputEle.value}`);
|
||||
|
||||
if (shouldHideFocus) {
|
||||
cloneInputComponent(this._plt, focusedInputEle);
|
||||
(<any>focusedInputEle.style)[this._plt.Css.transform] = 'scale(0)';
|
||||
|
||||
} else {
|
||||
removeClone(this._plt, focusedInputEle);
|
||||
}
|
||||
}
|
||||
|
||||
setValue(val: any) {
|
||||
this._elementRef.nativeElement['value'] = val;
|
||||
}
|
||||
|
||||
getValue(): string {
|
||||
return this.element().value;
|
||||
}
|
||||
|
||||
setMin(val: any) {
|
||||
this._elementRef.nativeElement['min'] = val;
|
||||
}
|
||||
|
||||
setMax(val: any) {
|
||||
this._elementRef.nativeElement['max'] = val;
|
||||
}
|
||||
|
||||
setStep(val: any) {
|
||||
this._elementRef.nativeElement['step'] = val;
|
||||
}
|
||||
|
||||
setElementClass(cssClass: string, shouldAdd: boolean) {
|
||||
this._renderer.setElementClass(this._elementRef.nativeElement, cssClass, shouldAdd);
|
||||
}
|
||||
|
||||
element(): HTMLInputElement {
|
||||
return this._elementRef.nativeElement;
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this._unrefBlur && this._unrefBlur();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cloneInputComponent(plt: Platform, srcNativeInputEle: HTMLInputElement) {
|
||||
// given a native <input> or <textarea> element
|
||||
// find its parent wrapping component like <ion-input> or <ion-textarea>
|
||||
// then clone the entire component
|
||||
const srcComponentEle = <HTMLElement>srcNativeInputEle.closest('ion-input,ion-textarea');
|
||||
if (srcComponentEle) {
|
||||
// DOM READ
|
||||
const srcTop = srcComponentEle.offsetTop;
|
||||
const srcLeft = srcComponentEle.offsetLeft;
|
||||
const srcWidth = srcComponentEle.offsetWidth;
|
||||
const srcHeight = srcComponentEle.offsetHeight;
|
||||
|
||||
// DOM WRITE
|
||||
// not using deep clone so we don't pull in unnecessary nodes
|
||||
const clonedComponentEle = <HTMLElement>srcComponentEle.cloneNode(false);
|
||||
clonedComponentEle.classList.add('cloned-input');
|
||||
clonedComponentEle.setAttribute('aria-hidden', 'true');
|
||||
clonedComponentEle.style.pointerEvents = 'none';
|
||||
clonedComponentEle.style.position = 'absolute';
|
||||
clonedComponentEle.style.top = srcTop + 'px';
|
||||
clonedComponentEle.style.left = srcLeft + 'px';
|
||||
clonedComponentEle.style.width = srcWidth + 'px';
|
||||
clonedComponentEle.style.height = srcHeight + 'px';
|
||||
|
||||
const clonedNativeInputEle = <HTMLInputElement>srcNativeInputEle.cloneNode(false);
|
||||
clonedNativeInputEle.value = srcNativeInputEle.value;
|
||||
clonedNativeInputEle.tabIndex = -1;
|
||||
|
||||
clonedComponentEle.appendChild(clonedNativeInputEle);
|
||||
srcComponentEle.parentNode.appendChild(clonedComponentEle);
|
||||
|
||||
srcComponentEle.style.pointerEvents = 'none';
|
||||
}
|
||||
|
||||
(<any>srcNativeInputEle.style)[plt.Css.transform] = 'scale(0)';
|
||||
}
|
||||
|
||||
function removeClone(plt: Platform, srcNativeInputEle: HTMLElement) {
|
||||
const srcComponentEle = <HTMLElement>srcNativeInputEle.closest('ion-input,ion-textarea');
|
||||
if (srcComponentEle && srcComponentEle.parentElement) {
|
||||
const clonedInputEles = srcComponentEle.parentElement.querySelectorAll('.cloned-input');
|
||||
for (var i = 0; i < clonedInputEles.length; i++) {
|
||||
clonedInputEles[i].parentNode.removeChild(clonedInputEles[i]);
|
||||
}
|
||||
|
||||
srcComponentEle.style.pointerEvents = '';
|
||||
}
|
||||
(<any>srcNativeInputEle.style)[plt.Css.transform] = '';
|
||||
srcNativeInputEle.style.opacity = '';
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { Directive, EventEmitter, HostListener, Output } from '@angular/core';
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[next-input]'
|
||||
})
|
||||
export class NextInput {
|
||||
@Output() focused: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||
|
||||
@HostListener('focus')
|
||||
receivedFocus() {
|
||||
console.debug('native-input, next-input received focus');
|
||||
this.focused.emit(true);
|
||||
}
|
||||
|
||||
}
|
||||
10
src/components/input/test/attributes/app/app.component.ts
Normal file
10
src/components/input/test/attributes/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { RootPage } from '../pages/root-page/root-page';
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
})
|
||||
export class AppComponent {
|
||||
root = RootPage;
|
||||
}
|
||||
19
src/components/input/test/attributes/app/app.module.ts
Normal file
19
src/components/input/test/attributes/app/app.module.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicApp, IonicModule } from '../../../../..';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { RootPageModule } from '../pages/root-page/root-page.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(AppComponent),
|
||||
RootPageModule
|
||||
],
|
||||
bootstrap: [IonicApp]
|
||||
})
|
||||
export class AppModule {}
|
||||
5
src/components/input/test/attributes/app/main.ts
Normal file
5
src/components/input/test/attributes/app/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
0
src/components/input/test/attributes/e2e.ts
Normal file
0
src/components/input/test/attributes/e2e.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
<ion-header>
|
||||
|
||||
<ion-toolbar>
|
||||
<ion-title>Input attributes</ion-title>
|
||||
</ion-toolbar>
|
||||
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<ion-label stacked>Stacked</ion-label>
|
||||
<ion-input #input1
|
||||
type="number"
|
||||
placeholder="Placeholder"
|
||||
value="1234"
|
||||
id="mystackinput"
|
||||
name="holaa"
|
||||
min="0"
|
||||
max="10000"
|
||||
step="2"
|
||||
autocomplete="on"
|
||||
autocorrect="on"
|
||||
autocapitalize="on"
|
||||
spellcheck="true"
|
||||
maxlength="4"
|
||||
disabled
|
||||
readonly
|
||||
></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-list>
|
||||
<ion-item *ngIf="input1Valid" color="secondary">Test passed</ion-item>
|
||||
<ion-item *ngIf="!input1Valid" color="danger">Test FAILED</ion-item>
|
||||
</ion-list>
|
||||
|
||||
</ion-list>
|
||||
|
||||
</ion-content>
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { IonicPageModule } from '../../../../../..';
|
||||
|
||||
import { RootPage } from './root-page';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
RootPage,
|
||||
],
|
||||
imports: [
|
||||
IonicPageModule.forChild(RootPage)
|
||||
]
|
||||
})
|
||||
export class RootPageModule {}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { TextInput } from '../../../../../../';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'root-page.html'
|
||||
})
|
||||
export class RootPage {
|
||||
|
||||
input1Valid: boolean;
|
||||
input2Valid: boolean;
|
||||
|
||||
@ViewChild('input1') input1: TextInput;
|
||||
|
||||
ionViewDidEnter() {
|
||||
this.input1Valid = this.checkInput1();
|
||||
}
|
||||
|
||||
checkInput1(): boolean {
|
||||
const nativeEle = <HTMLElement>this.input1._native.nativeElement;
|
||||
|
||||
return testAttributes(nativeEle, {
|
||||
id: null,
|
||||
type: 'number',
|
||||
placeholder: 'Placeholder',
|
||||
name: 'holaa',
|
||||
min: '0',
|
||||
max: '10000',
|
||||
step: '2',
|
||||
autocomplete: 'on',
|
||||
autocorrect: 'on',
|
||||
autocapitalize: 'on',
|
||||
spellcheck: 'true',
|
||||
maxLength: '4',
|
||||
'aria-labelledby': 'lbl-0',
|
||||
readOnly: true,
|
||||
disabled: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function testAttributes(ele: HTMLElement, attributes: any): boolean {
|
||||
for (let attr in attributes) {
|
||||
const expected = attributes[attr];
|
||||
const value = (<any>ele)[attr];
|
||||
|
||||
if (expected === null) {
|
||||
if (ele.hasAttribute(attr) || value !== '') {
|
||||
console.error(`Element should NOT have "${attr}"`);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (expected !== value && expected !== ele.getAttribute(attr)) {
|
||||
console.error(`Value "${attr}" does not match: ${expected} != ${value}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -102,4 +102,16 @@
|
||||
</ion-list>
|
||||
</ion-card>
|
||||
</form>
|
||||
</ion-content>
|
||||
</ion-content>
|
||||
|
||||
<ion-footer>
|
||||
<ion-toolbar>
|
||||
<ion-input style="background: white;
|
||||
margin: 3px;
|
||||
padding: 0px 8px;
|
||||
border: 1px solid gray;
|
||||
border-radius: 5px;
|
||||
width: auto;
|
||||
transform: translateZ(0);" placeholder="chat here"></ion-input>
|
||||
</ion-toolbar>
|
||||
</ion-footer>
|
||||
@@ -1,9 +1,38 @@
|
||||
import { getScrollData } from '../input';
|
||||
import { getScrollData, TextInput } from '../input';
|
||||
import { ContentDimensions } from '../../content/content';
|
||||
import { mockConfig, mockApp, mockPlatform, mockDomController, mockElementRef, mockElementRefEle, mockRenderer, mockItem, mockForm } from '../../../util/mock-providers';
|
||||
import { commonInputTest, TEXT_CORPUS } from '../../../util/input-tester';
|
||||
|
||||
|
||||
function newInput(): TextInput {
|
||||
const platform = mockPlatform();
|
||||
const config = mockConfig();
|
||||
const app = mockApp(config, platform);
|
||||
const elementRef = mockElementRef();
|
||||
const renderer = mockRenderer();
|
||||
const item: any = mockItem();
|
||||
const form = mockForm();
|
||||
const dom = mockDomController(platform);
|
||||
const input = new TextInput(config, platform, form, app, elementRef, renderer, null, item, null, dom);
|
||||
input._native = mockElementRefEle(document.createElement('input'));
|
||||
return input;
|
||||
}
|
||||
|
||||
describe('text input', () => {
|
||||
|
||||
it('should pass common test', () => {
|
||||
const textInput = newInput();
|
||||
const ele = textInput._native.nativeElement;
|
||||
textInput._item._elementRef = mockElementRefEle(document.createElement('div'));
|
||||
commonInputTest(textInput, {
|
||||
defaultValue: '',
|
||||
corpus: TEXT_CORPUS,
|
||||
onValueChange: (value) => ele.value === value,
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe('getScrollData', () => {
|
||||
|
||||
it('should scroll, top and bottom below safe area, no room to scroll', () => {
|
||||
|
||||
@@ -46,7 +46,7 @@ export class ItemReorderGesture {
|
||||
}
|
||||
this.reorderList._reorderPrepare();
|
||||
|
||||
let item = reorderMark.getReorderNode();
|
||||
const item = reorderMark.getReorderNode();
|
||||
if (!item) {
|
||||
console.error('reorder node not found');
|
||||
return false;
|
||||
@@ -71,26 +71,26 @@ export class ItemReorderGesture {
|
||||
}
|
||||
|
||||
private onDragMove(ev: any) {
|
||||
let selectedItem = this.selectedItemEle;
|
||||
const selectedItem = this.selectedItemEle;
|
||||
if (!selectedItem) {
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
|
||||
// Get coordinate
|
||||
let coord = pointerCoord(ev);
|
||||
let posY = coord.y;
|
||||
const coord = pointerCoord(ev);
|
||||
const posY = coord.y;
|
||||
|
||||
// Scroll if we reach the scroll margins
|
||||
let scrollPosition = this.scroll(posY);
|
||||
const scrollPosition = this.scroll(posY);
|
||||
|
||||
// Only perform hit test if we moved at least 30px from previous position
|
||||
if (Math.abs(posY - this.lastYcoord) > 30) {
|
||||
let overItem = this.itemForCoord(coord);
|
||||
var overItem = this.itemForCoord(coord);
|
||||
if (overItem) {
|
||||
let toIndex = indexForItem(overItem);
|
||||
var toIndex = indexForItem(overItem);
|
||||
if (toIndex !== undefined && (toIndex !== this.lastToIndex || this.emptyZone)) {
|
||||
let fromIndex = indexForItem(selectedItem);
|
||||
var fromIndex = indexForItem(selectedItem);
|
||||
this.lastToIndex = toIndex;
|
||||
this.lastYcoord = posY;
|
||||
this.emptyZone = false;
|
||||
@@ -102,12 +102,12 @@ export class ItemReorderGesture {
|
||||
}
|
||||
|
||||
// Update selected item position
|
||||
let ydiff = Math.round(posY - this.offset.y + scrollPosition);
|
||||
const ydiff = Math.round(posY - this.offset.y + scrollPosition);
|
||||
(<any>selectedItem.style)[this.plt.Css.transform] = `translateY(${ydiff}px)`;
|
||||
}
|
||||
|
||||
private onDragEnd(ev: any) {
|
||||
let selectedItem = this.selectedItemEle;
|
||||
const selectedItem = this.selectedItemEle;
|
||||
if (!selectedItem) {
|
||||
return;
|
||||
}
|
||||
@@ -116,9 +116,9 @@ export class ItemReorderGesture {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
|
||||
let toIndex = this.lastToIndex;
|
||||
let fromIndex = indexForItem(selectedItem);
|
||||
let reorderInactive = () => {
|
||||
const toIndex = this.lastToIndex;
|
||||
const fromIndex = indexForItem(selectedItem);
|
||||
const reorderInactive = () => {
|
||||
this.selectedItemEle.style.transition = '';
|
||||
this.selectedItemEle.classList.remove(ITEM_REORDER_ACTIVE);
|
||||
this.selectedItemEle = null;
|
||||
@@ -134,7 +134,7 @@ export class ItemReorderGesture {
|
||||
}
|
||||
|
||||
private itemForCoord(coord: PointerCoordinates): HTMLElement {
|
||||
const sideOffset = this.plt.isRTL ? 100 : -100;
|
||||
const sideOffset = this.reorderList._isStart === this.plt.isRTL ? -100 : 100;
|
||||
const x = this.offset.x + sideOffset;
|
||||
const y = coord.y;
|
||||
const element = this.plt.getElementFromPoint(x, y);
|
||||
@@ -167,6 +167,7 @@ const SCROLL_JUMP = 10;
|
||||
const ITEM_REORDER_ACTIVE = 'reorder-active';
|
||||
|
||||
export interface ItemReorderGestureDelegate {
|
||||
_isStart: boolean;
|
||||
getNativeElement: () => any;
|
||||
_reorderPrepare: () => void;
|
||||
_scrollContent: (scrollPosition: number) => number;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
@import "../../themes/ionic.globals";
|
||||
|
||||
$reorder-initial-transform: 160% !default;
|
||||
|
||||
// Item reorder
|
||||
// --------------------------------------------------
|
||||
|
||||
ion-reorder {
|
||||
@include transform(translate3d(160%, 0, 0));
|
||||
@include transform(translate3d($reorder-initial-transform, 0, 0));
|
||||
|
||||
display: none;
|
||||
|
||||
@@ -18,13 +20,18 @@ ion-reorder {
|
||||
font-size: 1.7em;
|
||||
opacity: .25;
|
||||
|
||||
|
||||
transition: transform 140ms ease-in;
|
||||
|
||||
pointer-events: all;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.reorder-side-start ion-reorder {
|
||||
@include transform(translate3d(-$reorder-initial-transform, 0, 0));
|
||||
|
||||
order: -1;
|
||||
}
|
||||
|
||||
ion-reorder ion-icon {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@@ -142,12 +142,14 @@ export class ReorderIndexes {
|
||||
host: {
|
||||
'[class.reorder-enabled]': '_enableReorder',
|
||||
'[class.reorder-visible]': '_visibleReorder',
|
||||
'[class.reorder-side-start]': '_isStart'
|
||||
}
|
||||
})
|
||||
export class ItemReorder implements ItemReorderGestureDelegate {
|
||||
|
||||
_enableReorder: boolean = false;
|
||||
_visibleReorder: boolean = false;
|
||||
_isStart: boolean = false;
|
||||
_reorderGesture: ItemReorderGesture;
|
||||
_lastToIndex: number = -1;
|
||||
_element: HTMLElement;
|
||||
@@ -158,6 +160,14 @@ export class ItemReorder implements ItemReorderGestureDelegate {
|
||||
*/
|
||||
@Output() ionItemReorder: EventEmitter<ReorderIndexes> = new EventEmitter<ReorderIndexes>();
|
||||
|
||||
/**
|
||||
* @input {string} Which side of the view the ion-reorder should be placed. Default `"end"`.
|
||||
*/
|
||||
@Input('side')
|
||||
set side(side: 'start' | 'end') {
|
||||
this._isStart = side === 'start';
|
||||
}
|
||||
|
||||
constructor(
|
||||
private _plt: Platform,
|
||||
private _dom: DomController,
|
||||
|
||||
@@ -344,24 +344,24 @@ export class ItemSliding {
|
||||
|
||||
if (isFinal) {
|
||||
this.item.setElementStyle(platform.Css.transition, '');
|
||||
}
|
||||
|
||||
if (openAmount > 0) {
|
||||
var state = (openAmount >= (this._optsWidthRightSide + SWIPE_MARGIN))
|
||||
? SlidingState.Right | SlidingState.SwipeRight
|
||||
: SlidingState.Right;
|
||||
|
||||
this._setState(state);
|
||||
|
||||
} else if (openAmount < 0) {
|
||||
var state = (openAmount <= (-this._optsWidthLeftSide - SWIPE_MARGIN))
|
||||
? SlidingState.Left | SlidingState.SwipeLeft
|
||||
: SlidingState.Left;
|
||||
|
||||
this._setState(state);
|
||||
|
||||
} else {
|
||||
if (openAmount > 0) {
|
||||
var state = (openAmount >= (this._optsWidthRightSide + SWIPE_MARGIN))
|
||||
? SlidingState.Right | SlidingState.SwipeRight
|
||||
: SlidingState.Right;
|
||||
|
||||
this._setState(state);
|
||||
|
||||
} else if (openAmount < 0) {
|
||||
var state = (openAmount <= (-this._optsWidthLeftSide - SWIPE_MARGIN))
|
||||
? SlidingState.Left | SlidingState.SwipeLeft
|
||||
: SlidingState.Left;
|
||||
|
||||
this._setState(state);
|
||||
}
|
||||
}
|
||||
if (openAmount === 0) {
|
||||
assert(openAmount === 0, 'bad internal state');
|
||||
this._tmr = platform.timeout(() => {
|
||||
this._setState(SlidingState.Disabled);
|
||||
this._tmr = null;
|
||||
@@ -371,7 +371,7 @@ export class ItemSliding {
|
||||
}
|
||||
|
||||
this.item.setElementStyle(platform.Css.transform, `translate3d(${-openAmount}px,0,0)`);
|
||||
let ionDrag = this.ionDrag;
|
||||
const ionDrag = this.ionDrag;
|
||||
if (ionDrag.observers.length > 0) {
|
||||
ionDrag.emit(this);
|
||||
}
|
||||
|
||||
@@ -323,6 +323,7 @@ export class Item extends Ion {
|
||||
this._setName(elementRef);
|
||||
this._hasReorder = !!reorder;
|
||||
this.id = form.nextId().toString();
|
||||
this.labelId = 'lbl-' + this.id;
|
||||
|
||||
// auto add "tappable" attribute to ion-item components that have a click listener
|
||||
if (!(<any>renderer).orgListen) {
|
||||
@@ -391,7 +392,7 @@ export class Item extends Ion {
|
||||
set contentLabel(label: Label) {
|
||||
if (label) {
|
||||
this._label = label;
|
||||
this.labelId = label.id = ('lbl-' + this.id);
|
||||
label.id = this.labelId;
|
||||
if (label.type) {
|
||||
this.setElementClass('item-label-' + label.type, true);
|
||||
}
|
||||
|
||||
@@ -13,24 +13,30 @@
|
||||
|
||||
<ion-list [reorder]="isReordering" (ionItemReorder)="reorder($event)">
|
||||
<button ion-item *ngFor="let item of items" (click)="clickedButton(item)"
|
||||
[style.background]="'rgb('+(255-item*4)+','+(255-item*4)+','+(255-item*4)+')'"
|
||||
[style.min-height]="item*2+35+'px'">
|
||||
[style.background]="'rgb('+(255-item*4)+','+(255-item*4)+','+(255-item*4)+')'"
|
||||
[style.min-height]="item*2+35+'px'">
|
||||
{{item}}
|
||||
</button>
|
||||
</ion-list>
|
||||
|
||||
<ion-list [reorder]="isReordering" (ionItemReorder)="$event.applyTo(items)">
|
||||
<ion-item-sliding *ngFor="let item of items">
|
||||
<button ion-item (click)="clickedButton(item)">
|
||||
<h2>Sliding item {{item}}</h2>
|
||||
</button>
|
||||
<ion-item-options side="right" icon-start>
|
||||
<button ion-button color='danger'>
|
||||
<ion-icon name="trash"></ion-icon>
|
||||
Remove
|
||||
</button>
|
||||
</ion-item-options>
|
||||
</ion-item-sliding>
|
||||
</ion-list>
|
||||
<div *ngFor="let side of ['start', 'end']">
|
||||
<ion-list>
|
||||
<ion-list-header>{{side}}</ion-list-header>
|
||||
<ion-item-group [reorder]="isReordering" (ionItemReorder)="$event.applyTo(items)" [side]="side">
|
||||
<ion-item-sliding *ngFor="let item of items">
|
||||
<button ion-item (click)="clickedButton(item)">
|
||||
<h2>Sliding item {{item}}</h2>
|
||||
<div item-end>right</div>
|
||||
</button>
|
||||
<ion-item-options side="right" icon-start>
|
||||
<button ion-button color='danger'>
|
||||
<ion-icon name="trash"></ion-icon>
|
||||
Remove
|
||||
</button>
|
||||
</ion-item-options>
|
||||
</ion-item-sliding>
|
||||
</ion-item-group>
|
||||
</ion-list>
|
||||
</div>
|
||||
|
||||
</ion-content>
|
||||
|
||||
@@ -9,7 +9,7 @@ export class RootPage {
|
||||
isReordering: boolean = false;
|
||||
|
||||
constructor() {
|
||||
let nu = 9;
|
||||
let nu = 5;
|
||||
for (let i = 0; i < nu; i++) {
|
||||
this.items.push(i);
|
||||
}
|
||||
|
||||
@@ -79,8 +79,6 @@ export class LoadingCmp {
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
this._plt.focusOutActiveElement();
|
||||
|
||||
// If there is a duration, dismiss after that amount of time
|
||||
if ( this.d && this.d.duration ) {
|
||||
this.durationTimeout = setTimeout(() => this.dismiss('backdrop'), this.d.duration);
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Config } from '../../config/config';
|
||||
import { DeepLinker } from '../../navigation/deep-linker';
|
||||
import { DomController } from '../../platform/dom-controller';
|
||||
import { GestureController } from '../../gestures/gesture-controller';
|
||||
import { Keyboard } from '../../platform/keyboard';
|
||||
import { Nav as INav } from '../../navigation/nav-interfaces';
|
||||
import { NavController } from '../../navigation/nav-controller';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
@@ -66,7 +65,6 @@ export class Nav extends NavControllerBase implements AfterViewInit, RootNode, I
|
||||
app: App,
|
||||
config: Config,
|
||||
plt: Platform,
|
||||
keyboard: Keyboard,
|
||||
elementRef: ElementRef,
|
||||
zone: NgZone,
|
||||
renderer: Renderer,
|
||||
@@ -77,7 +75,7 @@ export class Nav extends NavControllerBase implements AfterViewInit, RootNode, I
|
||||
domCtrl: DomController,
|
||||
errHandler: ErrorHandler
|
||||
) {
|
||||
super(parent, app, config, plt, keyboard, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler);
|
||||
super(parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler);
|
||||
|
||||
if (viewCtrl) {
|
||||
// an ion-nav can also act as an ion-page within a parent ion-nav
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Nav } from '../nav';
|
||||
|
||||
import { GestureController } from '../../../gestures/gesture-controller';
|
||||
import { Keyboard } from '../../../platform/keyboard';
|
||||
import {
|
||||
mockApp,
|
||||
mockConfig,
|
||||
@@ -88,7 +87,6 @@ function getNav() {
|
||||
const app = mockApp(config, platform);
|
||||
const zone = mockZone();
|
||||
const dom = mockDomController(platform);
|
||||
const keyboard = new Keyboard(config, platform, zone, dom);
|
||||
const elementRef = mockElementRef();
|
||||
const renderer = mockRenderer();
|
||||
const componentFactoryResolver: any = null;
|
||||
@@ -101,7 +99,6 @@ function getNav() {
|
||||
app,
|
||||
config,
|
||||
platform,
|
||||
keyboard,
|
||||
elementRef,
|
||||
zone,
|
||||
renderer,
|
||||
|
||||
@@ -161,8 +161,6 @@ export class PickerCmp {
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
this._plt.focusOutActiveElement();
|
||||
|
||||
let focusableEle = this._elementRef.nativeElement.querySelector('button');
|
||||
if (focusableEle) {
|
||||
focusableEle.focus();
|
||||
|
||||
@@ -67,7 +67,6 @@ export class PopoverCmp {
|
||||
}
|
||||
|
||||
ionViewPreLoad() {
|
||||
this._plt.focusOutActiveElement();
|
||||
this._load(this._navParams.data.component);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ export class Refresher {
|
||||
|
||||
constructor(private _plt: Platform, @Host() private _content: Content, private _zone: NgZone, gestureCtrl: GestureController) {
|
||||
this._events = new UIEventManager(_plt);
|
||||
_content.setElementClass('has-refresher', true);
|
||||
_content._hasRefresher = true;
|
||||
this._gesture = gestureCtrl.createGesture({
|
||||
name: GESTURE_REFRESHER,
|
||||
priority: GESTURE_PRIORITY_REFRESHER
|
||||
|
||||
@@ -224,6 +224,9 @@ describe('Refresher', () => {
|
||||
|
||||
});
|
||||
|
||||
it('should set hasRefresher on content', () => {
|
||||
expect(content._hasRefresher).toBeTruthy();
|
||||
});
|
||||
|
||||
let contentElementRef: any;
|
||||
let refresher: Refresher;
|
||||
|
||||
@@ -188,10 +188,11 @@ export class Searchbar extends BaseInput<string> {
|
||||
*/
|
||||
_inputUpdated() {
|
||||
const ele = this._searchbarInput.nativeElement;
|
||||
const value = this._value;
|
||||
// It is important not to re-assign the value if it is the same, because,
|
||||
// otherwise, the caret is moved to the end of the input
|
||||
if (ele && ele.value !== this.value) {
|
||||
ele.value = this.value;
|
||||
if (ele.value !== value) {
|
||||
ele.value = value;
|
||||
}
|
||||
this.positionElements();
|
||||
}
|
||||
|
||||
@@ -123,6 +123,31 @@ import { SelectPopover, SelectPopoverOption } from './select-popover-component';
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* ### Object Value References
|
||||
*
|
||||
* When using objects for select values, it is possible for the identities of these objects to
|
||||
* change if they are coming from a server or database, while the selected value's identity
|
||||
* remains the same. For example, this can occur when an existing record with the desired object value
|
||||
* is loaded into the select, but the newly retrieved select options now have different identities. This will
|
||||
* result in the select appearing to have no value at all, even though the original selection in still intact.
|
||||
*
|
||||
* Using the `compareWith` `Input` is the solution to this problem
|
||||
*
|
||||
* ```html
|
||||
* <ion-item>
|
||||
* <ion-label>Employee</ion-label>
|
||||
* <ion-select [(ngModel)]="employee" [compareWith]="compareFn">
|
||||
* <ion-option *ngFor="let employee of employees" [value]="employee">{{employee.name}}</ion-option>
|
||||
* </ion-select>
|
||||
* </ion-item>
|
||||
* ```
|
||||
*
|
||||
* ```ts
|
||||
* compareFn(e1: Employee, e2: Employee): boolean {
|
||||
* return e1 && e2 ? e1.id === e2.id : e1 === e2;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @demo /docs/demos/src/select/
|
||||
*/
|
||||
@Component({
|
||||
@@ -153,6 +178,7 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
_overlay: ActionSheet | Alert | Popover;
|
||||
_texts: string[] = [];
|
||||
_text: string = '';
|
||||
_compareWith: (o1: any, o2: any) => boolean = isCheckedProperty;
|
||||
|
||||
/**
|
||||
* @input {string} The text to display on the cancel button. Default: `Cancel`.
|
||||
@@ -187,6 +213,18 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
*/
|
||||
@Input() selectedText: string = '';
|
||||
|
||||
/**
|
||||
* @input {Function} The function that will be called to compare object values
|
||||
*/
|
||||
@Input()
|
||||
set compareWith(fn: (o1: any, o2: any) => boolean) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new Error(`compareWith must be a function, but received ${JSON.stringify(fn)}`);
|
||||
}
|
||||
this._compareWith = fn;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @output {any} Emitted when the selection was cancelled.
|
||||
*/
|
||||
@@ -206,10 +244,6 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
|
||||
@HostListener('click', ['$event'])
|
||||
_click(ev: UIEvent) {
|
||||
if (ev.detail === 0) {
|
||||
// do not continue if the click event came from a form submit
|
||||
return;
|
||||
}
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
this.open(ev);
|
||||
@@ -452,7 +486,7 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
this._options.forEach(option => {
|
||||
// check this option if the option's value is in the values array
|
||||
option.selected = this.getValues().some(selectValue => {
|
||||
return isCheckedProperty(selectValue, option.value);
|
||||
return this._compareWith(selectValue, option.value);
|
||||
});
|
||||
|
||||
if (option.selected) {
|
||||
|
||||
@@ -15,10 +15,13 @@ export class TabHighlight {
|
||||
constructor(private _elementRef: ElementRef, private _dom: DomController) {}
|
||||
|
||||
select(tab: Tab) {
|
||||
if (!tab) {
|
||||
return;
|
||||
}
|
||||
const dom = this._dom;
|
||||
|
||||
dom.read(() => {
|
||||
const btnEle: HTMLElement = tab.btn.getElementRef().nativeElement;
|
||||
const btnEle: HTMLElement = tab.btn.getNativeElement();
|
||||
const transform = `translate3d(${btnEle.offsetLeft}px,0,0) scaleX(${btnEle.offsetWidth})`;
|
||||
|
||||
dom.write(() => {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { DeepLinker } from '../../navigation/deep-linker';
|
||||
import { DomController } from '../../platform/dom-controller';
|
||||
import { GestureController } from '../../gestures/gesture-controller';
|
||||
import { isTrueProperty } from '../../util/util';
|
||||
import { Keyboard } from '../../platform/keyboard';
|
||||
import { Tab as ITab } from '../../navigation/nav-interfaces';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
import { NavOptions } from '../../navigation/nav-util';
|
||||
@@ -255,7 +254,6 @@ export class Tab extends NavControllerBase implements ITab {
|
||||
app: App,
|
||||
config: Config,
|
||||
plt: Platform,
|
||||
keyboard: Keyboard,
|
||||
elementRef: ElementRef,
|
||||
zone: NgZone,
|
||||
renderer: Renderer,
|
||||
@@ -268,7 +266,7 @@ export class Tab extends NavControllerBase implements ITab {
|
||||
errHandler: ErrorHandler
|
||||
) {
|
||||
// A Tab is a NavController for its child pages
|
||||
super(parent, app, config, plt, keyboard, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, _dom, errHandler);
|
||||
super(parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, _dom, errHandler);
|
||||
|
||||
this.id = parent.add(this);
|
||||
this._tabsHideOnSubPages = config.getBoolean('tabsHideOnSubPages');
|
||||
|
||||
@@ -302,7 +302,7 @@ $tabs-md-tab-icon-size: 2.4rem !default;
|
||||
transition-duration: 300ms;
|
||||
}
|
||||
|
||||
.tabs-md[tabsHighlight=true][tabsPlacement=bottom] .tab-highlight {
|
||||
.tabs-md[tabsHighlight=true][tabsPlacement=bottom] > .tabbar > .tab-highlight {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.tabbar-hidden .tabbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabbar.show-tabbar {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { AfterViewInit, Component, ElementRef, EventEmitter, forwardRef, Input, Output, Optional, Renderer, ViewChild, ViewContainerRef, ViewEncapsulation } from '@angular/core';
|
||||
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import 'rxjs/add/operator/takeUntil';
|
||||
|
||||
import { App } from '../app/app';
|
||||
import { Config } from '../../config/config';
|
||||
import { DeepLinker } from '../../navigation/deep-linker';
|
||||
import { Ion } from '../ion';
|
||||
import { isBlank, assert } from '../../util/util';
|
||||
import { Keyboard } from '../../platform/keyboard';
|
||||
import { Tabs as ITabs } from '../../navigation/nav-interfaces';
|
||||
import { NavController } from '../../navigation/nav-controller';
|
||||
import { NavControllerBase } from '../../navigation/nav-controller-base';
|
||||
@@ -176,7 +180,7 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
|
||||
/** @internal */
|
||||
_selectHistory: string[] = [];
|
||||
/** @internal */
|
||||
_resizeObs: any;
|
||||
_onDestroy = new Subject<void>();
|
||||
|
||||
/**
|
||||
* @input {number} The default selected tab index when first loaded. If a selected index isn't provided then it will use `0`, the first tab.
|
||||
@@ -231,7 +235,8 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
|
||||
elementRef: ElementRef,
|
||||
private _plt: Platform,
|
||||
renderer: Renderer,
|
||||
private _linker: DeepLinker
|
||||
private _linker: DeepLinker,
|
||||
keyboard?: Keyboard
|
||||
) {
|
||||
super(config, elementRef, renderer, 'tabs');
|
||||
|
||||
@@ -261,10 +266,33 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
|
||||
viewCtrl._setContent(this);
|
||||
viewCtrl._setContentRef(elementRef);
|
||||
}
|
||||
|
||||
const keyboardResizes = config.getBoolean('keyboardResizes', false);
|
||||
if (keyboard && keyboardResizes) {
|
||||
keyboard.willHide
|
||||
.takeUntil(this._onDestroy)
|
||||
.subscribe(() => {
|
||||
this._plt.timeout(() => this.setTabbarHidden(false), 50);
|
||||
});
|
||||
keyboard.willShow
|
||||
.takeUntil(this._onDestroy)
|
||||
.subscribe(() => this.setTabbarHidden(true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
setTabbarHidden(tabbarHidden: boolean) {
|
||||
this.setElementClass('tabbar-hidden', tabbarHidden);
|
||||
this.resize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this._resizeObs && this._resizeObs.unsubscribe();
|
||||
this._onDestroy.next();
|
||||
this.parent.unregisterChildNav(this);
|
||||
}
|
||||
|
||||
@@ -277,9 +305,9 @@ export class Tabs extends Ion implements AfterViewInit, RootNode, ITabs {
|
||||
this._setConfig('tabsHighlight', this.tabsHighlight);
|
||||
|
||||
if (this.tabsHighlight) {
|
||||
this._resizeObs = this._plt.resize.subscribe(() => {
|
||||
this._highlight.select(this.getSelected());
|
||||
});
|
||||
this._plt.resize
|
||||
.takeUntil(this._onDestroy)
|
||||
.subscribe(() => this._highlight.select(this.getSelected()));
|
||||
}
|
||||
|
||||
this.initTabs();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<p><button ion-button (click)="color = !color" [color]="color ? 'primary':'secondary'">Change color</button></p>
|
||||
<p>"Change color" should continue working after clicking Logout in the tabbar and cancelling (No in the alert)</p>
|
||||
<p>UserId: {{userId}}</p>
|
||||
<p><ion-input></ion-input></p>
|
||||
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>
|
||||
<div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div><div f></div>
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ export class Toast extends ViewController {
|
||||
*/
|
||||
present(navOptions: NavOptions = {}): Promise<any> {
|
||||
navOptions.disableApp = false;
|
||||
navOptions.keyboardClose = false;
|
||||
return this._app.present(this, navOptions, PORTAL_TOAST);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ export class Toggle extends BaseInput<boolean> implements IonicTapInput, AfterCo
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
_inputCheckHasValue() {}
|
||||
_inputUpdated() {}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
@@ -210,13 +210,6 @@ export class Toggle extends BaseInput<boolean> implements IonicTapInput, AfterCo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
initFocus() {
|
||||
this._elementRef.nativeElement.querySelector('button').focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
|
||||
@@ -62,8 +62,6 @@ export { NavPop } from './components/nav/nav-pop';
|
||||
export { NavPopAnchor } from './components/nav/nav-pop-anchor';
|
||||
export { NavPush } from './components/nav/nav-push';
|
||||
export { NavPushAnchor } from './components/nav/nav-push-anchor';
|
||||
export { NativeInput } from './components/input/native-input';
|
||||
export { NextInput } from './components/input/next-input';
|
||||
export { Note } from './components/note/note';
|
||||
export { Option } from './components/option/option';
|
||||
export { Picker } from './components/picker/picker';
|
||||
|
||||
@@ -69,8 +69,6 @@ import { Icon } from './components/icon/icon';
|
||||
import { Img } from './components/img/img';
|
||||
import { InfiniteScroll } from './components/infinite-scroll/infinite-scroll';
|
||||
import { InfiniteScrollContent } from './components/infinite-scroll/infinite-scroll-content';
|
||||
import { NativeInput } from './components/input/native-input';
|
||||
import { NextInput } from './components/input/next-input';
|
||||
import { TextInput } from './components/input/input';
|
||||
import { Item } from './components/item/item';
|
||||
import { ItemContent } from './components/item/item-content';
|
||||
@@ -221,8 +219,6 @@ import { VirtualScroll } from './components/virtual-scroll/virtual-scroll';
|
||||
ListHeader,
|
||||
Reorder,
|
||||
LoadingCmp,
|
||||
NativeInput,
|
||||
NextInput,
|
||||
Menu,
|
||||
MenuClose,
|
||||
MenuToggle,
|
||||
@@ -324,8 +320,6 @@ import { VirtualScroll } from './components/virtual-scroll/virtual-scroll';
|
||||
ListHeader,
|
||||
Reorder,
|
||||
LoadingCmp,
|
||||
NativeInput,
|
||||
NextInput,
|
||||
Menu,
|
||||
MenuClose,
|
||||
MenuToggle,
|
||||
|
||||
@@ -12,7 +12,6 @@ import { GestureController } from '../gestures/gesture-controller';
|
||||
import { isBlank, isNumber, isPresent, isTrueProperty, assert, removeArrayItem } from '../util/util';
|
||||
import { isViewController, ViewController } from './view-controller';
|
||||
import { Ion } from '../components/ion';
|
||||
import { Keyboard } from '../platform/keyboard';
|
||||
import { NavController } from './nav-controller';
|
||||
import { NavParams } from './nav-params';
|
||||
import { Platform } from '../platform/platform';
|
||||
@@ -63,7 +62,6 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
public _app: App,
|
||||
public config: Config,
|
||||
public plt: Platform,
|
||||
public _keyboard: Keyboard,
|
||||
elementRef: ElementRef,
|
||||
public _zone: NgZone,
|
||||
renderer: Renderer,
|
||||
@@ -760,7 +758,7 @@ export class NavControllerBase extends Ion implements NavController {
|
||||
if (opts.keyboardClose !== false) {
|
||||
// the keyboard is still open!
|
||||
// no problem, let's just close for them
|
||||
this._keyboard.close();
|
||||
this.plt.focusOutActiveElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable, NgZone } from '@angular/core';
|
||||
import { Injectable, NgZone, EventEmitter } from '@angular/core';
|
||||
|
||||
import { Config } from '../config/config';
|
||||
import { DomController } from './dom-controller';
|
||||
@@ -24,29 +24,85 @@ import { Platform } from './platform';
|
||||
*/
|
||||
@Injectable()
|
||||
export class Keyboard {
|
||||
private _tmr: any;
|
||||
|
||||
constructor(config: Config, private _plt: Platform, private _zone: NgZone, private _dom: DomController) {
|
||||
_tmr: number;
|
||||
|
||||
willShow = new EventEmitter<void>();
|
||||
willHide = new EventEmitter<void>();
|
||||
didShow = new EventEmitter<void>();
|
||||
didHide = new EventEmitter<void>();
|
||||
|
||||
eventsAvailable = false;
|
||||
|
||||
constructor(
|
||||
config: Config,
|
||||
private _plt: Platform,
|
||||
private _zone: NgZone,
|
||||
private _dom: DomController
|
||||
) {
|
||||
this.focusOutline(config.get('focusOutline'));
|
||||
|
||||
const win = _plt.win();
|
||||
const win = <any>_plt.win();
|
||||
if (config.getBoolean('keyboardResizes', false)) {
|
||||
this.listenV2(win);
|
||||
} else {
|
||||
this.listenV1(win);
|
||||
}
|
||||
}
|
||||
|
||||
_plt.registerListener(win, 'native.keyboardhide', () => {
|
||||
_plt.cancelTimeout(this._tmr);
|
||||
this._tmr = _plt.timeout(() => {
|
||||
private listenV2(win: any) {
|
||||
const platform = this._plt;
|
||||
platform.registerListener(win, 'keyboardWillShow', () => {
|
||||
this._zone.run(() => {
|
||||
this.willShow.emit();
|
||||
});
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
platform.registerListener(win, 'keyboardWillHide', () => {
|
||||
this._zone.run(() => {
|
||||
this.willHide.emit();
|
||||
});
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
platform.registerListener(win, 'keyboardDidShow', () => {
|
||||
this._zone.run(() => {
|
||||
this.didShow.emit();
|
||||
});
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
platform.registerListener(win, 'keyboardDidHide', () => {
|
||||
this._zone.run(() => {
|
||||
this.didHide.emit();
|
||||
});
|
||||
}, { zone: false, passive: true });
|
||||
this.eventsAvailable = true;
|
||||
}
|
||||
|
||||
private listenV1(win: any) {
|
||||
const platform = this._plt;
|
||||
|
||||
platform.registerListener(win, 'native.keyboardhide', () => {
|
||||
this.blurActiveInput(true);
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
platform.registerListener(win, 'native.keyboardshow', () => {
|
||||
this.blurActiveInput(false);
|
||||
}, { zone: false, passive: true });
|
||||
}
|
||||
|
||||
private blurActiveInput(shouldBlur: boolean) {
|
||||
const platform = this._plt;
|
||||
platform.cancelTimeout(this._tmr);
|
||||
if (shouldBlur) {
|
||||
this._tmr = platform.timeout(() => {
|
||||
// this custom cordova plugin event fires when the keyboard will hide
|
||||
// useful when the virtual keyboard is closed natively
|
||||
// https://github.com/ionic-team/ionic-plugin-keyboard
|
||||
if (this.isOpen()) {
|
||||
this._plt.focusOutActiveElement();
|
||||
platform.focusOutActiveElement();
|
||||
}
|
||||
}, 80);
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
_plt.registerListener(win, 'native.keyboardshow', () => {
|
||||
_plt.cancelTimeout(this._tmr);
|
||||
}, { zone: false, passive: true });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,6 +105,7 @@ export const PLATFORM_CONFIGS: { [key: string]: PlatformConfig } = {
|
||||
],
|
||||
settings: {
|
||||
autoFocusAssist: 'delay',
|
||||
hideCaretOnScroll: true,
|
||||
hoverCSS: false,
|
||||
inputBlurring: isIos,
|
||||
inputCloning: isIos,
|
||||
@@ -116,6 +117,8 @@ export const PLATFORM_CONFIGS: { [key: string]: PlatformConfig } = {
|
||||
tapPolyfill: isIosUIWebView,
|
||||
virtualScrollEventAssist: isIosUIWebView,
|
||||
disableScrollAssist: isIos,
|
||||
keyboardResizes: keyboardResizes,
|
||||
resizeAssist: keyboardResizes,
|
||||
},
|
||||
isMatch(plt: Platform) {
|
||||
return plt.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
|
||||
@@ -240,6 +243,13 @@ export const PLATFORM_CONFIGS: { [key: string]: PlatformConfig } = {
|
||||
}
|
||||
};
|
||||
|
||||
function keyboardResizes(plt: Platform): boolean {
|
||||
const win = <any>plt.win();
|
||||
if (win.Ionic && win.Ionic.keyboardResizes === true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export const PlatformConfigToken = new OpaqueToken('PLTCONFIG');
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
// Global app direction
|
||||
$app-direction: null !default;
|
||||
$app-direction: ltr !default;
|
||||
|
||||
|
||||
// Global font path
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
}
|
||||
|
||||
@mixin multi-dir() {
|
||||
@if $app-direction == null {
|
||||
@if $app-direction == multi {
|
||||
$root: #{&};
|
||||
@at-root [dir="ltr"], [dir="rtl"] {
|
||||
#{$root} {
|
||||
@@ -155,7 +155,7 @@
|
||||
}
|
||||
|
||||
@mixin rtl() {
|
||||
@if $app-direction == null {
|
||||
@if $app-direction == multi {
|
||||
$root: #{&};
|
||||
@at-root [dir="rtl"] {
|
||||
#{$root} {
|
||||
@@ -168,7 +168,7 @@
|
||||
}
|
||||
|
||||
@mixin ltr() {
|
||||
@if $app-direction == null {
|
||||
@if $app-direction == multi {
|
||||
$root: #{&};
|
||||
@at-root [dir="ltr"] {
|
||||
#{$root} {
|
||||
|
||||
@@ -62,8 +62,6 @@ ion-input :focus {
|
||||
|
||||
opacity: 0;
|
||||
|
||||
// background: red;
|
||||
// opacity: .3;
|
||||
contain: strict;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ import { AfterContentInit, ElementRef, EventEmitter, Input, NgZone, Output, Rend
|
||||
import { ControlValueAccessor } from '@angular/forms';
|
||||
import { NgControl } from '@angular/forms';
|
||||
|
||||
import { isPresent, isUndefined, isArray, isTrueProperty, deepCopy, assert } from './util';
|
||||
import { isPresent, isString, isUndefined, isArray, isTrueProperty, deepCopy, assert } from './util';
|
||||
import { IonicFormInput } from './form';
|
||||
import { Ion } from '../components/ion';
|
||||
import { Config } from '../config/config';
|
||||
import { Item } from '../components/item/item';
|
||||
@@ -10,7 +11,7 @@ import { Form } from './form';
|
||||
import { TimeoutDebouncer } from './debouncer';
|
||||
|
||||
|
||||
export interface CommonInput<T> extends ControlValueAccessor, AfterContentInit {
|
||||
export interface CommonInput<T> extends ControlValueAccessor, AfterContentInit, IonicFormInput {
|
||||
|
||||
id: string;
|
||||
disabled: boolean;
|
||||
@@ -76,21 +77,22 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
private _defaultValue: T,
|
||||
public _form: Form,
|
||||
public _item: Item,
|
||||
ngControl: NgControl
|
||||
public _ngControl: NgControl
|
||||
) {
|
||||
super(config, elementRef, renderer, name);
|
||||
_form && _form.register(this);
|
||||
this._value = deepCopy(this._defaultValue);
|
||||
|
||||
if (_item) {
|
||||
assert('lbl-' + _item.id === _item.labelId, 'labelId was not calculated correctly');
|
||||
this.id = name + '-' + _item.registerInput(name);
|
||||
this._labelId = 'lbl-' + _item.id;
|
||||
this._labelId = _item.labelId;
|
||||
this._item.setElementClass('item-' + name, true);
|
||||
}
|
||||
|
||||
// If the user passed a ngControl we need to set the valueAccessor
|
||||
if (ngControl) {
|
||||
ngControl.valueAccessor = this;
|
||||
if (_ngControl) {
|
||||
_ngControl.valueAccessor = this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +145,9 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
if (isUndefined(val)) {
|
||||
return false;
|
||||
}
|
||||
let normalized;
|
||||
if (val === null) {
|
||||
normalized = deepCopy(this._defaultValue);
|
||||
} else {
|
||||
normalized = this._inputNormalize(val);
|
||||
}
|
||||
const normalized = (val === null)
|
||||
? deepCopy(this._defaultValue)
|
||||
: this._inputNormalize(val);
|
||||
|
||||
const notUpdate = isUndefined(normalized) || !this._inputShouldChange(normalized);
|
||||
if (notUpdate) {
|
||||
@@ -157,7 +156,6 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
|
||||
console.debug('BaseInput: value changed:', normalized, this);
|
||||
this._value = normalized;
|
||||
this._inputCheckHasValue(normalized);
|
||||
if (this._init) {
|
||||
this._inputUpdated();
|
||||
}
|
||||
@@ -212,12 +210,11 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
if (this._isFocus) {
|
||||
return;
|
||||
}
|
||||
assert(this._init, 'component was not initialized');
|
||||
assert(NgZone.isInAngularZone(), '_fireFocus: should be zoned');
|
||||
console.debug('BaseInput: focused:', this);
|
||||
|
||||
this._isFocus = true;
|
||||
this._form && this._form.setAsFocused(this);
|
||||
this._setFocus(true);
|
||||
this.ionFocus.emit(this);
|
||||
this._inputUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,11 +224,27 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
if (!this._isFocus) {
|
||||
return;
|
||||
}
|
||||
assert(this._init, 'component was not initialized');
|
||||
assert(NgZone.isInAngularZone(), '_fireBlur: should be zoned');
|
||||
console.debug('BaseInput: blurred:', this);
|
||||
|
||||
this._isFocus = false;
|
||||
this._form && this._form.unsetAsFocused(this);
|
||||
this._setFocus(false);
|
||||
this.ionBlur.emit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
private _setFocus(isFocused: boolean) {
|
||||
assert(this._init, 'component was not initialized');
|
||||
assert(NgZone.isInAngularZone(), '_fireFocus: should be zoned');
|
||||
assert(isFocused !== this._isFocus, 'bad internal state');
|
||||
|
||||
this._isFocus = isFocused;
|
||||
const item = this._item;
|
||||
if (item) {
|
||||
item.setElementClass('input-has-focus', isFocused);
|
||||
item.setElementClass('item-input-has-focus', isFocused);
|
||||
}
|
||||
this._inputUpdated();
|
||||
}
|
||||
|
||||
@@ -255,16 +268,30 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
*/
|
||||
hasValue(): boolean {
|
||||
const val = this._value;
|
||||
return isArray(val)
|
||||
? val.length > 0
|
||||
: isPresent(val);
|
||||
if (!isPresent(val)) {
|
||||
return false;
|
||||
}
|
||||
if (isArray(val) || isString(val)) {
|
||||
return val.length > 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
focusNext() {
|
||||
this._form && this._form.tabFocus(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this._form && this._form.deregister(this);
|
||||
assert(this._init, 'input was destroed without being initialized');
|
||||
|
||||
const form = this._form;
|
||||
form && form.deregister(this);
|
||||
this._init = false;
|
||||
}
|
||||
|
||||
@@ -278,20 +305,11 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
_inputCheckHasValue(val: T) {
|
||||
if (!this._item) {
|
||||
return;
|
||||
}
|
||||
// TODO remove all uses of input-has-value in v4
|
||||
this._item.setElementClass('input-has-value', this.hasValue());
|
||||
this._item.setElementClass('item-input-has-value', this.hasValue());
|
||||
initFocus() {
|
||||
const ele = this._elementRef.nativeElement.querySelector('button');
|
||||
ele && ele.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
initFocus() { }
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@@ -326,5 +344,25 @@ export class BaseInput<T> extends Ion implements CommonInput<T> {
|
||||
*/
|
||||
_inputUpdated() {
|
||||
assert(this._init, 'component should be initialized');
|
||||
const item = this._item;
|
||||
if (item) {
|
||||
setControlCss(item, this._ngControl);
|
||||
// TODO remove all uses of input-has-value in v4
|
||||
let hasValue = this.hasValue();
|
||||
item.setElementClass('input-has-value', hasValue);
|
||||
item.setElementClass('item-input-has-value', hasValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setControlCss(element: Ion, control: NgControl) {
|
||||
if (!control) {
|
||||
return;
|
||||
}
|
||||
element.setElementClass('ng-untouched', control.untouched);
|
||||
element.setElementClass('ng-touched', control.touched);
|
||||
element.setElementClass('ng-pristine', control.pristine);
|
||||
element.setElementClass('ng-dirty', control.dirty);
|
||||
element.setElementClass('ng-valid', control.valid);
|
||||
element.setElementClass('ng-invalid', !control.valid);
|
||||
}
|
||||
|
||||
@@ -94,15 +94,15 @@ export function isTextInput(ele: any) {
|
||||
export const NON_TEXT_INPUT_REGEX = /^(radio|checkbox|range|file|submit|reset|color|image|button)$/i;
|
||||
|
||||
|
||||
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i;
|
||||
const SKIP_INPUT_ATTR = ['value', 'checked', 'disabled', 'readonly', 'placeholder', 'type', 'class', 'style', 'id', 'autofocus', 'autocomplete', 'autocorrect'];
|
||||
export function copyInputAttributes(srcElement: HTMLElement, destElement: HTMLElement) {
|
||||
// copy attributes from one element to another
|
||||
// however, skip over a few of them as they're already
|
||||
// handled in the angular world
|
||||
var attrs = srcElement.attributes;
|
||||
const attrs = srcElement.attributes;
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
var attr = attrs[i];
|
||||
if (!skipInputAttrsReg.test(attr.name)) {
|
||||
if (SKIP_INPUT_ATTR.indexOf(attr.name) === -1) {
|
||||
destElement.setAttribute(attr.name, attr.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,41 +7,47 @@ import { removeArrayItem } from './util';
|
||||
*/
|
||||
@Injectable()
|
||||
export class Form {
|
||||
private _focused: any = null;
|
||||
private _ids: number = -1;
|
||||
private _inputs: any[] = [];
|
||||
|
||||
register(input: any) {
|
||||
private _focused: IonicFormInput = null;
|
||||
private _ids: number = -1;
|
||||
private _inputs: IonicFormInput[] = [];
|
||||
|
||||
register(input: IonicFormInput) {
|
||||
this._inputs.push(input);
|
||||
}
|
||||
|
||||
deregister(input: any) {
|
||||
deregister(input: IonicFormInput) {
|
||||
removeArrayItem(this._inputs, input);
|
||||
this.unsetAsFocused(input);
|
||||
}
|
||||
|
||||
setAsFocused(input: IonicFormInput) {
|
||||
this._focused = input;
|
||||
}
|
||||
|
||||
unsetAsFocused(input: IonicFormInput) {
|
||||
if (input === this._focused) {
|
||||
this._focused = null;
|
||||
}
|
||||
}
|
||||
|
||||
setAsFocused(input: any) {
|
||||
this._focused = input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Focuses the next input element, if it exists.
|
||||
*/
|
||||
tabFocus(currentInput: any) {
|
||||
let index = this._inputs.indexOf(currentInput);
|
||||
if (index > -1 && (index + 1) < this._inputs.length) {
|
||||
let nextInput = this._inputs[index + 1];
|
||||
tabFocus(currentInput: IonicFormInput) {
|
||||
const inputs = this._inputs;
|
||||
let index = inputs.indexOf(currentInput) + 1;
|
||||
if (index > 0 && index < inputs.length) {
|
||||
var nextInput = inputs[index];
|
||||
if (nextInput !== this._focused) {
|
||||
console.debug('tabFocus, next');
|
||||
return nextInput.initFocus();
|
||||
}
|
||||
}
|
||||
|
||||
index = this._inputs.indexOf(this._focused);
|
||||
index = inputs.indexOf(this._focused);
|
||||
if (index > 0) {
|
||||
let previousInput = this._inputs[index - 1];
|
||||
var previousInput = inputs[index - 1];
|
||||
if (previousInput) {
|
||||
console.debug('tabFocus, previous');
|
||||
previousInput.initFocus();
|
||||
|
||||
@@ -45,6 +45,10 @@ export const ANY_CORPUS: any[] = [
|
||||
export interface TestConfig {
|
||||
defaultValue: any;
|
||||
corpus: any;
|
||||
testItem?: boolean;
|
||||
testForm?: boolean;
|
||||
onValueChange?: (value: any) => boolean;
|
||||
onFocusChange?: (isFocused: boolean) => boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +58,34 @@ export function commonInputTest<T>(input: BaseInput<T>, config: TestConfig) {
|
||||
// TODO test disable
|
||||
const zone = new NgZone(true);
|
||||
zone.run(() => {
|
||||
if (config.testItem === true && !input._item) {
|
||||
assert(false, 'input is invalid');
|
||||
}
|
||||
if (config.testForm === true && !input._form) {
|
||||
assert(false, 'form is invalid');
|
||||
}
|
||||
|
||||
// Run tests before initialization
|
||||
testInput(input, config, false);
|
||||
|
||||
input.ngAfterContentInit();
|
||||
(<any>input).ngAfterViewInit && (<any>input).ngAfterViewInit();
|
||||
|
||||
// Run tests after initialization
|
||||
testInput(input, config, true);
|
||||
|
||||
// Run tests without item
|
||||
if (config.testItem === true && !input._item) {
|
||||
input._item = undefined;
|
||||
testInput(input, config, true);
|
||||
}
|
||||
|
||||
// Run tests without item
|
||||
if (config.testForm === true && !input._form) {
|
||||
input._form = undefined;
|
||||
testInput(input, config, true);
|
||||
}
|
||||
|
||||
testInput(input, config, true);
|
||||
input.ngOnDestroy();
|
||||
assert(!input._init, 'input was not destroyed correctly');
|
||||
@@ -80,10 +110,16 @@ function testState<T>(input: BaseInput<T>, config: TestConfig, isInit: boolean)
|
||||
const subBlur = input.ionBlur.subscribe((ev: any) => {
|
||||
assertEqual(ev, input, 'ionBlur argument is wrong');
|
||||
blurCount++;
|
||||
if (config.onFocusChange && config.onFocusChange(false) !== true) {
|
||||
assert(false, 'onFocusChange test failed');
|
||||
}
|
||||
});
|
||||
const subFocus = input.ionFocus.subscribe((ev: any) => {
|
||||
assertEqual(ev, input, 'ionFocus argument is wrong');
|
||||
focusCount++;
|
||||
if (config.onFocusChange && config.onFocusChange(true) !== true) {
|
||||
assert(false, 'onFocusChange test failed');
|
||||
}
|
||||
});
|
||||
input._fireFocus();
|
||||
assertEqual(input._isFocus, true, 'should be focus');
|
||||
@@ -144,6 +180,9 @@ function testWriteValue<T>(input: BaseInput<T>, config: TestConfig, isInit: bool
|
||||
assertEqual(input.value, test[1], 'loop: input/output does not match');
|
||||
if (isInit) {
|
||||
assertEqual(ionChangeCalled, 1, 'loop: ionChange error');
|
||||
if (config.onValueChange && config.onValueChange(test[1]) !== true) {
|
||||
assert(false, 'onValueChange() test failed');
|
||||
}
|
||||
} else {
|
||||
assertEqual(ionChangeCalled, 0, 'loop: ionChange error');
|
||||
}
|
||||
@@ -215,6 +254,9 @@ function testNgModelChange<T>(input: BaseInput<T>, config: TestConfig, isInit: b
|
||||
assertEqual(input.value, test[1], 'input/output does not match');
|
||||
if (isInit) {
|
||||
assertEqual(ionChangeCalled, 1, 'ionChange error');
|
||||
if (config.onValueChange && config.onValueChange(test[1]) !== true) {
|
||||
assert(false, 'onValueChange() test failed');
|
||||
}
|
||||
} else {
|
||||
assertEqual(ionChangeCalled, 0, 'ionChange error');
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import { DomController } from '../platform/dom-controller';
|
||||
import { GestureController } from '../gestures/gesture-controller';
|
||||
import { Haptic } from '../tap-click/haptic';
|
||||
import { IonicApp } from '../components/app/app-root';
|
||||
import { Keyboard } from '../platform/keyboard';
|
||||
import { Menu } from '../components/menu/menu';
|
||||
import { NavOptions } from '../navigation/nav-util';
|
||||
import { NavControllerBase } from '../navigation/nav-controller-base';
|
||||
@@ -403,7 +402,6 @@ export function mockNavController(): NavControllerBase {
|
||||
let app = mockApp(config, platform);
|
||||
let zone = mockZone();
|
||||
let dom = mockDomController(platform);
|
||||
let keyboard = new Keyboard(config, platform, zone, dom);
|
||||
let elementRef = mockElementRef();
|
||||
let renderer = mockRenderer();
|
||||
let componentFactoryResolver: any = null;
|
||||
@@ -415,7 +413,6 @@ export function mockNavController(): NavControllerBase {
|
||||
app,
|
||||
config,
|
||||
platform,
|
||||
keyboard,
|
||||
elementRef,
|
||||
zone,
|
||||
renderer,
|
||||
@@ -447,7 +444,6 @@ export function mockNavController(): NavControllerBase {
|
||||
export function mockOverlayPortal(app: App, config: Config, plt: MockPlatform): OverlayPortal {
|
||||
let zone = mockZone();
|
||||
let dom = mockDomController(plt);
|
||||
let keyboard = new Keyboard(config, plt, zone, dom);
|
||||
let elementRef = mockElementRef();
|
||||
let renderer = mockRenderer();
|
||||
let componentFactoryResolver: any = null;
|
||||
@@ -460,7 +456,6 @@ export function mockOverlayPortal(app: App, config: Config, plt: MockPlatform):
|
||||
app,
|
||||
config,
|
||||
plt,
|
||||
keyboard,
|
||||
elementRef,
|
||||
zone,
|
||||
renderer,
|
||||
@@ -480,7 +475,6 @@ export function mockTab(parentTabs: Tabs): Tab {
|
||||
let app = (<any>parentTabs)._app || mockApp(config, platform);
|
||||
let zone = mockZone();
|
||||
let dom = mockDomController(platform);
|
||||
let keyboard = new Keyboard(config, platform, zone, dom);
|
||||
let elementRef = mockElementRef();
|
||||
let renderer = mockRenderer();
|
||||
let changeDetectorRef = mockChangeDetectorRef();
|
||||
@@ -493,7 +487,6 @@ export function mockTab(parentTabs: Tabs): Tab {
|
||||
app,
|
||||
config,
|
||||
platform,
|
||||
keyboard,
|
||||
elementRef,
|
||||
zone,
|
||||
renderer,
|
||||
|
||||
@@ -68,6 +68,20 @@ export class ScrollView {
|
||||
this._eventsEnabled = true;
|
||||
}
|
||||
|
||||
setScrolling(isScrolling: boolean, ev: ScrollEvent) {
|
||||
if (this.isScrolling) {
|
||||
if (isScrolling) {
|
||||
this.onScroll && this.onScroll(ev);
|
||||
} else {
|
||||
this.isScrolling = false;
|
||||
this.onScrollEnd && this.onScrollEnd(ev);
|
||||
}
|
||||
} else if (isScrolling) {
|
||||
this.isScrolling = true;
|
||||
this.onScrollStart && this.onScrollStart(ev);
|
||||
}
|
||||
}
|
||||
|
||||
private enableNativeScrolling() {
|
||||
assert(this.onScrollStart, 'onScrollStart is not defined');
|
||||
assert(this.onScroll, 'onScroll is not defined');
|
||||
@@ -94,6 +108,7 @@ export class ScrollView {
|
||||
}
|
||||
|
||||
ev.timeStamp = scrollEvent.timeStamp;
|
||||
|
||||
// Event.timeStamp is 0 in firefox
|
||||
if (!ev.timeStamp) {
|
||||
ev.timeStamp = Date.now();
|
||||
@@ -108,9 +123,6 @@ export class ScrollView {
|
||||
ev.scrollLeft = self.getLeft();
|
||||
|
||||
if (!self.isScrolling) {
|
||||
// currently not scrolling, so this is a scroll start
|
||||
self.isScrolling = true;
|
||||
|
||||
// remember the start positions
|
||||
ev.startY = ev.scrollTop;
|
||||
ev.startX = ev.scrollLeft;
|
||||
@@ -119,9 +131,6 @@ export class ScrollView {
|
||||
ev.velocityY = ev.velocityX = 0;
|
||||
ev.deltaY = ev.deltaX = 0;
|
||||
positions.length = 0;
|
||||
|
||||
// emit only on the first scroll event
|
||||
self.onScrollStart(ev);
|
||||
}
|
||||
|
||||
// actively scrolling
|
||||
@@ -157,20 +166,17 @@ export class ScrollView {
|
||||
}
|
||||
|
||||
function scrollEnd() {
|
||||
// haven't scrolled in a while, so it's a scrollend
|
||||
self.isScrolling = false;
|
||||
|
||||
// reset velocity, do not reset the directions or deltas
|
||||
ev.velocityY = ev.velocityX = 0;
|
||||
|
||||
// emit that the scroll has ended
|
||||
self.onScrollEnd(ev);
|
||||
self.setScrolling(false, ev);
|
||||
|
||||
self._endTmr = null;
|
||||
}
|
||||
|
||||
// emit on each scroll event
|
||||
self.onScroll(ev);
|
||||
self.setScrolling(true, ev);
|
||||
|
||||
// debounce for a moment after the last scroll event
|
||||
self._dom.cancel(self._endTmr);
|
||||
@@ -467,7 +473,7 @@ export class ScrollView {
|
||||
attempts++;
|
||||
|
||||
if (!self._el || stopScroll || attempts > maxAttempts) {
|
||||
self.isScrolling = false;
|
||||
self.setScrolling(false, null);
|
||||
(<any>el.style)[transform] = '';
|
||||
done();
|
||||
return;
|
||||
@@ -494,13 +500,14 @@ export class ScrollView {
|
||||
|
||||
} else {
|
||||
stopScroll = true;
|
||||
self.isScrolling = false;
|
||||
self.setScrolling(false, null);
|
||||
(<any>el.style)[transform] = '';
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
// start scroll loop
|
||||
self.setScrolling(true, null);
|
||||
self.isScrolling = true;
|
||||
|
||||
// chill out for a frame first
|
||||
@@ -525,7 +532,7 @@ export class ScrollView {
|
||||
}
|
||||
|
||||
stop() {
|
||||
this.isScrolling = false;
|
||||
this.setScrolling(false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user