资源库

This commit is contained in:
lizanle 2015-08-15 17:07:50 +08:00
parent 89b9a5c09d
commit 421f86cdaf
17 changed files with 2772 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<!--<button name="button" class="sub_btn" onclick="_file.click()" onmouseover="this.focus()" style="<%#= ie8? ? 'display:none' : ''%>" type="button" ><%#= l(:label_browse) %></button>-->
<a href="javascript:void(0);" class="uploadIcon f14" name="button" onclick="_file.click()" onmouseover="" style="<%= ie8? ? 'display:none' : ''%>">
<span class="chooseFile">选择文件</span></a>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => ie8? ? '':'file_selector',
:multiple => true,
:onchange => 'addInputFiles(this);',
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:upload_path => uploads_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all)
} %>
<!--<input type="submit" name="" value="上传文件" class="f_l ml10" style="width:80px; height:26px;">-->
<!--<span id="upload_file_count">-->
<!--<%#= l(:label_no_file_uploaded)%>-->
<!--</span>-->
<!--(<%#= l(:label_max_size) %>:-->
<%#= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>
<!--)-->

View File

@ -0,0 +1,43 @@
<script>
$(document).ready(function(){
var popupHeight = $(".resourceUploadPopup").outerHeight(true);
$(".resourceUploadPopup").css("marginTop",-popupHeight/2);
$(".resourcePopupClose").click(function(){
$(".resourceUploadPopup").css("display","none");
});
});
</script>
<div class="resourceUploadPopup"><span class="uploadText">上传资源 </span>
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose"></a></div>
<div class="uploadBoxContainer">
<div class="uploadBox"><a href="javascript:void(0);" class="uploadIcon f14"><span class="chooseFile">选择文件</span></a></div>
<div class="uploadResourceIntr">
<div class="uploadResourceName">(未选择文件)</div>
<div class="uploadResourceIntr2">您可以上传小于<span class="c_red">50MB</span>的文件</div>
</div>
</div>
<div>
<select class="uploadType">
<option value="">资源类型</option>
<option value="课件资源">课件资源</option>
<option value=“"项目资源">项目资源</option>
<option value="附件">附件</option>
<option value="无">无</option>
</select>
</div>
<div>
<input type="text" name="" placeholder="关键词" class="uploadKeyword" />
</div>
<div>
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText">确定</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText">取消</a></div>
</div>
<div class="cl"></div>
</div>

View File

@ -0,0 +1,17 @@
<% if attachments.nil? || attachments.empty? %>
<% else %>
<% attachments.each do |attach| %>
<ul>
<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),
:title => attach.filename+"\n"+attach.description.to_s,:class=>'resourcesBlack'%>
</li>
<li class="resourcesListSize fl"><%= number_to_human_size(attach.filesize) %></li>
<li class="resourcesListType fl"><%= get_resource_type(attach.container_type)%></li>
<li class="resourcesListUploader fl"><%=User.find(attach.author_id).realname %></li>
<li class="resourcesListTime fl"><%= format_date(attach.created_on) %></li>
<li style="display: none"><%= attach.id %></li>
</ul>
<% end %>
<% end %>

View File

@ -0,0 +1,53 @@
<div class="resourceUploadPopup"><span class="uploadDialogText">上传资源 </span>
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>
<div class="uploadBoxContainer">
<%= form_tag(user_resource_create_user_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
<div>
<span id="attachments_fields" xmlns="http://www.w3.org/1999/html">
<% if defined?(container) && container && container.saved_attachments %>
<script>alert('<% container%>')</script>
<% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'remove-upload')%>
<%= if attachment.id.nil?
#待补充代码
else
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
end
%>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span>
<% end %>
<% end %>
</span>
</div>
<div class="uploadBox">
<input type="hidden" name="attachment_type" value="1">
<%= render :partial => 'attachment_list' %>
<div class="cl"></div>
<!--<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="closeModal();"><%#= l(:button_cancel)%></a>-->
<!--<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%#= l(:button_confirm)%></a>-->
</div>
<div class="uploadResourceIntr">
<div class="uploadResourceName"><span id="upload_file_count">(未选择文件)</span></div>
<div class="uploadResourceIntr2">您可以上传小于<span class="c_red">50MB</span>的文件</div>
</div>
</div>
<div class="cl"></div>
<div style="margin-top: 10px" >
<div class="courseSendSubmit">
<!--<a href="javascript:void(0);" class="sendSourceText" onclick="">确定</a>-->
<%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:class=>'sendSourceText' %>
</div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="closeModal();">取消</a></div>
</div>
<% end %>
<div class="cl"></div>
</div>

View File

@ -0,0 +1 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');

View File

@ -0,0 +1,177 @@
<%= javascript_include_tag 'bootstrap'%>
<%= stylesheet_link_tag 'project' %>
<%= stylesheet_link_tag 'leftside' %>
<%= javascript_include_tag 'attachments'%>
<script>
function remote_get_resources(user_id,type){
}
function remote_search(){
$("#resource_search_form").submit();
}
function show_upload(){
var screenWidth = $(window).width();
var screenHeight = $(window).height(); //当前浏览器窗口的 宽高
var scrolltop = $(document).scrollTop();//获取当前窗口距离页面顶部高度
var objLeft = (screenWidth - 2)/2.5 ; //2 可以根据需要修改
var objTop = (screenHeight - 100)/2 + scrolltop; //100可以根据需要修改
var popupHeight = $(".resourceUploadPopup").outerHeight(true);
$(".resourceUploadPopup").css("marginTop",-popupHeight/2);
$("#upload_box").css('left',objLeft).css('top',objTop);
$("#upload_box").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>@user})%>');
$("#upload_box").css('display','block');
}
function closeModal()
{
//hideModal($("#popbox_upload"));
//$("#attachments_fields").html('');
$("#upload_box").css("display","none");
}
function check_files(){
return $("#attachments_fields").children().length == 0;
}
function submit_files(){
$("#upload_form").submit();
}
</script>
<div class="resources">
<div class="resourcesBanner">
<div class="bannerName">资源</div>
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType">
<li>
<!--<a href="javascript:void(0);" remote="true" onclick="remote_get_resources('',1)" class="resourcesGrey">全部</a>-->
<%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
</li>
<li>
<!--<a href="javascript:void(0);" class="resourcesGrey">课程资源</a>-->
<%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
</li>
<li>
<!--<a href="javascript:void(0);" class="resourcesGrey">项目资源</a>-->
<%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
</li>
<li>
<!--<a href="javascript:void(0);" class="resourcesGrey">附件</a>-->
<%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
</li>
</ul>
</li>
</ul>
</div>
<div class="resourcesSearchBanner">
<div class="resourcesUploadBox">
<div class="uploadIcon"></div>
<a href="javascript:void(0);" onclick="show_upload();" class="uploadText">上传资源</a></div>
<div>
<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>@user.id),
:remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
<input type="text" name="search" placeholder="输入资源关键词进行" class="searchResource" />
<%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %>
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
<% end %>
</div>
</div>
<div class="resourcesListBanner">
<ul class="resourcesListTab">
<li class="resourcesListName fl">资源名称</li>
<li class="resourcesListSize fl">大小</li>
<li class="resourcesListType fl">类别</li>
<li class="resourcesListUploader fl">上传者</li>
<li class="resourcesListTime fl">上传时间</li>
</ul>
</div>
<div>
<ul id="resources_list" class="resourcesList">
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
</ul>
</div>
</div>
<div id="upload_box" style="display: none">
<%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%>
</div>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" id="contextMenu">
<li><a tabindex="-1" href="#">预览</a></li>
<li><a tabindex="-1" href="#">重命名</a></li>
<li><a tabindex="-1" href="#" onclick="show_send();">发送</a></li>
<li><a tabindex="-1" href="#" onclick="delete_file();">删除</a></li>
</ul>
<script>
var pageX = 0;
var pageY = 0;
var line;
var last_line;
$(".resourcesList").mousedown(function(e) {
if (3 == e.which) {
document.oncontextmenu = function() {return false;}
pageX = e.clientX;
pageY = e.clientY;
$("#contextMenu").hide();
$("#contextMenu").attr("style","display: block; position: fixed; top:"
+ pageY
+ "px; left:"
+ pageX
+ "px; width: 80px;");
$("#contextMenu").show();
//当前光标所在的对象
var ele = document.elementFromPoint(pageX,pageY);
//转换为jquery对象
line = $(ele).parent();
//如果上一条存在被选中,那么将上一条的背景色改为白色
if(last_line){
last_line.children().css("background-color", 'white');
last_line == null;
}
//如果当前的tag是li那么还要li的父级元素
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
//将当前的元素的所有子元素的背景色改为蓝色
line.children().css("background-color", '#00ffff');
//将当前元素赋给 上一个对象 保存起来。
last_line = line;
}
});
$(".resourcesList").click(function(e) {
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
if(line == null){
var ele = document.elementFromPoint(e.clientX, e.clientY);
line = $(ele).parent();
if(line.get(0).tagName === 'LI'){
line = line.parent();
}
}
line.children().css("background-color", 'white');
line = null;
});
function show_send(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
line.children().last().html();
}
function delete_file(){
$("#contextMenu").hide();
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
$.ajax({
type:'post',
url:'<%= user_resource_delete_user_path(@user)%>'+'?resource_id='+id
});
}
</script>

View File

@ -0,0 +1 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');

View File

@ -0,0 +1,3 @@
closeModal();
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');

View File

@ -0,0 +1 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');

2363
public/javascripts/bootstrap.js vendored Normal file

File diff suppressed because it is too large Load Diff

19
public/javascripts/jquery-1.3.2.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,64 @@
/* =================================================
//
// jQuery Fixed Plugins 1.3.1
// author :
// Url:
// Data : 2012-03-30
//
// 参数 : float --> 悬浮方向[left or right]
// minStatue --> 最小状态只有show_btn
// skin --> 皮肤控制
// durationTime --> 完成时间
//事例 :
$("#scrollsidebar2").fix({
float : 'right', //default.left or right
minStatue : true, //default.false or true
skin : 'green', //default.gray or yellow 、blue 、green 、orange 、white
durationTime : 1000 //
});
//
// =================================================*/
;(function($){
$.fn.fix = function(options){
var defaults = {
float : 'left',
minStatue : false,
skin : 'blue',
durationTime : 1000
}
var options = $.extend(defaults, options);
this.each(function(){
//获取对象
var thisBox = $(this),
closeBtn = thisBox.find('.close_btn' ),
show_btn = thisBox.find('.show_btn' ),
sideContent = thisBox.find('.side_content'),
sideList = thisBox.find('.side_list')
;
var defaultTop = thisBox.offset().top; //对象的默认top
thisBox.css(options.float, 0);
if(options.minStatue){
$(".show_btn").css("float", options.float);
sideContent.css('width', 0);
show_btn.css('width', 25);
}
//close事件
closeBtn.bind("click",function(){
sideContent.animate({width: '0px'},"fast");
show_btn.stop(true, true).delay(300).animate({ width: '25px'},"fast");
});
//show事件
show_btn.click(function() {
$(this).animate({width: '0px'},"fast");
sideContent.stop(true, true).delay(200).animate({ width: '154px'},"fast");
});
}); //end this.each
};
})(jQuery);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB