init
This commit is contained in:
200
app/admin/view/webuploader/modal.html
Executable file
200
app/admin/view/webuploader/modal.html
Executable file
@@ -0,0 +1,200 @@
|
||||
<div id="filemanager" class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">文件管理器</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<a href="<?php echo $parent; ?>" data-toggle="tooltip" title="上一级" id="button-parent" class="btn btn-info"><i class="glyphicon glyphicon-level-up"></i></a>
|
||||
<a href="<?php echo $refresh; ?>" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-info"><i class="glyphicon glyphicon-refresh"></i></a>
|
||||
<a href="<?php echo $webuploader; ?>" data-toggle="tooltip" title="上传文件" id="button-webuploader" class="btn btn-info"><i class="glyphicon glyphicon-cloud-upload"></i></a>
|
||||
<button type="button" data-toggle="tooltip" title="直接上传" id="button-upload" class="btn btn-primary"><i class="glyphicon glyphicon-upload"></i></button>
|
||||
<button type="button" data-toggle="tooltip" title="新目录" id="button-folder" class="btn btn-info"><i class="glyphicon glyphicon-folder-close"></i></button>
|
||||
<button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i></button>
|
||||
</div>
|
||||
<div class="col-sm-7">
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" value="<?php echo $filter_name; ?>" placeholder="检索中....." class="form-control">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" data-toggle="tooltip" title="检索" id="button-search" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
|
||||
</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row"><iframe id="uploadiframe" style="width:100%;min-height:200px;height:480px;" frameborder="0" src="<?php echo $uploadiframe; ?>"></iframe></div>
|
||||
</div>
|
||||
<div class="modal-footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript"><!--
|
||||
$('#modal-image a.thumbnail').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var target = "<?php echo $target; ?>";
|
||||
var thumb = "<?php echo $thumb; ?>";
|
||||
var callback = "<?php echo $func;?>";
|
||||
if (callback != "undefined") {
|
||||
var fileurl_tmp = $(this).find('img').attr('src');
|
||||
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
|
||||
$('#modal-image').modal('hide');
|
||||
return;
|
||||
}
|
||||
if (thumb) {
|
||||
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
||||
}
|
||||
if (target) {
|
||||
$('#' + target).val($(this).parent().find('input').val());
|
||||
}
|
||||
$('#modal-image').modal('hide');
|
||||
});
|
||||
$('#modal-image a.directory').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#modal-image .pagination a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-parent').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-refresh').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-webuploader').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#modal-image input[name=\'search\']').on('keydown', function(e) {
|
||||
if (e.which == 13) {
|
||||
$('#button-search').trigger('click');
|
||||
}
|
||||
});
|
||||
$('#button-search').on('click', function(e) {
|
||||
var url = '<?php echo url("/admin/webuploader/show",array_filter(["target"=>$target,"thumb"=>$thumb,"type"=>$type,"func"=>$func,"num"=>$num,"directory"=>$directory])); ?>';
|
||||
var filter_name = $('#modal-image input[name=\'search\']').val();
|
||||
if (filter_name) {
|
||||
url += '&filter_name=' + encodeURIComponent(filter_name);
|
||||
}
|
||||
$('#modal-image').load(url);
|
||||
});
|
||||
//--></script>
|
||||
<script type="text/javascript"><!--
|
||||
$('#button-upload').on('click', function() {
|
||||
$('#form-upload').remove();
|
||||
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file[]" value="" multiple="multiple"/></form>');
|
||||
$('#form-upload input[name=\'file[]\']').trigger('click');
|
||||
if (typeof timer != 'undefined') {
|
||||
clearInterval(timer);
|
||||
}
|
||||
timer = setInterval(function() {
|
||||
if ($('#form-upload input[name=\'file[]\']').val() != '') {
|
||||
clearInterval(timer);
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/upload",["directory"=>$directory,"type"=>$type]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: $('#form-upload').serialize(),
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
beforeSend: function() {
|
||||
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-hourglass"></i>');
|
||||
$('#button-upload').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-upload"></i>');
|
||||
$('#button-upload').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
$('#button-folder').popover({
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
trigger: 'click',
|
||||
title: '文件夹名称',
|
||||
content: function() {
|
||||
var html = '<div class="input-group">';
|
||||
html += ' <input type="text" name="folder" value="" placeholder="名称,仅支持数字字母下划线" class="form-control">';
|
||||
html += ' <span class="input-group-btn"><button type="button" title="新目录" id="button-create" class="btn btn-primary"><i class="glyphicon glyphicon-plus-sign"></i></button></span>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$('#button-folder').on('shown.bs.popover', function() {
|
||||
$('#button-create').on('click', function() {
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/folder",["directory"=>$directory]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
|
||||
beforeSend: function() {
|
||||
$('#button-create').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-create').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#modal-image #button-delete').on('click', function(e) {
|
||||
if (confirm('确定删除吗?')) {
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/delete",["directory"=>$directory]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: $('input[name^=\'path\']:checked'),
|
||||
beforeSend: function() {
|
||||
$('#button-delete').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-delete').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//--></script>
|
||||
392
app/admin/view/webuploader/show.html
Executable file
392
app/admin/view/webuploader/show.html
Executable file
@@ -0,0 +1,392 @@
|
||||
<div id="filemanager" class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">文件管理器</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-5">
|
||||
<a href="<?php echo $parent; ?>" data-toggle="tooltip" title="上一级" id="button-parent" class="btn btn-info"><i class="glyphicon glyphicon-level-up"></i></a>
|
||||
<a href="<?php echo $refresh; ?>" data-toggle="tooltip" title="刷新" id="button-refresh" class="btn btn-info"><i class="glyphicon glyphicon-refresh"></i></a>
|
||||
<a href="<?php echo $webuploader; ?>" data-toggle="tooltip" title="上传文件" id="button-webuploader" class="btn btn-info"><i class="glyphicon glyphicon-cloud-upload"></i></a>
|
||||
<button type="button" data-toggle="tooltip" title="直接上传" id="button-upload" class="btn btn-primary"><i class="glyphicon glyphicon-upload"></i></button>
|
||||
<button type="button" data-toggle="tooltip" title="新目录" id="button-folder" class="btn btn-info"><i class="glyphicon glyphicon-folder-close"></i></button>
|
||||
<button type="button" data-toggle="tooltip" title="删除" id="button-delete" class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i></button>
|
||||
<button type="button" data-toggle="tooltip" title="重命名" id="button-rename" class="btn btn-danger"><i class="glyphicon glyphicon-transfer"></i></button>
|
||||
</div>
|
||||
<div class="col-sm-7">
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" value="<?php echo $filter_name; ?>" placeholder="检索中....." class="form-control">
|
||||
<span class="input-group-btn">
|
||||
<button type="button" data-toggle="tooltip" title="检索" id="button-search" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<?php foreach (array_chunk($images, 4) as $image4) { ?>
|
||||
<div class="row">
|
||||
<?php foreach ($image4 as $image) { ?>
|
||||
<div class="col-sm-3 col-xs-6 text-center">
|
||||
<?php switch($image['type']):
|
||||
case 'directory':?>
|
||||
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="directory" style="vertical-align: middle;"><i class="fa fa-fw fa-folder fa-5x"></i></a></div>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php break;
|
||||
case 'image':?>
|
||||
<a href="<?php echo $image['href']; ?>" class="thumbnail"><img src="<?php echo $image['thumb']; ?>" alt="<?php echo $image['name']; ?>" title="<?php echo $image['name']; ?>" /></a>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php break;
|
||||
case 'text':?>
|
||||
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-text fa-5x"></i></a></div>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php break;
|
||||
case 'archive':?>
|
||||
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-archive-o fa-5x"></i></a></div>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php break;
|
||||
case 'video':?>
|
||||
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file-video-o fa-5x"></i></a></div>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php break;
|
||||
default:?>
|
||||
<div class="text-center"><a href="<?php echo $image['href']; ?>" class="iconfile" style="vertical-align: middle;"><i class="fa fa-fw fa-file fa-5x"></i></a></div>
|
||||
<label>
|
||||
<input type="checkbox" name="path[]" value="<?php echo $image['path']; ?>" />
|
||||
<?php echo $image['name']; ?>
|
||||
</label>
|
||||
<?php endswitch;?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<br />
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="modal-footer"><?php echo $pagination; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var check_value = [];
|
||||
$('#modal-image a.thumbnail').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var target = "<?php echo $target; ?>";
|
||||
var thumb = "<?php echo $thumb; ?>";
|
||||
var callback = "<?php echo $func;?>";
|
||||
|
||||
if (callback != "undefined") {
|
||||
var fileurl_tmp = $(this).find('img').attr('src');
|
||||
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
|
||||
$('#modal-image').modal('hide');
|
||||
return;
|
||||
}
|
||||
|
||||
if (thumb) {
|
||||
if (thumb.indexOf('thumb-image') != -1)
|
||||
{
|
||||
$.each($('input:checkbox:checked'),function() {
|
||||
if(!$.isNumeric($(this).val())){
|
||||
check_value.push($(this).val());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
console.log(check_value);
|
||||
// 修改附加图
|
||||
var len = check_value.length;
|
||||
var arr_tmp = [];
|
||||
if (len > 1)
|
||||
{
|
||||
var tmp_obj = $.extend(true, {}, $('#' + thumb));
|
||||
for (var i=0; i<len; i++)
|
||||
{
|
||||
// console.log(image_row);
|
||||
var _id = 'thumb-image' + image_row;
|
||||
|
||||
tmp_obj.attr('id', _id);
|
||||
tmp_obj.children('img').attr('src', check_value[i]);
|
||||
var this_html = tmp_obj.prop("outerHTML");
|
||||
tmp_obj.parent().append(this_html);
|
||||
arr_tmp.push(check_value[i]);
|
||||
image_row++;
|
||||
}
|
||||
|
||||
arr_product_img.push(arr_tmp);
|
||||
tmp_obj.remove();
|
||||
|
||||
// console.log(arr_product_img);
|
||||
$("#albums").children('.image_111').remove();
|
||||
for (var j=0; j<arr_product_img.length; j++)
|
||||
{
|
||||
for (var k=0; k<arr_product_img[j].length; k++)
|
||||
{
|
||||
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + arr_product_img[j][k] + '">';
|
||||
$("#albums").append(tmp_html);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(arr_product_img);
|
||||
}
|
||||
else
|
||||
{
|
||||
arr_tmp.push($(this).find('img').attr('src'));
|
||||
arr_product_img.push(arr_tmp);
|
||||
$("#albums").children('.image_111').remove();
|
||||
for (var j=0; j<arr_product_img.length; j++)
|
||||
{
|
||||
for (var k=0; k<arr_product_img[j].length; k++)
|
||||
{
|
||||
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + arr_product_img[j][k] + '">';
|
||||
$("#albums").append(tmp_html);
|
||||
}
|
||||
}
|
||||
|
||||
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
||||
console.log(2);
|
||||
console.log(arr_product_img);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
||||
}
|
||||
|
||||
}
|
||||
if (target) {
|
||||
$('#' + target).val($(this).parent().find('input').val());
|
||||
}
|
||||
$('#modal-image').modal('hide');
|
||||
});
|
||||
$('#modal-image a.iconfile').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var target = "<?php echo $target; ?>";
|
||||
var thumb = "<?php echo $thumb; ?>";
|
||||
var callback = "<?php echo $func;?>";
|
||||
if (callback != "undefined") {
|
||||
var fileurl_tmp = $(this).parent().parent().find('input').val();
|
||||
eval('window.parent.' + callback + '(fileurl_tmp,target,thumb);');
|
||||
$('#modal-image').modal('hide');
|
||||
return;
|
||||
}
|
||||
// if (thumb) {
|
||||
// $('#' + thumb).find('img').attr('src', $(this).find('img').attr('src'));
|
||||
// }
|
||||
if (target) {
|
||||
//console.log($(this).parent().parent().find('input').val());
|
||||
$('#' + target).val($(this).parent().parent().find('input').val());
|
||||
}
|
||||
$('#modal-image').modal('hide');
|
||||
});
|
||||
$('#modal-image a.directory').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#modal-image .pagination a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-parent').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-refresh').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#button-webuploader').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$('#modal-image').load($(this).attr('href'));
|
||||
});
|
||||
$('#modal-image input[name=\'search\']').on('keydown', function(e) {
|
||||
if (e.which == 13) {
|
||||
$('#button-search').trigger('click');
|
||||
}
|
||||
});
|
||||
$('#button-search').on('click', function(e) {
|
||||
var url = '<?php echo url("/admin/webuploader/show",array_filter(["target"=>$target,"thumb"=>$thumb,"type"=>$type,"func"=>$func,"num"=>$num,"directory"=>$directory])); ?>';
|
||||
var filter_name = $('#modal-image input[name=\'search\']').val();
|
||||
if (filter_name) {
|
||||
url += '&filter_name=' + encodeURIComponent(filter_name);
|
||||
}
|
||||
$('#modal-image').load(url);
|
||||
});
|
||||
//--></script>
|
||||
<script type="text/javascript"><!--
|
||||
$('#button-upload').on('click', function() {
|
||||
$('#form-upload').remove();
|
||||
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file[]" value="" multiple="multiple"/></form>');
|
||||
$('#form-upload input[name=\'file[]\']').trigger('click');
|
||||
if (typeof timer != 'undefined') {
|
||||
clearInterval(timer);
|
||||
}
|
||||
timer = setInterval(function() {
|
||||
if ($('#form-upload input[name=\'file[]\']').val() != '') {
|
||||
clearInterval(timer);
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/upload",["directory"=>$directory,"type"=>$type]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: new FormData($('#form-upload')[0]),
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
beforeSend: function() {
|
||||
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-hourglass"></i>');
|
||||
$('#button-upload').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-upload i').replaceWith('<i class="glyphicon glyphicon-upload"></i>');
|
||||
$('#button-upload').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
$('#button-folder').popover({
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
trigger: 'click',
|
||||
title: '文件夹名称',
|
||||
content: function() {
|
||||
var html = '<div class="input-group">';
|
||||
html += ' <input type="text" name="folder" value="" placeholder="文件夹名称,仅支持字母数字下划线" class="form-control">';
|
||||
html += ' <span class="input-group-btn"><button type="button" title="新目录" id="button-create" class="btn btn-primary"><i class="glyphicon glyphicon-plus-sign"></i></button></span>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$('#button-folder').on('shown.bs.popover', function() {
|
||||
$('#button-create').on('click', function() {
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/folder",["directory"=>$directory]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: 'folder=' + encodeURIComponent($('input[name=\'folder\']').val()),
|
||||
beforeSend: function() {
|
||||
$('#button-create').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-create').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#button-rename').popover({
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
trigger: 'click',
|
||||
title: '文件名称',
|
||||
content: function() {
|
||||
var html = '<div class="input-group">';
|
||||
html += ' <input type="text" name="filenewname" value="" placeholder="文件名称,仅支持字母数字下划线" class="form-control">';
|
||||
html += ' <span class="input-group-btn"><button type="button" title="文件名" id="button-newname" class="btn btn-primary"><i class="glyphicon glyphicon-check"></i></button></span>';
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
});
|
||||
$('#button-rename').on('shown.bs.popover', function() {
|
||||
$('#button-newname').on('click', function() {
|
||||
//console.log($('input[name^=\'path\']:checked').val());
|
||||
var path = $('input[name^=\'path\']:checked').val();
|
||||
var filenewname = $('input[name=\'filenewname\']').val();
|
||||
if (path && /^[a-zA-Z0-9_-]+$/.test(filenewname)) {
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/rename",["directory"=>$directory]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {filenewname: encodeURIComponent(filenewname), path: encodeURIComponent(path)},
|
||||
beforeSend: function() {
|
||||
$('#button-newname').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-newname').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert('未选择文件或文件名为不是由字母数字下划线组成');
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#modal-image #button-delete').on('click', function(e) {
|
||||
if (confirm('确定删除吗?')) {
|
||||
$.ajax({
|
||||
url: '<?php echo url("/admin/webuploader/delete",["directory"=>$directory]); ?>',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: $('input[name^=\'path\']:checked'),
|
||||
beforeSend: function() {
|
||||
$('#button-delete').prop('disabled', true);
|
||||
},
|
||||
complete: function() {
|
||||
$('#button-delete').prop('disabled', false);
|
||||
},
|
||||
success: function(json) {
|
||||
if (json['error']) {
|
||||
alert(json['error']);
|
||||
}
|
||||
if (json['success']) {
|
||||
alert(json['success']);
|
||||
$('#button-refresh').trigger('click');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
//--></script>
|
||||
111
app/admin/view/webuploader/uploadiframe.html
Executable file
111
app/admin/view/webuploader/uploadiframe.html
Executable file
@@ -0,0 +1,111 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>文件管理</title>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/adminlte/webuploader/dist/webuploader.css">
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/adminlte/webuploader/style/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="container">
|
||||
<!--头部,文件选择和格式选择-->
|
||||
<div id="uploader">
|
||||
<div class="statusBar" style="display:none;">
|
||||
<div class="progress">
|
||||
<span class="text">0%</span>
|
||||
<span class="percentage"></span>
|
||||
</div><div class="info"></div>
|
||||
<div class="btns">
|
||||
<div id="filePicker2"></div><div class="uploadBtn">开始上传</div><div class="saveBtn">确定使用</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="queueList">
|
||||
<div id="dndArea" class="placeholder">
|
||||
<div id="filePicker"></div>
|
||||
<p>或将文件拖到这里,单次最多可选<?php echo empty($num)?1:$num;?>个</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fileWarp" style="display:none;">
|
||||
<fieldset>
|
||||
<legend>列表</legend>
|
||||
<ul></ul>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- jQuery 3 -->
|
||||
<script src="__PUBLIC__/adminlte/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<script src="__PUBLIC__/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="__PUBLIC__/adminlte/webuploader/dist/webuploader.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var BASE_URL = '__PUBLIC__';
|
||||
var bgmoudle = 'admin';
|
||||
var webuploader_config = {
|
||||
"swf": BASE_URL + "/adminlte/webuploader/dist/Uploader.swf",
|
||||
"server": "<?php echo $uploadurl;?>",
|
||||
"deleteurl": "<?php echo $deleteurl;?>",
|
||||
"chunked": false,
|
||||
"chunkSize": 512 * 1024,
|
||||
"fileNumLimit": "<?php echo empty($num)?1:$num;?>",
|
||||
"fileSizeLimit": 512 * 1024 * 1024,
|
||||
"fileSingleSizeLimit": 512 * 1024 * 1024,
|
||||
"fileVal": "file",
|
||||
"auto": true,
|
||||
"type": "<?php echo ucfirst($type);?>",
|
||||
"compress": false, //不启用压缩
|
||||
"resize": false, //尺寸不改变
|
||||
"formData": {},
|
||||
"pick": {id: '#filePicker', label: '点击选择文件', "name": "file"},
|
||||
"thumb": {"width": 110, "height": 110, "quality": 70, "allowMagnify": true, "crop": true, "preserveHeaders": false, "type": "image\/jpeg"}
|
||||
};
|
||||
$(function() {
|
||||
/*点击保存按钮时
|
||||
*判断允许上传数,检测是单一文件上传还是组文件上传
|
||||
*如果是单一文件,上传结束后将地址存入$input元素
|
||||
*如果是组文件上传,则创建input样式,添加到$input后面
|
||||
*隐藏父框架,清空列队,移除已上传文件样式*/
|
||||
$(".statusBar .saveBtn").click(function() {
|
||||
var callback = "<?php echo $func;?>";
|
||||
var num = "<?php echo $num;?>";
|
||||
var target = "<?php echo $target;?>";
|
||||
var thumb = "<?php echo $thumb;?>";
|
||||
var fileurl_tmp = [];
|
||||
if (callback != "undefined") {
|
||||
if (num > 1) {
|
||||
$("input[name^='fileurl_tmp']").each(function(index, dom) {
|
||||
fileurl_tmp[index] = dom.value;
|
||||
});
|
||||
} else {
|
||||
fileurl_tmp = $("input[name^='fileurl_tmp']").val();
|
||||
}
|
||||
eval('window.parent.' + callback + '(fileurl_tmp,target);');
|
||||
window.parent.webuploader_modal_close();
|
||||
return;
|
||||
}
|
||||
if (num > 1) {
|
||||
var fileurl_tmp = "";
|
||||
$("input[name^='fileurl_tmp']").each(function() {
|
||||
fileurl_tmp += '<li rel="' + this.value + '"><input class="input-text" type="text" name="<?php echo $target;?>[]" value="' + this.value + '" /><a href="javascript:void(0);" onclick="ClearPicArr(\'' + this.value + '\',\'\')">删除</a></li>';
|
||||
});
|
||||
$("#" + target, window.parent.document).append(fileurl_tmp);
|
||||
} else {
|
||||
if (thumb) {
|
||||
$('#' + thumb, window.parent.document).find('img').attr('src', $("input[name^='fileurl_tmp']").val());
|
||||
}
|
||||
if (target) {
|
||||
$("#" + target, window.parent.document).val($("input[name^='fileurl_tmp']").val());
|
||||
}
|
||||
}
|
||||
window.parent.webuploader_modal_close();
|
||||
// $('#modal-image', window.parent.document).on('hidden.bs.modal', function(e) {
|
||||
// window.parent.document.find("div.modal-backdrop").remove();
|
||||
// }).modal('hide').remove();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript" src="__PUBLIC__/adminlte/webuploader/style/upload.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user