return []
@http.route('/blogpsot/get_custom_options', type='json', auth="public", website=True)
- def get_custom_options(self, post_id=0,image=None, **post):
+ def get_custom_options(self, image=None, **post):
values = {}
- post_obj = request.registry.get('blog.post').browse(request.cr, SUPERUSER_ID, int(post_id))
- values['author_name'] = post_obj.create_uid.name
inherit_options = request.registry.get('ir.ui.view').search_read(request.cr, SUPERUSER_ID, [('name','in',['Allow comment in text','Select to Tweet'])], ['inherit_id','name'])
for options in inherit_options:
values[options.get('name')] = options.get('inherit_id')
},
getContent : function() {
var current_url = window.location.href
- var selected_text = this.getSelection('string').substring(0,option.maxLength-(current_url.length+3)-(option.author_name.length+4));
+ var selected_text = this.getSelection('string').substring(0,option.maxLength-(current_url.length+option.author_name.length+7));
var text = encodeURIComponent('\"'+selected_text+'\" '+'--@'+option.author_name+' '+current_url)
return '<a onclick="window.open(\''+option.shareLink+text+'\',\'_'+option.target+'\',\'location=yes,height=570,width=520,scrollbars=yes,status=yes\')"><i class="fa fa-twitter fa-lg"/></a>';
},
});
}
- function arrow_scroll(){
- var node = $('#blog_angle_down');
- var stickyTop = node.offset().top - 50;
- $(window).scroll(function(event){
- 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', {
- 'post_id': $('#blog_post_name').attr('data-oe-id')
- }).then(function(res){
+ openerp.jsonRpc("/blogpsot/get_custom_options", 'call', {}).then(function(res){
discussion = res['Allow comment in text'];
share = res['Select to Tweet'];
- var author_name = res['author_name']
var content = $("#blog_content p");
if(content.length && discussion){
$('#discussions_wrapper').empty();
new openerp.website.blog_discussion({'content' : content});
}
- if (share) $("p,h3,h4,ul").share({'author_name':author_name});
+ if (share) $("p,h1,h2,h3,h4,ul").share({'author_name':$('#blog_author').text()});
});
$('.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;
if (content && discussion){
new openerp.website.blog_discussion({'content' : content});
}
- arrow_scroll();
}, 500 );
}
$('main').append($(data).find('main').html());
page_upwards();
//bind again it takes control from now on, until page relaod.
- var author_name = $(data).find('#blog_author:first').text()
$(document).find('.cover_footer').on('click',page_transist);
+ console.log($(data).find('#blog_author'))
$(document).find('a[href^="#blog_content"]').on('click', animate);
- if (share) $("p,h3,h4,ul").share({'author_name':author_name});
+ if (share) $("p,h1,h2,h3,h4,ul").share({'author_name':$(data).find('#blog_author:first').text()});
if (newLocation != window.location)
history.pushState(null, null, newLocation);
});