forgot to add browse_publications.js
This commit is contained in:
parent
7c51f54242
commit
209b4febb2
|
@ -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)
|
||||
|
||||
|
|
40
edgware/static/js/browse_publications.js
Normal file
40
edgware/static/js/browse_publications.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
$(function() {
|
||||
|
||||
$('#articleThemes').change(function() {
|
||||
var $this = $(this);
|
||||
var $ul = $('#articleList');
|
||||
var theme_id = $(this).val();
|
||||
$ul.empty();
|
||||
|
||||
var $loadingLi = $('<li />').addClass("loadingArticles").text("Loading ...").appendTo($ul);
|
||||
$.getJSON("/edit/articlesByTheme/", {
|
||||
'theme_id': theme_id
|
||||
}, function(articles) {
|
||||
$('.loadingArticles').hide();
|
||||
if (articles.length == 0) {
|
||||
var $li = $('<li />').addClass("noArticles").text("No publications for this yet..").appendTo($ul);
|
||||
}
|
||||
for (var i=0; i<articles.length; i++) {
|
||||
var a = articles[i];
|
||||
var $li = $('<li />').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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user