mirror of https://gitee.com/zorlan/skycaiji
13 lines
4.9 KiB
PHP
13 lines
4.9 KiB
PHP
/*
|
|
|--------------------------------------------------------------------------
|
|
| SkyCaiji (蓝天采集器)
|
|
|--------------------------------------------------------------------------
|
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
|
|--------------------------------------------------------------------------
|
|
| 使用协议 https://www.skycaiji.com/licenses
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
'use strict';function ToolFileManager(){}
|
|
ToolFileManager.prototype={constructor:ToolFileManager,file_load:function(){var $_o=this;var curFile=$('#ipt_file').val();$('#btn_back').bind('click',function(){if(curFile){window.location.href=ulink('tool/file?file=_file_',{'_file_':curFile.replace(/\/{0,1}[^\/\\]+$/,'')})}else{prompt_error('数据根目录,不能后退!')}});$('#btn_refresh').bind('click',function(){window.location.href=window.location.href});$('#fileList .open').bind('click',function(){var file=$_o.file_prop(this,'data-file');var isDir=$_o.file_prop(this,'data-is-dir');var fileUrl=ulink('tool/file?file=_file_',{'_file_':curFile+'/'+file});if(isDir){window.location.href=fileUrl}else{windowIframe(file,fileUrl,{lg:1})}});$('#btn_new_txt,#btn_new_folder').bind('click',function(){var isFolder=($(this).attr('id')=='btn_new_folder')?true:!1;windowModal('新建'+(isFolder?'文件夹':'空白文本'),ulink('tool/file'),{ajax:{data:{'file':curFile,'op':'new','new_type':(isFolder?'folder':'txt'),'new_name':$('#confirm_ipt_name').val()}}})});$('#fileList .move').bind('click',function(){var file=$_o.file_prop(this,'data-file');var fileUrl=ulink('tool/file?op=move&file=_file_',{'_file_':curFile+'/'+file});windowModal(file,fileUrl)});$('#fileList .rename').bind('click',function(){var file=$_o.file_prop(this,'data-file');var fileUrl=ulink('tool/file?op=rename&file=_file_',{'_file_':curFile+'/'+file});windowModal(file,fileUrl)});$('#fileList .delete').bind('click',function(){var tr=$(this).parents('tr').eq(0);var file=$_o.file_prop(this,'data-file');var fileUrl=ulink('tool/file?op=delete&file=_file_',{'_file_':curFile+'/'+file});confirmRight('确定删除?',function(){ajaxOpen({type:'post',url:fileUrl,success:function(data){ajaxDataMsg(data);if(data.code==1){tr.remove()}}})})});$('#fileList .download').bind('click',function(){var file=$_o.file_prop(this,'data-file');var fileUrl=ulink('tool/file?op=download&file=_file_',{'_file_':curFile+'/'+file});window.open(fileUrl,'_blank')});$('#chkall,#chkall1').bind('click',function(){var status=$(this).is(":checked")?true:!1;checkall(this);$('#chkall,#chkall1').prop('checked',status)});$('#btn_list_delete').bind('click',function(){var fileUrl=ulink('tool/files?op=delete');var files=$_o.checked_files();files=files.join(',');confirmRight('确定删除?',function(){ajaxOpen({type:'post',url:fileUrl,data:{cur:curFile,files:files},success:function(data){ajaxDataMsg(data)}})})});$('#btn_list_move').bind('click',function(){var files=$_o.checked_files();files=files.join(',');var fileUrl=ulink('tool/files?op=move');windowModal('移动',fileUrl,{ajax:{type:'post',data:{cur:curFile,files:files}}})})},file:function(fileData){$(document).ready(function(){var editorHeight=$(document.body).height()-$('#ifr_editor').offset().top;editorHeight=parseInt(editorHeight)-50;$('#ifr_editor').css('height',editorHeight+'px');globalOp.editorCodeIfr('#ifr_editor',{'set_value':fileData.data,'set_option':{indentUnit:0}});$('#btn_save').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('tool/file'),data:{'file':fileData.file,'op':'save','save_data':globalOp.editorCodeIfr('#ifr_editor',{'get_value':1})},beforeSend:function(){$('#btn_save').attr('disabled',!0)},success:function(data){if(data){data.url=''}
|
|
ajaxDataMsg(data)},complete:function(){$('#btn_save').removeAttr('disabled')}})})})},file_prop(obj,type){type=type?type:'data-file';var tr=$(obj).parents('tr').eq(0);var val=tr.attr(type);return val},checked_files:function(){var files=[];$('#fileList').find('[name="files[]"]').each(function(){if($(this).is(':checked')){files.push($(this).val())}});return files},file_other:function(){var $_o=this;$('#btn_down').bind('click',function(){var file=$('#ipt_file').val();var fileUrl=ulink('tool/file?op=download&file=_file_',{'_file_':file});window.open(fileUrl,'_blank')});$('#file_info').bind('mouseover',function(){$('#file_info').attr('data-mouse','over');$_o.file_other_embed()});$('#file_info').bind('mouseout',function(){$('#file_info').attr('data-mouse','out');$_o.file_other_embed()});$('#file_embed').bind('load',function(){$('#file_info').attr('data-loaded',1);$_o.file_other_embed()})},file_other_embed:function(){if($('#file_info').attr('data-loaded')==1){if($('#file_info').attr('data-mouse')=='over'){$('#file_info').stop(!0,!0);$('#file_info').show()}else{$('#file_info').fadeOut(1000,function(){if($('#file_info').attr('data-mouse')!='over'){$('#file_embed').removeClass('embed-hide').addClass('embed-show')}})}}}}
|
|
var toolFileManager=new ToolFileManager() |