From 209b4febb257e91fa985b043af5376fe4f26c4ce Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 10 Jul 2011 06:43:06 +0530 Subject: [PATCH] forgot to add browse_publications.js --- edgware/main/views.py | 2 +- edgware/static/js/browse_publications.js | 40 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 edgware/static/js/browse_publications.js diff --git a/edgware/main/views.py b/edgware/main/views.py index efbde0b..902899d 100644 --- a/edgware/main/views.py +++ b/edgware/main/views.py @@ -46,7 +46,7 @@ def publish(request): def browse(request): user = request.user themes = ArticleTheme.objects.all() - first_article = Article.objects.all()[0].get_list_dict(user) + first_article = Article.objects.all().filter(published=True).exclude(name__istartswith='template')[0].get_list_dict(user) context = RequestContext(request, {'themes': themes, 'first_article': first_article}) return render_to_response("main/browse.html", context) diff --git a/edgware/static/js/browse_publications.js b/edgware/static/js/browse_publications.js new file mode 100644 index 0000000..b198398 --- /dev/null +++ b/edgware/static/js/browse_publications.js @@ -0,0 +1,40 @@ +$(function() { + + $('#articleThemes').change(function() { + var $this = $(this); + var $ul = $('#articleList'); + var theme_id = $(this).val(); + $ul.empty(); + + var $loadingLi = $('
  • ').addClass("loadingArticles").text("Loading ...").appendTo($ul); + $.getJSON("/edit/articlesByTheme/", { + 'theme_id': theme_id + }, function(articles) { + $('.loadingArticles').hide(); + if (articles.length == 0) { + var $li = $('
  • ').addClass("noArticles").text("No publications for this yet..").appendTo($ul); + } + for (var i=0; i').addClass("articleItem").text(a.title).data("article", a).appendTo($ul); + } + }); + }); + + $('#articleThemes').change(); + +}); + + +$('.articleItem').live("click", function(e) { + if ($(this).is(".selectedArticle")) { + return false; + } + var $this = $(this); + $('.selectedArticle').removeClass("selectedArticle"); + $this.addClass("selectedArticle"); + var data = $this.data("article"); + $('#iframePreview').attr("src", data.iframe_url); + $('#articleLink').attr("href", data.web_url); + $('#articleLink').text(data.title); +});