@@ -1501,8 +1501,9 @@ var Hm_Utils = {
15011501 * Shows pending messages added with the add_sys_message method
15021502 */
15031503 show_sys_messages : function ( ) {
1504- hm_msg . forEach ( ( v , k ) => {
1505- alert . createAlert ( v , k ) ;
1504+ const hm_alert = new Hm_Alert ( ) ;
1505+ hm_msgs . forEach ( ( msg ) => {
1506+ hm_alert . createAlert ( msg . text , msg . type ) ;
15061507 } ) ;
15071508 } ,
15081509
@@ -1515,9 +1516,8 @@ var Hm_Utils = {
15151516 if ( ! msg ) {
15161517 return ;
15171518 }
1518- const icon = type == 'success' ? 'bi-check-circle' : 'bi-exclamation-circle' ;
1519- $ ( '.sys_messages' ) . append ( '<div class="alert alert-' + type + ' alert-dismissible fade show" role="alert"><i class="bi ' + icon + ' me-2"></i><span class="' + type + '">' + msg + '</span><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>' ) ;
1520- this . show_sys_messages ( ) ;
1519+ const hm_alert = new Hm_Alert ( ) ;
1520+ hm_alert . createAlert ( msg , type ) ;
15211521 } ,
15221522
15231523 clear_sys_messages : function ( ) {
@@ -1838,9 +1838,6 @@ $(function() {
18381838 /* fire up the job scheduler */
18391839 Hm_Timer . fire ( ) ;
18401840
1841- /* Use this to create alerts */
1842- var alert = new Hm_Alert ( ) ;
1843-
18441841 /* show any pending notices */
18451842 Hm_Utils . show_sys_messages ( ) ;
18461843
@@ -2425,8 +2422,9 @@ class Hm_Alert {
24252422 * @param {string } message - The message to display.
24262423 * @param {string } type - The type of alert (primary, secondary, success, danger, warning, info).
24272424 * @param {boolean } dismissible - Whether the alert can be dismissed.
2425+ * @param {integer } dismissTime - Number of seconds before alert auto-closes
24282426 */
2429- createAlert ( message , type = 'primary' , dismissible = true ) {
2427+ createAlert ( message , type = 'primary' , dismissible = true , dismissTime = 10 ) {
24302428 if ( ! this . container ) {
24312429 return ;
24322430 }
@@ -2442,7 +2440,7 @@ class Hm_Alert {
24422440 iconContainer . appendChild ( icon ) ;
24432441
24442442 const messageElement = document . createElement ( 'div' ) ;
2445- messageElement . className = 'flex-grow-1 pe-2 ' ;
2443+ messageElement . className = 'flex-grow-1 pe-4 ' ;
24462444 messageElement . textContent = message ;
24472445
24482446 alert . appendChild ( iconContainer ) ;
@@ -2460,15 +2458,16 @@ class Hm_Alert {
24602458
24612459 this . container . appendChild ( alert ) ;
24622460
2463- // Auto close after 10 seconds with animation
2461+ dismissTime *= 1000 ;
2462+ // Auto close with animation
24642463 setTimeout ( ( ) => {
24652464 alert . style . opacity = '0' ;
24662465 alert . style . transform = 'translateY(-20px)' ;
24672466 setTimeout ( ( ) => {
24682467 const bsAlert = new bootstrap . Alert ( alert ) ;
24692468 bsAlert . close ( ) ;
24702469 } , 500 ) ;
2471- } , 10000 ) ;
2470+ } , dismissTime ) ;
24722471 }
24732472
24742473 toggleVisibility ( ) {
0 commit comments