%PDF- %PDF-
Direktori : /var/www/projetos/suporte.iigd.com.br/js/ |
Current File : //var/www/projetos/suporte.iigd.com.br/js/glpi_dialog.min.js |
/** * --------------------------------------------------------------------- * * GLPI - Gestionnaire Libre de Parc Informatique * * http://glpi-project.org * * @copyright 2015-2024 Teclib' and contributors. * @copyright 2003-2014 by the INDEPNET Development Team. * @licence https://www.gnu.org/licenses/gpl-3.0.html * * --------------------------------------------------------------------- * * LICENSE * * This file is part of GLPI. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. * * --------------------------------------------------------------------- */ var glpi_html_dialog=function({title:t="",body:a="",footer:o="",modalclass:n="",dialogclass:s="",id:i="modal_"+Math.random().toString(36).substring(7),appendTo:l="body",autoShow:e=true,show:d=(()=>{}),close:r=(()=>{}),buttons:c=[],bs_focus:_=true}={}){if(c.length>0){var m="";c.forEach((t=>{var a="id"in t?t.id:"button_"+Math.random().toString(36).substring(7);var o="label"in t?t.label:__("OK");var n="class"in t?t.class:"btn-secondary";m+=`\n <button type="button" id="${a}"\n class="btn ${n}" data-bs-dismiss="modal">\n ${o}\n </button>`;if("click"in t){$(document).on("click","#"+a,(function(a){t.click(a)}))}}));o+=m}if(o.length>0){o=`<div class="modal-footer">\n ${o}\n </div>`}const b=!_?'data-bs-focus="false"':"";var u=`<div class="modal fade ${n}" id="${i}" role="dialog" ${b}>\n <div class="modal-dialog ${s}">\n <div class="modal-content">\n <div class="modal-header">\n <h4 class="modal-title">${t}</h4>\n <button type="button" class="btn-close" data-bs-dismiss="modal"\n aria-label="${__("Close")}"></button>\n </div>\n <div class="modal-body">${a}</div>\n ${o}\n </div>\n </div>\n </div>`;glpi_close_all_dialogs();$(l).append(u);var g=document.getElementById(i);var f=new bootstrap.Modal(g,{});if(e){f.show()}g.addEventListener("shown.bs.modal",(function(t){$("#"+i).find("input, textearea, select").first().trigger("focus");d(t)}));g.addEventListener("hidden.bs.modal",(function(t){r(t);if($("div.modal.show").length===0){$("div.modal-backdrop").remove()}$("#"+i).remove()}));return i};var glpi_ajax_dialog=function({url:t="",params:a={},method:o="post",title:n="",footer:s="",modalclass:i="",dialogclass:l="",id:e="modal_"+Math.random().toString(36).substring(7),appendTo:d="body",autoShow:r=true,done:c=(()=>{}),fail:_=(()=>{}),show:m=(()=>{}),close:b=(()=>{}),buttons:u=[],bs_focus:g=true}={}){if(t.length==0){return}glpi_close_all_dialogs();$.ajax({url:t,type:o,data:a,success:function(t){glpi_html_dialog({title:n,body:t,footer:s,id:e,appendTo:d,modalclass:i,dialogclass:l,autoShow:r,buttons:u,show:m,close:b,bs_focus:g})}}).done((function(t){c(t)})).fail((function(t,a){_(t,a)}));return e};var glpi_alert=function({title:t=_n("Information","Information",1),message:a="",id:o="modal_"+Math.random().toString(36).substring(7),ok_callback:n=(()=>{})}={}){glpi_html_dialog({title:t,body:a,id:o,buttons:[{label:__("OK"),click:function(t){n(t)}}]});return o};var glpi_confirm=function({title:t=_n("Information","Information",1),message:a="",id:o="modal_"+Math.random().toString(36).substring(7),confirm_callback:n=(()=>{}),confirm_label:s=_x("button","Confirm"),cancel_callback:i=(()=>{}),cancel_label:l=_x("button","Cancel")}={}){glpi_html_dialog({title:t,body:a,id:o,buttons:[{label:s,click:function(t){n(t)}},{label:l,click:function(t){i(t)}}]});return o};var glpi_close_all_dialogs=function(){$(".modal.show").modal("hide").remove()};var toast_id=0;const glpi_toast=(t,a,o,n={})=>{toast_id++;n=Object.assign({delay:1e4,animated:true,animation:"animate__tada",animation_extra_classes:"animate__delay-2s animate__slow"},n);const s=n.animated?`animate__animated ${n.animation} ${n.animation_extra_classes}`:"";const i=`<div class='toast-container bottom-0 end-0 p-3 messages_after_redirect'>\n <div id='toast_js_${toast_id}' class='toast ${s}' role='alert' aria-live='assertive' aria-atomic='true'>\n <div class='toast-header ${o}'>\n <strong class='me-auto'>${t}</strong>\n <button type='button' class='btn-close' data-bs-dismiss='toast' aria-label='${__("Close")}'></button>\n </div>\n <div class='toast-body'>\n ${a}\n </div>\n </div>\n </div>`;$("body").append(i);const l=new bootstrap.Toast(document.querySelector("#toast_js_"+toast_id),{delay:n.delay});l.show()};const glpi_toast_success=(t,a,o={})=>{glpi_toast(a||__("Success"),t,"bg-success text-white border-0",o)};const glpi_toast_info=function(t,a,o={}){glpi_toast(a||_n("Information","Informations",1),t,"bg-info text-white border-0",o)};const glpi_toast_warning=(t,a,o={})=>{glpi_toast(a||__("Warning"),t,"bg-warning text-white border-0",o)};const glpi_toast_error=(t,a,o={})=>{glpi_toast(a||__("Error"),t,"bg-danger text-white border-0",o)};