add icons for file items

This commit is contained in:
Sanj 2011-07-01 00:00:49 +05:30
parent 8765b34683
commit c00a619ab4
3 changed files with 18 additions and 4 deletions

View File

@ -133,13 +133,15 @@ class File(models.Model):
except:
url = ''
thumbnail = ''
studies = [{'id': s.id, 'name': s.name} for s in self.categories.all()]
return {
'id': self.id,
'url': url,
'thumbnail': thumbnail,
'title': self.title,
'description': self.description,
'type': self.type
'type': self.type,
'studies': studies
}
def save_chunk(self, chunk, name='data.bin'):

View File

@ -1,4 +1,5 @@
$(function() {
// alert("hi");
$('#filterForm').submit(function(e) {
e.preventDefault();
var formData = $(this).serializeArray();
@ -40,7 +41,8 @@ $(function() {
});
function getJQ(f) {
var jq = $("<div />").data("data", f).addClass("fileItem").text(f.type + ": " + f.title);
var jq = getListElement(f);
// var jq = $("<div />").data("data", f).addClass("fileItem").text(f.type + ": " + f.title);
jq.click(function() {
var $this = $(this);
$('.selectedItem').removeClass("selectedItem");
@ -81,3 +83,13 @@ function getItemForm(f) {
var $submit = $('<input />').addClass("submitItem").attr("type", "submit").val("Submit").appendTo($form);
return $form;
}
function getListElement(f) {
// console.log(f);
var $item = $('<div />').addClass("fileItem").data("data", f);
var $icon = $('<img />').addClass("fileIcon").attr("src", "/static/images/icons2/" + f.type.toLowerCase() + ".jpg").appendTo($item);
var $title = $('<span />').addClass("fileTitle").text(f.title).appendTo($item);
var $study = $('<span />').addClass("fileStudy").text(" " + f.studies[0].name).appendTo($item);
var $checkbox = $('<input />').attr("type", "checkbox").addClass("fileCheckbox").appendTo($item);
return $item;
}

View File

@ -19,8 +19,8 @@
<div id="fileList">
</div>
<div id="prevBtn"><<</div>
<div id="nextBtn">>></div>
<div id="prevBtn">prev</div>
<div id="nextBtn">next</div>
</div>
<div id="previewPane">