From 47e15c2d2dcdaac947a9b9ca8bd02c0c0a59b7b5 Mon Sep 17 00:00:00 2001 From: Seth webster Date: Thu, 7 Jan 2016 14:06:43 -0500 Subject: [PATCH] Added ability to provide a click handler to the notification Added mods to css for when clickable Added README.md updates Moved to using classBindingsArray instead of separate property Pinned to 1.11.3 (jquery) --- README.md | 20 +++++++++++ addon/components/notification-message.js | 8 ++++- .../services/notification-messages-service.js | 3 +- addon/styles/_component.scss | 5 +++ bower.json.orig | 34 +++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 bower.json.orig diff --git a/README.md b/README.md index b14ec670..3cda7fd8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/addon/components/notification-message.js b/addon/components/notification-message.js index 0b42f5cf..fe4e7b54 100644 --- a/addon/components/notification-message.js +++ b/addon/components/notification-message.js @@ -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, @@ -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); diff --git a/addon/services/notification-messages-service.js b/addon/services/notification-messages-service.js index 070ae33b..f938b921 100644 --- a/addon/services/notification-messages-service.js +++ b/addon/services/notification-messages-service.js @@ -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); diff --git a/addon/styles/_component.scss b/addon/styles/_component.scss index 5cae5440..1e073209 100644 --- a/addon/styles/_component.scss +++ b/addon/styles/_component.scss @@ -43,6 +43,11 @@ } +// Notification clickable +&.#{$notification-css-prefix}--clickable { + cursor:pointer; +} + // Notification content // ------------------------- diff --git a/bower.json.orig b/bower.json.orig new file mode 100644 index 00000000..f9b53a9d --- /dev/null +++ b/bower.json.orig @@ -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" + } +}