From 0ac29d1e433db33364bb563667dd63410dbd129c Mon Sep 17 00:00:00 2001 From: "ajay javiya (OpenERP)" Date: Wed, 26 Feb 2014 11:14:15 +0530 Subject: [PATCH] [IMP]: code bzr revid: aja@tinyerp.com-20140226054415-no0s6hex4wx52xpu --- .../static/src/js/website_blog.js | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index ad8d007edd3..1abb5f14d00 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -1,26 +1,6 @@ $(document).ready(function() { var discussion = false; var share = false; - - var def = $.Deferred(); - openerp.jsonRpc("/blogpsot/get_custom_options", 'call', { - }).then(function(res){ - discussion = res['Inline Discussion'] - share = res['Select to Tweet'] - return def.resolve() - }); - def.done( function(){ - var content = $("#blog_content p"); - if(content.length && discussion){ - $('#discussions_wrapper').empty(); - new openerp.website.blog_discussion({'content' : content}); - } - if (share) $("p").share(); - }); - $('.cover_footer').on('click',page_transist); - $('a[href^="#blog_content"]').on('click', animate); - arrow_scroll(); - function page_transist(event) { event.preventDefault(); newLocation = $('.js_next')[0].href; @@ -40,19 +20,33 @@ $(document).ready(function() { } function arrow_scroll(){ - var node = $('#blog_angle_down') + var node = $('#blog_angle_down'); var stickyTop = node.offset().top - 50; $(window).scroll(function(event){ - var scrolltop = $(window).scrollTop() + var scrolltop = $(window).scrollTop(); if (stickyTop > scrolltop) node.stop().animate({"marginTop": ($(window).scrollTop() - 50) + "px"}, "slow" ); }); } + //check custome options inline discussion and select to tweet(share) are checked. + openerp.jsonRpc("/blogpsot/get_custom_options", 'call', {}).then(function(res){ + discussion = res['Inline Discussion']; + share = res['Select to Tweet']; + var content = $("#blog_content p"); + if(content.length && discussion){ + $('#discussions_wrapper').empty(); + new openerp.website.blog_discussion({'content' : content}); + } + if (share) $("p").share(); + }); + $('.cover_footer').on('click',page_transist); + $('a[href^="#blog_content"]').on('click', animate); + arrow_scroll(); + function page_upwards() { var translationValue = $("#wrap:last-child").get(0).getBoundingClientRect().top; - $("#wrap:last-child") - .addClass('easing_upward') + $("#wrap:last-child").addClass('easing_upward'); setTimeout(function(){ $html = $(document.documentElement); $("#wrap:first-child").add($html).scrollTop(0); @@ -68,17 +62,16 @@ $(document).ready(function() { function newpage() { $.ajax({ - url: newLocation, + url: newLocation }).done(function(data) { $('main').append($(data).find('main').html()); - page_upwards() + page_upwards(); //bind again it takes control from now on, until page relaod. $(document).find('.cover_footer').on('click',page_transist); $(document).find('a[href^="#blog_content"]').on('click', animate); if (share) $("p").share(); - if (newLocation != window.location) { + if (newLocation != window.location) history.pushState(null, null, newLocation); - } }); } });