ja1984 / jackbox

Javascript library to display notifications
https://ja1984.github.io/jackbox/
GNU General Public License v3.0
17 stars 6 forks source link

Add per notification customizable settings #11

Closed Fredrik-Oberg closed 8 years ago

Fredrik-Oberg commented 8 years ago

Should be able to add custom settings per each notification.

var notificationSettings = {
   time: 5, 
   classNames: "custom-class-name"
}
Jackbox.error("message", notificationSettings):
godric3 commented 8 years ago

I think I can try do that, but got one question. Overriding all settings of notification will be right, or should it only override specific settings?

ja1984 commented 8 years ago

@godric3 i would say override all settings, so a notification should be able to take in the same settings object as the lib itself.

Fredrik-Oberg commented 8 years ago

Only override settings that you send in. I think you can use Object.assign for this to work. Something in the line like this I believe would do it.

var createNotification = function (_message, type, customSettings) {
   var settings = Object.assign({}, lib.settings.notification, customSettings);
   var ttl = settings.time;
}

Then we will only overwrite the settings for that notification.

* edited javascript variable name