%PDF- %PDF-
Direktori : /home/tradesc/www/relax/wp-content/plugins/wpforms-lite/assets/js/admin/builder/ |
Current File : /home/tradesc/www/relax/wp-content/plugins/wpforms-lite/assets/js/admin/builder/help.min.js |
"use strict";var WPForms=window.WPForms||{};WPForms.Admin=WPForms.Admin||{},WPForms.Admin.Builder=WPForms.Admin.Builder||{},WPForms.Admin.Builder.Help=WPForms.Admin.Builder.Help||function(l){var n,p={init:function(){l(p.ready)},ready:function(){p.setup(),p.initCategories(),p.events()},setup:function(){n={$builder:l("#wpforms-builder"),$builderForm:l("#wpforms-builder-form"),$helpBtn:l("#wpforms-help"),$help:l("#wpforms-builder-help"),$closeBtn:l("#wpforms-builder-help-close"),$search:l("#wpforms-builder-help-search"),$result:l("#wpforms-builder-help-result"),$noResult:l("#wpforms-builder-help-no-result"),$categories:l("#wpforms-builder-help-categories"),$footer:l("#wpforms-builder-help-footer")}},events:function(){n.$helpBtn.on("click",a.openHelp),n.$closeBtn.on("click",a.closeHelp),n.$categories.on("click",".wpforms-builder-help-category header",a.toggleCategory),n.$categories.on("click",".wpforms-builder-help-category button.viewall",a.viewAllCategoryDocs),n.$search.on("keyup","input",_.debounce(a.inputSearch,250)),n.$search.on("click","#wpforms-builder-help-search-clear",a.clearSearch)},initCategories:function(){var e,r;wpf.empty(wpforms_builder_help.docs)?n.$categories.html(wp.template("wpforms-builder-help-categories-error")):(e=wp.template("wpforms-builder-help-categories"),r={categories:wpforms_builder_help.categories,docs:p.getDocsByCategories()},n.$categories.html(e(r)))},getDocsByCategories:function(){var e=wpforms_builder_help.categories,o=wpforms_builder_help.docs||[],i={};return _.each(e,function(e,r){var t=[];_.each(o,function(e){e.categories&&-1<e.categories.indexOf(r)&&t.push(e)}),i[r]=t}),i},getRecommendedDocs:function(e){if(wpf.empty(e))return[];e=e.toLowerCase();var r=wpforms_builder_help.docs,t=[];return wpf.empty(wpforms_builder_help.context.docs[e])?[]:(_.each(wpforms_builder_help.context.docs[e],function(e){wpf.empty(r[e])||t.push(r[e])}),t)},getFilteredDocs:function(r){var e,t;return wpf.empty(r)?[]:(e=wpforms_builder_help.docs,t=[],r=r.toLowerCase(),_.each(e,function(e){e.title&&-1<e.title.toLowerCase().indexOf(r)&&t.push(e)}),t)},getBuilderContext:function(){if(wpf.empty(n.$builderForm.data("id")))return"new_form";var e=n.$builder.find("#wpforms-panels-toggle button.active").data("panel"),r=n.$builder.find("#wpforms-panel-"+e),t="",o="";switch(e){case"fields":t=r.find(".wpforms-panel-sidebar .wpforms-tab a.active").parent().attr("id");break;case"setup":t="";break;default:t=r.find(".wpforms-panel-sidebar a.active").data("section")}return[e,t=wpf.empty(t)?"":t.replace(/-/g,"_"),o="field_options"===t?r.find("#wpforms-field-options .wpforms-field-option:visible .wpforms-field-option-hidden-type").val():o].filter(function(e){return!wpf.empty(e)&&"default"!==e}).join("/")},getBuilderContextTerm:function(){return wpforms_builder_help.context.terms[p.getBuilderContext()]||""}},o={config:{speed:300},fadeIn:function(e){e.length&&(e.css({display:"",transition:`opacity ${o.config.speed}ms ease-in 0s`}),setTimeout(function(){e.css("opacity","1")},0))},fadeOut:function(e){e.length&&(e.css({opacity:"0",transition:`opacity ${o.config.speed}ms ease-in 0s`}),setTimeout(function(){e.css("display","none")},o.config.speed))},collapseAllCategories:function(){n.$categories.find(".wpforms-builder-help-category").removeClass("opened"),n.$categories.find(".wpforms-builder-help-docs").slideUp()}},a={openHelp:function(e){e.preventDefault();var e=n.$categories.find(".wpforms-builder-help-category").first(),r=p.getBuilderContextTerm();""!==r||e.hasClass("opened")?o.collapseAllCategories():e.find("header").first().trigger("click"),n.$search.find("input").val(r).trigger("keyup"),o.fadeIn(n.$help),setTimeout(function(){o.fadeIn(n.$result),o.fadeIn(n.$categories),o.fadeIn(n.$footer)},o.config.speed)},closeHelp:function(e){e.preventDefault(),o.fadeOut(n.$result),o.fadeOut(n.$categories),o.fadeOut(n.$footer),o.fadeOut(n.$help)},toggleCategory:function(e){var r=l(this).parent(),t=r.find(".wpforms-builder-help-docs");t.is(":visible")?r.removeClass("opened"):r.addClass("opened"),t.stop().slideToggle(o.config.speed)},viewAllCategoryDocs:function(e){var r=l(this);r.prev("div").stop().slideToggle(o.config.speed,function(){r.closest(".wpforms-builder-help-category").addClass("viewall")}),o.fadeOut(r),r.slideUp()},inputSearch:function(e){var r=l(this).val(),t=wp.template("wpforms-builder-help-docs"),o=p.getRecommendedDocs(r),i=a.removeDuplicates(o,p.getFilteredDocs(r)),s="";n.$search.toggleClass("wpforms-empty",!r),wpf.empty(o)||(s+=t({docs:o})),wpf.empty(i)||(s+=t({docs:i})),n.$noResult.toggle(""===s&&""!==r),n.$result.html(s),n.$help[0].scrollTop=0},removeDuplicates:function(e,r){if(wpf.empty(e)||wpf.empty(r))return r;for(var t=[],o=0;e.length,o++;)for(var i=0;r.length,i++;)r[i].url!==e[o].url&&t.push(r[i]);return t},clearSearch:function(e){n.$search.find("input").val("").trigger("keyup")}};return p}((document,window,jQuery)),WPForms.Admin.Builder.Help.init();