From 90951e6108a0c21972311abab2fe10e51f3994d0 Mon Sep 17 00:00:00 2001 From: thesved <2893181+thesved@users.noreply.github.com> Date: Fri, 24 Nov 2017 19:24:12 +0100 Subject: [PATCH] Add restrict feature use 'restrict' in settings, if you set it to a number bigger than 0, then it doesn't let more than 'restrict' amount of notifications to be open --- bootstrap-notify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bootstrap-notify.js b/bootstrap-notify.js index d97e4c0..135dca8 100644 --- a/bootstrap-notify.js +++ b/bootstrap-notify.js @@ -33,6 +33,7 @@ from: "top", align: "right" }, + restrict: 0, offset: 20, spacing: 10, z_index: 1031, @@ -121,6 +122,12 @@ //if duplicate messages are not allowed, then only continue if this new message is not a duplicate of one that it already showing if (this.settings.allow_duplicates || (!this.settings.allow_duplicates && !isDuplicateNotification(this))) { this.init(); + + // if restrict + var _length = $('[data-notify="container"]').length; + if (this.settings.restrict > 0 && _length >= this.settings.restrict) { + $('[data-notify="container"]').find('button[data-notify="dismiss"]').slice(0,_length-this.settings.restrict).trigger('click'); + } } } @@ -413,5 +420,3 @@ })); - -