{% load i18n %}

var enabledEditText = "{% trans "Enable edit inline" %}";
var disabledEditText = "{% trans "Disable edit inline" %}";
var toggleInplaceEdit = function () {
    var trigger = $(this);
    if (trigger.hasClass('active')) {
        inplaceManager.disable();
        trigger.removeClass('active');
        trigger.html(enabledEditText);
    } else {
        inplaceManager.enable();
        trigger.addClass('active');
        trigger.html(disabledEditText);
    }
    return false;
};
var menu = $(".navbar-fixed-top");
menu.css("top", menu.height());
var padding_top = $("body").css("padding-top");
if (padding_top.indexOf("px") != -1) {
    padding_top = parseInt(padding_top.replace("px", ""));
    if (padding_top != 0) {
        padding_top = padding_top + menu.height();
        $("body").css("padding-top", padding_top);
    }
}

var toolbar = $("<div class=\"navbar navbar-inverse navbar-fixed-top\"><div class=\"container\"></div></div>").prependTo("body"); 

toolbar.find(".container").append("<ul class=\"nav navbar-nav\"></ul>");
var actions = toolbar.find("ul.navbar-nav");
actions.append("<li id=\"ActivateInplaceEdit\" class=\"active\"><a href=\"#\">" + enabledEditText + "</a></li>");
$("#ActivateInplaceEdit a").click(toggleInplaceEdit);