From f7f932d1d0aca9146ceba2f8d8b4b5e9f614e709 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 1 Jun 2012 00:21:01 +0530 Subject: [PATCH 1/3] pagination etc to work --- itf/app/models.py | 2 ++ itf/templates/noel/render_object.html | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/itf/app/models.py b/itf/app/models.py index 6788a5e..b840192 100755 --- a/itf/app/models.py +++ b/itf/app/models.py @@ -340,6 +340,8 @@ class ItfModel(models.Model): return { + 'has_next': results.has_next(), + 'has_previous': results.has_previous(), 'page_no': page_no, 'num_pages': paginator.num_pages, 'items': ret diff --git a/itf/templates/noel/render_object.html b/itf/templates/noel/render_object.html index 25202e1..9c05ad2 100755 --- a/itf/templates/noel/render_object.html +++ b/itf/templates/noel/render_object.html @@ -6,11 +6,15 @@ + + @@ -150,8 +154,8 @@ -
prev
-
next
+ {% if object_list.has_previous %}
prev
{% endif %} + {% if object_list.has_next %}
next
{% endif %}
From 67ef0edfd9934b3a413a4e6d6a85157b6f53e436 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 1 Jun 2012 00:27:14 +0530 Subject: [PATCH 2/3] try fix image --- itf/templates/noel/render_object.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/itf/templates/noel/render_object.html b/itf/templates/noel/render_object.html index 9c05ad2..f85f93d 100755 --- a/itf/templates/noel/render_object.html +++ b/itf/templates/noel/render_object.html @@ -181,7 +181,7 @@ pin
-
+
From 91eb4f9b4d837549dfb2a0e1a88c2b853efac5e4 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 1 Jun 2012 00:29:50 +0530 Subject: [PATCH 3/3] forgot to add js :/ --- itf/static/js/render_object.js | 531 +++++++++++++++++++++++++++++++++ 1 file changed, 531 insertions(+) create mode 100755 itf/static/js/render_object.js diff --git a/itf/static/js/render_object.js b/itf/static/js/render_object.js new file mode 100755 index 0000000..bc4279c --- /dev/null +++ b/itf/static/js/render_object.js @@ -0,0 +1,531 @@ +var queryData; //will store initial query data as a global var for submodule js to potentially use + +$('.toggleBtn').live("click", function() { + var $this = $(this); + var toggleElem = $('#' + $this.attr("data-toggle")); + if (toggleElem.is(":visible")) { + toggleElem.slideUp(); + } else { + toggleElem.slideDown(); + } +}); + +/* +$('#listLeft ul li a').live("click", function() { + if ($(this).hasClass("listLeftSelected")) { + return false; + } + $('.listLeftSelected').removeClass("listLeftSelected"); + $(this).addClass('listLeftSelected'); + var objId = $(this).attr("data-id"); + var tab = $('.innerSelected').attr("data-slug"); + var formData = getSearchFormJSON(); + $('#textRight').text("Loading..."); + $('#bottomRight').text("Loading..."); + formData.object_id = objId; + var urlString = JSONtoQueryString(formData); + var urlString = JSONtoQueryString({ + 'tab': tab, + 'object_id': objId + }); + History.pushState(formData, "", urlString); + $.getJSON("/m/get_details", { + 'tab': tab, + 'object_id': objId + }, function(data) { + $('#imageInside').css({'backgroundImage': 'url(' + data.main_image.thumb + ')'}); + $('#textRight').text(data.title).formatTitle(); + var urlComponent = "?tab=" + $('.innerSelected').attr("data-slug") + "&object_id=" + objId; + var baseUrl = location.protocol + "//" + location.hostname + location.pathname; + var url = baseUrl + urlComponent; + +// var fb_url = url.replace("&", "&"); +// $('#fb_like').attr("data-href", fb_url); + var twitter_url = "https://twitter.com/share?url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(data.title); + $('#twitterBtn').attr("href", twitter_url); + $('#permalinkBtn').attr("href", url); + var searchTerm = $('.searchListField').val(); + var html = data.html; + html = "
" + html + "
"; //Wrap to make IE happy +// globalFoo = html; + if (searchTerm != '') { + for (var i=0; i" + searchTerm + ""); + } + $('#bottomRight').html(html); + + postLoadQuery(); //parse query string params for post load actions +// console.log(data); + }); + return false; +}); +*/ + +function postLoadQuery() { + if (queryData.hasOwnProperty("goto")) { + var locationHash = queryData['goto']; + var scrollTop = $('a[name=' + locationHash + ']').position().top; + $(window).scrollTop(scrollTop); //FIXME!! + delete queryData['goto']; + } +/* + if (queryData.hasOwnProperty("btn")) { + var $btn = $('#' + queryData.btn); + $btn.click(); + console.log($btn); + delete queryData['btn']; + } +*/ +} + +$('.lightboxNext').live("click", function(e) { + var $i = $(this).data("image"); + $i.click(); +}); + +$('.lightboxPrev').live("click", function(e) { + var $i = $(this).data("image"); + $i.click(); +}); + +$('.thumbsDetails').live("click", function(e) { +// alert($(this).attr("data-bigimage")); + var $that = $(this); + var totalImages = $(this).parent().find(".thumbsDetails").length; + var thisIndex = $(this).index(); + + if (thisIndex < (totalImages - 1)) { + var hasNext = true; + var nextImage = $(this).parent().find(".thumbsDetails").eq(thisIndex + 1); + var preloadImage = new Image(); + preloadImage.src = nextImage.attr("data-bigimage"); + } + + if (thisIndex > 0 && totalImages > 1) { + var hasPrev = true; + var prevImage = $(this).parent().find(".thumbsDetails").eq(thisIndex - 1); + } + var $lbox = $('#lightboxPanel'); + var $cont = $('
').addClass("lightboxContainer"); + var bigImage = $(this).attr("data-bigimage"); + var $img = $('').attr("src", bigImage).addClass("lightboxImg"); + $img.appendTo($cont); + var imgWidth = parseInt($that.attr("data-width")); + var imgHeight = parseInt($that.attr("data-height")); + var lightboxWidth = imgWidth + 40; + var lightboxHeight = imgHeight + 60; + $lbox.width(lightboxWidth); + $lbox.height(lightboxHeight); + var viewportWidth = $(window).width(); + var viewportHeight = $(window).height(); + if (viewportHeight < lightboxHeight) { + $lbox.height(viewportHeight - 40); + } + var lightboxTop = parseInt((viewportHeight - $lbox.height()) / 2); + $lbox.css({'top': lightboxTop + "px"}); + + + +// showLightbox($img); + var title = $(this).hasAttr("title") ? $(this).attr("title") : ''; +// var $c = $('#lightboxContent'); + + + if (title != '') { + var $caption = $('
').addClass("lightboxCaption").text(title).appendTo($cont); + } + if (hasNext) { + var $next = $('
').addClass("lightboxNext").text("next").data("image", nextImage).appendTo($cont); + } + if (hasPrev) { + var $prev = $('
').addClass("lightboxPrev").text("prev").data("image", prevImage).appendTo($cont); + } + showLightbox($cont); +}); + +function hideLightbox() { + $('#lightbox, #lightboxPanel').fadeOut(400); +} + +function showLightbox($content) { + if (!$('#lightbox').is("visible")) { + $('#lightbox, #lightboxPanel').fadeIn(400); + } + $('#lightboxContent').empty().append($content); +} + + +$('.toggleNext').live("click", function(e) { + e.preventDefault(); + var $next = $(this).next(); + if (!$next.is(":visible")) { + $next.slideDown(); + } else { + $next.slideUp(); + } +}); + +function highlightWordsNoCase(data, word) +{ + var regex = new RegExp("(" + word + ")", "gi"); + return data.replace(regex, "$1"); +} + +/* Get a jquery