资源库最新界面修改

This commit is contained in:
lizanle 2015-08-19 17:13:57 +08:00
parent 0ef7d5f0fa
commit 929da7512d
8 changed files with 133 additions and 45 deletions

View File

@ -825,7 +825,38 @@ class UsersController < ApplicationController
# 删除用户资源
def user_resource_delete
Attachment.delete(params[:resource_id])
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
#@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
if(params[:type].nil? || params[:type] == "1") #全部
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
"and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " +
"or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
"or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
end
elsif params[:type] == "4" #附件
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
end
end
@type = params[:type]
respond_to do |format|
format.js
end

View File

@ -2,6 +2,6 @@
:remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" />
<%= hidden_field_tag(:type,type) %>
<%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %>
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
<% end %>

View File

@ -1,8 +1,17 @@
<div class="resourceSharePopup"> <span class="sendText">将资源移动至 </span>
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>
<div class="resourceSharePopup">
<div>
<div class="sendText fl">将资源发送至</div>
<div class="resourcesSendTo">
<select class="resourcesSendType">
<option value="课程">课程</option>
<option value="项目">项目</option>
</select>
</div>
</div>
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>
<div class="fl">
<%= form_tag search_user_course_user_path(user),:method => 'get',
:remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %>
<%= hidden_field_tag(:send_id, @send_id) %>
@ -17,7 +26,7 @@
<%= hidden_field_tag(:send_id, @send_id) %>
<% if !courses.empty? %>
<% courses.each do |course| %>
<ul class="courseSend">
<ul class="courseSend fl">
<li class="fl">
<input name="course_ids[]" type="checkbox" value="<%= course.id %>" class="courseSendCheckbox"/>
</li>

View File

@ -1,7 +1,10 @@
<% if attachments.nil? || attachments.empty? %>
<% else %>
<% attachments.each do |attach| %>
<ul>
<ul class="resourcesList">
<li class="resourcesListCheckbox fl">
<input name="checkbox1" type="checkbox" class="resourcesCheckbox" />
</li>
<li class="resourcesListName fl">
<!--<a href="javascript:void(0);" class="resourcesBlack"><%#=truncate(attach.filename,:length=>18)%></a>-->
<%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename),

View File

@ -40,22 +40,22 @@
}
</script>
<div class="resources">
<div class="resourcesBanner">
<div class="bannerName">资源</div>
<div class="homepageRightBanner">
<div class="NewsBannerName">资源库</div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType">
<li>
<%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
<%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesTypeAll resourcesGrey' %>
</li>
<li>
<%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
<%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'homepagePostTypeAssignment postTypeGrey' %>
</li>
<li>
<%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
<%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'homepagePostTypeQuiz postTypeGrey' %>
</li>
<li>
<%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
<%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
</li>
</ul>
</li>
@ -63,14 +63,14 @@
</div>
<div class="resourcesSearchBanner">
<div class="resourcesUploadBox">
<div class="uploadIcon"></div>
<a href="javascript:void(0);" onclick="show_upload();" class="uploadText">上传资源</a></div>
<a href="javascript:void(0);" onclick="show_upload();" class="uploadBoxIcon">上传资源</a></div>
<div id="search_div">
<%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %>
</div>
</div>
<div class="resourcesListBanner">
<ul class="resourcesListTab">
<li class="resourcesListCheckbox fl"> </li>
<li class="resourcesListName fl">资源名称</li>
<li class="resourcesListSize fl">大小</li>
<li class="resourcesListType fl">类别</li>
@ -78,11 +78,21 @@
<li class="resourcesListTime fl">上传时间</li>
</ul>
</div>
<div>
<ul id="resources_list" class="resourcesList">
<div id="resources_list" class="resourcesList">
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
</ul>
</div>
<div class="resourcesListOption">
<div class="resourcesCheckAll">
<input id="checkboxAll" type="checkbox" value="" class="resourcesCheckbox" />
</div>
<a href="javascript:void(0);" class="replyGrey mr15">全选</a>
<a href="javascript:void(0);" class="replyGrey">删除</a>
<div class="resourcesSelectSend">
<div class="fl">选择&nbsp;<span class="c_red">10</span>&nbsp;个资源</div>
<div class="resourcesSelectSendButton">
<a href="javascript:void(0);" class="c_blue db">发送</a>
</div>
</div>
</div>
</div>
<div id="upload_box" style="display: none">
@ -190,9 +200,9 @@ $(".resourcesList").click(function(e) {
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
res_name = line.children().first().children().attr('title');
res_link = line.children().first().html();
line.children().first().html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'value="'+res_name+
@ -228,23 +238,23 @@ $(".resourcesList").click(function(e) {
$("#res_name_form").serialize(),
function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().first().html(res_link);
last_line.children().first().children().attr('title',name);
last_line.children().first().children().attr('href',data);
last_line.children().first().children().html(name.length > 17? name.substring(0,17)+'...' : name);
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title',name);
last_line.children().eq(1).children().attr('href',data);
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
}else{
last_line.children().first().html(res_link);
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
},
'text'
);
}else{
last_line.children().first().html(res_link);
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空
}
}else {
last_line.children().first().html(res_link);
last_line.children().eq(1).html(res_link);
res_link = null;//如果没有做修改恢复之后将res_link置空
}
@ -259,10 +269,10 @@ $(".resourcesList").click(function(e) {
}
line.children().css("background-color", 'white');
id = line.children().last().html();
if (confirm('确定要删除资源"' + line.children().first().children().attr('title').trim() + '"么?')){
if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')){
$.ajax({
type: 'post',
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id
url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id+'&type='+$('#type').val()
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -445,34 +445,52 @@ div.ke-statusbar{height:1px; border-top:none;}
/*a.f_grey {color:#666666;}*/
/*a.f_grey:hover {color:#000000;}*/
/*资源库*/
.resources {width:730px; background-color:#ffffff; padding:10px;float: right}
.resources {width:728px; background-color:#ffffff; padding:10px; border:1px solid #dddddd;float: right}
/*.resources {width:730px; background-color:#ffffff; padding:10px;float: right}*/
.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}
.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}
.resourcesSelect {width:40px; height:40px; float:right; position:relative;}
.resourcesSelected {width:25px; height:20px;}
.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}
.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}
.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}
.resourcesSelect {width:30px; height:34px; float:right; position:relative; margin-top:-6px;}
.resourcesSelected {width:25px; height:20px; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat;}
.resourcesSelected:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}
.resourcesIcon {margin-top:15px; display:block; width:25px; height:20px;}
/*.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}*/
/*.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}*/
/*.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}*/
a.resourcesGrey {font-size:12px; color:#888888;}
a.resourcesGrey:hover {font-size:12px; color:#15bccf;}
.resourcesBanner ul li:hover ul.resourcesType {display:block;}
ul li:hover ul {display:block;}
.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}
.resourcesUploadBox:hover {background-color:#0781b4;}
.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}
a.uploadText {color:#ffffff; font-size:14px;}
.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}
.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:left; background-color:#ffffff;}
.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}
.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}
.resourcesSearchBanner {height:34px; margin-bottom:10px;}
.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}
.resourcesListName {width:175px; height:40px; line-height:40px; text-align:center;}
.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}
/*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/
.resourcesSearchBanner {width:710px; height:34px; margin-bottom:10px; margin-top:15px; margin-left:auto; margin-right:auto;}
/*.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}*/
.resourcesListTab {width:710px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a; margin-left:auto; margin-right:auto;}
/*.resourcesListName {width:175px; height:40px; line-height:40px; text-align:center;}*/
/*.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}*/
/*.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}*/
/*.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}*/
/*.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}*/
.resourcesListName {width:160px; height:40px; line-height:40px; text-align:left;}
.resourcesListSize {width:105px; height:40px; line-height:40px; text-align:center;}
.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}
.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}
.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}
.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}
.resourcesListUploader {width:180px; height:40px; line-height:40px; text-align:center;}
.resourcesListTime {width:95px; height:40px; line-height:40px; text-align:center;}
/*.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}*/
a.resourcesBlack {font-size:12px; color:#4c4c4c;white-space: nowrap;text-align: left}
a.resourcesBlack:hover {font-size:12px; color:#000000;}
.resourcesListCheckbox {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle;}
.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;}
.resourcesList {width:710px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px; margin-left:auto; margin-right:auto;}
.resourcesListOption {width:710px; height:40px; line-height:40px; vertical-align:middle; margin-left:auto; margin-right:auto; background-color:#f6f6f6;}
.resourcesCheckAll {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle; float:left;}
.resourcesSelectSend {float:right;}
.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;}
.dropdown-menu {
position: absolute;
top: 100%;
@ -508,12 +526,26 @@ a.resourcesBlack:hover {font-size:12px; color:#000000;}
background-color: #64bdd9;
outline:none;
}
.homepageRightBanner {width:720px; height:34px; margin:0px auto; border-bottom:1px solid #e9e9e9;}
.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; background:url(images/homepage_icon.png) -18px -230px no-repeat; width:150px; float:left; padding-left:15px; margin-top:4px;}
a.resourcesTypeAll {background:url(images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;}
a.resourcesTypeAtt {background:url(images/homepage_icon.png) -180px -49px no-repeat; padding-left:23px;}
.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;}
.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}
.resourcesUploadBox:hover {background-color:#0781b4;}
/* 个人主页右边部分*/
.homepageSearchIcon {width:30px; height:32px; background:url(images/nav_icon.png) -8px 3px no-repeat; float:left;}
a.homepagePostTypeQuiz {background:url(images/homepage_icon.png) -90px -124px no-repeat; padding-left:23px;}
a.homepagePostTypeAssignment {background:url(images/homepage_icon.png) -93px -318px no-repeat; padding-left:23px;}
a.replyGrey {color:#888888; display:inline-block;}
a.replyGrey:hover {color:#4b4b4b;}
/*上传资源弹窗*/
.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}
.uploadDialogText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative}
.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;}
a.uploadBoxIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:81px; height:30px; padding-left:22px; font-size:14px; color:#ffffff;}
a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}
.chooseFile {color:#ffffff; display:block; margin-left:32px;}
.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}
@ -524,8 +556,9 @@ a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat;
/*发送资源弹窗*/
/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/
/*.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}*/
.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}
.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}
.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:100px; display:inline-block;}
.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}
.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}
.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
@ -538,5 +571,7 @@ a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat;
.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}
a.sendSourceText {font-size:14px; color:#ffffff;}
input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;}
.resourcesSendTo {float:left; height:20px; margin-top:15px;}
.resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;}