Commit a20815d6532b575f8700ba9671bb0f0377f9ac3a
Committed by
Gabriela Navarro
1 parent
dfd195b4
Exists in
master
and in
5 other branches
Put download block javascript into its own file
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
2 changed files
with
37 additions
and
0 deletions
Show diff stats
lib/software_communities_plugin.rb
| @@ -138,6 +138,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -138,6 +138,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
| 138 | mpog-search.js | 138 | mpog-search.js |
| 139 | software-catalog.js | 139 | software-catalog.js |
| 140 | mpog-software-block.js | 140 | mpog-software-block.js |
| 141 | + mpog-download-block.js | ||
| 141 | ) | 142 | ) |
| 142 | end | 143 | end |
| 143 | 144 |
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +(function($) { | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + function add_new_link(){ | ||
| 5 | + var newDownload = $(window.download_list_template); | ||
| 6 | + newDownload.attr('data-counter-id', 1); | ||
| 7 | + $("#droppable-list-downloads").append(newDownload); | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + function delete_link(add_element){ | ||
| 12 | + var deleteDownload = $(add_element).parent().parent().parent(); | ||
| 13 | + deleteDownload.remove(); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + function get_download_list_template() { | ||
| 18 | + if(sessionStorage.getItem('download_list_block_template')) { | ||
| 19 | + window.download_list_template = sessionStorage.getItem('download_list_block_template'); | ||
| 20 | + } { | ||
| 21 | + $.get('/plugin/software_communities/get_block_template', function(response) { | ||
| 22 | + window.download_list_template = response; | ||
| 23 | + sessionStorage.setItem('download_list_block_template', response); | ||
| 24 | + }); | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + $(document).ready(function() { | ||
| 29 | + window.add_new_link = add_new_link; | ||
| 30 | + window.delete_link = delete_link; | ||
| 31 | + | ||
| 32 | + if( window.download_list_template === undefined ) { | ||
| 33 | + get_download_list_template(); | ||
| 34 | + } | ||
| 35 | + }); | ||
| 36 | +})(jQuery); |