merged karens css changes, sending back-end vars for page no, etc. + basic form for edit item

This commit is contained in:
Sanj 2011-06-30 22:29:41 +05:30
parent 50de0175db
commit c78ac848c6
2 changed files with 33 additions and 5 deletions

View File

@ -253,7 +253,9 @@ def fileList(request):
files = results.object_list files = results.object_list
d = {} d = {}
d['noOfResults'] = qset.count() d['noOfResults'] = qset.count()
d['noOfPages'] = 2 d['noOfPages'] = paginator.num_pages
# d['hasPrev'] = paginator.has_previous()
# d['hasNext'] = paginator.has_next()
d['files'] = [] d['files'] = []
for f in files: for f in files:
d['files'].append(f.get_dict()) d['files'].append(f.get_dict())

View File

@ -10,6 +10,9 @@ $(function() {
var files = data.files; var files = data.files;
// console.log(files); // console.log(files);
$('#fileList').empty(); $('#fileList').empty();
$('#noOfPages').text(data.noOfPages);
$('#noOfResults').text(data.noOfResults);
$('#currentPageNo').text($('#page_no').val());
for (var i=0; i<files.length; i++) { for (var i=0; i<files.length; i++) {
// console.log(files[i]); // console.log(files[i]);
var $file = getJQ(files[i]); var $file = getJQ(files[i]);
@ -43,15 +46,38 @@ function getJQ(f) {
$('.selectedItem').removeClass("selectedItem"); $('.selectedItem').removeClass("selectedItem");
$this.addClass("selectedItem"); $this.addClass("selectedItem");
var d = $this.data("data"); var d = $this.data("data");
var $pane = $('<div />').addClass("previewPane");
var $previewObj = $('<div />').addClass("previewObject").appendTo($pane);
var html = '';
switch (d.type) { switch (d.type) {
case "image": case "image":
var html = "<img width='400' src='" + d.thumbnail + "' />"; html += "<img width='400' src='" + d.thumbnail + "' />";
break;
case "video":
html += "<video width='400' src='" + d.url + "' />";
break;
case "audio":
html += "<audio width='400' src='" + d.url + "' />";
break; break;
default: default:
var html = "<a href='" + d.url + "' target='_blank'>Click to view</a>"; html += "";
} break;
$('#previewPane').html(html); };
html += "<br />";
html += "<a href='" + d.url + "' target='_blank'>Click to View Original File</a>";
$previewObj.html(html);
$itemForm = getItemForm(f);
$itemForm.appendTo($pane);
$('#previewPane').empty();
$('#previewPane').append($pane);
}); });
return jq; return jq;
} }
function getItemForm(f) {
var $form = $('<div />').addClass("itemForm");
var $title = $('<input />').val(f.title).appendTo($form);
var $description = $('<textarea />').val(f.description).appendTo($form);
var $submit = $('<input />').addClass("submitItem").attr("type", "submit").val("Submit").appendTo($form);
return $form;
}