From 9025c309b3757c9541465bc1886dc883c54393c3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 28 Sep 2011 16:57:19 +0530 Subject: [PATCH] js for no_has_list --- itf/bestpractices/models.py | 9 ++++- itf/festival/models.py | 2 +- itf/static/js/insidepage.js | 33 ++++++++++++++++--- .../{guidelines.html => guideline.html} | 10 +++--- 4 files changed, 44 insertions(+), 10 deletions(-) rename itf/templates/modules/bestpractices/{guidelines.html => guideline.html} (58%) diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index edb51c0..f1b348d 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -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 diff --git a/itf/festival/models.py b/itf/festival/models.py index 4fcac80..2526c49 100644 --- a/itf/festival/models.py +++ b/itf/festival/models.py @@ -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 { diff --git a/itf/static/js/insidepage.js b/itf/static/js/insidepage.js index 268b08e..73f5a4e 100644 --- a/itf/static/js/insidepage.js +++ b/itf/static/js/insidepage.js @@ -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 = $('
'); + for (var i=0; i').addClass("noListItem"); + var $title = $("
").addClass("orange").appendTo($ret); + var $a = $('').attr("href", item.url).text(item.text).appendTo($title); + var $text = $("
").addClass("noListText").html(item.text).appendTo($ret); + } else { + var $ret = $('
').addClass("noListItem").addClass("collapsible"); + var $title = $("
").addClass("orange").addClass("toggleNext").text(item.title).appendTo($ret); + var $text = $("
").addClass("noListText").addClass("hidden").html(item.text).appendTo($ret); + } + return $ret; +} diff --git a/itf/templates/modules/bestpractices/guidelines.html b/itf/templates/modules/bestpractices/guideline.html similarity index 58% rename from itf/templates/modules/bestpractices/guidelines.html rename to itf/templates/modules/bestpractices/guideline.html index fc0a8cc..37aef09 100644 --- a/itf/templates/modules/bestpractices/guidelines.html +++ b/itf/templates/modules/bestpractices/guideline.html @@ -1,10 +1,12 @@ + +
- Dummy Link 1 + Dummy Link 1
Dummy text that displays on clicking link
- Dummy Link 2 + Dummy Link 2
Dummy text that displays on clicking link
- Dummy Link 3 + Dummy Link 3
Dummy text that displays on clicking link
- Dummy Link 4 + Dummy Link 4
Dummy text that displays on clicking link