Skip to content

Commit

Permalink
移动端优化布局
Browse files Browse the repository at this point in the history
  • Loading branch information
Husen committed Jan 15, 2018
1 parent 7995f33 commit b171d3d
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 55 deletions.
20 changes: 15 additions & 5 deletions WebContent/css/navigation/topbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}

.access-today {
margin-left: 70px !important;
margin-left: 5% !important;
}

.online-current {
Expand All @@ -28,15 +28,15 @@
padding: 2px 2px !important;
font-size: 13px;
border: 1px solid #f0ad4e;
margin-left: 50px;
margin-left: 2%;
display: none;
}

.topbar-btn-pers {
padding: 2px 2px !important;
font-size: 13px;
border: 1px solid #5bc0de;
margin-left: 50px;
margin-left: 2%;
display: none;
}

Expand All @@ -49,13 +49,23 @@
}

.choose-theme {
margin: 10px 200px;
margin: 10px;
}

.web-pc-blank {
float: left;
margin-left: 20px;
}

.header-nav {
margin: 0;
float: left;
margin-left: 6%;
}

.choose-theme button {
float: left;
}

.top-bar-div{
margin: 18px 0px 5px 10px;
}
17 changes: 12 additions & 5 deletions WebContent/css/personal_center/mycenter.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

.version-input {
/* resize: none; */
}

.return-index-blank {
margin-left: 20px;

}

.form-show-userinfo {
Expand All @@ -22,6 +19,16 @@
height: 80px;
}

.form-show-p{
.form-show-p {
width: 30%;
}

.return-index-blank {
float: left;
margin-left: 20px;
}

.left-bar{
clear:both;
margin-top: 40px;
}
1 change: 1 addition & 0 deletions WebContent/css/personal_center/upload-file.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

.upload-file-form {
margin-top: 50px;
margin-bottom: 50px;
}
4 changes: 2 additions & 2 deletions WebContent/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@
<div class="fh5co-narrow-content article-box-div">
<h2 class="fh5co-heading article-bar"
data-animate-effect="fadeInLeft">最近更新的博客</h2>
<a href="/module/blog.jsp" class="read-more-article"><span
<a href="/module/blog.hms" class="read-more-article"><span
class="glyphicon glyphicon-hand-right"></span>&nbsp;阅读更多博客</a>
<div id="latestBlog" class="row"></div>
</div>
<hr class="index-hr" />
<div class="fh5co-narrow-content article-box-div">
<h2 class="fh5co-heading article-bar"
data-animate-effect="fadeInLeft">最近更新的代码</h2>
<a href="/module/code_library.jsp" class="read-more-article"><span
<a href="/module/code.hms" class="read-more-article"><span
class="glyphicon glyphicon-hand-right"></span>&nbsp;阅读更多代码</a>
<div id="latestCode" class="row"></div>
</div>
Expand Down
30 changes: 30 additions & 0 deletions WebContent/js/is-center-mobile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @desc 判断后台是否是手机
*
* @author 何明胜
*
* @created 2018年1月15日 下午1:05:01
*/

$(function() {
var mobile_flag = $.isMobile(); // false为PC端,true为手机端

if (mobile_flag) {
// 顶部导航栏
$('.header-nav').css({
'margin-left': '0 !important'
})
$('#accessToday').css({
'margin-left' : '0'
});
$('#onlineCurrent').css({
'margin-left' : '5px'
});

setTimeout(function() {
alert(1)
//导航栏加上边距
$('#topBar').children('div').addClass('top-bar-div');
}, 300);
}
});
64 changes: 38 additions & 26 deletions WebContent/js/is-pc-or-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,47 @@
*
* 2017年9月27日
*/
$(function(){
$(function() {
var mobile_flag = $.isMobile(); // false为PC端,true为手机端

if(mobile_flag){
//调整中间内容布局
$('#fh5co-main').css({'width': '100%', 'float': 'right'});
$('#trademark').css({'margin-left': '48px','margin-top': '16px'});

//左侧菜单栏

if (mobile_flag) {
// 调整中间内容布局
$('#fh5co-main').css({
'width' : '100%',
'float' : 'right'
});

// 左侧菜单栏
$('.fh5co-footer.footer-div').css('margin-top', 0);

//顶部导航栏
$('#accessToday').css({'margin-left': '0'});

//博客和代码左边距
$('#fh5co-main').css({'margin-left': '0px'});
$('#list_code').css({'margin-left': '0px'});

//留言是动态加载的,需等待一会儿
setTimeout(function(){
//右边导航栏隐藏

// 顶部导航栏
$('#accessToday').css({
'margin-left' : '0'
});

// 博客和代码左边距
$('#fh5co-main').css({
'margin-left' : '0'
});
$('#list_code').css({
'margin-left' : '0'
});

// 留言是动态加载的,需等待一会儿
setTimeout(function() {
// 右边导航栏隐藏
$('#rightBar').hide();

if($('#message_box').length>0){
//留言框
$('#message_box').find('textarea').css('width','42%');
//回复留言
$('#message_box').children().children().find('button').css({'cssText' : 'margin-left: 20% !important'});
//导航栏加上边距
$('#topBar').children('div').addClass('top-bar-div');

if ($('#message_box').length > 0) {
// 留言框
$('#message_box').find('textarea').css('width', '42%');
// 回复留言
$('#message_box').children().children().find('button').css({
'cssText' : 'margin-left: 20% !important'
});
}
},300);
}, 300);
}
});
4 changes: 2 additions & 2 deletions WebContent/js/personal_center/personal-center.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ function uploadFile() {
$('#mainWindow').html('');

$.ajax({
url : '/personal_center/upload_file.html', // 这里是静态页的地址
url : '/personal_center/upload_file.html',
async : false,
type : 'GET', // 静态页用get方法,否则服务器会抛出405错误
type : 'GET',
success : function(data) {
$('#mainWindow').html(data);
}
Expand Down
133 changes: 133 additions & 0 deletions WebContent/js/personal_center/upload-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* @author 何明胜
*
* 2017年12月1日
*/

var $fileList;
var $btnUpload;
var state = 'pending';
var web_uploader;

$(function() {
$fileList = $('#file_list');
$btnUpload = $('#btn_uploadStart');

initWebLoader();
showFileList();
uploadProgress();
callbackFun();
uploadClick();
});

/**
* 初始化Web Uploader
*
* @returns
*/
function initWebLoader() {
web_uploader = WebUploader.create({
// swf文件路径
swf : '/plugins/webuploader/Uploader.swf',

// 文件接收服务端。
server : '/fileUpload.hms',

// 选择文件的按钮。可选。
// 内部根据当前运行时创建,可能是input元素,也可能是flash.
pick : '#file_choose',

// 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传!
resize : false
});
}

/**
* 显示用户选择
*
* @returns
*/
function showFileList() {
// 当有文件被添加进队列的时候
web_uploader.on('fileQueued', function(file) {
$fileList.append('<div id="' + file.id + '" class="item">'
+ '<h4 class="info">' + file.name + '</h4>'
+ '<p class="state">等待上传...</p>' + '</div>');
});
}

/**
* 文件上传进度显示
* @returns
*/
function uploadProgress(){
// 文件上传过程中创建进度条实时显示。
web_uploader.on( 'uploadProgress', function( file, percentage ) {
var $li = $( '#'+file.id );
var $percent = $li.find('.progress .progress-bar');

// 避免重复创建
if ( !$percent.length ) {
$percent = $('<div class="progress progress-striped active">' +
'<div class="progress-bar" role="progressbar" style="width: 0%">' +
'</div>' +
'</div>').appendTo( $li ).find('.progress-bar');
}

$li.find('p.state').text('上传中');

$percent.css( 'width', percentage * 100 + '%' );
});
}

/**
* 回调函数
* @returns
*/
function callbackFun(){
/** 文件上传成功 **/
web_uploader.on('uploadSuccess', function( file ) {
$('#'+file.id).find('p.state').text('已上传');
});

/** 文件上传失败 **/
web_uploader.on('uploadError', function( file ) {
$('#'+file.id).find('p.state').text('上传出错');
});

/** 不管成功或者失败,在文件上传完后都会触发uploadComplete事件 **/
web_uploader.on('uploadComplete', function( file ) {
$('#'+file.id).find('.progress').fadeOut();
});

/** 所有的事件触发都会响应到,改变当前状态 **/
web_uploader.on( 'all', function( type ) {
if ( type === 'startUpload' ) {
state = 'uploading';
} else if ( type === 'stopUpload' ) {
state = 'paused';
} else if ( type === 'uploadFinished' ) {
state = 'done';
}

if ( state === 'uploading' ) {
$btnUpload.text('暂停上传');
} else {
$btnUpload.text('开始上传');
}
});
}

/**
* 开始上传点击事件
* @returns
*/
function uploadClick(){
$btnUpload.click(function() {
if (state === 'uploading') {
web_uploader.stop();
} else {
web_uploader.upload();
}
});
}
Loading

0 comments on commit b171d3d

Please sign in to comment.