class is being removed from a div

The OpenERP web interface relies heavily on javascript, QWeb, jQuery (I think), and css.

The default view has a black menu bar along the top, a side menu bar along the left, and the rest of the screen for the content being served.

The issue I was trying to "fix" is that it is displayed as one large page, meaning if you scroll the page the top menu and side menu also scroll off.

I have a nearly working solution:

  • adjust top menu bar to be fixed
  • adjust side menu bar to be fixed
  • adjust remainder to take up the remaining space

In order to do that I also had to add a new css class, which I called oe_main_window, and located the code which sets up the view to add oe_main_window to the div with the class oe_view_manager_current.

This works fine for primary views.

However, if I click on a link in a primary view, say to show a product, it removes the oe_main_window class and messes up the display. If I go into developer tools and add oe_main_window back the display is again correct.

I have tried searching for where this is happening, but so far have failed to locate the appropriate code either to not remove the new class or to add it back after the transition.

Any ideas?

Answers:

Answer

You can find how to put a breakpoint on DOM mutation here: https://developer.chrome.com/devtools/docs/javascript-debugging#breakpoints-mutation-events

mainly it's opening the chrome dev-tools using F12, right click on your div and click "Break on...>> Attributes modifications"

Answer

The final solution to the problem involved targeting the first oe_view_manager found. Here's the (clumsy) JavaScript:

function addOeMainWindow() {
    var newChildren = [];
    var currentChild, getAttr, oldClass, newClass;
    var i;
    for (i=0; i<document.childNodes.length; i+=1) {
        newChildren.push(document.childNodes[i]);
    }
    while (newChildren.length > 0) {
        currentChild = newChildren.shift();
        getAttr = currentChild.getAttribute;
        if (getAttr !== undefined) {
            oldClass = currentChild.getAttribute("class");
            if (/oe_view_manager/.test(oldClass) && !/oe_main_window/.test(oldClass)) {
                newClass = oldClass + " oe_main_window";
                currentChild.setAttribute("class", newClass);
                return;
            }
        }
        for (i=0; i<currentChild.childNodes.length; i+=1) {
            newChildren.push(currentChild.childNodes[i]);
        }
    }
    return;
}

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.