%PDF- %PDF-
Direktori : /var/www/projetos/suporte.iigd.com.br/js/ |
Current File : //var/www/projetos/suporte.iigd.com.br/js/flatpickr_buttons_plugin.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/>. * * --------------------------------------------------------------------- */ window.CustomFlatpickrButtons=(t={})=>e=>{let n;if(t.buttons===undefined){t.buttons=[{label:e.config.enableTime?__("Now"):__("Today"),attributes:{class:"btn btn-outline-secondary"},onClick:(t,e)=>{e.setDate(new Date)}}]}return{onReady:()=>{n=`<div class="flatpickr-custom-buttons pb-1 text-start"><div class="buttons-container">`;t.buttons.forEach(((t,s)=>{const o=document.createElement("button");o.type="button";o.classList.add("ms-2");o.innerHTML=t.label;o.setAttribute("btn-id",s);if(typeof t.attributes!=="undefined"){Object.keys(t.attributes).forEach((e=>{if(e==="class"){o.classList.add(...t.attributes[e].split(" "));return}o.setAttribute(e,t.attributes[e])}))}n+=o.outerHTML;e.pluginElements.push(o)}));n+="</div></div>";e.calendarContainer.appendChild($.parseHTML(n)[0]);$(e.calendarContainer).on("click",".flatpickr-custom-buttons button",(n=>{n.stopPropagation();n.preventDefault();const s=$(n.target);const o=s.attr("btn-id");const a=t.buttons[o].onClick;if(typeof a!=="function"){return}a(n,e)}))},onDestroy:()=>{$(n).remove()}}};