[MERGE] fme
[odoo/odoo.git] / addons / web / static / src / js / chrome.js
index de3275f..99fc3cf 100644 (file)
@@ -47,7 +47,7 @@ openerp.web.Notification =  openerp.web.OldWidget.extend(/** @lends openerp.web.
 
 openerp.web.dialog = function(element) {
     var result = element.dialog.apply(element, _.rest(_.toArray(arguments)));
-    result.dialog("widget").addClass("openerp");
+    result.dialog("widget").addClass("openerp2");
     return result;
 }
 
@@ -351,44 +351,6 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
         return result;
     },
     /**
-     * Waits until the new database is done creating, then unblocks the UI and
-     * logs the user in as admin
-     *
-     * @param {Number} db_creation_id identifier for the db-creation operation, used to fetch the current installation progress
-     * @param {Object} info info fields for this database creation
-     * @param {String} info.db name of the database being created
-     * @param {String} info.password super-admin password for the database
-     */
-    wait_for_newdb: function (db_creation_id, info) {
-        var self = this;
-        self.rpc('/web/database/progress', {
-            id: db_creation_id,
-            password: info.password
-        }, function (result) {
-            var progress = result[0];
-            // I'd display a progress bar, but turns out the progress status
-            // the server report kind-of blows goats: it's at 0 for ~75% of
-            // the installation, then jumps to 75%, then jumps down to either
-            // 0 or ~40%, then back up to 75%, then terminates. Let's keep that
-            // mess hidden behind a not-very-useful but not overly weird
-            // message instead.
-            if (progress < 1) {
-                setTimeout(function () {
-                    self.wait_for_newdb(db_creation_id, info);
-                }, 500);
-                return;
-            }
-
-            var admin = result[1][0];
-            setTimeout(function () {
-                self.getParent().do_login(
-                        info.db, admin.login, admin.password);
-                self.destroy();
-                self.unblockUI();
-            });
-        });
-    },
-    /**
      * Blocks UI and replaces $.unblockUI by a noop to prevent third parties
      * from unblocking the UI
      */
@@ -427,23 +389,19 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
         self.$option_id.find("form[name=create_db_form]").validate({
             submitHandler: function (form) {
                 var fields = $(form).serializeArray();
-                self.blockUI();
                 self.rpc("/web/database/create", {'fields': fields}, function(result) {
-                    if (result.error) {
-                        self.unblockUI();
-                        self.display_error(result);
-                        return;
-                    }
                     if (self.db_list) {
                         self.db_list.push(self.to_object(fields)['db_name']);
                         self.db_list.sort();
                         self.getParent().set_db_list(self.db_list);
                     }
+
                     var form_obj = self.to_object(fields);
-                    self.wait_for_newdb(result, {
-                        password: form_obj['super_admin_pwd'],
-                        db: form_obj['db_name']
-                    });
+                    self.getParent().do_login(
+                            form_obj['db_name'],
+                            'admin',
+                            form_obj['create_admin_pwd']);
+                    self.destroy();
                 });
             }
         });
@@ -455,10 +413,10 @@ openerp.web.Database = openerp.web.OldWidget.extend(/** @lends openerp.web.Datab
             submitHandler: function (form) {
                 var $form = $(form),
                     fields = $form.serializeArray(),
-                    $db_list = $form.find('select[name=drop_db]'),
+                    $db_list = $form.find('[name=drop_db]'),
                     db = $db_list.val();
 
-                if (!confirm("Do you really want to delete the database: " + db + " ?")) {
+                if (!db || !confirm("Do you really want to delete the database: " + db + " ?")) {
                     return;
                 }
                 self.rpc("/web/database/drop", {'fields': fields}, function(result) {
@@ -666,186 +624,6 @@ openerp.web.Login =  openerp.web.OldWidget.extend(/** @lends openerp.web.Login#
     }
 });
 
-openerp.web.Header =  openerp.web.OldWidget.extend(/** @lends openerp.web.Header# */{
-    template: "Header",
-    /**
-     * @constructs openerp.web.Header
-     * @extends openerp.web.OldWidget
-     *
-     * @param parent
-     */
-    init: function(parent) {
-        this._super(parent);
-        this.qs = "?" + jQuery.param.querystring();
-        this.$content = $();
-        this.update_promise = $.Deferred().resolve();
-    },
-    start: function() {
-        this._super();
-    },
-    do_update: function () {
-        var self = this;
-        var fct = function() {
-            self.$content.remove();
-            if (!self.session.uid)
-                return;
-            var func = new openerp.web.Model("res.users").get_func("read");
-            return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
-                self.$content = $(QWeb.render("Header-content", {widget: self, user: res}));
-                self.$content.appendTo(self.$element);
-                self.$element.find(".logout").click(self.on_logout);
-                self.$element.find("a.preferences").click(self.on_preferences);
-                self.$element.find(".about").click(self.on_about);
-                return self.shortcut_load();
-            });
-        };
-        this.update_promise = this.update_promise.pipe(fct, fct);
-    },
-    on_about: function() {
-        var self = this;
-        self.rpc("/web/webclient/version_info", {}).then(function(res) {
-            var $help = $(QWeb.render("About-Page", {version_info: res}));
-            $help.find('a.oe_activate_debug_mode').click(function (e) {
-                e.preventDefault();
-                window.location = $.param.querystring(
-                        window.location.href, 'debug');
-            });
-            openerp.web.dialog($help, {autoOpen: true,
-                modal: true, width: 960, title: _t("About")});
-        });
-    },
-    shortcut_load :function(){
-        var self = this,
-            sc = self.session.shortcuts,
-            shortcuts_ds = new openerp.web.DataSet(this, 'ir.ui.view_sc');
-        // TODO: better way to communicate between sections.
-        // sc.bindings, because jquery does not bind/trigger on arrays...
-        if (!sc.binding) {
-            sc.binding = {};
-            $(sc.binding).bind({
-                'add': function (e, attrs) {
-                    shortcuts_ds.create(attrs, function (out) {
-                        $('<li>', {
-                            'data-shortcut-id':out.result,
-                            'data-id': attrs.res_id
-                        }).text(attrs.name)
-                          .appendTo(self.$element.find('.oe-shortcuts ul'));
-                        attrs.id = out.result;
-                        sc.push(attrs);
-                    });
-                },
-                'remove-current': function () {
-                    var menu_id = self.session.active_id;
-                    var $shortcut = self.$element
-                        .find('.oe-shortcuts li[data-id=' + menu_id + ']');
-                    var shortcut_id = $shortcut.data('shortcut-id');
-                    $shortcut.remove();
-                    shortcuts_ds.unlink([shortcut_id]);
-                    var sc_new = _.reject(sc, function(shortcut){ return shortcut_id === shortcut.id});
-                    sc.splice(0, sc.length);
-                    sc.push.apply(sc, sc_new);
-                    }
-            });
-        }
-        return this.rpc('/web/session/sc_list', {}, function(shortcuts) {
-            sc.splice(0, sc.length);
-            sc.push.apply(sc, shortcuts);
-
-            self.$element.find('.oe-shortcuts')
-                .html(QWeb.render('Shortcuts', {'shortcuts': shortcuts}))
-                .undelegate('li', 'click')
-
-                .delegate('li', 'click', function(e) {
-                    e.stopPropagation();
-                    var id = $(this).data('id');
-                    self.session.active_id = id;
-                    self.rpc('/web/menu/action', {'menu_id':id}, function(ir_menu_data) {
-                        if (ir_menu_data.action.length){
-                            self.on_action(ir_menu_data.action[0][2]);
-                        }
-                    });
-                });
-        });
-    },
-
-    on_action: function(action) {
-    },
-    on_preferences: function(){
-        var self = this;
-        var action_manager = new openerp.web.ActionManager(this);
-        var dataset = new openerp.web.DataSet (this,'res.users',this.context);
-        dataset.call ('action_get','',function (result){
-            self.rpc('/web/action/load', {action_id:result}, function(result){
-                action_manager.do_action(_.extend(result['result'], {
-                    res_id: self.session.uid,
-                    res_model: 'res.users',
-                    flags: {
-                        action_buttons: false,
-                        search_view: false,
-                        sidebar: false,
-                        views_switcher: false,
-                        pager: false
-                    }
-                }));
-            });
-        });
-        this.dialog = new openerp.web.Dialog(this,{
-            title: _t("Preferences"),
-            width: '700px',
-            buttons: [
-                {text: _t("Cancel"), click: function(){ $(this).dialog('destroy'); }},
-                {text: _t("Change password"), click: function(){ self.change_password(); }},
-                {text: _t("Save"), click: function(){
-                        var inner_viewmanager = action_manager.inner_viewmanager;
-                        inner_viewmanager.views[inner_viewmanager.active_view].controller.do_save()
-                        .then(function() {
-                            self.dialog.destroy();
-                            // needs to refresh interface in case language changed
-                            window.location.reload();
-                        });
-                    }
-                }
-            ]
-        }).open();
-       action_manager.appendTo(this.dialog);
-       action_manager.render(this.dialog);
-    },
-
-    change_password :function() {
-        var self = this;
-        this.dialog = new openerp.web.Dialog(this, {
-            title: _t("Change Password"),
-            width : 'auto'
-        }).open();
-        this.dialog.$element.html(QWeb.render("Change_Pwd", self));
-        this.dialog.$element.find("form[name=change_password_form]").validate({
-            submitHandler: function (form) {
-                self.rpc("/web/session/change_password",{
-                    'fields': $(form).serializeArray()
-                }, function(result) {
-                    if (result.error) {
-                        self.display_error(result);
-                        return;
-                    } else {
-                        openerp.webclient.on_logout();
-                    }
-                });
-            }
-        });
-    },
-    display_error: function (error) {
-        return openerp.web.dialog($('<div>'), {
-            modal: true,
-            title: error.title,
-            buttons: [
-                {text: _("Ok"), click: function() { $(this).dialog("close"); }}
-            ]
-        }).html(error.error);
-    },
-    on_logout: function() {
-    }
-});
-
 openerp.web.Menu =  openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
     /**
      * @constructs openerp.web.Menu
@@ -854,6 +632,17 @@ openerp.web.Menu =  openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
      * @param parent
      */
     template: 'Menu',
+    init: function() {
+        this._super.apply(this, arguments);
+        this.has_been_loaded = $.Deferred();
+        this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
+    },
+    start: function() {
+        this._super.apply(this, arguments);
+        this.$secondary_menus = this.getParent().$element.find('.oe_secondary_menus_container');
+        this.$secondary_menus.on('click', 'a[data-menu]', this.on_menu_click);
+        $('html').bind('click', this.do_hide_more);
+    },
     do_reload: function() {
         var self = this;
         return this.rpc("/web/menu/load", {}, this.on_loaded).then(function () {
@@ -863,56 +652,85 @@ openerp.web.Menu =  openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
         });
     },
     on_loaded: function(data) {
+        var self = this;
         this.data = data;
-        this.render_element();
-        if (!this.$secondary_menu && this.getParent()) {
-            // TODO: create Widget openerp.web.SubMenu
-            this.$secondary_menu = this.getParent().$element.find('.oe_secondary_menu');
+        this.renderElement();
+        this.limit_entries();
+        this.$element.on('click', 'a[data-menu]', this.on_menu_click);
+        this.$element.on('click', 'a.oe_menu_more_link', function() {
+            self.$element.find('.oe_menu_more').toggle();
+            return false;
+        });
+        this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
+        // Hide second level submenus
+        this.$secondary_menus.find('.oe_menu_toggler').siblings('.oe_secondary_submenu').hide();
+        this.has_been_loaded.resolve();
+    },
+    limit_entries: function() {
+        var maximum_visible_links = this.maximum_visible_links;
+        if (maximum_visible_links === 'auto') {
+            maximum_visible_links = this.auto_limit_entries();
         }
-        this.$secondary_menu.html(QWeb.render("Menu.secondary", { widget : this }));
-        this.$element.add(this.$secondary_menu).find("a").click(this.on_menu_click);
+        if (maximum_visible_links < this.data.data.children.length) {
+            var $more = $(QWeb.render('Menu.more')),
+                $index = this.$element.find('li').eq(maximum_visible_links - 1);
+            $index.after($more);
+            $more.find('.oe_menu_more').append($index.next().nextAll());
+        }
+    },
+    auto_limit_entries: function() {
+        // TODO: auto detect overflow and bind window on resize
+        var width = $(window).width();
+        return Math.floor(width / 125);
+    },
+    do_hide_more: function() {
+        this.$element.find('.oe_menu_more').hide();
     },
     /**
      * Opens a given menu by id, as if a user had browsed to that menu by hand
      * except does not trigger any event on the way
      *
-     * @param {Number} menu_id database id of the terminal menu to select
+     * @param {Number} id database id of the terminal menu to select
      */
-    open_menu: function (menu_id) {
-        this.$element.add(this.$secondary_menu).find('.oe_active')
-                .removeClass('oe_active');
-        this.$secondary_menu.find('> .oe_secondary_menu').hide();
+    open_menu: function (id) {
+        var $clicked_menu, $sub_menu, $main_menu;
+        $clicked_menu = this.$element.add(this.$secondary_menus).find('a[data-menu=' + id + ']');
 
-        var $primary_menu;
-        var $secondary_submenu = this.$secondary_menu.find(
-                'a[data-menu=' + menu_id +']');
-        if ($secondary_submenu.length) {
-            for(;;) {
-                if ($secondary_submenu.hasClass('leaf')) {
-                    $secondary_submenu.addClass('oe_active');
-                } else if ($secondary_submenu.hasClass('submenu')) {
-                    $secondary_submenu.addClass('opened')
-                }
-                var $parent = $secondary_submenu.parent().show();
-                if ($parent.hasClass('oe_secondary_menu')) {
-                    var primary_id = $parent.data('menu-parent');
-                    $primary_menu = this.$element.find(
-                            'a[data-menu=' + primary_id + ']');
-                    break;
-                }
-                $secondary_submenu = $parent.prev();
-            }
+        if (this.$secondary_menus.has($clicked_menu).length) {
+            $sub_menu = $clicked_menu.parents('.oe_secondary_menu');
+            $main_menu = this.$element.find('a[data-menu=' + $sub_menu.data('menu-parent') + ']');
         } else {
-            $primary_menu = this.$element.find('a[data-menu=' + menu_id + ']');
+            $sub_menu = this.$secondary_menus.find('.oe_secondary_menu[data-menu-parent=' + $clicked_menu.attr('data-menu') + ']');
+            $main_menu = $clicked_menu;
         }
-        if (!$primary_menu.length) {
-            return;
+
+        // Activate current main menu
+        this.$element.find('.oe_active').removeClass('oe_active');
+        $main_menu.addClass('oe_active');
+
+        // Show current sub menu
+        this.$secondary_menus.find('.oe_secondary_menu').hide();
+        $sub_menu.show();
+
+        // Activate current menu item and show parents
+        this.$secondary_menus.find('.oe_active').removeClass('oe_active');
+        if ($main_menu !== $clicked_menu) {
+            $clicked_menu.parents().show();
+            if ($clicked_menu.is('.oe_menu_toggler')) {
+                $clicked_menu.toggleClass('oe_menu_opened').siblings('.oe_secondary_submenu:first').toggle();
+            } else {
+                $clicked_menu.parent().addClass('oe_active');
+            }
+        }
+    },
+    open_action: function (id) {
+        var menu_id, $menu = this.$element.add(this.$secondary_menus).find('a[data-action-id=' + id + ']');
+        if (menu_id = $menu.data('menu')) {
+            this.open_menu(menu_id);
         }
-        $primary_menu.addClass('oe_active');
-        this.$secondary_menu.find(
-            'div[data-menu-parent=' + $primary_menu.data('menu') + ']').addClass('oe_active');
     },
     on_menu_click: function(ev, id) {
+        this.do_hide_more();
         id = id || 0;
         var $clicked_menu, manual = false;
 
@@ -921,103 +739,52 @@ openerp.web.Menu =  openerp.web.Widget.extend(/** @lends openerp.web.Menu# */{
             manual = true;
             $clicked_menu = this.$element.find('a[data-menu=' + id + ']');
             if (!$clicked_menu.length) {
-                $clicked_menu = this.$secondary_menu.find('a[data-menu=' + id + ']');
+                $clicked_menu = this.$secondary_menus.find('a[data-menu=' + id + ']');
             }
         } else {
             $clicked_menu = $(ev.currentTarget);
             id = $clicked_menu.data('menu');
         }
 
-        if (this.do_menu_click($clicked_menu, manual) && id) {
+        this.trigger('menuClicked', id, $clicked_menu);
+
+        if (id) {
+            this.open_menu(id);
             this.current_menu = id;
             this.session.active_id = id;
-            this.rpc('/web/menu/action', {'menu_id': id}, this.on_menu_action_loaded);
+            var action_id = $clicked_menu.data('action-id');
+            if (action_id) {
+                this.on_action(action_id);
+            }
         }
         if (ev) {
             ev.stopPropagation();
         }
         return false;
     },
-    do_menu_click: function($clicked_menu, manual) {
-        var $sub_menu, $main_menu,
-            active = $clicked_menu.is('.oe_active'),
-            sub_menu_visible = false,
-            has_submenu_items = false;
-
-        if (this.$secondary_menu.has($clicked_menu).length) {
-            $sub_menu = $clicked_menu.parents('.oe_secondary_menu');
-            $main_menu = this.$element.find('a[data-menu=' + $sub_menu.data('menu-parent') + ']');
-        } else {
-            $sub_menu = this.$secondary_menu.find('.oe_secondary_menu[data-menu-parent=' + $clicked_menu.attr('data-menu') + ']');
-            $main_menu = $clicked_menu;
-        }
-
-        sub_menu_visible = $sub_menu.is(':visible');
-        has_submenu_items = !!$sub_menu.children().length;
-        this.$secondary_menu.find('.oe_secondary_menu').hide();
-
-        $('.oe_active', this.$element.add(this.$secondary_menu)).removeClass('oe_active');
-        $main_menu.add($clicked_menu).add($sub_menu).addClass('oe_active');
-
-        if (has_submenu_items) {
-            if (!manual) {
-                this.do_show_secondary($sub_menu, $main_menu);
-            } else {
-                this.do_show_secondary();
-            }
-        }
-
-        if ($main_menu != $clicked_menu) {
-            if ($clicked_menu.is('.submenu')) {
-                $sub_menu.find('.submenu.opened').each(function() {
-                    if (!$(this).next().has($clicked_menu).length && !$(this).is($clicked_menu)) {
-                        $(this).removeClass('opened').next().hide();
-                    }
-                });
-                $clicked_menu.toggleClass('opened').next().toggle();
-            } else if ($clicked_menu.is('.leaf')) {
-                return true;
-            }
-        } else {
-            return true;
-        }
-        return false;
-    },
-    do_hide_secondary: function() {
-        //this.$secondary_menu.hide();
-    },
     do_show_secondary: function($sub_menu, $main_menu) {
         var self = this;
-        this.$secondary_menu.show();
+        this.$secondary_menus.show();
         if (!arguments.length) {
             return;
         }
         $sub_menu.show();
     },
-    on_menu_action_loaded: function(data) {
-        var self = this;
-        if (data.action.length) {
-            var action = data.action[0][2];
-            action.from_menu = true;
-            self.on_action(action);
-        } else {
-            self.on_action({type: 'null_action'});
-        }
-    },
     on_action: function(action) {
     }
 });
 
-openerp.web.DropDownMenu =  openerp.web.Widget.extend(/** @lends openerp.web.Header# */{
-    template: "DropDownMenu",
+openerp.web.UserMenu =  openerp.web.Widget.extend(/** @lends openerp.web.UserMenu# */{
+    template: "UserMenu",
     /**
-     * @constructs openerp.web.DropDownMenu
-     * @extends openerp.web.OldWidget
+     * @constructs openerp.web.UserMenu
+     * @extends openerp.web.Widget
      *
      * @param parent
      */
     init: function(parent) {
         this._super(parent);
+        this.update_promise = $.Deferred().resolve();
     },
     start: function() {
         var self = this;
@@ -1029,13 +796,111 @@ openerp.web.DropDownMenu =  openerp.web.Widget.extend(/** @lends openerp.web.Hea
             self.$element.find('.oe_dropdown_options').toggle();
             return false;
         });
-        this.$element.find('.oe_dropdown_options li a').click(function() {
+        this.$element.on('click', '.oe_dropdown_options li a[data-menu]', function() {
             var f = self['on_menu_' + $(this).data('menu')];
-            f && f();
+            f && f($(this));
             self.$element.find('.oe_dropdown_options').hide();
             return false;
         });
     },
+    change_password :function() {
+        var self = this;
+        this.dialog = new openerp.web.Dialog(this, {
+            title: _t("Change Password"),
+            width : 'auto'
+        }).open();
+        this.dialog.$element.html(QWeb.render("Change_Pwd", self));
+        this.dialog.$element.find("form[name=change_password_form]").validate({
+            submitHandler: function (form) {
+                self.rpc("/web/session/change_password",{
+                    'fields': $(form).serializeArray()
+                }, function(result) {
+                    if (result.error) {
+                        self.display_error(result);
+                        return;
+                    } else {
+                        openerp.webclient.on_logout();
+                    }
+                });
+            }
+        });
+    },
+    display_error: function (error) {
+        return openerp.web.dialog($('<div>'), {
+            modal: true,
+            title: error.title,
+            buttons: [
+                {text: _("Ok"), click: function() { $(this).dialog("close"); }}
+            ]
+        }).html(error.error);
+    },
+    do_update: function () {
+        var self = this;
+        var fct = function() {
+            var $avatar = self.$element.find('.oe_topbar_avatar');
+            $avatar.attr('src', $avatar.data('default-src'));
+            if (!self.session.uid)
+                return;
+            var func = new openerp.web.Model("res.users").get_func("read");
+            return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
+                // TODO: Show company if multicompany is in use
+                var topbar_name = _.str.sprintf("%s (%s)", res.name, openerp.connection.db, res.company_id[1]);
+                self.$element.find('.oe_topbar_name').text(topbar_name);
+                var avatar_src = _.str.sprintf('%s/web/binary/image?session_id=%s&model=res.users&field=avatar&id=%s', self.session.prefix, self.session.session_id, self.session.uid);
+                $avatar.attr('src', avatar_src);
+                return self.shortcut_load();
+            });
+        };
+        this.update_promise = this.update_promise.pipe(fct, fct);
+    },
+    on_action: function() {
+    },
+    shortcut_load :function(){
+        var self = this,
+            sc = self.session.shortcuts,
+            shortcuts_ds = new openerp.web.DataSet(this, 'ir.ui.view_sc');
+        self.$element.find('.oe_dropdown_options a[data-menu=shortcut]').each(function() {
+            $(this).parent().remove();
+        });
+        // TODO: better way to communicate between sections.
+        // sc.bindings, because jquery does not bind/trigger on arrays...
+        if (!sc.binding) {
+            sc.binding = {};
+            $(sc.binding).bind({
+                'add': function (e, attrs) {
+                    shortcuts_ds.create(attrs, function (out) {
+                        var shortcut = QWeb.render('UserMenu.shortcut', {
+                            shortcuts : [{
+                                name : attrs.name,
+                                id : out.result,
+                                res_id : attrs.res_id
+                            }]
+                        });
+                        $(shortcut).appendTo(self.$element.find('.oe_dropdown_options'));
+                        attrs.id = out.result;
+                        sc.push(attrs);
+                    });
+                },
+                'remove-current': function () {
+                    var menu_id = self.session.active_id;
+                    var $shortcut = self.$element.find('.oe_dropdown_options li a[data-id=' + menu_id + ']');
+                    var shortcut_id = $shortcut.data('shortcut-id');
+                    $shortcut.remove();
+                    shortcuts_ds.unlink([shortcut_id]);
+                    var sc_new = _.reject(sc, function(shortcut){ return shortcut_id === shortcut.id});
+                    sc.splice(0, sc.length);
+                    sc.push.apply(sc, sc_new);
+                }
+            });
+        }
+        return this.rpc('/web/session/sc_list', {}, function(shortcuts) {
+            sc.splice(0, sc.length);
+            sc.push.apply(sc, shortcuts);
+
+            $(QWeb.render('UserMenu.shortcut', {'shortcuts': shortcuts}))
+                .appendTo(self.$element.find('.oe_dropdown_options'));
+        });
+    },
     on_menu_logout: function() {
     },
     on_menu_settings: function() {
@@ -1075,8 +940,31 @@ openerp.web.DropDownMenu =  openerp.web.Widget.extend(/** @lends openerp.web.Hea
                 }
             ]
         }).open();
-       action_manager.appendTo(this.dialog);
+       action_manager.appendTo(this.dialog.$element);
        action_manager.render(this.dialog);
+    },
+    on_menu_about: function() {
+        var self = this;
+        self.rpc("/web/webclient/version_info", {}).then(function(res) {
+            var $help = $(QWeb.render("About-Page", {version_info: res}));
+            $help.find('a.oe_activate_debug_mode').click(function (e) {
+                e.preventDefault();
+                window.location = $.param.querystring(
+                        window.location.href, 'debug');
+            });
+            openerp.web.dialog($help, {autoOpen: true,
+                modal: true, width: 960, title: _t("About")});
+        });
+    },
+    on_menu_shortcut: function($link) {
+        var self = this,
+            id = $link.data('id');
+        self.session.active_id = id;
+        self.rpc('/web/menu/action', {'menu_id': id}, function(ir_menu_data) {
+            if (ir_menu_data.action.length){
+                self.on_action(ir_menu_data.action[0][2]);
+            }
+        });
     }
 });
 
@@ -1089,12 +977,12 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie
         var self = this;
         this._super(parent);
         openerp.webclient = this;
-
+        this.querystring = '?' + jQuery.param.querystring();
         this._current_state = null;
     },
     start: function() {
         var self = this;
-        this.$element.addClass("openerp openerp2");
+        this.$element.addClass("openerp2");
         if (jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
             this.$element.addClass("kitten-mode-activated");
             this.$element.delegate('img.oe-record-edit-link-img', 'hover', function(e) {
@@ -1108,13 +996,13 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie
         });
         this.session.on_session_valid.add(function() {
             self.show_application();
-            
-            self.header.do_update();
+
+            self.user_menu.do_update();
             self.menu.do_reload();
             if(self.action_manager)
                 self.action_manager.destroy();
             self.action_manager = new openerp.web.ActionManager(self);
-            self.action_manager.appendTo($("#oe_app"));
+            self.action_manager.appendTo(self.$element.find('.oe_application'));
             self.bind_hashchange();
             var version_label = _t("OpenERP - Unsupported/Community Version");
             if (!self.session.openerp_entreprise) {
@@ -1122,6 +1010,9 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie
                 document.title = version_label;
             }
         });
+        this.$element.on('mouseenter', '.oe_systray > div:not([data-tipsy=true])', function() {
+            $(this).attr('data-tipsy', 'true').tipsy().trigger('mouseenter');
+        });
     },
     show_login: function() {
         var self = this;
@@ -1136,16 +1027,13 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie
         this.show_common();
         self.$table = $(QWeb.render("WebClient", {}));
         self.$element.append(self.$table);
-        self.header = new openerp.web.Header(self);
-        self.header.on_logout.add(this.proxy('on_logout'));
-        self.header.on_action.add(this.proxy('on_menu_action'));
-        self.header.appendTo($("#oe_header"));
         self.menu = new openerp.web.Menu(self);
         self.menu.replace(this.$element.find('.oe_menu_placeholder'));
         self.menu.on_action.add(this.proxy('on_menu_action'));
-        self.dropdown_menu = new openerp.web.DropDownMenu(self);
-        self.dropdown_menu.replace(this.$element.find('.oe_dropdown_menu_placeholder'));
-        self.dropdown_menu.on_menu_logout.add(this.proxy('on_logout'));
+        self.user_menu = new openerp.web.UserMenu(self);
+        self.user_menu.replace(this.$element.find('.oe_user_menu_placeholder'));
+        self.user_menu.on_menu_logout.add(this.proxy('on_logout'));
+        self.user_menu.on_action.add(this.proxy('on_menu_action'));
     },
     show_common: function() {
         var self = this;
@@ -1229,6 +1117,12 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie
                 self.menu.on_menu_click(null, action.menu_id);
             });
         }
+    },
+    set_content_full_screen: function(fullscreen) {
+        if (fullscreen)
+            $(".oe_webclient", this.$element).addClass("oe_content_full_screen");
+        else
+            $(".oe_webclient", this.$element).removeClass("oe_content_full_screen");
     }
 });
 
@@ -1244,7 +1138,7 @@ openerp.web.EmbeddedClient = openerp.web.OldWidget.extend({
 
     start: function() {
         var self = this;
-        this.am.appendTo(this.$element.addClass('openerp'));
+        this.am.appendTo(this.$element.addClass('openerp openerp2'));
         return this.rpc("/web/action/load", { action_id: this.action_id }, function(result) {
             var action = result.result;
             action.flags = _.extend({