芝麻web文件管理V1.00
编辑当前文件:/home/disqkgca/aqanet.org/wp-content/plugins/js_composer/modules/ai/assets/dist/module.min.js
!function(o){var l=o("#vc_ui-helper-modal-ai"),e=o("#wpwrap"),a=l.find('[data-vc-ui-element="button-save"]');function r(e){window.vc.showMessage(e,"error",1e4,"#vc_ui-helper-modal-ai .vc_ui-panel-window-inner")}function c(e){o(e.target).closest('[data-vc-ui-element="button-close"]').length&&(l.removeClass("vc_active"),l.off("click",c),l.removeData(),l.find(" .vc_ui-panel-content-container").addClass("vc_ui-hidden"),l.find(" .vc_ui-helper-modal-ai-placeholder").addClass("vc_ui-hidden"),a.hide())}function s(){return window.i18nLocale||window.i18nLocaleSettings}e.on("click",".vc_ui-icon-ai",function(e){var e=o(e.currentTarget),a=e.closest(".vc_shortcode-param"),i=null,n=e.data();a.length&&(i=a.data());var t=n.wpbAiElementType||"textarea",d=n.fieldId||t;l.find(".vc_ui-helper-modal-ai-preloader").length||l.find(".vc_ui-post-settings-header-container").after('
');(function(e,a){e={action:"wpb_ai_get_modal_data",data:{ai_element_type:e,ai_element_id:a},_vcnonce:window.vcAdminNonce};o.ajax({type:"POST",url:window.ajaxurl,data:e}).done(function(e){var a;!0===e.success?(void 0===window.vc.ai_modal_view?window.vc.ai_modal_view=new vc.AiFormView({el:"#vc_ui-helper-modal-ai",data:e.data}):window.vc.ai_modal_view.render(e.data),e.data.tokens_left&&e.data.tokens_total&&(a=s().ai_credit_usage+e.data.tokens_left+" / "+e.data.tokens_total,l.find(".vc-ai-tokens-usage").text(a)),l.find(" .vc_ui-panel-content-container").scrollTop(0),l.find(".vc_ui-helper-modal-ai-preloader").remove(),l.find(" .vc_ui-panel-content-container").removeClass("vc_ui-hidden")):e&&e.data&&e.data[0]&&e.data[0].code&&e.data[0].message?(console.error(e.data[0].message),r(e.data[0].message)):(console.error(s().ai_response_error),r(s().ai_response_error))}).fail(function(e){console.error(s().ai_response_error),_this.resetButton(),r(s().ai_response_error)})})(t,d),i?(t=a.find("."+i.param_type),l.data("element",t),o.each(i,function(e,a){l.data(e,a)})):n.fieldId&&(d=e.closest(".edit_form_line"),a=e.closest(".vc_ui-settings-text-wrapper"),t=e.closest("#postdivrich"),i=null,d.length?i=d.find("#"+n.fieldId):a.length?i=a.siblings("#"+n.fieldId):t.length&&(i=t.find("#"+n.fieldId)),l.data("fieldId",n.fieldId),l.data("element",i));l.addClass("vc_active"),l.on("click",c)})}(window.jQuery); !function(o){window.vc.AiFormView=Backbone.View.extend({events:{"click .vc_ai-generate-button":"generateContent",'change [name="contentType"]':"changeContentType",'input [name="prompt"]':"changePrompt",'click [data-vc-ui-element="button-save"]':"insertContent"},seconds:0,minutes:0,timerInterval:null,isGenerating:!1,maxWaitingCacheInterval:9e5,maxPromptLength:2e3,initialize:function(e){this.toggleModalPromoClass(e.data.type),this.$el.find(".vc_ui-helper-modal-ai-preloader").after(e.data.content),this.setFormElements(),o(".edit-form-info").initializeTooltips()},render:function(e){return this.timerInterval&&this.clearTimer(),this.toggleModalPromoClass(e.type),this.$form.after(e.content),this.$form.remove(),this.setFormElements(),this},setFormElements:function(){this.$form=this.$el.find(".vc_ui-panel-content-container"),this.$generate_button=this.$el.find(".vc_ai-generate-button"),this.$close_button=this.$el.find('[data-vc-ui-element="button-close"]'),this.$insert_button=this.$el.find('[data-vc-ui-element="button-save"]'),this.$generated_content=this.$el.find(".wpb_ai-generated-content"),this.$prompt_field=this.$el.find('[name="prompt"]'),this.$generate_placeholder=this.$el.find(".vc_ui-helper-modal-ai-placeholder"),this.$generate_placeholder_timer=this.$generate_placeholder.find(".vc_ai-timer"),this.initialButtonText=this.$generate_button.text().trim(),this.contentType=this.$el.find('[name="contentType"]').val(),"new_content"!==this.contentType||this.$prompt_field.val().trim()||this.disableButton()},generateContent:function(e){e.preventDefault();var r=this,e=this.$prompt_field.val().split(" "),e=(this.maxPromptLength
this.maxPromptLength&&(e.target.value=t.slice(0,this.maxPromptLength).join(" "))},showErrorMessage:function(e){window.vc.showMessage(e,"error",1e4,"#vc_ui-helper-modal-ai .vc_ui-panel-window-inner")},insertContent:function(){var e=this.$el.find(".wpb_ai-generated-content").val();if(!e)return!1;var t,n,a,i=this.$el.data();"textarea_html"===i.param_type||"content"===i.fieldId?(n=(t=i.element).attr("id"),"new_content"===this.contentType&&(e=t.val()+" "+e),(n=window.tinymce.get(n))&&n.setContent(e),t.val(e).trigger("input").trigger("change").trigger("blur")):["textarea","textfield","textarea_raw_html"].includes(i.param_type)?(n=i.element,"new_content"===this.contentType&&(e=n.val()+" "+e),n.val(e).trigger("input").trigger("change").trigger("blur")):i.fieldId&&(["wpb_css_editor","wpb_js_header_editor","wpb_js_footer_editor"].includes(i.fieldId)?(n=(t=window.ace.edit(i.fieldId)).getValue(),a=o(t.container).find("textarea"),t.setValue(e=n+"\n\n"+e),a.trigger("input").trigger("change").trigger("blur")):i.element&&i.element.length&&("new_content"===this.contentType&&(e=i.element.val()+" "+e),i.element.val(e).trigger("input").trigger("change").trigger("blur"))),this.$close_button.click()},toggleModalPromoClass:function(e){"promo"===e?this.$el.addClass("vc_modal-ai-container--promo"):this.$el.removeClass("vc_modal-ai-container--promo")},hideFormFields:function(n){this.$form.find("div[data-optional-form-field]").each(function(){var e=o(this),t=e.attr("data-optional-form-field");n.includes(t)?e.show():e.hide()})},getLocale:function(){return window.i18nLocale||window.i18nLocaleSettings}})}(window.jQuery);