[IMP] website_*forum,blog,instantclick,...: Move Js in assets
authorJeremy Kersten <jke@odoo.com>
Thu, 28 Aug 2014 10:21:47 +0000 (12:21 +0200)
committerJeremy Kersten <jke@odoo.com>
Thu, 28 Aug 2014 10:21:47 +0000 (12:21 +0200)
addons/mass_mailing/views/website_mass_mailing.xml
addons/website_blog/static/src/js/website_blog.editor.js
addons/website_blog/static/src/js/website_blog.js
addons/website_blog/views/website_blog_templates.xml
addons/website_forum/static/src/js/website_forum.js
addons/website_forum/views/website_forum.xml
addons/website_instantclick/views/website_instantclick.xml

index bc55f61..b76b48e 100644 (file)
@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
-<data>
+    <data>
+        <template id="assets_frontend" inherit_id="website.assets_frontend" name="wesbite_mass_mailing assets">
+            <xpath expr="." position="inside">
+                <script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.js"></script>
+            </xpath>
+        </template>
 
-<template id="head" inherit_id="website.layout" name="Mail customization">
-    <xpath expr="//head" position="inside">
-        <script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.editor.js" groups="base.group_website_publisher"></script>
-        <script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.js"></script>
-        <link rel='stylesheet' href='/website_mail/static/src/css/website_mail.css'/>
-    </xpath>
-</template>
-
-</data>
+        <template id="assets_editor" inherit_id="website.assets_editor" name="wesbite_mass_mailing Editor assets">
+            <xpath expr="/t" position="inside">
+                <script type="text/javascript" src="/mass_mailing/static/src/js/website_mass_mailing.editor.js" groups="base.group_website_publisher"></script>
+            </xpath>
+        </template>
+    </data>
 </openerp>
index c169406..8a1845e 100644 (file)
             });
         },
     });
-
-    website.EditorBar.include({
-        edit: function () {
-            var self = this;
-            $('.popover').remove();
-            this._super();
-            var vHeight = $(window).height();
-            $('body').on('click','#change_cover',_.bind(this.change_bg, self.rte.editor, vHeight));
-            $('body').on('click', '#clear_cover',_.bind(this.clean_bg, self.rte.editor, vHeight));
-        },
-        save : function() {
-            var res = this._super();
-            if ($('.cover').length) {
-                openerp.jsonRpc("/blogpost/change_background", 'call', {
-                    'post_id' : $('#blog_post_name').attr('data-oe-id'),
-                    'image' : $('.cover').css('background-image').replace(/url\(|\)|"|'/g,''),
+    if ($('.website_blog').length) {
+        website.EditorBar.include({
+            edit: function () {
+                var self = this;
+                $('.popover').remove();
+                this._super();
+                var vHeight = $(window).height();
+                $('body').on('click','#change_cover',_.bind(this.change_bg, self.rte.editor, vHeight));
+                $('body').on('click', '#clear_cover',_.bind(this.clean_bg, self.rte.editor, vHeight));
+            },
+            save : function() {
+                var res = this._super();
+                if ($('.cover').length) {
+                    openerp.jsonRpc("/blogpost/change_background", 'call', {
+                        'post_id' : $('#blog_post_name').attr('data-oe-id'),
+                        'image' : $('.cover').css('background-image').replace(/url\(|\)|"|'/g,''),
+                    });
+                }
+                return res;
+            },
+            clean_bg : function(vHeight) {
+                $('.js_fullheight').css({"background-image":'none', 'min-height': vHeight});
+            },
+            change_bg : function(vHeight) {
+                var self  = this;
+                var element = new CKEDITOR.dom.element(self.element.find('.cover-storage').$[0]);
+                var editor  = new website.editor.MediaDialog(self, element);
+                $(document.body).on('media-saved', self, function (o) {
+                    var url = $('.cover-storage').attr('src');
+                    $('.js_fullheight').css({"background-image": !_.isUndefined(url) ? 'url(' + url + ')' : "", 'min-height': vHeight});
+                    $('.cover-storage').remove();
                 });
-            }
-            return res;
-        },
-        clean_bg : function(vHeight) {
-            $('.js_fullheight').css({"background-image":'none', 'min-height': vHeight});
-        },
-        change_bg : function(vHeight) {
-            var self  = this;
-            var element = new CKEDITOR.dom.element(self.element.find('.cover-storage').$[0]);
-            var editor  = new website.editor.MediaDialog(self, element);
-            $(document.body).on('media-saved', self, function (o) {
-                var url = $('.cover-storage').attr('src');
-                $('.js_fullheight').css({"background-image": !_.isUndefined(url) ? 'url(' + url + ')' : "", 'min-height': vHeight});
-                $('.cover-storage').remove();
-            });
-            editor.appendTo('body');
-        },
-    });
+                editor.appendTo('body');
+            },
+        });
+    }
 })();
index 3217bf1..c811677 100644 (file)
@@ -1,40 +1,41 @@
 $(document).ready(function() {
+    if ($('.website_blog').length) {
+        function page_transist(event) {
+            event.preventDefault();
+            newLocation = $('.js_next')[0].href;
+            var top = $('.cover_footer').offset().top;
+            $('.cover_footer').animate({
+                height: $(window).height()+'px'
+            }, 300);
+            $('html, body').animate({
+                scrollTop: top
+            }, 300, 'swing', function() {
+               window.location.href = newLocation;
+            });
+        }
+        function animate(event) {
+            event.preventDefault();
+            event.stopImmediatePropagation();
+            var target = $(this.hash);
+            $('html, body').stop().animate({
+                'scrollTop': target.offset().top - 32
+            }, 500, 'swing', function () {
+                window.location.hash = 'blog_content';
+            });
+        }
 
-    function page_transist(event) {
-        event.preventDefault();
-        newLocation = $('.js_next')[0].href;
-        var top = $('.cover_footer').offset().top;
-        $('.cover_footer').animate({
-            height: $(window).height()+'px'
-        }, 300);
-        $('html, body').animate({
-            scrollTop: top
-        }, 300, 'swing', function() {
-           window.location.href = newLocation;
-        });
-    }
-    function animate(event) {
-        event.preventDefault();
-        event.stopImmediatePropagation();
-        var target = $(this.hash);
-        $('html, body').stop().animate({
-            'scrollTop': target.offset().top - 32
-        }, 500, 'swing', function () {
-            window.location.hash = 'blog_content';
-        });
-    }
+        var content = $("div[enable_chatter_discuss='True']").find('p[data-chatter-id]');
+        if (content) {
+            openerp.jsonRpc("/blog/get_user/", 'call', {}).then(function(data){
+                $('#discussions_wrapper').empty();
+                new openerp.website.blog_discussion({'content' : content, 'public_user':data[0]});
+            });
+        }
 
-    var content = $("div[enable_chatter_discuss='True']").find('p[data-chatter-id]');
-    if (content) {
-        openerp.jsonRpc("/blog/get_user/", 'call', {}).then(function(data){
-            $('#discussions_wrapper').empty();
-            new openerp.website.blog_discussion({'content' : content, 'public_user':data[0]});
-        });
+        $('.js_fullheight').css('min-height', $(window).height());
+        $(".js_tweet").share({'author_name':$('#blog_author').text()});
+        $('.cover_footer').on('click',page_transist);
+        $('a[href^="#blog_content"]').on('click', animate);
     }
 
-    $('.js_fullheight').css('min-height', $(window).height());
-    $(".js_tweet").share({'author_name':$('#blog_author').text()});
-    $('.cover_footer').on('click',page_transist);
-    $('a[href^="#blog_content"]').on('click', animate);
-
 });
index cdee16d..ef56a54 100644 (file)
 </template>
 
 <!-- Page -->
+<template id="assets_frontend" inherit_id="website.assets_frontend" name="website_blog assets" >
+    <xpath expr="/t" position="inside">
+        <link rel='stylesheet' href='/website_blog/static/src/css/website_blog.css'/>
+        <script type="text/javascript" src="/website_blog/static/src/js/website_blog.inline.discussion.js"></script>
+        <script type="text/javascript" src="/website_blog/static/src/js/website_blog.js"/>
+        <script type="text/javascript" src="/website_blog/static/lib/contentshare.js"/>
+    </xpath>
+</template>
+
 <template id="index" name="Blog Navigation">
     <t t-call="website.layout">
-        <t t-set="head">
-            <link rel='stylesheet' href='/website_blog/static/src/css/website_blog.css'/>
-            <script type="text/javascript" src="/website_blog/static/src/js/website_blog.inline.discussion.js"></script>
-            <script type="text/javascript" src="/website_blog/static/src/js/website_blog.js"/>
-            <script type="text/javascript" src="/website_blog/static/lib/contentshare.js"/>
-        </t>
-        <div id="wrap" class="js_blog">
+        <div id="wrap" class="js_blog website_blog">
             <t t-raw="0"/>
         </div>
     </t>
index 14e29d4..9a00eb7 100644 (file)
 $(document).ready(function () {
+    if ($('.website_forum').length){
+        $('.karma_required').on('click', function (ev) {
+            var karma = $(ev.currentTarget).data('karma');
+            if (karma) {
+                ev.preventDefault();
+                var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
+                    '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+                    karma + ' karma is required to perform this action. You can earn karma by answering questions or having '+
+                    'your answers upvoted by the community.</div>');
+                var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
+                if (vote_alert.length == 0) {
+                    $(ev.currentTarget).parent().append($warning);
+                }
+            }
+        });
 
-    $('.karma_required').on('click', function (ev) {
-        var karma = $(ev.currentTarget).data('karma');
-        if (karma) {
+        $('.vote_up,.vote_down').not('.karma_required').on('click', function (ev) {
             ev.preventDefault();
-            var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
-                '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
-                karma + ' karma is required to perform this action. You can earn karma by answering questions or having '+
-                'your answers upvoted by the community.</div>');
-            var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
-            if (vote_alert.length == 0) {
-                $(ev.currentTarget).parent().append($warning);
-            }
-        }
-    });
+            var $link = $(ev.currentTarget);
+            openerp.jsonRpc($link.data('href'), 'call', {})
+                .then(function (data) {
+                    if (data['error']){
+                        if (data['error'] == 'own_post'){
+                            var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
+                                '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+                                'Sorry, you cannot vote for your own posts'+
+                                '</div>');
+                        } else if (data['error'] == 'anonymous_user'){
+                            var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
+                                '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
+                                'Sorry you must be logged to vote'+
+                                '</div>');
+                        }
+                        vote_alert = $link.parent().find("#vote_alert");
+                        if (vote_alert.length == 0) {
+                            $link.parent().append($warning);
+                        }
+                    } else {
+                        $link.parent().find("#vote_count").html(data['vote_count']);
+                        if (data['user_vote'] == 0) {
+                            $link.parent().find(".text-success").removeClass("text-success");
+                            $link.parent().find(".text-warning").removeClass("text-warning");
+                        } else {
+                            if (data['user_vote'] == 1) {
+                                $link.addClass("text-success");
+                            } else {
+                                $link.addClass("text-warning");
+                            }
+                        }
+                    }
+                });
+            return true;
+        });
 
-    $('.vote_up,.vote_down').not('.karma_required').on('click', function (ev) {
-        ev.preventDefault();
-        var $link = $(ev.currentTarget);
-        openerp.jsonRpc($link.data('href'), 'call', {})
-            .then(function (data) {
-                if (data['error']){
-                    if (data['error'] == 'own_post'){
-                        var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
-                            '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
-                            'Sorry, you cannot vote for your own posts'+
-                            '</div>');
-                    } else if (data['error'] == 'anonymous_user'){
-                        var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="vote_alert">'+
+        $('.accept_answer').not('.karma_required').on('click', function (ev) {
+            ev.preventDefault();
+            var $link = $(ev.currentTarget);
+            openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
+                if (data['error']) {
+                    if (data['error'] == 'anonymous_user') {
+                        var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
                             '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
-                            'Sorry you must be logged to vote'+
+                            'Sorry, anonymous users cannot choose correct answer.'+
                             '</div>');
                     }
-                    vote_alert = $link.parent().find("#vote_alert");
-                    if (vote_alert.length == 0) {
+                    correct_answer_alert = $link.parent().find("#correct_answer_alert");
+                    if (correct_answer_alert.length == 0) {
                         $link.parent().append($warning);
                     }
                 } else {
-                    $link.parent().find("#vote_count").html(data['vote_count']);
-                    if (data['user_vote'] == 0) {
-                        $link.parent().find(".text-success").removeClass("text-success");
-                        $link.parent().find(".text-warning").removeClass("text-warning");
+                    if (data) {
+                        $link.addClass("oe_answer_true").removeClass('oe_answer_false');
                     } else {
-                        if (data['user_vote'] == 1) {
-                            $link.addClass("text-success");
-                        } else {
-                            $link.addClass("text-warning");
-                        }
+                        $link.removeClass("oe_answer_true").addClass('oe_answer_false');
                     }
                 }
             });
-        return true;
-    });
+            return true;
+        });
 
-    $('.accept_answer').not('.karma_required').on('click', function (ev) {
-        ev.preventDefault();
-        var $link = $(ev.currentTarget);
-        openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
-            if (data['error']) {
-                if (data['error'] == 'anonymous_user') {
-                    var $warning = $('<div class="alert alert-danger alert-dismissable" id="correct_answer_alert" style="position:absolute; margin-top: -30px; margin-left: 90px;">'+
-                        '<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
-                        'Sorry, anonymous users cannot choose correct answer.'+
-                        '</div>');
-                }
-                correct_answer_alert = $link.parent().find("#correct_answer_alert");
-                if (correct_answer_alert.length == 0) {
-                    $link.parent().append($warning);
-                }
-            } else {
+        $('.favourite_question').on('click', function (ev) {
+            ev.preventDefault();
+            var $link = $(ev.currentTarget);
+            openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
                 if (data) {
-                    $link.addClass("oe_answer_true").removeClass('oe_answer_false');
+                    $link.addClass("forum_favourite_question")
                 } else {
-                    $link.removeClass("oe_answer_true").addClass('oe_answer_false');
+                    $link.removeClass("forum_favourite_question")
                 }
-            }
+            });
+            return true;
         });
-        return true;
-    });
 
-    $('.favourite_question').on('click', function (ev) {
-        ev.preventDefault();
-        var $link = $(ev.currentTarget);
-        openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
-            if (data) {
-                $link.addClass("forum_favourite_question")
-            } else {
-                $link.removeClass("forum_favourite_question")
-            }
+        $('.comment_delete').on('click', function (ev) {
+            ev.preventDefault();
+            var $link = $(ev.currentTarget);
+            openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
+                $link.parents('.comment').first().remove();
+            });
+            return true;
         });
-        return true;
-    });
 
-    $('.comment_delete').on('click', function (ev) {
-        ev.preventDefault();
-        var $link = $(ev.currentTarget);
-        openerp.jsonRpc($link.data('href'), 'call', {}).then(function (data) {
-            $link.parents('.comment').first().remove();
+        $('.notification_close').on('click', function (ev) {
+            ev.preventDefault();
+            var $link = $(ev.currentTarget);
+            openerp.jsonRpc("/forum/notification_read", 'call', {
+                'notification_id': $link.attr("id")})
+            return true;
         });
-        return true;
-    });
 
-    $('.notification_close').on('click', function (ev) {
-        ev.preventDefault();
-        var $link = $(ev.currentTarget);
-        openerp.jsonRpc("/forum/notification_read", 'call', {
-            'notification_id': $link.attr("id")})
-        return true;
-    });
+        if($('input.load_tags').length){
+            var tags = $("input.load_tags").val();
+            $("input.load_tags").val("");
+            set_tags(tags);
+        };
 
-    if($('input.load_tags').length){
-        var tags = $("input.load_tags").val();
-        $("input.load_tags").val("");
-        set_tags(tags);
-    };
-
-    function set_tags(tags) {
-        $("input.load_tags").textext({
-            plugins: 'tags focus autocomplete ajax',
-            tagsItems: tags.split(","),
-            //Note: The following list of keyboard keys is added. All entries are default except {32 : 'whitespace!'}.
-            keys: {8: 'backspace', 9: 'tab', 13: 'enter!', 27: 'escape!', 37: 'left', 38: 'up!', 39: 'right',
-                40: 'down!', 46: 'delete', 108: 'numpadEnter', 32: 'whitespace!'},
-            ajax: {
-                url: '/forum/get_tags',
-                dataType: 'json',
-                cacheResults: true
-            }
-        });
-        // Adds: create tags on space + blur
-        $("input.load_tags").on('whitespaceKeyDown blur', function () {
-            $(this).textext()[0].tags().addTags([ $(this).val() ]);
-            $(this).val("");
-        });
-        $("input.load_tags").on('isTagAllowed', function(e, data) {
-            if (_.indexOf($(this).textext()[0].tags()._formData, data.tag) != -1) {
-                data.result = false;
-            }
-        });
-    }
+        function set_tags(tags) {
+            $("input.load_tags").textext({
+                plugins: 'tags focus autocomplete ajax',
+                tagsItems: tags.split(","),
+                //Note: The following list of keyboard keys is added. All entries are default except {32 : 'whitespace!'}.
+                keys: {8: 'backspace', 9: 'tab', 13: 'enter!', 27: 'escape!', 37: 'left', 38: 'up!', 39: 'right',
+                    40: 'down!', 46: 'delete', 108: 'numpadEnter', 32: 'whitespace!'},
+                ajax: {
+                    url: '/forum/get_tags',
+                    dataType: 'json',
+                    cacheResults: true
+                }
+            });
+            // Adds: create tags on space + blur
+            $("input.load_tags").on('whitespaceKeyDown blur', function () {
+                $(this).textext()[0].tags().addTags([ $(this).val() ]);
+                $(this).val("");
+            });
+            $("input.load_tags").on('isTagAllowed', function(e, data) {
+                if (_.indexOf($(this).textext()[0].tags()._formData, data.tag) != -1) {
+                    data.result = false;
+                }
+            });
+        }
 
-    if ($('textarea.load_editor').length) {
-        var editor = CKEDITOR.instances['content'];
-        editor.on('instanceReady', CKEDITORLoadComplete);
+        if ($('textarea.load_editor').length) {
+            var editor = CKEDITOR.instances['content'];
+            editor.on('instanceReady', CKEDITORLoadComplete);
+        }
     }
 });
 
+
 function IsKarmaValid(eventNumber,minKarma){
     "use strict";
     if(parseInt($("#karma").val()) >= minKarma){
index 7b74293..458ad1c 100644 (file)
@@ -2,12 +2,10 @@
 <openerp>
     <data>
 
-<!-- Editor custo -->
-<template id="editor_head" inherit_id="website.editor_head"
-    name="Event Editor">
-    <xpath expr="." position="inside">
+<!-- Editor custom -->
+<template id="assets_frontend" inherit_id="website.assets_frontend" name="website_forum assets">
+    <xpath expr="/t" position="inside">
         <link rel='stylesheet' href="/website_forum/static/src/css/website_forum.css"/>
-
         <script type="text/javascript" src="/website_forum/static/src/js/website.tour.forum.js"/>
         <script type="text/javascript" src="/website_forum/static/src/js/website_forum.editor.js"/>
     </xpath>
     </form>
 </template>
 
+<template id="assets_frontend" inherit_id="website.assets_frontend" name="website_instantclick assets"  groups="base.group_public">
+    <xpath expr="/t" position="inside">
+        <link rel='stylesheet' href="/web/static/lib/jquery.textext/jquery.textext.css"/>
+        <link rel='stylesheet' href='/website_forum/static/src/css/website_forum.css'/>
+        <script type="text/javascript" src="/website_forum/static/src/js/website_forum.js"/>
+        <script type="text/javascript" src="/web/static/lib/jquery.textext/jquery.textext.js"/>
+    </xpath>
+</template>
+
 <!-- Page Index -->
 <template id="header" name="Forum Index">
     <t t-call="website.layout">
         <t t-set="head">
-            <link rel='stylesheet' href="/web/static/lib/jquery.textext/jquery.textext.css"/>
-            <link rel='stylesheet' href='/website_forum/static/src/css/website_forum.css'/>
-            <script type="text/javascript" src="/website_forum/static/src/js/website_forum.js"/>
-            <script type="text/javascript" src="/web/static/lib/jquery.textext/jquery.textext.js"/>
             <script type="text/javascript" src="/web/static/lib/ckeditor/ckeditor.js"/>
             <script type="text/javascript">
                 CKEDITOR.config.toolbar = [['Bold','Italic','Underline','Strike'],['NumberedList','BulletedList', 'Blockquote']
                 ,['Outdent','Indent','Link','Unlink','Image'],] ;
             </script>
+            <t t-raw="0"/>
         </t>
-        <div class="container mt16">
+        <div class="container mt16 website_forum">
             <div class="navbar navbar-default">
                 <div class="navbar-header">
                     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#oe-help-navbar-collapse">
index 39afa93..3674cea 100644 (file)
@@ -1,18 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- vim:fdn=3:
--->
+
 <openerp>
     <data>
+        <template id="assets_frontend" inherit_id="website.assets_frontend" name="website_instantclick assets"  groups="base.group_public">
+            <xpath expr="/t" position="inside">
+                <script type="text/javascript" src="/website_instantclick/static/lib/instantclick/instantclick.js" data-no-instant=""></script>
+            </xpath>
+        </template>
 
-<template id="show_sign_in_anonymous" inherit_id="website.show_sign_in" name="Show Sign In" groups="base.group_public">
-    <xpath expr="//div[@id='wrapwrap']" position="after">
-        <script type="text/javascript" src="/website_instantclick/static/lib/instantclick/instantclick.js" data-no-instant=""></script>
-        <script data-no-instant="">
-            InstantClick.init();
-        </script>
-    </xpath>
-</template>
-
-
+        <template id="instant_click_init" inherit_id="website.layout" name="Instant Click Init" groups="base.group_public">
+            <xpath expr="//div[@id='wrapwrap']" position="after">
+                <script data-no-instant="">
+                    InstantClick.init();
+                </script>
+            </xpath>
+        </template>
      </data>
 </openerp>