Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom simple function for bootstrap themplate #227

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.idea/
2 changes: 1 addition & 1 deletion bootstrap-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
onClosed: null,
onClick: null,
icon_type: 'class',
template: '<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">&times;</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
template: '<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="btn-close close" data-notify="dismiss">&times;</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
};

String.format = function () {
Expand Down
105 changes: 105 additions & 0 deletions custom-notify-5.0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
*/

// $(document).ready(function () {
$.fn.cbn = function (var_message, var_type = 'info', var_update = 'no', var_delay=5000) {
// alert('a');
var var_title = '';
var var_icon = '';
var val_showProgressbar = false;
var val_allow_dismiss = true;
let val_placement = {
from: 'top',
align: 'right'
};

if (var_type == 'success') {
var_title = 'Success!! ';
var_icon = 'fas fa-check-circle';

} else if (var_type == 'danger') {
var_title = 'Error!! ';
var_icon = 'fas fa-exclamation-circle';

} else if (var_type == 'warning') {
var_title = 'Warning!! ';
var_icon = 'fas fa-exclamation-circle';
} else if (var_type == 'loading') {
var_type = 'info';
var_title = 'Loading!! ';
var_icon = 'fas fa-spinner fa-spin';
/* val_allow_dismiss= false; */
/* val_showProgressbar = true; */
var_delay = 0;
} else if (var_type == 'wait') {
var_type = 'info';
var_title = 'Wait!! ';
var_icon = 'fas fa-spinner fa-spin';
/* val_allow_dismiss= false; */
/* val_showProgressbar = true; */
var_delay = 0;
} else {
var_type = 'info';
var_title = 'Message!! ';
var_icon = 'fas fa-info-circle';
}

if(var_update=='no') {

if (typeof window.cbn_placement === 'undefined') {
// variable is undefined
}
else {
val_placement = window.cbn_placement;
}

return window.notify = $.notify({
// obj.message
// options
icon: var_icon,
title: var_title,
message: var_message,
/*
url: 'https://github.com/mouse0270/bootstrap-notify',
target: '_blank'
*/
},
{
/* allow_dismiss: false, */
type: var_type,
z_index: 6001,
showProgressbar: val_showProgressbar,
allow_dismiss: val_allow_dismiss,
delay: var_delay,
placement : val_placement,
/*
placement: {
from: 'top',
align: 'right'
},
delay: 3000,
timer: 2000,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
*/
});
}
else {
if(typeof(var_update) != 'object') {
var_update = window.notify;
}

var_update.update({type: var_type, icon: var_icon, title: var_title, message: var_message});

setTimeout(function() {
// $.notifyClose();
var_update.close();
}, var_delay);

}
};

// });
109 changes: 109 additions & 0 deletions custom-notify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.min.css">
*/

// $(document).ready(function () {
$.fn.cbn = function (var_message, var_type = 'info', var_update = 'no', var_delay=5000) {
// alert('a');
var var_title = '';
var var_icon = '';
var val_showProgressbar = false;
var val_allow_dismiss = true;
let val_placement = {
from: 'top',
align: 'right'
};
let val_z_index = 6001;

if (var_type == 'success') {
var_title = 'Success!! ';
var_icon = 'fa fa-check-circle-o';

} else if (var_type == 'danger') {
var_title = 'Error!! ';
var_icon = 'fa fa-exclamation-circle';

} else if (var_type == 'warning') {
var_title = 'Warning!! ';
var_icon = 'fa fa-exclamation-circle';
} else if (var_type == 'loading') {
var_type = 'info';
var_title = 'Loading!! ';
var_icon = 'fa fa-refresh fa-spin fa-fw';
val_allow_dismiss= false;
/* val_showProgressbar = true; */
var_delay = 0;
} else if (var_type == 'wait') {
var_type = 'info';
var_title = 'Wait!! ';
var_icon = 'fa fa-refresh fa-spin fa-fw';
/* val_allow_dismiss= false; */
/* val_showProgressbar = true; */
var_delay = 0;
} else {
var_type = 'info';
var_title = 'Message!! ';
var_icon = 'fa fa-info-circle';
}

if(var_update=='no') {
if (typeof window.cbn_placement === 'undefined') {
// variable is undefined
}
else {
val_placement = window.cbn_placement;
}

if (typeof window.cbn_z_index === 'undefined') {
// variable is undefined
}
else {
val_z_index = window.cbn_z_index;
}

return window.notify = $.notify({
// obj.message
// options
icon: var_icon,
title: var_title,
message: var_message,
/*
url: 'https://github.com/mouse0270/bootstrap-notify',
target: '_blank'
*/
},
{
/* allow_dismiss: false, */
type: var_type,
z_index: val_z_index,
showProgressbar: val_showProgressbar,
allow_dismiss: val_allow_dismiss,
delay: var_delay,
placement : val_placement,
/*
placement: {
from: 'top',
align: 'right'
},
timer: 2000,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
*/
});
}
else {
if(typeof(var_update) != 'object') {
var_update = window.notify;
}

var_update.update({type: var_type, icon: var_icon, title: var_title, message: var_message,});
setTimeout(function() {
var_update.close();
}, var_delay);
}
};

// });

28 changes: 28 additions & 0 deletions test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>

<!-- Latest compiled and minified CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Latest compiled JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>



<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script type="text/javascript" src="//milan-sahana.github.io/bootstrap-notify/bootstrap-notify.js" charset="UTF-8"></script>
<script type="text/javascript" src="custom-notify-5.0.js" charset="UTF-8"></script>
<script>
window.cbn_placement = {
from: 'top',
align: 'center'
}

$.fn.cbn('This a test message');
</script>
</body>