Skip to content

Commit

Permalink
Merge pull request #73 from sethwebster/master
Browse files Browse the repository at this point in the history
Adds the ability to click on the notification and supply a callback to be called.
  • Loading branch information
ynnoj committed Jan 22, 2016
2 parents 3a08ae0 + 47e15c2 commit 7515caa
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ actions: {
}
```

### Add a clickable notification with callback
```js
actions: {
saveOptions() {
this.get('model').save()
.then(() => {
this.notifications.success('Successfully saved your settings', {
autoClear: true
});
}),
.catch((err) => {
this.notifications.error('Something went wrong - click to retry.', {
onClick: (notification) => {
this.get('model').save();
}
});
});
}
}
```
### Remove all active notifications using clearAll() before adding a new notification

```js
Expand Down
8 changes: 7 additions & 1 deletion addon/components/notification-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export default Ember.Component.extend({
classNames: ['c-notification'],
classNameBindings: [
'processedType',
'notification.dismiss::c-notification--in'
'notification.dismiss::c-notification--in',
'notification.onClick:c-notification--clickable'
],

paused: false,
Expand Down Expand Up @@ -44,6 +45,11 @@ export default Ember.Component.extend({
}
}),

mouseDown() {
if (this.get('notification.onClick')) {
this.get('notification.onClick')(this.get('notification'));
}
},
mouseEnter() {
if (this.get('notification.autoClear')) {
this.set('paused', true);
Expand Down
3 changes: 2 additions & 1 deletion addon/services/notification-messages-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default Ember.ArrayProxy.extend({
message: options.message,
type: options.type || 'info', // info, success, warning, error
autoClear: options.autoClear || this.get('defaultAutoClear'),
clearDuration: options.clearDuration || this.get('defaultClearDuration')
clearDuration: options.clearDuration || this.get('defaultClearDuration'),
onClick: options.onClick
});

this.pushObject(notification);
Expand Down
5 changes: 5 additions & 0 deletions addon/styles/_component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
}


// Notification clickable
&.#{$notification-css-prefix}--clickable {
cursor:pointer;
}

// Notification content
// -------------------------

Expand Down
34 changes: 34 additions & 0 deletions bower.json.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "ember-cli-notifications",
"dependencies": {
<<<<<<< 848182e318cf16be7c01fb9a0cce59cf9c857b25
"ember": "1.13.12",
"ember-cli-shims": "0.0.6",
"ember-cli-test-loader": "0.2.1",
"ember-data": "1.13.15",
"ember-load-initializers": "0.1.7",
"ember-qunit": "0.4.16",
"ember-qunit-notifications": "0.1.0",
"ember-resolver": "~0.1.20",
"jquery": "1.11.3",
"loader.js": "ember-cli/loader.js#3.4.0",
"qunit": "~1.20.0"
=======
"ember": "1.13.3",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.13.5",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5",
"ember-qunit": "0.4.1",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.18",
"jquery": "^1.11.3",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1"
>>>>>>> Pinned to 1.11.3 (jquery)
},
"devDependencies": {
"font-awesome": "~4.3.0",
"basscss": "~6.0.2"
}
}

0 comments on commit 7515caa

Please sign in to comment.