Commit 205cb054e0bd67848c4a88a0f923b1d69e3e8729

Authored by Arthur Sturzbecher
1 parent 6a1469de

Add files dropdown for download block

src/noosfero-spb/software_communities/public/blocks/software-download.js
... ... @@ -4,14 +4,13 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos
4 4 function SoftwareDownload() {
5 5 }
6 6  
7   -
8 7 SoftwareDownload.prototype.addNewDonwload = function() {
9 8 var new_download = $('#download-list-item-template').html();
10 9 $("#droppable-list-downloads").append(new_download);
11 10 }
12 11  
13 12 SoftwareDownload.prototype.selectFile = function(element) {
14   - var path = "/" + noosfero.profile + "/" + $(element).find('.file-path').html();
  13 + var path = $(element).find('.file-path').html();
15 14 var size = $(element).find('.file-size').html();
16 15  
17 16 var download_option = $(element).find('.file-size').closest('.download-option');
... ... @@ -19,8 +18,14 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos
19 18 download_option.find('#block_downloads__size').val(size);
20 19 }
21 20  
  21 + SoftwareDownload.prototype.toggleFiles = function(element) {
  22 + var files_ul = $(element).parent().find('ul')[0];
  23 + files_ul.classList.toggle('opened');
  24 + files_ul.classList.toggle('closed');
  25 + }
  26 +
22 27 SoftwareDownload.prototype.deleteDownload = function(element) {
23   - var delete_download = $(element).parent().parent().parent().remove();
  28 + var delete_download = $(element).closest('.download-option').remove();
24 29 }
25 30  
26 31 return {
... ... @@ -28,7 +33,6 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos
28 33 return $('.download-block').length !== 0;
29 34 },
30 35  
31   -
32 36 init: function() {
33 37 window.softwareDownload = new SoftwareDownload();
34 38 }
... ...
src/noosfero-spb/software_communities/public/style.css
... ... @@ -140,4 +140,19 @@
140 140 margin-top: 10px;
141 141 }
142 142  
  143 +.download-option .files ul {
  144 + width: 450px;
  145 + background: #9E9E9E;
  146 + transition: height ease .35s;
  147 + overflow: scroll;
  148 +}
  149 +
  150 +.download-option ul.closed {
  151 + height: 0px;
  152 +}
  153 +
  154 +.download-option ul.opened {
  155 + height: 70px;
  156 +}
  157 +
143 158 /* end of profile_design download block */
... ...
src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb
1 1 <div id='edit-download-block'>
2 2  
3 3 <h3><%= _('Download options') %></h3>
4   - <div id="droppable-list-downloads">
  4 + <ul id="droppable-list-downloads">
5 5 <% @block.downloads.each do |download| %>
6 6 <%= render :partial => 'download_list_item', :locals => {:download => download} %>
7 7 <% end %>
8   - </div>
  8 + </ul>
9 9  
10 10 <%= link_to_function _('New link'), 'softwareDownload.addNewDonwload(); return false', :class => 'button icon-add with-text download-new-link-button' %>
11 11  
... ...
src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb
1 1 <li class='download-option download-forms'>
2   - <ul>
3   - <li>
  2 +
4 3 <%= labelled_form_field(_('Name'), text_field_tag('block[downloads][][name]', (defined? download) ? download[:name] : '')) %>
5   - </li>
6   - <li>
  4 +
7 5 <%= labelled_form_field(_('Link'), text_field_tag('block[downloads][][link]', (defined? download) ? download[:link] : '')) %>
8   - <div class=<%= (defined? download) ? "closed" : "opened" %>>
9   - <ul>
  6 + <div class="files">
  7 + <%= button_without_text(:edit, _('Edit'), "#" , { :onclick => 'softwareDownload.toggleFiles(this); return false', :class=>"edit-link-list-row" }) %>
  8 + <ul class=<%= (defined? download) ? "closed" : "opened" %>>
10 9 <% @block.uploaded_files.each do |file| %>
11 10 <%= render :partial => 'download_file', :locals => {:file => file} %>
12 11 <% end %>
13   - <li style="clear: both">
14   - </li>
  12 + <li style="clear: both"></li>
15 13 </ul>
16 14 </div>
17   - </li>
18 15  
19   - <li>
20 16 <%= labelled_form_field(_('Platforms'), text_field_tag('block[downloads][][software_description]', (defined? download) ? download[:software_description] : '')) %>
21   - </li>
22 17  
23   - <li>
24 18 <%= labelled_form_field(_('Minimum Requirements'), text_field_tag('block[downloads][][minimum_requirements]', (defined? download) ? download[:minimum_requirements] : '')) %>
25   - </li>
26 19  
27   - <li>
28   - <%= required labelled_form_field(_('Size'), text_field_tag('block[downloads][][size]', (defined? download) ? download[:size] : '')) %>
29   - </li>
  20 + <%= labelled_form_field(_('Size'), text_field_tag('block[downloads][][size]', (defined? download) ? download[:size] : '')) %>
30 21  
31   - <li class='delete-download-button'><%= button_without_text(:delete, _('Delete'), "#" , { :onclick => 'softwareDownload.deleteDownload(this); return false', :class=>"delete-link-list-row" }) %></li>
32   - </ul>
33   -</li>
  22 + <span class='delete-download-button'>
  23 + <%= button_without_text(:delete, _('Delete'), "#" , { :onclick => 'softwareDownload.deleteDownload(this); return false', :class=>"delete-link-list-row" }) %>
  24 + </span>
  25 + </li>
... ...