Add files via upload

This commit is contained in:
Last
2018-11-15 17:39:11 +08:00
committed by GitHub
parent ed7db38abd
commit eec60a63f2
28 changed files with 2338 additions and 0 deletions

21
z_daisy/hook/forum_js.htm Normal file
View File

@@ -0,0 +1,21 @@
<script type="text/javascript">
/*判断可显示区域高度 用于决定显示主图的高度 这里高度比例和内容页不同*/
var getBgHeight = function(windowHeight, bannerHeight, mobileBannerHeight){
windowHeight = windowHeight || 560;
if (windowHeight > window.screen.availHeight) {
windowHeight = window.screen.availHeight;
}
bannerHeight = bannerHeight.trim();
mobileBannerHeight = mobileBannerHeight.trim();
if (window.innerHeight > window.innerWidth) {
bannerHeight = parseFloat(mobileBannerHeight);
} else {
bannerHeight = parseFloat(bannerHeight);
}
bannerHeight = Math.round(windowHeight * bannerHeight / 100);
return bannerHeight;
};
var head = $("#masthead");
var bgHeight = getBgHeight(window.innerHeight, '35', '25');
head.css('height', bgHeight + "px");
</script>

View File

@@ -0,0 +1,32 @@
<!-- 直接结束掉 container 并去除上下边距 -->
</div>
<!-- 部分 style 打包放进气泡的 CSS 文件, 只有列表,主题,编辑页面需要 主页不要 -->
<style>
.blog-background { background:#2C2A2A url(<?php echo $forum['icon_url'];?>); color:#CCC; }
#body { padding-bottom: 0; padding-top: 0;}
</style>
<!-- CSS3 气泡 不能放全局 否则不需要气泡的页面会被遮挡-->
<link rel="stylesheet" href="plugin/z_daisy/view/css/bubble.css">
<!-- DAISY 需要最大宽度, 所以要把 header 中限制宽度的 DIV 移到每个页面中去? -->
<header id="masthead">
<div class="blog-background"></div>
<div class="inner">
<!-- 似乎没有必要再显示名称
<h1 class="blog-title" style="" itemprop="name"><?php //echo $forum['name'];?></h1>
<h2 class="blog-description light bordered bordered-top" style="" itemprop="description">12 月 23 日 2015 年 • 已有 3952 位童鞋围观过</h2>
-->
</div>
<!-- CSS3 气泡 同上 放全局并先隐藏-->
<ul class="bg-bubbles">
<li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li>
</ul>
</header>
<!-- 重新开始 container 这是一种兼容的做法 thread 页的 id="body" 将失去意义-->
<div class="container">

58
z_daisy/hook/post_js.htm Normal file
View File

@@ -0,0 +1,58 @@
<script>
//上传view图片到附件表
$('#addattachs').on('change', function(e) {
var files = xn.get_files_from_event(e);
if (!files) return;
// 并发下会 服务端 session 写入会有问题,由客户端控制改为串行
var jprogress = $('.attachlist_parents').find('progress');
if (!$('.attachlist_parents').find('.attachlist').length) {
$('.attachlist_parents').append('<ul class="attachlist"><ul>');
}
if(!jprogress.length) {
jprogress = $('<progress class="progress progress-success" value="0" max="100">0%</progress>').appendTo('.attachlist_parent > ul');
//jprogress = $('.attachlist_parents').append('<div class="progress"><div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">25%</div></div>');
}
$.each_sync(files, function(i, callback) {
var file = files[i];
xn.upload_file(file, xn.url('attach-create'), {
is_image: 2
}, function(code, message) {
if (code != 0) return $.alert(message);
// 把文件 append 到附件列表 替换到wivebg
var url = message.url;
var filetype = message.filetype;
var aid = message.aid;
$('.attachlist').append('<li aid="' + aid + '"><a href="' + message.url + '" target="_blank"><i class="icon filetype ' + filetype + '"></i> ' + message.orgfilename + '</a> <a href="javascript:void(0);" class="delete m-l-1"><i class="icon-remove"></i> <?php echo lang('delete');?></a></li>');
callback();
jprogress.hide();
jprogress.val(0);
jprogress.text('0%');
}, function(percent) {
/*
var jprogress = $('.attachlist_parents').find('.progress');
jprogressbar = jprogress.find('.progress-bar');
jprogressbar.css('width', percent+'%');
jprogressbar.text(percent+'%');
*/
jprogress.show();
jprogress.val(percent);
jprogress.text(percent+'%');
console.log('progress:'+ percent);
});
});
});
// 删除附件 这里的删除hhh
$('.attachlist_parents').on('click', 'a.delete', function() {
var jlink = $(this);
var jli = jlink.parents('li');
var aid = jli.attr('aid');
if(!window.confirm(lang.confirm_delete)) return false;
$.xpost(xn.url('attach-delete-'+aid), function(code, message) {
if(code != 0) return $.alert(message);
jlink.parent().remove();
});
return false;
})
</script>

View File

@@ -0,0 +1,20 @@
<?php
//判断图片是否存在输出BG路径, 如果没有则为空
$u = db_find_one('attach', array('tid'=>$tid,'isimage'=>2));
if ($u==NULL){ $viewimg = '';}
else{ $viewimg = 'url('.$conf['upload_url'].'attach/'.$u['filename'].')'; }
?>
<!-- 部分 style 打包成文件放进气泡的 CSS, 只有列表,主题,编辑页面需要 主页不要 -->
<style>.viewimg { background:#2C2A2A <?php echo $viewimg; ?>; color:#CCC; }</style>
<!-- CSS3 气泡 不能放全局 否则不需要气泡的页面会被遮挡-->
<link rel="stylesheet" href="plugin/z_daisy/view/css/bubble.css">
<!-- 主题图片的上传按钮, 只有编辑页需要 还要有删除按钮 -->
<div class="row" style="padding: 0px 0 0 0">
<div class="col-lg-10 attachlist_parents">
<p class="small text-right"><label class="addattach" id="addattachs"><i class="icon-plus-square-o icon-3x"></i><input type="file" multiple="multiple" /></label></p>
</div>
</div>

View File

@@ -0,0 +1,21 @@
<script type="text/javascript">
/*判断可显示区域高度 用于决定显示主图的高度*/
var getBgHeight = function(windowHeight, bannerHeight, mobileBannerHeight){
windowHeight = windowHeight || 560;
if (windowHeight > window.screen.availHeight) {
windowHeight = window.screen.availHeight;
}
bannerHeight = bannerHeight.trim();
mobileBannerHeight = mobileBannerHeight.trim();
if (window.innerHeight > window.innerWidth) {
bannerHeight = parseFloat(mobileBannerHeight);
} else {
bannerHeight = parseFloat(bannerHeight);
}
bannerHeight = Math.round(windowHeight * bannerHeight / 100);
return bannerHeight;
};
var head = $("#masthead");
var bgHeight = getBgHeight(window.innerHeight, '65', '45');
head.css('height', bgHeight + "px");
</script>

View File

@@ -0,0 +1,35 @@
<!-- 直接结束掉 container 并去除上下边距 -->
</div>
<?php
//判断图片是否存在 输出BG路径, 没有则为空
$u = db_find_one('attach', array('tid'=>$tid,'isimage'=>2));
if ($u==NULL){ $viewimg = '';}
else{ $viewimg = 'url('.$conf['upload_url'].'attach/'.$u['filename'].')'; }
?>
<!-- 部分 style 打包放进气泡的 CSS 文件, 只有列表,主题,编辑页面需要 主页不要 -->
<style>
.blog-background { background:#2C2A2A <?php echo $viewimg; ?>; color:#CCC; }
#body { padding-bottom: 0; padding-top: 0;}
</style>
<!-- CSS3 气泡 不能放全局 否则不需要气泡的页面会被遮挡-->
<link rel="stylesheet" href="plugin/z_daisy/view/css/bubble.css">
<!-- DAISY 需要最大宽度, 所以要把 header 中限制宽度的 DIV 移到每个页面中去? -->
<header id="masthead">
<div class="blog-background"></div>
<div class="inner">
<h1 class="blog-title" style="" itemprop="name"><?php echo $thread['subject'];?></h1>
<h2 class="blog-description light bordered bordered-top" style="" itemprop="description">12 月 23 日 2015 年 • 已有 3952 位童鞋围观过</h2>
</div>
<!-- CSS3 气泡 同上 放全局并先隐藏-->
<ul class="bg-bubbles">
<li></li><li></li><li></li><li></li><li></li>
<li></li><li></li><li></li><li></li><li></li>
</ul>
</header>
<!-- 重新开始 container 这是一种兼容的做法 thread 页的 id="body" 将失去意义-->
<div class="container">