Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobius1 committed Aug 18, 2021
1 parent d8aedda commit d080662
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 151 deletions.
40 changes: 31 additions & 9 deletions bulletin/bulletin.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
----------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Copyright © Mobius1 2021
-- * Bulletin
-- * Copyright (c) 2021 Karl Saunders (Mobius1)
-- * Licensed under GPLv3

-- * Version: 1.1.4
--
-- ! Edit it if you want, but don't re-release this without my permission, and never claim it to be yours !

-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
Expand All @@ -14,15 +19,18 @@
----------------------------------------------------------------------------------------------------------------------------------------------------------------
local notifications = {}

function Send(message, timeout, position, progress, theme)
function Send(message, timeout, position, progress, theme, exitAnim, flash)

if type(message) == 'table' then
SendCustom(message)
return
end

if message == nil then
return PrintError("^1BULLETIN ERROR: ^7Notification message is nil")
end

if type(message) == "number" then
message = tostring(message)
end
message = tostring(message)

if not tonumber(timeout) then
timeout = Config.Timeout
Expand Down Expand Up @@ -55,6 +63,8 @@ function Send(message, timeout, position, progress, theme)
position = position,
progress = progress,
theme = theme,
exitAnim = exitAnim,
flash = flash
})

end
Expand All @@ -75,15 +85,13 @@ function SendError(message, timeout, position, progress)
Send(message, timeout, position, progress, "error")
end

function SendAdvanced(message, title, subject, icon, timeout, position, progress, theme)
function SendAdvanced(message, title, subject, icon, timeout, position, progress, theme, exitAnim, flash)

if message == nil then
return PrintError("^1BULLETIN ERROR: ^7Notification message is nil")
end

if type(message) == "number" then
message = tostring(message)
end
message = tostring(message)

if title == nil then
return PrintError("^1BULLETIN ERROR: ^7Notification title is nil")
Expand Down Expand Up @@ -127,9 +135,23 @@ function SendAdvanced(message, title, subject, icon, timeout, position, progress
position = position,
progress = progress,
theme = theme,
exitAnim = exitAnim,
flash = flash
})
end

function SendCustom(options)
if type(options) ~= 'table' then
error("BULLETIN ERROR: options passed to `SendCustom` must be a table")
end

if options.type == "standard" or options.type == nil then
Send(options.message, options.timeout, options.position, options.progress, options.theme, options.exitAnim, options.flash)
elseif options.type == "advanced" then
SendAdvanced(options.message, options.title, options.subject, options.icon, options.timeout, options.position, options.progress, options.theme, options.exitAnim, options.flash)
end
end

function AddNotification(data)
data.config = Config
SendNUIMessage(data)
Expand Down
1 change: 1 addition & 0 deletions bulletin/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Config.Stacking = true
Config.ShowStackedCount = true
Config.AnimationOut = "fadeOut"; -- Exit animation - 'fadeOut', 'fadeOutLeft', 'flipOutX', 'flipOutY', 'bounceOutLeft', 'backOutLeft', 'slideOutLeft', 'zoomOut', 'zoomOutLeft'
Config.AnimationTime = 500 -- Entry / exit animation interval
Config.FlashCount = 5 -- No. of times to flash the notification
Config.SoundFile = false -- Sound file stored in ui/audio used for notification sound. Leave as false to disable.
Config.SoundVolume = 0.4 -- 0.0 - 1.0

Expand Down
7 changes: 3 additions & 4 deletions bulletin/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description 'bulletin'

author 'Karl Saunders (Mobius1)'

version '1.1.1'
version '1.1.4'

client_scripts {
'config.lua',
Expand All @@ -22,9 +22,8 @@ files {
'ui/audio/*.mp3',
'ui/audio/*.wav',
'ui/fonts/*.ttf',
'ui/css/app.css',
'ui/css/custom.css',
'ui/js/app.js'
'ui/css/*.css',
'ui/js/*.js'
}

exports {
Expand Down
7 changes: 7 additions & 0 deletions bulletin/ui/css/animate.min.css

Large diffs are not rendered by default.

134 changes: 5 additions & 129 deletions bulletin/ui/css/app.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
Bulletin
Copyright (c) 2021 Karl Saunders (Mobius1)
Licensed under MIT (http://www.opensource.org/licenses/mit-license.php)
Licensed under GPLv3
Version: 1.0.0
Version: 1.1.4
*/
@font-face {
font-family: "ChaletComprime";
Expand Down Expand Up @@ -182,8 +182,8 @@ body {
color: #fff;
}

.bulletin-notification .b {
color: #0099cc;
.bulletin-notification .u {
color: #000000;
}

.bulletin-notification .r {
Expand Down Expand Up @@ -223,133 +223,9 @@ body {
width: 0%;
}

@keyframes fadeIn {
from {
opacity: 0;
}

to {
opacity: 1;
}
}

@keyframes fadeOut {
from {
opacity: 1;
}

to {
opacity: 0;
}
}

@keyframes fadeOutLeft {
from {
opacity: 1;
}

to {
opacity: 0;
transform: translate3d(-100%, 0, 0);
}
}

@keyframes flipOutX {
from {
transform: perspective(400px);
}

30% {
transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
opacity: 1;
}

to {
transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
opacity: 0;
}
}

@keyframes flipOutY {
from {
transform: perspective(400px);
}

30% {
transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
opacity: 1;
}

to {
transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
opacity: 0;
}
}

@keyframes bounceOutLeft {
20% {
opacity: 1;
transform: translate3d(20px, 0, 0) scaleX(0.9);
}

to {
opacity: 0;
transform: translate3d(-2000px, 0, 0) scaleX(2);
}
}

@keyframes backOutLeft {
0% {
transform: scale(1);
opacity: 1;
}

20% {
transform: translateX(0px) scale(0.7);
opacity: 0.7;
}

100% {
transform: translateX(-2000px) scale(0.7);
opacity: 0.7;
}
}

@keyframes slideOutLeft {
from {
transform: translate3d(0, 0, 0);
}

to {
visibility: hidden;
transform: translate3d(-120%, 0, 0);
}
}

@keyframes zoomOut {
from {
opacity: 1;
}

@keyframes flash {
50% {
opacity: 0;
transform: scale3d(0.3, 0.3, 0.3);
}

to {
opacity: 0;
}
}

@keyframes zoomOutLeft {
40% {
opacity: 1;
transform: scale3d(0.475, 0.475, 0.475) translate3d(42px, 0, 0);
}

to {
opacity: 0;
transform: scale(0.1) translate3d(-2000px, 0, 0);
}
}

Expand Down
42 changes: 33 additions & 9 deletions bulletin/ui/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/*!
* Copyright © Mobius1 2021
* Copyright (c) 2021 Karl Saunders (Mobius1)
* Licensed under GPLv3
*
* Version: 1.1.4
*
* ! Edit it if you want, but don't re-release this without my permission, and never claim it to be yours !
*/
Expand Down Expand Up @@ -147,6 +150,10 @@ class Notification {
this.el.classList.remove("active");
this.el.classList.add("hiding");
this.hiding = true;

if ( this.exitAnim ) {
this.el.style.animationName = this.exitAnim;
}

setTimeout(() => {
const index = this.container.notifications.indexOf(this);
Expand Down Expand Up @@ -258,7 +265,7 @@ class Notification {
}

class StandardNotification extends Notification {
constructor(cfg, id, message, interval, position, progress = false, theme = "default") {
constructor(cfg, id, message, interval, position, progress = false, theme = "default", exitAnim = "fadeOut", flash = false) {

super();

Expand All @@ -271,6 +278,8 @@ class StandardNotification extends Notification {
this.progress = progress;
this.offset = 0;
this.theme = theme;
this.exitAnim = exitAnim;
this.flash = flash;
this.count = 1;

this.init();
Expand All @@ -279,7 +288,8 @@ class StandardNotification extends Notification {
init() {
this.el = document.createElement("div");
this.el.classList.add("bulletin-notification");

this.el.classList.toggle("flash", this.flash);

this.message = this.parseMessage(this.message);
this.el.innerHTML = this.message;

Expand All @@ -303,7 +313,7 @@ class StandardNotification extends Notification {
}

class AdvancedNotification extends Notification {
constructor(cfg, id, message, title, subject, icon, interval, position, progress = false, theme = "default") {
constructor(cfg, id, message, title, subject, icon, interval, position, progress = false, theme = "default", exitAnim = "fadeOut", flash = false) {

super();

Expand All @@ -319,6 +329,8 @@ class AdvancedNotification extends Notification {
this.progress = progress;
this.offset = 0;
this.theme = theme;
this.exitAnim = exitAnim;
this.flash = flash;
this.count = 1;

this.init();
Expand All @@ -332,6 +344,7 @@ class AdvancedNotification extends Notification {

this.el = document.createElement("div");
this.el.classList.add("bulletin-notification");
this.el.classList.toggle("flash", this.flash);

if ( this.theme ) {
this.el.classList.add(this.theme);
Expand Down Expand Up @@ -385,10 +398,21 @@ const onData = function(e) {

if ( !styled ) {
const css = `
.animate__animated {
-webkit-animation-duration: ${data.config.AnimationTime};
animation-duration: ${data.config.AnimationTime};
}
.bulletin-notification.active {
opacity: 0;
animation: fadeIn ${data.config.AnimationTime}ms ease 0ms forwards;
}
.bulletin-notification.active.flash {
opacity: 1;
animation: flash 400ms linear infinite;
animation-iteration-count: ${data.config.FlashCount};
}
.bulletin-notification.hiding {
opacity: 1;
Expand All @@ -406,13 +430,13 @@ const onData = function(e) {
if ( data.duplicate && data.config.Stacking ) {
stackDuplicate(data)
} else {
new StandardNotification(data.config, data.id, data.message, data.timeout, data.position, data.progress, data.theme).show();
new StandardNotification(data.config, data.id, data.message, data.timeout, data.position, data.progress, data.theme, data.exitAnim, data.flash).show();
}
} else if (data.type == "advanced") {
if ( data.duplicate && data.config.Stacking ) {
stackDuplicate(data)
} else {
new AdvancedNotification(data.config, data.id, data.message, data.title, data.subject, data.icon, data.timeout, data.position, data.progress, data.theme).show();
} else {
new AdvancedNotification(data.config, data.id, data.message, data.title, data.subject, data.icon, data.timeout, data.position, data.progress, data.theme, data.exitAnim, data.flash).show();
}
}
}
Expand All @@ -424,9 +448,9 @@ function stackDuplicate(data) {
if ( notification.id == data.id ) {
if ( notification.hiding ) {
if (data.type == "standard") {
new StandardNotification(data.config, data.id, data.message, data.timeout, data.position, data.progress, data.theme).show();
new StandardNotification(data.config, data.id, data.message, data.timeout, data.position, data.progress, data.theme, data.flash).show();
} else if (data.type == "advanced") {
new AdvancedNotification(data.config, data.id, data.message, data.title, data.subject, data.icon, data.timeout, data.position, data.progress, data.theme).show();
new AdvancedNotification(data.config, data.id, data.message, data.title, data.subject, data.icon, data.timeout, data.position, data.progress, data.theme, data.flash).show();
}
} else {
notification.stack();
Expand Down
Loading

0 comments on commit d080662

Please sign in to comment.