software-download.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
modulejs.define('SoftwareDownload', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) {
'use strict';
var AJAX_URL = {
get_download_template:
NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/get_block_template")
};
var $download_html_template;
function getDownloadListTemplate() {
$.get(AJAX_URL.get_download_template, { profile: noosfero.profile })
.done(function(response) {
console.log("asdasd");
console.log(response);
$download_html_template = response;
}).fail(function() {
alert( "error" );
});
}
function SoftwareDownload() {
getDownloadListTemplate();
}
SoftwareDownload.prototype.addNewDonwload = function() {
var new_download = $($download_html_template);
$("#droppable-list-downloads").append(new_download);
}
SoftwareDownload.prototype.deleteDownload = function(element) {
var delete_download = $(element).parent().parent().parent().remove();
}
return {
isCurrentPage: function() {
return $('.download-block').length !== 0;
},
init: function() {
window.softwareDownload = new SoftwareDownload();
}
}
});