awsmug/torro-forms

View on GitHub
assets/dist/js/admin-email-notifications.min.js

Summary

Maintainability
A
0 mins
Test Coverage
/*!
 * Torro Forms Version 1.0.8 (https://torro-forms.com)
 * Licensed under GNU General Public License v2 (or later) (http://www.gnu.org/licenses/gpl-2.0.html)
 */
!function(e,t,a,l){"use strict";function i(e,t){var a=l.templateTagSlug.replace("%element_id%",e.get("id")),i=l.templateTagGroup,n=t.find(".template-tag-"+a);n&&(n.remove(),t.find(".template-tag-list-group-"+i+" > ul > li").length||t.find(".template-tag-list-group-"+i).remove())}function n(e,t){var i={slug:l.templateTagSlug.replace("%element_id%",e.get("id")),group:l.templateTagGroup,label:l.templateTagLabel.replace("%element_label%",e.get("label")),description:l.templateTagDescription.replace("%element_label%",e.get("label"))},n={slug:l.templateTagGroup,label:l.templateTagGroupLabel},p=a(l.templateTagTemplate.replace(/%slug%/g,i.slug).replace(/%group%/g,i.group).replace(/%label%/g,i.label).replace(/%description%/g,i.description)),o=t.find(".template-tag-list-group-"+i.group+" > ul");o.length||(o=a(l.templateTagGroupTemplate.replace(/%slug%/g,n.slug).replace(/%label%/g,n.label)),t.append(o),o=o.children("ul")),o.append(p),e.on("change:label",function(e,t){var a=l.templateTagLabel.replace("%element_label%",t);p.html(p.html().replace(i.label,a)),i.label=a})}function p(e,t){var a,l=t.parents(".template-tag-list-wrap").prev('input[type="email"]');l.length?(a=e.element_settings.findWhere({name:"input_type"}),a&&("email_address"===a.get("value")&&n(e,t),a.on("change:value",function(a,l){"email_address"===l?n(e,t):i(e,t)}))):n(e,t)}var o=e.Builder.getInstance(),g={};o.on("addElement",function(e){g[e.get("id")]=e,a(".plugin-lib-repeatable-group-email_notifications__notifications-wrap .template-tag-list").each(function(){p(e,a(this))})}),o.on("removeElement",function(e){g[e.get("id")]&&delete g[e.get("id")],a(".plugin-lib-repeatable-group-email_notifications__notifications-wrap .template-tag-list").each(function(){i(e,a(this))})}),a(document).ready(function(){var e,l=a("#torro_module_actions-field-manager-instance");l&&(l=l.val(),e=t.FieldManager.instances[l].get(l+"_email-notifications--notifications"),e&&e.on("addItem",function(e,t){a("#"+t.id+" .template-tag-list").each(function(){var e,t=Object.keys(g);for(e=0;e<t.length;e++)p(g[t[e]],a(this))})}))})}(window.torro,window.pluginLibFieldsAPI,window.jQuery,window.torroEmailNotifications);