This commit is contained in:
2021-11-19 22:06:30 +03:00
parent d5d20afa59
commit 5daadad67f
5 changed files with 63 additions and 85 deletions
-57
View File
@@ -1,57 +0,0 @@
.toast {
width: 350px;
max-width: 100%;
font-size: 0.875rem;
pointer-events: auto;
background-color: rgba(255, 255, 255, 0.85);
background-clip: padding-box;
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
}
.toast.showing {
opacity: 0;
}
.toast:not(.show) {
display: none;
}
.toast-container {
width: -webkit-max-content;
width: -moz-max-content;
width: max-content;
max-width: 100%;
pointer-events: none;
}
.toast-container > :not(:last-child) {
margin-bottom: 0.75rem;
}
.toast-title {
margin-right: auto;
}
.toast-desc {}
.toast-icon {
}
.toast-header {
display: flex;
align-items: center;
padding: 0.5rem 0.75rem;
color: #6c757d;
background-color: rgba(255, 255, 255, 0.85);
background-clip: padding-box;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
border-top-left-radius: calc(0.25rem - 1px);
border-top-right-radius: calc(0.25rem - 1px);
}
.toast-header .btn-close {
margin-right: -0.375rem;
margin-left: 0.75rem;
}
.toast-body {
padding: 0.75rem;
word-wrap: break-word;
}
+59
View File
@@ -1,3 +1,62 @@
.toast {
width: 350px;
max-width: 100%;
font-size: 0.875rem;
pointer-events: auto;
background-color: rgba(255, 255, 255, 0.85);
background-clip: padding-box;
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
}
.toast.showing {
opacity: 0;
}
.toast:not(.show) {
display: none;
}
.toast-container {
width: -webkit-max-content;
width: -moz-max-content;
width: max-content;
max-width: 100%;
pointer-events: none;
}
.toast-container > :not(:last-child) {
margin-bottom: 0.75rem;
}
.toast-title {
margin-right: auto;
}
.toast-desc {}
.toast-icon {
margin-right: 0.5em;
max-width: 1.5em;
max-height: 1.5em;
}
.toast-header {
display: flex;
align-items: center;
padding: 0.5rem 0.75rem;
color: #6c757d;
background-color: rgba(255, 255, 255, 0.85);
background-clip: padding-box;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
border-top-left-radius: calc(0.25rem - 1px);
border-top-right-radius: calc(0.25rem - 1px);
}
.toast-header .btn-close {
margin-right: -0.375rem;
margin-left: 0.75rem;
}
.toast-body {
padding: 0.75rem;
word-wrap: break-word;
}
.toast-container--default { .toast-container--default {
z-index: 10000; z-index: 10000;
+2 -2
View File
@@ -13,7 +13,7 @@ kit.PluginManager.register('bsToastService', function(module, exports, require,
delay: 4000, delay: 4000,
}; };
this.closeTemplate = '<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Закрыть"/>'; this.closeTemplate = '<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Закрыть"/>';
this.iconTemplate = '<svg class="bd-placeholder-img rounded me-2" width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#007aff"/></svg>'; this.iconTemplate = '<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" preserveAspectRatio="xMidYMid slice" focusable="false"><rect width="100%" height="100%" fill="#007aff"/></svg>';
/** /**
* @type {HTMLElement} * @type {HTMLElement}
*/ */
@@ -45,7 +45,7 @@ kit.PluginManager.register('bsToastService', function(module, exports, require,
Service.prototype.getToastNode = function (title, message, desc = '') { Service.prototype.getToastNode = function (title, message, desc = '') {
var closeTemplate = this.close?this.closeTemplate:''; var closeTemplate = this.close?this.closeTemplate:'';
var toastTemplate = '<div class="toast fade hide" role="alert" aria-live="assertive" aria-atomic="true"><div class="toast-header"><div class="toast-icon">'+this.iconTemplate+'</div><strong class="toast-title">'+title+'</strong><small class="toast-desc">' + desc+ '</small>'+closeTemplate+'</div><div class="toast-body">'+message+'</div></div>'; var toastTemplate = '<div class="toast fade hide" role="alert" aria-live="assertive" aria-atomic="true"><div class="toast-header"><div class="kit-icon toast-icon">'+this.iconTemplate+'</div><strong class="toast-title">'+title+'</strong><small class="toast-desc">' + desc+ '</small>'+closeTemplate+'</div><div class="toast-body">'+message+'</div></div>';
return support.makeNode(toastTemplate); return support.makeNode(toastTemplate);
}; };
-3
View File
@@ -49,9 +49,6 @@ __PluginManager__.registerPlugins({
path: __pmConfig__.assetsPath + '/bsToast', path: __pmConfig__.assetsPath + '/bsToast',
module: '/bsToast.js', module: '/bsToast.js',
type: 'loader', type: 'loader',
css: [
'/bsToast.css'
],
deps: ['bsCore'], deps: ['bsCore'],
}, },
bsToastService: { bsToastService: {
+1 -22
View File
@@ -24,8 +24,6 @@ $APPLICATION->ShowHead();
unit.logger.notice(' '); unit.logger.notice(' ');
var audio = new Audio('https://issue.megapolis-it.ru/local/media/new_message_tone.mp3'); var audio = new Audio('https://issue.megapolis-it.ru/local/media/new_message_tone.mp3');
kit.service.toast.onShow.push(function (toast, node) { kit.service.toast.onShow.push(function (toast, node) {
unit.logger.info(toast.data.title, toast.data); unit.logger.info(toast.data.title, toast.data);
audio.play(); audio.play();
@@ -33,6 +31,7 @@ $APPLICATION->ShowHead();
var intervalId = setInterval(function(){ var intervalId = setInterval(function(){
kit.service.toast.info('Новая заявка', 'Заявка от Пупкина на дальний склад. Очень срочно! Нужно еще вчера...', kit.date('H:i:s')); kit.service.toast.info('Новая заявка', 'Заявка от Пупкина на дальний склад. Очень срочно! Нужно еще вчера...', kit.date('H:i:s'));
//stop();
}, 5000); }, 5000);
@@ -45,23 +44,3 @@ $APPLICATION->ShowHead();
<div class="kit-wrapper"> <div class="kit-wrapper">
<div class="kit-logger"></div> <div class="kit-logger"></div>
</div> </div>
<style>
img, svg {
vertical-align: middle;
}
.me-2 {
margin-right: 0.5rem !important;
}
.rounded {
border-radius: 0.25rem !important;
}
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
</style>
<?
?>