js for no_has_list

This commit is contained in:
Sanj 2011-09-28 16:57:19 +05:30
parent dcc59293ba
commit 9025c309b3
4 changed files with 44 additions and 10 deletions

View File

@ -124,7 +124,7 @@ class BestPracticeCategory(models.Model):
'description': self.description
}
class BestPracticeLink(models.Model):
class BestPracticeLink(ItfModel):
url = models.URLField()
text = models.TextField(blank=True)
bestpractice = models.ForeignKey(BestPractice)
@ -135,6 +135,13 @@ class BestPracticeLink(models.Model):
'text': self.text
}
def list_dict(self):
return {
'id': self.id,
'text': self.text,
'url': self.url,
}
def __unicode__(self):
return self.url

View File

@ -81,7 +81,7 @@ class Participant(ItfModel):
return self.name
def get_title(self):
return self.title
return self.name
def list_dict(self):
return {

View File

@ -69,7 +69,7 @@ $(function() {
// $('#loadingList').hide();
stopListLoading(data.page);
/* begin if for has_list, ideally make into separate render function */
// if (data.has_list) {
if (data.has_list) {
/* handle sort options on list */
$select = $('#orderBySelect');
$select.empty();
@ -86,10 +86,12 @@ $(function() {
displayList(data.page.items);
/* end display initial list */
// }
} else {
/* end if has_list */
$('#textRight').text(data.title);
var $html = getNoListHtml(data.page.items);
$('#bottomRight').empty().append($html);
}
});
});
@ -170,3 +172,26 @@ function getPage(pageNo) {
displayList(page.items);
});
}
function getNoListHtml(items) {
var $rhs = $('<div />');
for (var i=0; i<items.length; i++) {
var $obj = getNoListItemHtml(items[i]);
$rhs.append($obj);
}
return $rhs;
}
function getNoListItemHtml(item) {
if (item.hasOwnProperty("url")) {
var $ret = $('<div />').addClass("noListItem");
var $title = $("<div />").addClass("orange").appendTo($ret);
var $a = $('<a />').attr("href", item.url).text(item.text).appendTo($title);
var $text = $("<div />").addClass("noListText").html(item.text).appendTo($ret);
} else {
var $ret = $('<div />').addClass("noListItem").addClass("collapsible");
var $title = $("<div />").addClass("orange").addClass("toggleNext").text(item.title).appendTo($ret);
var $text = $("<div />").addClass("noListText").addClass("hidden").html(item.text).appendTo($ret);
}
return $ret;
}

View File

@ -1,10 +1,12 @@
<div class="linksInnerOrange">
<a href="" class="orange">Dummy Link 1</a>
<a href="#" class="orange toggleNext">Dummy Link 1</a>
<div class="hideText">Dummy text that displays on clicking link</div>
<a href="" class="orange">Dummy Link 2</a>
<a href="#" class="orange toggleNext">Dummy Link 2</a>
<div class="hideText">Dummy text that displays on clicking link</div>
<a href="" class="orange">Dummy Link 3</a>
<a href="#" class="orange toggleNext">Dummy Link 3</a>
<div class="hideText">Dummy text that displays on clicking link</div>
<a href="" class="orange">Dummy Link 4</a>
<a href="#" class="orange toggleNext">Dummy Link 4</a>
<div class="hideText">Dummy text that displays on clicking link</div>
</div>