ZwiiCMS/core/vendor/filemanager/js/include.js

2 lines
34 KiB
JavaScript
Raw Normal View History

2018-11-13 18:33:22 +01:00
var encodeURL,show_animation,hide_animation,apply,apply_none,apply_img,apply_any,apply_video,apply_link,apply_file_rename,apply_file_duplicate,apply_folder_rename;!function(e,a,t){"use strict";function r(e){show_animation();var a=new Image;a.src=e,jQuery(a).on("load",function(){hide_animation()})}function n(){jQuery("#textfile_create_area").parent().parent().remove(),e.ajax({type:"GET",url:"ajax_calls.php?action=new_file_form"}).done(function(a){bootbox.dialog(a,[{label:jQuery("#cancel").val(),"class":"btn"},{label:jQuery("#ok").val(),"class":"btn-inverse",callback:function(){var a=jQuery("#create_text_file_name").val()+jQuery("#create_text_file_extension").val(),t=jQuery("#textfile_create_area").val();if(null!==a){a=b(a);var r=jQuery("#sub_folder").val()+jQuery("#fldr_value").val();e.ajax({type:"POST",url:"execute.php?action=create_file",data:{path:r,name:a,new_content:t}}).done(function(e){""!=e&&bootbox.alert(e,function(){setTimeout(function(){window.location.href=jQuery("#refresh").attr("href")+"&"+(new Date).getTime()},500)})})}}}],{header:jQuery("#lang_new_file").val()})})}function i(a){jQuery("#textfile_edit_area").parent().parent().remove();var t=a.find(".rename-file-paths").attr("data-path");e.ajax({type:"POST",url:"ajax_calls.php?action=get_file&sub_action=edit&preview_mode=text",data:{path:t}}).done(function(r){bootbox.dialog(r,[{label:jQuery("#cancel").val(),"class":"btn"},{label:jQuery("#ok").val(),"class":"btn-inverse",callback:function(){var a=jQuery("#textfile_edit_area").val();e.ajax({type:"POST",url:"execute.php?action=save_text_file",data:{path:t,new_content:a}}).done(function(e){""!=e&&bootbox.alert(e)})}}],{header:a.find(".name_download").val()})})}function l(){e.ajax({type:"POST",url:"ajax_calls.php?action=get_lang",data:{}}).done(function(a){bootbox.dialog(a,[{label:jQuery("#cancel").val(),"class":"btn"},{label:jQuery("#ok").val(),"class":"btn-inverse",callback:function(){var a=jQuery("#new_lang_select").val();e.ajax({type:"POST",url:"ajax_calls.php?action=change_lang",data:{choosen_lang:a}}).done(function(e){""!=e?bootbox.alert(e):setTimeout(function(){window.location.href=jQuery("#refresh").attr("href").replace(/lang=[\w]*&/i,"lang="+a+"&")+"&"+(new Date).getTime()},100)})}}],{header:jQuery("#lang_lang_change").val()})})}function o(a){jQuery("#files_permission_start").parent().parent().remove();var t=a.find(".rename-file-paths"),r=t.attr("data-path"),n=t.attr("data-permissions"),i=t.attr("data-folder");e.ajax({type:"POST",url:"ajax_calls.php?action=chmod",data:{path:r,permissions:n,folder:i}}).done(function(a){bootbox.dialog(a,[{label:jQuery("#cancel").val(),"class":"btn"},{label:jQuery("#ok").val(),"class":"btn-inverse",callback:function(){var a="-";a+=jQuery("#u_4").is(":checked")?"r":"-",a+=jQuery("#u_2").is(":checked")?"w":"-",a+=jQuery("#u_1").is(":checked")?"x":"-",a+=jQuery("#g_4").is(":checked")?"r":"-",a+=jQuery("#g_2").is(":checked")?"w":"-",a+=jQuery("#g_1").is(":checked")?"x":"-",a+=jQuery("#a_4").is(":checked")?"r":"-",a+=jQuery("#a_2").is(":checked")?"w":"-",a+=jQuery("#a_1").is(":checked")?"x":"-";var n=jQuery("#chmod_form #chmod_value").val();if(""!=n&&"undefined"!=typeof n){var l=jQuery("#chmod_form input[name=apply_recursive]:checked").val();""!=l&&"undefined"!=typeof l||(l="none"),e.ajax({type:"POST",url:"execute.php?action=chmod",data:{path:r,new_mode:n,is_recursive:l,folder:i}}).done(function(e){""!=e?bootbox.alert(e):t.attr("data-permissions",a)})}}}],{header:jQuery("#lang_file_permission").val()}),setTimeout(function(){u(!1)},100)})}function u(a){var t=[];if(t.user=0,t.group=0,t.all=0,"undefined"!=typeof a&&1==a){var r=jQuery("#chmod_form #chmod_value").val();t.user=r.substr(0,1),t.group=r.substr(1,1),t.all=r.substr(2,1),e.each(t,function(a){(""==t[a]||0==e.isNumeric(t[a])||parseInt(t[a])<0||parseInt(t[a])>7)&&(t[a]="0")}),jQuery("#chmod_form input:checkbox").each(function(){var e=jQuery(this).attr("data-group"),a=jQuery(this).attr("data-value");c(t[e],a)?jQuery(this).prop("checked",!0):jQuery(this).prop("checked",!1)})}else jQuery("#chmod_form input:checkbox:checked").eac
_()}else apply_any(n[0])},apply_none=function(e){var a=jQuery("ul.grid").find('li[data-name="'+e+'"] figcaption a');a[1].click(),jQuery(".tip-right").tooltip("hide")},apply_any=function(e){if(1==jQuery("#crossdomain").val())window.parent.postMessage({sender:"responsivefilemanager",url:e,field_id:null},"*");else{var a=jQuery("#editor").val();if("ckeditor"==a){var t=Q("CKEditorFuncNum");window.opener.CKEDITOR.tools.callFunction(t,e),window.close()}else parent.tinymce.majorVersion<4?(parent.tinymce.activeEditor.windowManager.params.setUrl(e),parent.tinymce.activeEditor.windowManager.close(parent.tinymce.activeEditor.windowManager.params.mce_window_id)):(parent.tinymce.activeEditor.windowManager.getParams().setUrl(e),parent.tinymce.activeEditor.windowManager.close())}},apply_file_duplicate=function(e,a){var t=e.parent().parent().parent().parent();t.after("<li class='"+t.attr("class")+"' data-name='"+t.attr("data-name")+"'>"+t.html()+"</li>");var r=t.next();apply_file_rename(r.find("figure"),a);var n=r.find(".download-form"),i="form"+(new Date).getTime();n.attr("id",i),n.find(".tip-right").attr("onclick","jQuery('#"+i+"').submit();")},apply_file_rename=function(e,a){var t;e.attr("data-name",a),e.parent().attr("data-name",a),e.find("h4").text(a);var r=e.find("a.link");t=r.attr("data-file");var n=t.substring(t.lastIndexOf("/")+1),i=t.substring(t.lastIndexOf(".")+1);r.each(function(){jQuery(this).attr("data-file",encodeURIComponent(a+"."+i))}),e.find("img").each(function(){var e=jQuery(this).attr("src");jQuery(this).attr("src",e.replace(n,a+"."+i)+"?time="+(new Date).getTime()),jQuery(this).attr("alt",a+" thumbnails")});var l=e.find("a.preview");t=l.attr("data-url"),"undefined"!=typeof t&&t&&l.attr("data-url",t.replace(encodeURIComponent(n),encodeURIComponent(a+"."+i))),e.parent().attr("data-name",a+"."+i),e.attr("data-name",a+"."+i),e.find(".name_download").val(a+"."+i);var o=e.find("a.rename-file"),u=e.find("a.delete-file"),c=o.attr("data-path"),s=c.replace(n,a+"."+i);o.attr("data-path",s),u.attr("data-path",s)},apply_folder_rename=function(e,a){e.attr("data-name",a),e.find("figure").attr("data-name",a);var t=e.find("h4").find("a").text();e.find("h4 > a").text(a);var r=e.find(".folder-link"),n=r.attr("href"),i=jQuery("#fldr_value").val(),l=n.replace("fldr="+i+encodeURIComponent(t),"fldr="+i+encodeURIComponent(a));r.each(function(){jQuery(this).attr("href",l)});var o=e.find("a.delete-folder"),u=e.find("a.rename-folder"),c=u.attr("data-path"),s=c.lastIndexOf("/"),d=c.substr(0,s+1)+a;o.attr("data-path",d),u.attr("data-path",d)},show_animation=function(){jQuery("#loading_container").css("display","block"),jQuery("#loading").css("opacity",".7")},hide_animation=function(){jQuery("#loading_container").fadeOut()}}(jQuery,Modernizr,image_editor),function(){function e(e,a){a=a||{bubbles:!1,cancelable:!1,detail:void 0};var t=document.createEvent("CustomEvent");return t.initCustomEvent(e,a.bubbles,a.cancelable,a.detail),t}return"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,void(window.CustomEvent=e))}();