芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentformpro/public/js/fluentformproPostUpdate.js
(()=>{function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n
1&&void 0!==arguments[1]?arguments[1]:"";t||(t=""),"string"!=typeof t&&(t=t.length>0?t.map((function(e){return e.value?e.value.toString():e.toString()})):t.toString()),e.hasClass("ff_has_multi_select")?e.data("choicesjs")&&(e.data("choicesjs").removeActiveItems(t),e.data("choicesjs").setChoiceByValue(t)):e.val(t)}function o(a){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=!1;"string"!=typeof r&&"number"!=typeof r||("1"===r&&(o=!0),r=r.includes(",")?r.split(","):[r]),"object"!==n(r)||Array.isArray(r)||(r=Object.keys(r));var s=(r=(i=[]).concat.apply(i,e(r))).map((function(e){return e.value?e.value.toString().trim():e.toString().trim()}));a.each((function(e,n){var a=t(n);-1!==t.inArray(a.val(),s)||"on"===a.val()&&o?(a.closest(".ff-el-form-check").addClass("ff_item_selected"),a.prop("checked",!0)):a.prop("checked",!1)}))}function s(e,n,a){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"img";if(Array.isArray(n)&&n.length>0)t.each(n,(function(t,n){s(e,n,a,i)}));else{var r=f(n),o='
'),l=c(e,n,o,i);r&&e.closest(".ff-el-input--content").append('
')),e.closest(".ff-el-input--content").append(l)}}function l(e,n){var a="Something is wrong when doing ajax request! Please try again";e.responseJSON&&e.responseJSON.data&&e.responseJSON.data.message?a=e.responseJSON.data.message:e.responseJSON&&e.responseJSON.message?a=e.responseJSON.message:e.responseText&&(a=e.responseText);var i=t("
",{class:"error text-danger"});n.closest(".ff-el-group").addClass("ff-el-is-error"),n.closest(".ff-el-input--content").find("div.error").remove(),n.closest(".ff-el-input--content").append(i.text(a))}function c(e,n,a){var i,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"img";if(!n||Array.isArray(n)&&!n.length)return"";"image"===(null===(i=n)||void 0===i?void 0:i.type)&&(r="img");var o=t("
",{class:"ff-post-update-thumb-wrapper",css:{position:"relative","margin-bottom":"15px"}}),s=t("
",{text:"X",title:"Remove "+("file"===r?"File":"Image"),"data-attachment-id":f(n),css:{position:"absolute",background:"#f00","border-radius":"50%",color:"#fff",right:"-3px",top:"-3px",width:"15px",height:"15px",display:"flex","align-items":"center","justify-content":"center","font-weight":"700","font-size":"10px",cursor:"pointer","z-index":1},on:{click:function(){t(this).closest(".ff-el-input--content").append(a),o.remove()}}}),l="";if("string"==typeof n&&"file"===r){var c=n.split(/(\\|\/)/g).pop(),d=c.split(".").pop().toLowerCase().trim();if(!["png","jpg","gif","jpeg","webp","bmp"].includes(d)){var p={};p.url=n,p.filename=c,p.filesize=function(e){var t=0,n=new XMLHttpRequest;n.open("HEAD",e,!1),n.send(null),200===n.status&&(t=n.getResponseHeader("content-length"));return parseInt(t)}(n),n=p}}if("file"===r&&"string"!=typeof n)l=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:140;return t-=91,e.filesize=(null==e?void 0:e.filesize)||(null==e?void 0:e.filesizeInBytes),'\n
\n
\n
\n \n
\n
\n
\n
').concat(null!=e&&e.filename?e.filename:null==e?void 0:e.name,'
\n
\n
\n
\n
').concat(null!=e&&e.filesize?(e.filesize/1024).toFixed(2):0,' KB
\n
\n
\n
\n
\n ')}(n,parseInt(e.closest(".ff-el-group").width()));else{var u;if("string"!=typeof n)n=null===(u=n)||void 0===u?void 0:u.url;l='
'}return o.append(s).append(l),o}function f(e){return"string"==typeof e?"":(null==e?void 0:e.ID)||(null==e?void 0:e.id)||""}t(document).on("change","#"+a,(function(e){var n=this,a=t(this).val(),f=t(this).closest("form");if(function(e){var t=e.find(".ff-post-update-thumb-wrapper");t.length&&t.remove()}(f),i&&function(e){var t=e.find(".ff-el-repeater.js-repeater table tbody");t.find("tr").remove(),t.append(i)}(f),a){var d=f.attr("data-form_id");jQuery.post(window.fluentFormVars.ajaxUrl,{action:"fluentformpro_get_post_details",post_id:a,form_id:d,fluentformpro_post_update_nonce:window.fluentformpro_post_update_vars.nonce}).then((function(e){e.data.post?(!function(e,n){t.each(e,(function(e,t){if("post_content"===e)window.wpActiveEditor&&tinyMCE.get(wpActiveEditor).setContent(t);else if("thumbnail"===e){var a=n.find("input[name='featured_image']");if(a.length&&t){var i=c(a,t,'
');a.closest(".ff-el-input--content").append(i)}}else"post_excerpt"===e?n.find("textarea[name='"+e+"']").val(t).trigger("change"):n.find("input[name='"+e+"']").val(t).trigger("change")}))}(e.data.post,f),function(e,n){t.each(e,(function(e,t){var a=n.find('[data-name="'+e+'"]');if("select"===a.attr("type"))r(a,t);else if("checkbox"===a.attr("type"))o(a,t);else{var i=t.map((function(e){return e.label})).join(",");a.val(i)}a.change()}))}(e.data.taxonomy,f),["custom_meta","acf_metas","advanced_acf_metas","mb_general_metas","mb_advanced_metas","jetengine_metas","advanced_jetengine_metas"].forEach((function(n){var a=e.data[n];!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;t.each(e,(function(e,t){!function(e,t){var n=t.name;n.includes(".")&&(n=n.split(".").join("[")+"]");var a=t.value,l=e.find('[data-name="'+n+'"]');l.length||(l=e.find('[name="'+n+'"]'));if(l.length){switch(t.type){case"image":case"image_upload":case"single_image":case"gallery":case"media":s(l,a,n,"img");break;case"file":case"file_upload":case"file_input":case"file_advanced":s(l,a,n,"file");break;case"select":case"image_select":case"checkbox":case"radio":case"button_group":case"checkbox_list":!function(e,t){var n="select"===e.attr("type")||"select"===e.prop("nodeName").toLowerCase();n?r(e,t):o(e,t)}(l,a);break;case"date_picker":case"date_time_picker":case"time_picker":case"jetengine_date_type":!function(e,t,n){var a;"date_picker"===n?a="Ymd":"date_time_picker"===n?a="Y-m-d H:i:s":"time_picker"===n&&(a="H:i:s");if(e.length>0&&e[0]._flatpickr){var i=e[0]._flatpickr,r=i.parseDate(t,a)||t;i.setDate(r)}else e.val(t)}(l,a,t.type);break;case"repeater":!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t||null==t||!t.length)return;var n=e.find("table"),a=n.find("tbody tr"),r=parseInt(n.attr("data-max_repeat"));t.forEach((function(e){var t=n.find("tbody tr").length-1;if(r&&t===r)n.addClass("repeat-maxed");else{var o=a.clone();i||(i=a.clone());var s=Object.values(e);o.find("td").each((function(e,t){var n=jQuery(this).find(".ff-el-form-control:last-child"),a=n.attr("data-mask");a&&n.mask(a);var i="ffrpt-"+(new Date).getTime()+e,r={value:s[e]||"",id:i};n.prop(r)})),o.insertBefore(a)}})),a.remove();var o=n.attr("data-root_name"),s=0;n.find("tbody tr").each((function(e,t){jQuery(this).find(".ff-el-form-control").each((function(t,n){var a=jQuery(n);0===e&&(s=a.attr("tabindex")),a.prop({name:o+"["+e+"][]"}),a.attr("data-name",o+"_"+t+"_"+e),s&&a.attr("tabindex",s)}))})),n.trigger("repeat_change")}(l,a);break;case"wysiwyg":if(l.hasClass("fluentform-post-content")){var c,f=l.attr("id")||"";null===(c=tinyMCE.get(f))||void 0===c||c.setContent(a)}else l.val(a);break;default:"string"==typeof a&&l.val(a)}l.change()}}(n,t)}))}(a||[],f)}))):l(e,t(n))})).fail((function(e){l(e,t(n))})).always((function(){}))}else f.trigger("reset")})),setTimeout((function(){t("#"+a).change()}),500)}(jQuery)})();