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

2 lines
34 KiB
JavaScript
Raw Normal View History

2019-01-11 09:59:01 +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 i(){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 n(a){jQuery("#textfile_edit_area").parent().parent().remove();var t=a.closest("figure").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();window.editor&&(a=window.editor.getData()),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=a.closest("figure").attr("data-path"),i=t.attr("data-permissions"),n=t.attr("data-folder");e.ajax({type:"POST",url:"ajax_calls.php?action=chmod",data:{path:r,permissions:i,folder:n}}).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 i=jQuery("#chmod_form #chmod_value").val();if(""!=i&&"undefined"!=typeof i){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:i,is_recursive:l,folder:n}}).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)})}e
g()}else apply_any(i[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 i=r.find(".download-form"),n="form"+(new Date).getTime();i.attr("id",n),i.find(".tip-right").attr("onclick","jQuery('#"+n+"').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 i=t.substring(t.lastIndexOf("/")+1),n=t.substring(t.lastIndexOf(".")+1);n=n?"."+n:"",r.each(function(){jQuery(this).attr("data-file",encodeURIComponent(a+n))}),e.find("img").each(function(){var e=jQuery(this).attr("src");if(e)jQuery(this).attr("src",e.replace(i,a+n)+"?time="+(new Date).getTime());else{var e=jQuery(this).attr("data-src");jQuery(this).attr("data-src",e.replace(i,a+n)+"?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(i),encodeURIComponent(a+n))),e.parent().attr("data-name",a+n),e.attr("data-name",a+n),e.find(".name_download").val(a+n);var o=e.attr("data-path"),u=o.replace(i,a+n);e.attr("data-path",u)},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"),i=r.attr("href"),n=jQuery("#fldr_value").val(),l=i.replace("fldr="+n+encodeURIComponent(t),"fldr="+n+encodeURIComponent(a));r.each(function(){jQuery(this).attr("href",l)});var o=e.attr("data-path"),u=o.lastIndexOf("/"),c=o.substr(0,u+1)+a;e.attr("data-path",c)},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))}();