Skip to content

Commit

Permalink
Merge pull request #8 from ivanvanderbyl/added-stripe-element-and-eve…
Browse files Browse the repository at this point in the history
…nt-to-actions

Added stripe element and event to actions
  • Loading branch information
joshsmith authored Nov 11, 2017
2 parents f715078 + 5e9478b commit 60ecfc4
Show file tree
Hide file tree
Showing 10 changed files with 5,968 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ npm-debug.log*
testem.log

.env

.DS_Store
37 changes: 23 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,44 @@ node_js:
- "6"

sudo: false
dist: trusty

cache:
yarn: true
directories:
- $HOME/.npm
- $HOME/.cache # includes bowers cache

addons:
chrome: stable

env:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default
global:
# See https://git.io/vdao3 for details.
- JOBS=1
matrix:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- npm config set spin false
- npm install -g bower phantomjs-prebuilt
- bower --version
- phantomjs --version
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- if [[ $(npm -v | cut -d '.' -f 1) -lt 3 ]]; then npm i -g npm@^3; fi
- yarn global add bower
- bower install

install:
- npm install
- bower install
- yarn install --no-lockfile --non-interactive

script:
# Usually, it's ok to finish the test scenario without reverting
Expand Down
18 changes: 12 additions & 6 deletions addon/components/stripe-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
get,
inject: { service },
set,
computed,
computed
} = Ember;

export default Component.extend({
Expand All @@ -25,7 +25,7 @@ export default Component.extend({
didInsertElement() {
this._super(...arguments);

let elements = get(this, 'elements');
let elements = get(this, 'stripev3.elements')();

// Fetch user options
let options = get(this, 'options');
Expand Down Expand Up @@ -70,12 +70,18 @@ export default Component.extend({

setEventListeners() {
let stripeElement = get(this, 'stripeElement');
stripeElement.on('blur', () => this.sendAction('blur'));
stripeElement.on('focus', () => this.sendAction('focus'));
stripeElement.on('blur', (event) => this.sendAction('blur', stripeElement, event));
stripeElement.on('focus', (event) => this.sendAction('focus', stripeElement, event));
stripeElement.on('change', (...args) => {
let { error } = args[0];
let { error, complete } = args[0];
set(this, 'error', error);
this.sendAction('change', ...args);
this.sendAction('change', stripeElement, ...args);

if (complete) {
this.sendAction('complete', stripeElement);
} else if (error) {
this.sendAction('error', error);
}
});
}
});
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "ember-stripe-elements",
"dependencies": {
"sinonjs": "^1.17.1"
}
}
9 changes: 9 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env node */
module.exports = {
useYarn: true,
scenarios: [
{
name: 'ember-lts-2.4',
Expand Down Expand Up @@ -33,6 +34,14 @@ module.exports = {
}
}
},
{
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0'
}
}
},
{
name: 'ember-release',
bower: {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = {
name: 'ember-stripe-elements',

contentFor(type) {
if (type === 'head') {
return '<script type="text/javascript" src="https://js.stripe.com/v3/"></script>';
if (type === 'head') {
return '<script type="text/javascript" src="https://js.stripe.com/v3/"></script>';
}
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"ember-cli": "2.12.0",
"ember-cli-code-coverage": "0.3.11",
"ember-cli-dependency-checker": "^1.3.0",
"ember-cli-eslint": "^3.0.0",
"ember-cli-eslint": "^4.2.2",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^3.1.0",
"ember-cli-shims": "^1.0.2",
Expand All @@ -42,7 +42,7 @@
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.6.0",
"ember-resolver": "^2.0.3",
"ember-sinon": "0.2.1",
"ember-sinon": "^1.0.1",
"ember-sinon-qunit": "1.4.1",
"ember-source": "~2.12.0",
"loader.js": "^4.2.3"
Expand Down
16 changes: 13 additions & 3 deletions testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ module.exports = {
"test_page": "tests/index.html?hidepassed",
"disable_watching": true,
"launch_in_ci": [
"PhantomJS"
"Chrome"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
],
browser_args: {
Chrome: {
mode: 'ci',
args: [
'--disable-gpu',
'--headless',
'--remote-debugging-port=9222',
'--window-size=1440,900'
]
},
}
};
Loading

0 comments on commit 60ecfc4

Please sign in to comment.