File: /var/www/epamokos.kaunokolegija.lt/wp-content/plugins/lifterlms/assets/js/llms-metaboxes.min.js
!function(p){p(document).ready(function(){"public"===p('input[name="visibility"]:checked').val()&&p("body.post-type-llms_coupon #visibility, body.post-type-llms_voucher #visibility").hide()});function t(){var t=p(this).closest(".llms-collapsible"),e=t.siblings(".llms-collapsible");t.toggleClass("opened").trigger("llms-collapsible-toggled"),t.find(".llms-collapsible-body").slideToggle(400),e.each(function(){p(this).removeClass("opened"),p(this).find(".llms-collapsible-body").slideUp(400)})}p.fn.llmsCollapsible=function(){return this.off("click",".llms-collapsible-header",t).on("click",".llms-collapsible-header",t),this},window.llms=window.llms||{};window.llms.metaboxes=new function(){this.repeaters={metaboxes:this,$repeaters:null,init:function(){var t=this;t.$repeaters=p(".llms-mb-list.repeater"),t.$repeaters.length&&(LLMS.wait_for(function(){return"undefined"!=typeof tinyMCE},function(){t.load(),t.bind()}),p('#post input[type="submit"], #post-preview').on("click",function(){p(this).attr("data-llms-clicked","yes")}),p("#post").on("submit",t.handle_submit))},bind:function(){var n=this;n.$repeaters.each(function(){var a=p(this),l=a.find(".llms-repeater-rows");a.find(".llms-repeater-new-btn").on("click",function(){n.add_row(a,null,!0)}),l.sortable({handle:".llms-drag-handle",items:".llms-repeater-row",start:function(t,e){l.addClass("dragging")},stop:function(t,e){l.removeClass("dragging"),e.item.find("textarea.wp-editor-area").each(function(){var t=p(this).attr("id");tinyMCE.EditorManager.execCommand("mceRemoveEditor",!0,t),tinyMCE.EditorManager.execCommand("mceAddEditor",!0,t)}),n.save(a)}}),a.on("click",".llms-repeater-remove",function(t){t.stopPropagation();t=p(this).closest(".llms-repeater-row");window.confirm(LLMS.l10n.translate("Are you sure you want to delete this row? This cannot be undone."))&&(t.remove(),setTimeout(function(){n.save(a)},1))})})},add_row:function(t,e,a){var l=this,n=t.find(".llms-repeater-rows"),i=t.find(".llms-repeater-model"),s=l.clone_row(i.find(".llms-repeater-row")),i=t.find(".llms-repeater-row").length,i=l.reindex(s,i);e&&p.each(e,function(t,e){var a=s.find('[name^="'+t+'"]');a.hasClass("llms-select2-student")?(p.each(e,function(t,e){a.append('<option value="'+e.key+'" selected="selected">'+e.title+"</option>")}),a.trigger("change")):a.val(e)}),setTimeout(function(){l.bind_row(s)},1),n.append(s),a&&s.find(".llms-collapsible-header").trigger("click"),tinyMCE.EditorManager.execCommand("mceAddEditor",!0,i),t.trigger("llms-new-repeater-row",{$row:s,data:e})},bind_row:function(t){this.bind_row_header(t),t.find(".llms-select2").llmsSelect2({width:"100%"}),t.find(".llms-select2-student").llmsStudentsSelect2(),this.metaboxes.bind_datepickers(t.find(".llms-datepicker")),this.metaboxes.bind_controllers(t.find("[data-is-controller]"))},bind_row_header:function(t){var e=t.find(".llms-repeater-title"),t=t.find(".llms-collapsible-header-title-field");e.attr("data-default",e.text()),t.on("keyup focusout blur",function(){var t=(t=p(this).val())||e.attr("data-default");e.text(t)}).trigger("keyup")},clone_row:function(t){return($ed=t.find(".editor textarea")).length&&tinyMCE.EditorManager.execCommand("mceRemoveEditor",!0,$ed.attr("id")),t.clone()},handle_submit:function(t){var e,a,l,n=p('#post [data-llms-clicked="yes"]'),i=n.parent().find(".spinner");n.is("#post-preview")?n.removeAttr("data-llms-clicked"):(t.preventDefault(),p('#post input[type="submit"]').addClass("disabled").attr("disabled","disabled"),i.addClass("is-active"),e=window.llms.metaboxes.repeaters,a=0,e.$repeaters.each(function(){e.save(p(this))}),l=setInterval(function(){59<=a||!p(".llms-mb-list.repeater.processing").length?(clearInterval(l),p("#post").off("submit",this.handle_submit),i.removeClass("is-active"),n.removeClass("disabled").removeAttr("disabled").trigger("click")):a++},1e3))},load:function(){var l=this;l.$repeaters.each(function(){var a=p(this);a.hasClass("is-loaded")||a.hasClass("processing")||l.store(a,"load",function(t){a.addClass("is-loaded"),p.each(t.data,function(t,e){l.add_row(a,e,!1)}),a.find(".llms-repeater-rows .llms-repeater-row").each(function(){l.bind_row(p(this))})})})},reindex:function(t,a){var l=t.attr("data-row-order"),e=t.find(".llms-mb-list.editor textarea");function n(t,e){t.each(function(){var t=p(this).attr(e);p(this).attr(e,t.replace(l,a))})}return tinyMCE.EditorManager.execCommand("mceRemoveEditor",!0,e.attr("id")),t.attr("data-row-order",a),n(t,"data-row-order"),n(t.find("button.insert-media"),"data-editor"),n(t.find('input[name^="_llms"], textarea[name^="_llms"], select[name^="_llms"]'),"id"),n(t.find('input[name^="_llms"], textarea[name^="_llms"], select[name^="_llms"]'),"name"),n(t.find("[data-controller]"),"data-controller"),n(t.find("[data-controller]"),"data-controller"),n(t.find("button.wp-switch-editor"),"data-wp-editor-id"),n(t.find("button.wp-switch-editor"),"id"),n(t.find(".wp-editor-tools"),"id"),n(t.find(".wp-editor-container"),"id"),e.attr("id")},save:function(t){t.trigger("llms-repeater-before-save",{$el:t}),this.store(t,"save")},serialize:function(t){var a=[];return t.find(".llms-repeater-rows .llms-repeater-row").each(function(){var e={};p(this).find('input[name^="_llms"], select[name^="_llms"]').each(function(){e[p(this).attr("name")]=p(this).val()}),p(this).find('textarea[name^="_llms"]').each(function(){var t=p(this).attr("name");tinyMCE.editors[t]?e[t]=tinyMCE.editors[t].getContent():e[t]=p(this).val()}),a.push(e)}),a},store:function(e,t,a){a=a||function(){};var l={action:e.find(".llms-repeater-field-handler").val(),store_action:t};"save"===t&&(l.rows=this.serialize(e)),LLMS.Ajax.call({data:l,beforeSend:function(){e.addClass("processing"),LLMS.Spinner.start(e)},success:function(t){a(t),LLMS.Spinner.stop(e),e.removeClass("processing")}})}},this.repeaters.init(),this.init=function(){var l=this,t=(p(".llms-select2-post").each(function(){l.post_select(p(this))}),p(".llms-collapsible-group").llmsCollapsible(),this.bind_tabs(),this.bind_mce_fixes(),[{selector:p(".llms-datepicker"),func:"bind_datepickers"},{selector:p(".llms-select2"),func:function(t){t.llmsSelect2({width:"100%"})}},{selector:p(".llms-select2-student"),func:function(t){t.llmsStudentsSelect2()}},{selector:p('input[type="checkbox"][data-controls]'),func:"bind_cb_controllers"},{selector:p("[data-is-controller]"),func:"bind_controllers"},{selector:p(".llms-table"),func:"bind_tables"},{selector:p(".llms-merge-code-wrapper"),func:"bind_merge_code_buttons"},{selector:p("a.llms-editable, button.llms-editable"),func:"bind_editables"}]);p.each(t,function(t,e){var a;e.selector.length&&(a=e.selector.filter(function(){return 0===p(this).closest(".llms-repeater-model").length}),"string"==typeof e.func?l[e.func](a):"function"==typeof e.func&&e.func(a))}),window.llms.post.post_type&&"function"==typeof this[t="bind_"+window.llms.post.post_type]&&this[t]()},this.bind_cb_controllers=function(t){(t=t||p('input[type="checkbox"][data-controls]')).each(function(){var t=p(this),e=p(t.attr("data-controls")).closest(".llms-mb-list");t.on("change",function(){p(this).is(":checked")?e.slideDown(200):e.slideUp(200)}),t.trigger("change")})},this.bind_controllers=function(t){(t=t||p("[data-is-controller]")).each(function(){var a,t=p(this),e=p('[data-controller="#'+t.attr("id")+'"]');t.on("change",function(){a="checkbox"!==t.attr("type")||t.is(":checked")?t.val():"false",e.each(function(){var t=p(this).attr("data-controller-value"),e=[];-1!==t.indexOf(",")?e=t.split(","):e.push(t),-1!==e.indexOf(a)?p(this).slideDown(200):p(this).slideUp(200)})}),t.trigger("change")})},this.bind_datepicker=function(t){var e=t.attr("data-format")||"mm/dd/yy",a=t.attr("data-alt-format")||"",l=t.attr("data-alt-field")||"",n=t.attr("data-max-date")||null,i=t.attr("data-min-date")||null;t.datepicker({dateFormat:e,maxDate:n,minDate:i,altField:l,altFormat:a}).on("keyup",function(){var t;try{t=p.datepicker.parseDate(p.datepicker._defaults.dateFormat,this.value)}catch(t){}!t&&0<l.length&&/^#[A-Za-z0-9\-_]+$/.test(l)&&p(l).val("")})},this.bind_datepickers=function(t){var e=this;(t=t||p(".llms-datepicker")).each(function(){e.bind_datepicker(p(this))})},this.bind_editables=function(){var u=this;p("a.llms-editable, button.llms-editable").on("click",function(t){t.preventDefault();var t=p(this),e=t.attr("data-fields")?p(t.attr("data-fields")):t.closest(".llms-metabox-section").find("[data-llms-editable]");t.remove(),e.each(function(){var t,e,a,l=p(this),n=l.find("label").clone(),i=l.attr("data-llms-editable"),s=l.attr("data-llms-editable-type"),r=l.attr("data-llms-editable-required")||"no",o=l.attr("data-llms-editable-value"),r="yes"===r?' required="required"':"";if("select"===s){var d,c=JSON.parse(l.attr("data-llms-editable-options")),m=p('<select name="'+i+'"'+r+" />");for(d in c)m.append('<option value="'+d+'"'+(o===d?' selected="selected"':"")+">"+c[d]+"</option>")}else"datetime"===s?(m=p('<div class="llms-datetime-field" />'),o=JSON.parse(o),t=l.attr("data-llms-editable-date-format")||"",e=l.attr("data-llms-editable-date-min")||"",a=l.attr("data-llms-editable-date-max")||"",$picker=p('<input class="llms-date-input llms-datepicker" data-format="'+t+'" data-max-date="'+a+'" data-min-date="'+e+'" name="'+i+'[date]" type="text" value="'+o.date+'">'),u.bind_datepicker($picker),m.append($picker),m.append("<em>@</em>"),m.append('<input class="llms-time-input" max="23" min="0" name="'+i+'[hour]" type="number" value="'+o.hour+'">'),m.append("<em>:</em>"),m.append('<input class="llms-time-input" max="59" min="0" name="'+i+'[minute]" type="number" value="'+o.minute+'">')):m=p('<input name="'+i+'" type="'+s+'" value="'+o+'"'+r+">");l.empty().append(n).append(m),"select"===s&&setTimeout(function(){m.trigger("change")},100)})})},this.bind_llms_engagement=function(){var n=this;p("#_llms_engagement_type").on("change",function(){p("#_llms_engagement").trigger("llms-engagement-type-change",p(this).val())}),p("#_llms_engagement").on("llms-engagement-type-change",function(t,e){var a=p(this);switch(e){case"achievement":case"certificate":case"email":var l="llms_"+e;a.val(null).attr("data-post-type",l).trigger("change"),n.post_select(a);break;default:a.trigger("llms-engagement-type-change-external",e)}})},this.bind_course=function(){wp?.data&&"function"==typeof wp.data.dispatch&&null!==wp.data.dispatch("core/editor")&&"function"==typeof wp.data.dispatch("core/editor").editPost&&p("#_llms_length").on("input change",function(t){wp.data.dispatch("core/editor").editPost({meta:{_llms_length:t.target.value}})})},this.bind_llms_membership=function(){var e=p(".llms-mb-list._llms_content_table");function l(){var t=e.find("tbody tr");1===t.length?t.first().show():t.first().hide()}function n(){var t=[];return e.find('tbody tr a[href="#llms-course-remove"]').each(function(){t.push(p(this).attr("data-id"))}),t}l(),e.on("click",'a[href="#llms-course-remove"]',function(t){t.preventDefault();var t=p(this),e=t.closest("tr"),a=t.closest(".llms-mb-list");LLMS.Spinner.start(a),window.LLMS.Ajax.call({data:{action:"membership_remove_auto_enroll_course",course_id:t.attr("data-id")},beforeSend:function(){a.find("p.error").remove()},success:function(t){t.success?(e.fadeOut(200),setTimeout(function(){e.remove(),l()},400)):a.prepend('<p class="error">'+t.message+"</p>"),LLMS.Spinner.stop(a)}})}),e.on("click",'a[href="#llms-course-bulk-enroll"]',function(t){t.preventDefault();var e=p(this),a=(e.closest("tr"),e.closest(".llms-mb-list"));window.confirm(LLMS.l10n.translate("Click okay to enroll all active members into the selected course. Enrollment will take place in the background and you may leave your site after confirmation. This action cannot be undone!"))&&(LLMS.Spinner.start(a),window.LLMS.Ajax.call({data:{action:"bulk_enroll_membership_into_course",course_id:e.attr("data-id")},beforeSend:function(){a.find("p.error").remove()},success:function(t){t.success?e.replaceWith('<strong style="float:right;">'+t.data.message+" </strong>"):a.prepend('<p class="error">'+t.message+"</p>"),LLMS.Spinner.stop(a)}}))}),p("#_llms_auto_enroll").on("change",function(){var t,e=p(this).val(),a=p(this).find('option[value="'+p(this).val()+'"]').text();e&&(-1!==n().indexOf(e)?(alert(LLMS.l10n.replace('"%s" is already in the course list.',{"%s":a})),p(this).val("").trigger("change")):(t=p(".llms-mb-list._llms_content_table"),($tr=p("<tr />")).append('<td><span class="dashicons dashicons-menu llms-drag-handle ui-sortable-handle"></span></td>'),$tr.append('<td><a href="'+window.llms.admin_url+"post.php?action=edit&post="+e+'">'+a+"</a></td>"),$tr.append('<td><a class="llms-button-danger small" data-id="'+e+'" href="#llms-course-remove" style="float:right;">'+LLMS.l10n.translate("Remove course")+'</a><a class="llms-button-secondary small" data-id="'+e+'" href="#llms-course-bulk-enroll" style="float:right;margin-right:5px;">'+LLMS.l10n.translate("Enroll All Members")+"</a></td>"),t.find("table tbody").append($tr),p(this).val("").trigger("change"),l(),t.trigger("llms-save-autoenroll-courses")))}),e.find("table tbody").sortable({handle:".llms-drag-handle",stop:function(t,e){e.item.closest(".llms-mb-list").trigger("llms-save-autoenroll-courses")}}),e.on("llms-save-autoenroll-courses",function(){var t=p(this);LLMS.Spinner.start(t),window.LLMS.Ajax.call({data:{action:"llms_save_membership_autoenroll_courses",courses:n()},error:function(t,e,a){alert(a)},complete:function(){LLMS.Spinner.stop(t)}})})},this.bind_llms_order=function(){p('button[name="llms-refund-toggle"]').on("click",function(){var t=p(this),e=t.closest("tr"),a=e.attr("data-transaction-id"),l=t.attr("data-refundable"),n="1"===t.attr("data-gateway-supports"),i=t.attr("data-gateway"),s=p("#llms-txn-refund-model .llms-txn-refund-form").clone(),r=s.find(".gateway-btn");"remove"!==t.attr("data-action")?(t.text(LLMS.l10n.translate("Cancel")),t.attr("data-action","remove"),s.find("input").removeAttr("disabled"),s.find('input[name="llms_refund_amount"]').attr("max",l),s.find('input[name="llms_refund_txn_id"]').val(a),n&&(r.find(".llms-gateway-title").text(i),r.show()),e.after(s)):(t.text(LLMS.l10n.translate("Refund")),t.attr("data-action",""),e.next("tr").remove())}),p('button[name="llms-manual-txn-toggle"]').on("click",function(){var t=p(this),e=t.closest("tr"),a=p("#llms-manual-txn-model .llms-manual-txn-form").clone();"remove"!==t.attr("data-action")?(t.text(LLMS.l10n.translate("Cancel")),t.attr("data-action","remove"),a.find("input").removeAttr("disabled"),e.after(a)):(t.text(LLMS.l10n.translate("Record a Manual Payment")),t.attr("data-action",""),e.next("tr").remove())}),p(".llms-metabox").one("focus",'.llms-metabox-field[data-llms-editable="payment_gateway"] select',function(){p(this).attr("data-original-value")||p(this).attr("data-original-value",p(this).val())}),p(".llms-metabox").on("change",'.llms-metabox-field[data-llms-editable="payment_gateway"] select',function(){var t,e=p(this),a=e.val(),l=JSON.parse(e.closest(".llms-metabox-field").attr("data-gateway-fields"))[a];for(t in l){var n=p('input[name="'+l[t].name+'"]'),i=n.closest(".llms-metabox-field");l[t].enabled?(i.show(),n.attr("required","required"),n.removeAttr("disabled"),a===e.attr("data-original-value")&&n.val(i.attr("data-llms-editable-value"))):(n.attr("value",""),n.removeAttr("required"),i.hide())}})},this.bind_mce_fixes=function(){void 0===wp.data||[null,void 0].includes(wp.data.select("core/edit-post"))||LLMS.wait_for(function(){return void 0!==wp.data.select("core/edit-post").getMetaBoxesPerLocation("normal")},function(){var t=!1;for(e in find=["lifterlms-product","lifterlms-membership","lifterlms-course-options"],metaboxes=wp.data.select("core/edit-post").getMetaBoxesPerLocation("normal"))if(-1!==find.indexOf(metaboxes[e].id)){t=!0;break}if(t){var e,a,l={};for(e in tinyMCE.EditorManager.editors)"excerpt"!==(a=e)&&-1===a.indexOf("llms")&&-1===a.indexOf("lifterlms")||(l[e]=tinyMCE.EditorManager.get(e),tinyMCE.EditorManager.execCommand("mceRemoveEditor",!0,e));setTimeout(function(){for(var t in l)tinyMCE.EditorManager.init(l[t].settings||tinyMCE.EditorManager.settings)},500)}})},this.bind_merge_code_buttons=function(t){(t=t||p(".llms-merge-code-wrapper")).find(".llms-merge-code-button").on("click",function(){p(this).next(".llms-merge-codes").toggleClass("active")}),t.find(".llms-merge-codes li").on("click",function(){var t,e=p(this),a=e.closest(".llms-merge-codes"),l=a.attr("data-target"),e=e.attr("data-code");-1===l.indexOf("#")?(t=window.tinymce.editors[l])?t.insertContent(e):alert(LLMS.l10n.translate("Copy this code and paste it into the desired area")+": "+e):p(l).val(p(l).val()+e),a.removeClass("active")})},this.bind_tabs=function(){p(".llms-nav-tab-wrapper .tabs li").on("click",function(){var t=p(this),e=t.closest(".llms-mb-container"),a=t.attr("data-tab");t.siblings().removeClass("llms-active"),e.find(".tab-content").removeClass("llms-active"),t.addClass("llms-active"),p("#"+a).addClass("llms-active")})},this.post_select=function(t){var e,a="multiple"===t.attr("multiple"),l=t.attr("data-no-view-button"),n=t.attr("data-edit-button");t.llmsPostsSelect2({width:a||l?"100%":"65%"}),a||l||((e=t.next(".select2").next("a.llms-button-secondary")).length||(a=n?LLMS.l10n.translate("Edit"):LLMS.l10n.translate("View"),e=p('<a class="llms-button-secondary small" style="margin-left:5px;" target="_blank" href="#">'+a+' <i class="fa fa-external-link" aria-hidden="true"></i></a>'),t.next(".select2").after(e),t.on("change",function(){var t=p(this).val();t?(n?e.attr("href",window.llms.admin_url+"post.php?action=edit&post="+parseInt(t)):e.attr("href",window.llms.home_url+"/?p="+parseInt(t))).show():e.hide()})),t.trigger("change"))},this.bind_tables=function(){p('.llms-table button[name="llms-expand-table"]').on("click",function(){var t,e=p(this),a=e.closest(".llms-table");e.attr("data-text")&&(t=e.text(),e.text(e.attr("data-text")),e.attr("data-text",t)),a.find(".expandable").each(function(){p(this).hasClass("closed")?p(this).addClass("opened").removeClass("closed"):p(this).addClass("closed").removeClass("opened")})})},this.init()}}(jQuery);
//# sourceMappingURL=../maps/js/llms-metaboxes.min.js.map