From 205cb054e0bd67848c4a88a0f923b1d69e3e8729 Mon Sep 17 00:00:00 2001 From: ArthurJahn Date: Wed, 27 Jan 2016 16:58:24 -0200 Subject: [PATCH] Add files dropdown for download block --- src/noosfero-spb/software_communities/public/blocks/software-download.js | 12 ++++++++---- src/noosfero-spb/software_communities/public/style.css | 15 +++++++++++++++ src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb | 4 ++-- src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb | 30 +++++++++++------------------- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/noosfero-spb/software_communities/public/blocks/software-download.js b/src/noosfero-spb/software_communities/public/blocks/software-download.js index 0661bba..b177e34 100644 --- a/src/noosfero-spb/software_communities/public/blocks/software-download.js +++ b/src/noosfero-spb/software_communities/public/blocks/software-download.js @@ -4,14 +4,13 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos function SoftwareDownload() { } - SoftwareDownload.prototype.addNewDonwload = function() { var new_download = $('#download-list-item-template').html(); $("#droppable-list-downloads").append(new_download); } SoftwareDownload.prototype.selectFile = function(element) { - var path = "/" + noosfero.profile + "/" + $(element).find('.file-path').html(); + var path = $(element).find('.file-path').html(); var size = $(element).find('.file-size').html(); var download_option = $(element).find('.file-size').closest('.download-option'); @@ -19,8 +18,14 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos download_option.find('#block_downloads__size').val(size); } + SoftwareDownload.prototype.toggleFiles = function(element) { + var files_ul = $(element).parent().find('ul')[0]; + files_ul.classList.toggle('opened'); + files_ul.classList.toggle('closed'); + } + SoftwareDownload.prototype.deleteDownload = function(element) { - var delete_download = $(element).parent().parent().parent().remove(); + var delete_download = $(element).closest('.download-option').remove(); } return { @@ -28,7 +33,6 @@ modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, Noos return $('.download-block').length !== 0; }, - init: function() { window.softwareDownload = new SoftwareDownload(); } diff --git a/src/noosfero-spb/software_communities/public/style.css b/src/noosfero-spb/software_communities/public/style.css index 0ba3d8a..2dc4c5f 100644 --- a/src/noosfero-spb/software_communities/public/style.css +++ b/src/noosfero-spb/software_communities/public/style.css @@ -140,4 +140,19 @@ margin-top: 10px; } +.download-option .files ul { + width: 450px; + background: #9E9E9E; + transition: height ease .35s; + overflow: scroll; +} + +.download-option ul.closed { + height: 0px; +} + +.download-option ul.opened { + height: 70px; +} + /* end of profile_design download block */ diff --git a/src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb b/src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb index 173a1ee..7627bd1 100644 --- a/src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb +++ b/src/noosfero-spb/software_communities/views/box_organizer/_download_block.html.erb @@ -1,11 +1,11 @@

<%= _('Download options') %>

-
+
    <% @block.downloads.each do |download| %> <%= render :partial => 'download_list_item', :locals => {:download => download} %> <% end %> -
+ <%= link_to_function _('New link'), 'softwareDownload.addNewDonwload(); return false', :class => 'button icon-add with-text download-new-link-button' %> diff --git a/src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb b/src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb index 372b9b0..86a7a64 100644 --- a/src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb +++ b/src/noosfero-spb/software_communities/views/box_organizer/_download_list_item.html.erb @@ -1,33 +1,25 @@
  • -
      -
    • + <%= labelled_form_field(_('Name'), text_field_tag('block[downloads][][name]', (defined? download) ? download[:name] : '')) %> -
    • -
    • + <%= labelled_form_field(_('Link'), text_field_tag('block[downloads][][link]', (defined? download) ? download[:link] : '')) %> -
      > -
        +
        + <%= button_without_text(:edit, _('Edit'), "#" , { :onclick => 'softwareDownload.toggleFiles(this); return false', :class=>"edit-link-list-row" }) %> +
          > <% @block.uploaded_files.each do |file| %> <%= render :partial => 'download_file', :locals => {:file => file} %> <% end %> -
        • -
        • +
        - -
      • <%= labelled_form_field(_('Platforms'), text_field_tag('block[downloads][][software_description]', (defined? download) ? download[:software_description] : '')) %> -
      • -
      • <%= labelled_form_field(_('Minimum Requirements'), text_field_tag('block[downloads][][minimum_requirements]', (defined? download) ? download[:minimum_requirements] : '')) %> -
      • -
      • - <%= required labelled_form_field(_('Size'), text_field_tag('block[downloads][][size]', (defined? download) ? download[:size] : '')) %> -
      • + <%= labelled_form_field(_('Size'), text_field_tag('block[downloads][][size]', (defined? download) ? download[:size] : '')) %> -
      • <%= button_without_text(:delete, _('Delete'), "#" , { :onclick => 'softwareDownload.deleteDownload(this); return false', :class=>"delete-link-list-row" }) %>
      • -
      -
    • + + <%= button_without_text(:delete, _('Delete'), "#" , { :onclick => 'softwareDownload.deleteDownload(this); return false', :class=>"delete-link-list-row" }) %> + + -- libgit2 0.21.2