Skip to content

Commit

Permalink
PIMP FileManager WIP"
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Sep 4, 2010
1 parent cd7e657 commit 6aad840
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 96 deletions.
3 changes: 2 additions & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def display_targets_table(display = true)
handle_table_actions
end

@active_table_output = email_targets_table_generate params, :per_page => 25, :include => [:user_class, :domain_file]
params[email_targets_table_name] = params[:email_targets_table]
@active_table_output = email_targets_table_generate params, :per_page => 10, :include => [:user_class, :domain_file]

@handlers_data = UserSegment.get_handlers_data(@active_table_output.data(&:id), @fields)

Expand Down
11 changes: 10 additions & 1 deletion app/helpers/file_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ def fm_file_info(file)
end
end

def filemanager_details(file)
details = []
details << "#{file.width}x#{file.height}" if file.image?
details << number_to_human_size(file.file_size) if file.file_size
details << "Created " + file.created_at.localize(DEFAULT_DATETIME_FORMAT.t) if file.created_at
details.join(", ")

end

def filemanager_register_details(file)
file_info = fm_file_info(file)
<<-END_OF_SCRIPT
Expand Down Expand Up @@ -44,7 +53,7 @@ def file_manager_image_tag(file,size,icon_size)
tag("img",
:title => file.name,
:src => url,
:align => 'middle',
:align => 'absmiddle',
:id => "thumb_image_#{file.id}",
:width => thumb_size[0],
:height => thumb_size[1]
Expand Down
2 changes: 1 addition & 1 deletion app/views/file/_create_folder.rjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ page << 'FileEditor.showDetails();'

page << "setTimeout('FileEditor.refreshUploadedFolder(#{@folder.id},#{@parent_id})',10);"
page << "FileEditor.recreateDragAndDroppables();"
page << "FileEditor.highlightTreeFolder(#{@folder.id});"
# page << "FileEditor.highlightTreeFolder(#{@folder.id});"
page << "setTimeout('FileEditor.nameChange(#{@folder.id});',20); "
14 changes: 4 additions & 10 deletions app/views/file/_file_item.rhtml
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
<div id='item_<%= file.id %>' class='fm_element <%= file.file_type=='fld'?'fm_folder':'fm_item' %>' <%= "style='display:none'" if (@hide_item || @file_manager_update) %> >
<div class='fm_image fm_image_<%= file.file_type %>' id='handle_item_<%= file.id %>' >
<div id='item_<%= file.id %>' class='fm_element <%= file.file_type=='fld'?'fm_folder':'fm_item' %>' <%= "style='display:none'" if (@hide_item || @file_manager_update) %> >
<div class='fm_image fm_image_<%= file.file_type %>' id='handle_item_<%= file.id %>' >
<%= file_manager_image_tag(file,@image_size,@icon_size) %>
</div>
<div class='fm_cover' id='cover_<%= file.id %>'></div>
<div id='name_item_<%= file.id %>' class='fm_title'><%= file.name %>
<div class='fm_details'>
<%= details = []
details << "#{file.width}x#{file.height}" if file.image?
details << number_to_human_size(file.file_size) if file.file_size
details << "Created " + file.created_at.localize(DEFAULT_DATETIME_FORMAT.t) if file.created_at
details.join(", ")
-%>
</div>
<div class='fm_details'><%= filemanager_details(file) -%></div>
</div>

<div class='fm_lock' id='item_lock_<%= file.id %>' <%= "style='display:none;'" unless file.private? %>><span class='sprite_icon lock_sprite'></span></div>
<div class='fm_extension' ><%= file.extension %></div>
<div class='fm_processing'><%= "Processing" if file.processor_status == 'processing' %></div>
<div style='display:none;' class='fm_item_count'></div>
<div class='fm_dragger' id='handle_wrapper_<%= file.id %>'></div>


<%= filemanager_register_file(file,@icon_size,@select) %>
Expand Down
20 changes: 15 additions & 5 deletions app/views/file/_file_javascript.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ FileEditor = {
FileEditor.display = 'list';
$('file_manager').className = 'file_manager_list clearfix';
FileEditor.updateIconSizes();
$j(window).resize();
}
else if(view_type == 'icon') {
$('view_icon').className = 'image_icon_selected';
$('view_list').className = 'image_icon';
FileEditor.display = 'icon';
$('file_manager').className = 'file_manager_icon clearfix';
FileEditor.updateIconSizes();
$j(window).resize();
}
},

Expand All @@ -67,6 +69,7 @@ FileEditor = {
if(selectedSize != FileEditor.iconSizeName) {
FileEditor.reloadThumbImages(selectedSize);
}
$j(window).resize();
}


Expand Down Expand Up @@ -274,7 +277,8 @@ FileEditor = {
fmCreateDraggable: function (elem) {
if(elem && elem.id != '') {
var draggable = new Draggable(elem.id,
{ handle: 'handle_' + elem.id,
{
handle: 'handle_wrapper_' + SCMS.getElemNum(elem.id),
revert:true,
scroll: window,
starteffect: FileEditor.iconStartDrag,
Expand Down Expand Up @@ -413,7 +417,7 @@ FileEditor = {


createTreeFolderDroppable: function(elem) {
var dropTitle = getChild(elem,'node_line');
var dropTitle = $(elem).select('.node_line')[0];

return Droppables.add(dropTitle.id, {
hoverclass:'node_accept',
Expand All @@ -438,7 +442,7 @@ FileEditor = {
FileEditor.selectTreeNode(null);
elem.saved_bg = elem.style.backgroundImage;
elem.style.backgroundImage = 'none';
var droppable = getChild(elem,'node_line');
var droppable= $(elem).select('.node_line')[0];
Droppables.remove(droppable.id);
},

Expand All @@ -451,7 +455,7 @@ FileEditor = {

// Tree Related Functions
refreshNodeView: function(nodeDiv) {
var updateDiv = getChild(nodeDiv,'node_children');
var updateDiv = $(nodeDiv).select('.node_children')[0];

var elems = getChildElementsByClass(updateDiv,'node');

Expand Down Expand Up @@ -495,7 +499,7 @@ FileEditor = {
var moved_folder = $('node_element_' + moved_folder_id);
var dest_folder = $('node_element_' + dest_folder_id);

var dest_children = getChild(dest_folder,'node_children');
var dest_children = $(dest_folder).select('.node_children')[0];

var moved_folder_parent_children = moved_folder.parentNode;
var moved_folder_parent = moved_folder_parent_children.parentNode;
Expand Down Expand Up @@ -717,6 +721,10 @@ FileEditor = {

deleteSelected: function(file_ids) {
if(confirm('<%= jh "Are you sure you want to delete the selected item(s)?" %>')) {
var loadParent = null
if(file_ids[0] == FileEditor.nodeSelected) {
loadParent = SCMS.getElemNum($('node_element_' + FileEditor.nodeSelected).parentNode);
}
var itms = file_ids ? file_ids : FileEditor.selectedItems;
var req = $H({ 'file_id[]' : itms });
new Ajax.Request('<%= url_for :controller => "file", :action => "delete_files" %>',
Expand All @@ -726,6 +734,7 @@ FileEditor = {
itms.each(function(item_id) { FileEditor.removeItem(item_id); });
FileEditor.hideDetails();
FileEditor.updateAvailableStorage();
if(loadParent) FileEditor.gotoFolder(loadParent);
} });
}
},
Expand Down Expand Up @@ -756,6 +765,7 @@ FileEditor = {
uploadProgressID: null,

startUpload:function(form) {
FileEditor.selectUpload();
var uuid = "";
for (i = 0; i < 32; i++) { uuid += Math.floor(Math.random() * 16).toString(16); }
form.action = "<%= url_for :action => 'upload' -%>?X-Progress-ID=" + uuid;
Expand Down
6 changes: 2 additions & 4 deletions app/views/file/_file_search_bar.rhtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<div class='action_area_content' style='float:right'>
<%= form_tag '', :onsubmit => "FileEditor.runSearch(this); return false;" %>
<h2>
<%= theme_image_tag('framework/filemanager_search.gif') -%>
Search For <input class="text_field_input" id="search_search" name="search[search]" size="20" type="text" />
<%= theme_image_tag('framework/filemanager_search.gif', :align => 'baseline') -%>
Search For <input class="text_field_input" id="search_search" name="search[search]" size="15" type="text" />
<input class="button_link" id="search_submit" name="commit" type="submit" value="Search" />
</h2>
</form>
</div>

5 changes: 3 additions & 2 deletions app/views/file/_file_tree.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<% end -%>
<% if fld.parent_id.nil? %>
<%= theme_image_tag("icons/menu/white.gif") -%>
<%= #theme_image_tag("icons/menu/white.gif")
-%>
<% elsif fld.subfolders.length > 0 -%>
<%= theme_image_tag "icons/menu/last_closed.gif", :class => "line_icon", :id => "toggle_#{fld.id}", :onclick => "FileEditor.toggleVisible(this);" -%>
<% else -%>
Expand Down Expand Up @@ -52,7 +53,7 @@


<br/>
<div id='children_<%= fld.id %>' class='node_children' <%= "style='display:none;'" unless fld.parent_id.nil? %>>
<div id='children_<%= fld.id %>' class='node_children<%= " node_children_first" if fld.parent_id.nil? %>' <%= "style='display:none;'" unless fld.parent_id.nil? %>>
<% if fld.subfolders.length > 0 -%>
<%= render :partial => "file_tree", :locals => { :folders => fld.subfolders } %>
<% end -%>
Expand Down
7 changes: 2 additions & 5 deletions app/views/file/_file_upload_area.rhtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

<div class='action_area_content' id='files_upload_area' style='float:left;' >
<div id='upload_progress' style='display:none;' ></div>
<div id='upload_action'>
<%= form_tag({:action => 'upload'}, :onsubmit => "this.target = 'UploadTarget'; FileEditor.startUpload(this); FileEditor.hideDetails(); return true;", :enctype => 'multipart/form-data') %>
<div style='float:left;'>
<h2>
<%= theme_image_tag('framework/filemanager_upload_file.gif') -%>
<%= "Upload New File:".t %>
<%= theme_image_tag('framework/filemanager_upload_file.gif',:align =>'baseline') -%>
<%= "Upload File".t %>&nbsp;
</h2>
</div>
<div style='float:left; position:relative;'>
Expand Down Expand Up @@ -37,4 +35,3 @@
</div>

<iframe id="UploadTarget" name="UploadTarget" src="" style="width:0px;height:0px;border:0"></iframe>
</div>
3 changes: 3 additions & 0 deletions app/views/file/details/_file_image.rhtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<% if file.image? || file.thumb? -%>
<div id='fm_file_image_details'>
Preview:
<div id='fm_file_image'>
<%= (file.image? && file.width < 256 && file.height < 256) ? file.image_tag(:original) : file.image_tag(:small) %>

</div>
</diV>
<% end -%>

11 changes: 6 additions & 5 deletions app/views/file/details/_folder_details.rhtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<%= render :partial => '/file/details/file_name', :locals => {:file => file } %>
<div id='details_<%= file.id -%>'>
<div class='tree_detail_body'>
<%= render :partial => '/file/details/file_name', :locals => {:file => file } %>

<div id='fm_file_actions' >
<% if file.file_type_match(@select) -%>
<button onclick='FileEditor.callbackFile(<%= file.id %>);'>Select</button>
<button class='button_link' onclick='FileEditor.callbackFile(<%= file.id %>);'>Select</button>
<% end -%>
<button onclick='FileEditor.folderArchive(<%= file.id %>);'>Create Archive</button>
<button class='last' onclick='FileEditor.deleteSelected([<%= file.id %>]);'>Delete</button>
<button class='button_link' onclick='FileEditor.folderArchive(<%= file.id %>);'>Create Archive</button>
<button class='button_link' class='last' onclick='FileEditor.deleteSelected([<%= file.id %>]);'>Delete</button>
<div style='clear:both;'></div>
</div>

</div>

<% ajax_tabs ['Folder Details'], 'Folder Details' do |t| %>
<% t.tab do -%>
Expand Down
24 changes: 11 additions & 13 deletions app/views/file/index.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
<div id='fm_dragbox' style='display:none;'></div>
<%= render :partial => 'file_javascript' %>

<div id='folder_action_area'>
<%= render :partial => 'file_upload_area' %>
</div>


<div class='action_area_content' style='float:right'>
<%= render :partial => 'file_search_bar' %>
</div>
<div style='clear:both'></div>
<div class='action_area'>
<div id='folder_action_area' class='block_left' >
<%= render :partial => 'file_upload_area' %>
</div>

</div>

<div class='block_right'>
<%= render :partial => 'file_search_bar' %>
</div>
</div>
<div class='clear'></div>

<div id='filemanager_files'>

Expand Down Expand Up @@ -48,7 +47,7 @@
</div>
</div>

<h2> <div style='float:left;' id='folder_title'><%= render :partial => 'folder_title',:locals => { :folder => @folder } %></div>
<h2> <div class='block_left' id='folder_title'><%= render :partial => 'folder_title',:locals => { :folder => @folder } %></div>
<ul class='page_detail_buttons' style='position:relative; top:-5px;'>
<li>
<span id='folder_order'>
Expand All @@ -74,12 +73,11 @@
<div class='file_manager_icon clearfix' id='file_manager' >
<%= render :partial => "folder_details", :locals => { :folder => @folder } %>
</div>
<div class='clear'></div>
</div>


</div>

<div class='clear'></div>
</div>
</div> <!-- end #filemanager_files -->

Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/manage.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<%= javascript_include_tag "slider" %>
<%= javascript_include_tag "swfobject" %>
<%= javascript_include_tag "tiny_mce/tiny_mce" %>
<%= stylesheet_link_tag 'redbox' %>
<%= javascript_include_tag 'redbox' %>
<% end -%>
<%= javascript_include_tag 'active_table' %>
Expand Down
45 changes: 44 additions & 1 deletion app/views/layouts/themes/standard/_manage.rhtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

<div id='cms_container'>

<header>
<div id='cms_header_wrapper'>
<header id='cms_header'>
<% if myself.id && myself.editor? %>

<div id='cms_header_tools'>
Expand Down Expand Up @@ -33,6 +34,7 @@
</ul>
</nav>
</header>
</div>
<div id='cms_breadcrumbs'>
<%= render_webiva_breadcrumbs(@cms_page_info) %>
</div>
Expand All @@ -55,3 +57,44 @@
</div>

</div>
<script>
$j(document).scroll(function(d) {
var top = $j(document).scrollTop();
var offset = $j("#cms_header").height();
var diff = top - offset;
if(diff < 0) { diff = 0; }

if(diff > 0) {
$j('header').width($j('header').width());
$j("header").addClass('fixed_header');
}
else {
$j("header").removeClass('fixed_header');
$j('header').width('auto');

}
});


$j(window).bind('resize',function(d) {
var top = $j(document).scrollTop();
var offset = $j("#cms_header").height();
var diff = top - offset;
if(diff < 0) { diff = 0; }

if(diff > 0) {
$j("header").removeClass('fixed_header');
$j('header').width('auto');
$j('header').width($j('header').width());
$j("header").addClass('fixed_header');
}
else {
$j("header").removeClass('fixed_header');
$j('header').width('auto');

}
});



</script>
2 changes: 1 addition & 1 deletion app/views/structure/_structure_editor.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ var StructureEditor = {
scrollElementInfo: function() {
var top = $j(document).scrollTop();
var offset = $j("#site_structure").offset();
var diff = top - offset.top + 15;
var diff = top - offset.top + 40;
if(diff < 0) { diff = 0; }
$j('#element_info').css({'margin-top': diff });
},
Expand Down
2 changes: 1 addition & 1 deletion app/views/structure/view.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if @show_archived == 'hide'
$j(document).scroll(function(d) {
var top = $j(document).scrollTop();
var offset = $j("#site_structure").offset();
var diff = top - offset.top;
var diff = top - offset.top + 22;
if(diff < 0) { diff = 0; }

if(diff > 0) {
Expand Down
Loading

0 comments on commit 6aad840

Please sign in to comment.