[IMP][REM] : improve code and remove unwated changes
authorajay javiya (OpenERP) <aja@tinyerp.com>
Tue, 18 Mar 2014 10:47:23 +0000 (16:17 +0530)
committerajay javiya (OpenERP) <aja@tinyerp.com>
Tue, 18 Mar 2014 10:47:23 +0000 (16:17 +0530)
bzr revid: aja@tinyerp.com-20140318104723-zhw8h01tk6v46ev3

addons/website_blog/controllers/main.py
addons/website_blog/static/lib/contentshare.js
addons/website_blog/static/src/js/website_blog.js

index bbe7c8e..039caff 100644 (file)
@@ -332,10 +332,8 @@ class WebsiteBlog(http.Controller):
         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')
index b60cc70..aa9561a 100644 (file)
@@ -14,7 +14,7 @@
             },
             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>';
             },
index 426ba47..e710599 100644 (file)
@@ -19,33 +19,19 @@ $(document).ready(function() {
         });
     }
 
-    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;
@@ -59,7 +45,6 @@ $(document).ready(function() {
             if (content && discussion){
                new openerp.website.blog_discussion({'content' : content});
             }
-           arrow_scroll();
         }, 500 );
     }
 
@@ -70,10 +55,10 @@ $(document).ready(function() {
             $('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);
         });