AJS.toInit(function($) {
    AJS.log("confluence-keyboard-shortcuts initialising");

    // CGP-151/CONFDEV-811 - Skip this if you are in the Page Gadget
    if (AJS.PageGadget || (window.parent.AJS && window.parent.AJS.PageGadget)) {
        AJS.log("Inside the Page Gadget. Skipping keyboard shortcuts");
        return;
    }

    Confluence.KeyboardShortcuts.enabled = AJS.Meta.getBoolean('use-keyboard-shortcuts');

    AJS.bind("shortcuts-loaded.keyboardshortcuts", function (e, data) {
        Confluence.KeyboardShortcuts.shortcuts = data.shortcuts;
        $("#keyboard-shortcuts-link").click(Confluence.KeyboardShortcuts.openDialog);
    });

    AJS.bind("register-contexts.keyboardshortcuts", function(e, data){

        // Only bind the shortcuts for contexts if the user has the preference set
        if (!Confluence.KeyboardShortcuts.enabled) {
            return;
        }
        // Here we bind to register-contexts.keyboardshortcuts so that we can select which
        // keyboard shortcut contexts should be enabled. We use jQuery selectors to determine
        // which keyboard shortcut contexts are applicable to a page.

        var shortcutRegistry = data.shortcutRegistry;
        shortcutRegistry.enableContext("global");
        $("#action-menu-link").length && !$("#preview").length && shortcutRegistry.enableContext("viewcontent");
        $("#viewPageLink").length && shortcutRegistry.enableContext("viewinfo");

        if ($("#wysiwyg").length) {
            shortcutRegistry.enableContext("editor");

            // tinymce shortcuts are added through the tinymce apis
            var ed = tinyMCE.activeEditor,
                editorForm = $("#rte").closest("form");

            $.each(Confluence.KeyboardShortcuts.shortcuts, function (i, shortcut) {
                if (shortcut.context.indexOf("tinymce") != 0) return;

                var operation = shortcut.op,
                    param = shortcut.param;
                $.each(shortcut.keys, function () {
                    var shortcutKey = this,
                        shortcutFunc;
                    if (operation == "click") {
                        shortcutFunc = function() { $(param).click(); };
                    }
                    else if (operation == "execute") {
                        shortcutFunc = param;
                    }
                    if (shortcutFunc) {
                        if ($.isArray(shortcutKey)) {
                            shortcutKey = shortcutKey.join(",");
                        }
                        AJS.debug("Adding shortcut for " + shortcutKey);
                        ed.addShortcut(shortcutKey.toLowerCase(), "", shortcutFunc);

                        // CONFDEV-3711: Binds a keydown event to the form input elements to capture the editor
                        // save and preview shortcuts
                        if (shortcut.context == "tinymce.actions" && shortcutKey.indexOf("+") != -1) {
                            AJS.debug("Binding shortcut on inputs too for " + shortcutKey);
                            editorForm.delegate(":input", "keydown", function(event) {
                                var code = (event.keyCode ? event.keyCode : event.which);
                                var shortcutarray = shortcutKey.split("+");
                                // Parses the shortcut and checks if correct keys are present.
                                shortcutarray = $.map(shortcutarray, function(key) {
                                    return (((key == "Ctrl") && (event.metaKey)) || ((key == "Shift") && (event.shiftKey)) || (code == key.charCodeAt(0)) ? null : key);
                                });
                                if (!(shortcutarray.length)) {
                                    shortcutFunc();
                                    event.preventDefault();
                                }
                            });
                        }

                    } else {
                        AJS.log("ERROR: unkown editor shortcut key operation " + operation + " for shortcut " + shortcutKey);
                    }
                });
            });
        }

        Confluence.KeyboardShortcuts.ready = true;
    });

    function initShortcuts() {
        // AKS requires that we load the I18n resources before we ask to initialize the keyboard shortcuts
        AJS.I18n.get(["com.atlassian.confluence.keyboardshortcuts","com.atlassian.plugins.editor"], function() {
            AJS.trigger("initialize.keyboardshortcuts");
        }, function() {
            AJS.log("There was an error loading the keyboard shortcuts, please try again");
        });
    }

    // Why is this if statment needed? It seems that when we are ready to do an import, the pluginsystem is up, and we
    // pull down the super batch. This superbatch contains this code and it fires off a request to Confluence to get the
    // i18n resources. This request gets redirected to 'selectsetupstep.action' which due to the fact that the import is
    // running thinks we are done, and redirects to 'finishsetup.action' and things blow up.
    if (typeof Confluence.getContextPath() != "undefined") {
        if ($("#rte").length) { //If there is an editor on the page wait for it to load before initializing shortcuts
            AJS.bind("init.rte", function() {
                initShortcuts();
            });
        } else {
            initShortcuts();
        }
    }

    //CONFDEV-4913 - Disable shortcuts after we click add comment
    $("#add-comment-menu-link, #add-comment-rte").click(function() {
        AJS.trigger("remove-bindings.keyboardshortcuts");
    });

});

// Add functions that are referenced from the execute shortcut operations in atlassian-plugin.xml here
Confluence.KeyboardShortcuts = {
    Editor: [], // hack for jira issue plugin, remove once the plugin has been updated
    enabled: false,
    ready: false,
    dialog: null,
    closeDialog: function() {
        Confluence.KeyboardShortcuts.getDialog().then(function(dialog) {
            dialog.hide();
        });
        return false;
    },
    openDialog: function() {
        Confluence.KeyboardShortcuts.getDialog().then(function(dialog) {
            dialog.show();
        });
        return false;
    }
};


(function($) {

var popup;

Confluence.KeyboardShortcuts.getDialog = function () {
    var dfr = $.Deferred();

    if (popup) {
        return dfr.resolve(popup);
    }

    var shortcuts = Confluence.KeyboardShortcuts.shortcuts,

    cancel = function() {
        AJS.log("Hiding Shortcuts help");
        popup.hide();
        return false;
    },

    //Same technique as tinyMCE.
    isMac = navigator.platform.indexOf('Mac') != -1,

    //Construct the key sequence diagram shown on the keyboard shortcuts help dialog
    //e.g. shortcut.keys = [["g", "d"]]
    makeKeySequence = function (shortcut) {
        var sequenceSpan = AJS("span").addClass("item-action");
        // TODO - may need "or" in future if keys has length > 1
        var keySequence = shortcut.keys[0];

        for(var i = 0; i < keySequence.length; i++) {
            if(i > 0)
                sequenceSpan.append(makeKbdSeparator("then"));

            makeKeyCombo(keySequence[i], sequenceSpan);
        }

        return sequenceSpan;
    },

    makeKeyCombo = function(combo, sequence) {
        var keys = combo.split("+");

        for (var i = 0; i < keys.length; i++) {
            if (i > 0)
                sequence.append(makeKbdSeparator("+"));

            makeKeyAlternatives(keys[i], sequence);
        }
    },

    makeKeyAlternatives = function(key, sequence) {
        var keys = key.split("..");

        for (var i = 0; i < keys.length; i++) {
            if (i > 0)
                sequence.append(makeKbdSeparator("to"));

            sequence.append(makeKbd(keys[i]));
        }
    },

    makeKbd = function(key) {
        var kbd = AJS("kbd");

        switch (key){
            case "Shift":
            case "Sh":
                kbd.text("Shift");
                kbd.addClass("modifier-key");
                break;
            case "Ctrl":
                var text = isMac ? '\u2318' : "Ctrl";  //Apple command key
                kbd.text(text);
                kbd.addClass("modifier-key");
                break;
            case "Tab":
                kbd.text("Tab");
                kbd.addClass("modifier-key");
                break;
            case "Alt":
                kbd.text("Alt");
                kbd.addClass("modifier-key");
                break;
            default:
                kbd.text(key);
                kbd.addClass("regular-key");
        }

        return kbd;
    },

    makeKbdSeparator = function(text) {
        var separator = AJS("span");
        separator.text(text);
        separator.addClass("key-separator");
        return separator;
    },

    makeShortcutModule = function(title, contexts, shortcuts) {
        var module = $(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutModule({title: title}));
        var list = module.find("ul");

        for (var i = 0; i < shortcuts.length; i++) {
            var shortcut = shortcuts[i];
            if (shortcut.hidden) {
                continue;
            }
            if($.inArray(shortcut.context, contexts) != -1) {
                var shortcutItem = AJS("li").addClass("item-details");
                var desc = AJS("strong").addClass("item-description").append(AJS.I18n.getText(shortcut.descKey));
                shortcutItem.append(desc);
                shortcutItem.append(makeKeySequence(shortcut));
                list.append(shortcutItem);
            }
        }

        return module;
    },

    makeGeneralShortcutsMenu = function() {
        var generalShortcutsMenuPane = $(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutPanel({panelId: "general-shortcuts-panel"}));
        var generalShortcutsMenu = $(generalShortcutsMenuPane).children(".shortcutsmenu");

        if (AJS.Meta.get("remote-user")) {
            generalShortcutsMenuPane.find(".keyboard-shortcut-dialog-panel-header").append(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutEnabledCheckbox());
        }

        generalShortcutsMenu.append(makeShortcutModule("Global Shortcuts", ["global"], shortcuts));
        generalShortcutsMenu.append(makeShortcutModule("Page \/ Blog Post Actions", ["viewcontent", "viewinfo"], shortcuts));

        return generalShortcutsMenuPane;
    },

    makeEditorShortcutsMenu = function() {
        var editorShortcutsMenuPane = $(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutPanel({panelId: "editor-shortcuts-panel"}));
        var editorShortcutsMenu = $(editorShortcutsMenuPane).children(".shortcutsmenu");

        editorShortcutsMenu.append(makeShortcutModule("Block Formatting", ["tinymce.block"], shortcuts));
        editorShortcutsMenu.append(makeShortcutModule("Rich Formatting", ["tinymce.rich"], shortcuts));
        editorShortcutsMenu.append(makeShortcutModule("Editing Actions", ["tinymce.actions"], shortcuts));

        return editorShortcutsMenuPane;
    },

    toggleEnabled = function (event) {
        var enable = $(this).attr('checked');
        // TODO - after 3.4-m4 and blitz - error handling architecture
        AJS.$.post(Confluence.getContextPath() + "/rest/confluenceshortcuts/latest/enabled", {enabled: enable}, function(){
            Confluence.KeyboardShortcuts.enabled = enable;
            Confluence.KeyboardShortcuts.ready = false;
            if (enable) {
                AJS.trigger("add-bindings.keyboardshortcuts");
            } else {
                AJS.trigger("remove-bindings.keyboardshortcuts");
            }
        });
    },

    initialiseEnableShortcutsCheckbox = function () {
        $('#keyboard-shortcut-enabled-checkbox')
            .attr('checked', Confluence.KeyboardShortcuts.enabled)
            .click(toggleEnabled);
    };

    popup = AJS.ConfluenceDialog({
        width: 950,
        height: 590,
        id: "keyboard-shortcuts-dialog"
    });

    popup.addHeader("Keyboard Shortcuts");
    popup.addPanel("General", makeGeneralShortcutsMenu());
    popup.addPanel("Editor", makeEditorShortcutsMenu());
    popup.addCancel("Close", cancel);
    popup.popup.element.find(".dialog-title").append(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutHelpLink());
    AJS.trigger("keyboard-shortcut-dialog-ready", popup);

    // If you have an editor active, automatically open the Editor tab.
    if (typeof(tinyMCE) != "undefined" && tinyMCE.activeEditor) {
        popup.overrideLastTab();
        popup.gotoPanel(1);
    } else {
        popup.gotoPanel(0);
    }

    dfr.resolve(popup);
    initialiseEnableShortcutsCheckbox();
    return dfr;
};

}(AJS.$));

/*
Adds the "Editor Autoformatting" tab to the Keyboard Shortcuts help dialog
 */
AJS.toInit(function($) {
    var templates = Confluence.Templates.KeyboardShortcutsDialog.Autoformat,

    buildShortcutModule = function(title, context, itemBuilder) {
        var module = $(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutModule({title: title})),
        list = module.find("ul"),
        items = getMenuItemsForContext(context);

        for (var i = 0, ii = items.length; i < ii; i++) {
            list.append (
                itemBuilder(items[i])
            );
        }

        return module;       
    },

    buildStandardShortcutModule = function(title, context, itemTemplate) {
        return buildShortcutModule(
                title,
                context,
                function (item) {
                    return itemTemplate({output: item.description, type: item.action});
                }
        );
    },

    buildEmoticonModule = function(title, context) {
        var emoticonResourceUrl = AJS.params.staticResourceUrlPrefix + "/images/icons/emoticons/";
        return buildShortcutModule(
                title,
                context,
                function (item) {
                    return templates.emoticonHelpItem(
                            {src: emoticonResourceUrl + item.img, type: item.action}
                    );
                }
        );
    },

    getMenuItemsForContext = function(context) {
        return $.grep(Confluence.KeyboardShortcuts.Autoformat, function(e) {
            return e.context == context;
        });
    },

    buildHelpPanel = function() {
        var autoformatHelpPanel = $(Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutPanel({panelId: 'autoformat-shortcuts-panel'})),
        autoformatHelpPanelMenu = autoformatHelpPanel.children(".shortcutsmenu");

        autoformatHelpPanelMenu.append(
                buildStandardShortcutModule(
                        "Font Formatting",
                        "autoformat.font_formatting",
                        templates.simpleHelpItem
                )
        );
        autoformatHelpPanelMenu.append(
                buildStandardShortcutModule("Autocomplete",
                        "autoformat.autocomplete",
                        templates.keyboardShortcutItem
                )
        );
        autoformatHelpPanelMenu.append(
                buildStandardShortcutModule(
                        "Tables",
                        "autoformat.tables",
                        templates.tableHelpItem
                )
        );
        autoformatHelpPanelMenu.append(
                buildStandardShortcutModule(
                        "Styles",
                        "autoformat.styles",
                        templates.styleHelpItem
                ).addClass("styles-module")
        );
        autoformatHelpPanelMenu.append(
                buildEmoticonModule(
                        "Emoticons",
                        "autoformat.emoticons"
                )
        );
        autoformatHelpPanelMenu.append(
                buildStandardShortcutModule(
                        "Lists",
                        "autoformat.lists",
                        templates.simpleHelpItem
                )
        );

        if (AJS.Meta.get("remote-user"))
        {
            autoformatHelpPanel.find(".keyboard-shortcut-dialog-panel-header").append(
                templates.configureAutocomplete(
                        {href: Confluence.getContextPath() + "/users/viewmyeditorsettings.action"}
                )
            );
        }

        return autoformatHelpPanel;
    };

    AJS.bind("keyboard-shortcut-dialog-ready", function(e, popup) {
        popup.addPanel("Editor Autoformatting", buildHelpPanel());
    });

    Confluence.KeyboardShortcuts.Autoformat = [
        {
            context: "autoformat.font_formatting",
            description: templates.boldDescription(),
            action: "*Bold*"
        },
        {
            context: "autoformat.font_formatting",
            description: templates.underlineDescription(),
            action: "+Underline+"
        },
        {
            context: "autoformat.font_formatting",
            description: templates.italicDescription(),
            action: "_Italic_"
        },
        {
            context: "autoformat.font_formatting",
            description: templates.monospaceDescription(),
            action: "{{Monospace}}"
        },
        {
            context: "autoformat.tables",
            description: templates.tableDescription(),
            action: "||||| + enter"
        },
        {
            context: "autoformat.tables",
            description: templates.tableWithHeadingsDiscriptions(),
            action: "||heading||heading||"
        },
        {
            context: "autoformat.styles",
            description: templates.h1Description(),
            action: "h1. Heading"
        },
        {
            context: "autoformat.styles",
            description: templates.h3Description(),
            action: "h3. Heading"
        },
        {
            context: "autoformat.styles",
            description: templates.bqDescription(),
            action: "bq. Quote"
        },
        {
            context: "autoformat.emoticons",
            img: "check.png",
            action: "(\/)"
        },
        {
            context: "autoformat.emoticons",
            img: "smile.png",
            action: ":)"
        },
        {
            context: "autoformat.lists",
            description: templates.numberedListDescription(),
            action: "# list"
        },
        {
            context: "autoformat.lists",
            description: templates.bulletedListDescription(),
            action: "* bullets"
        },
        {
            context: "autoformat.autocomplete",
            description: "Image\/Media",
            action: "!"
        },
        {
            context: "autoformat.autocomplete",
            description: "Link",
            action: "["
        },
        {
            context: "autoformat.autocomplete",
            description: "Macro",
            action: "{"
        }
    ];
});
// This file was automatically generated from shortcut-dialog-tab-autoformat.soy.
// Please don't edit this file by hand.

if (typeof Confluence == 'undefined') { var Confluence = {}; }
if (typeof Confluence.Templates == 'undefined') { Confluence.Templates = {}; }
if (typeof Confluence.Templates.KeyboardShortcutsDialog == 'undefined') { Confluence.Templates.KeyboardShortcutsDialog = {}; }
if (typeof Confluence.Templates.KeyboardShortcutsDialog.Autoformat == 'undefined') { Confluence.Templates.KeyboardShortcutsDialog.Autoformat = {}; }


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.configureAutocomplete = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<div id="keyboard-shortcut-autocomplete-message">', soy.$$escapeHtml("To configure Autocomplete,"), ' <a target="_blank" href=', soy.$$escapeHtml(opt_data.href), '>', soy.$$escapeHtml("go to your editor settings"), '</a></div>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.helpItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<li class="item-details"><span class="item-description wiki-content">', opt_data.output, '</span><span class="', opt_data.actionClass, ' item-action">', opt_data.type, '</span></li>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.simpleHelpItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  Confluence.Templates.KeyboardShortcutsDialog.Autoformat.helpItem({output: opt_data.output, type: '<code>' + opt_data.type + '</code>', actionClass: ''}, output);
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.tableHelpItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  Confluence.Templates.KeyboardShortcutsDialog.Autoformat.helpItem({output: opt_data.output, type: '<code>' + opt_data.type + '</code>', actionClass: 'table-action'}, output);
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.styleHelpItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  Confluence.Templates.KeyboardShortcutsDialog.Autoformat.helpItem({output: opt_data.output, type: '<code>' + opt_data.type + '</code>', actionClass: 'style-action'}, output);
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.keyboardShortcutItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  Confluence.Templates.KeyboardShortcutsDialog.Autoformat.helpItem({output: soy.$$escapeHtml(opt_data.output), type: '<kbd class="regular-key">' + soy.$$escapeHtml(opt_data.type) + '</kbd>', actionClass: ''}, output);
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.emoticonHelpItem = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  Confluence.Templates.KeyboardShortcutsDialog.Autoformat.simpleHelpItem({output: '<img src=' + soy.$$escapeHtml(opt_data.src) + '></img>', type: opt_data.type}, output);
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.boldDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<b>', soy.$$escapeHtml("Bold"), '</b> ', soy.$$escapeHtml("text"));
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.underlineDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<span style="text-decoration: underline;">', soy.$$escapeHtml("Underline"), '</span> ', soy.$$escapeHtml("text"));
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.italicDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<em>', soy.$$escapeHtml("Italic"), '</em> ', soy.$$escapeHtml("text"));
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.monospaceDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<code>', soy.$$escapeHtml("Monospace"), '</code> ', soy.$$escapeHtml("text"));
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.tableDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<table class="confluenceTable"><tbody><tr><td class="confluenceTd">', soy.$$escapeHtml("first cell"), '</td><td class="confluenceTd">&nbsp;</td><td class="confluenceTd">&nbsp;</td><td class="confluenceTd">&nbsp;</td></tr></tbody></table>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.tableWithHeadingsDiscriptions = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<table class="confluenceTable"><tbody><tr><th class="confluenceTh">', soy.$$escapeHtml("heading"), '</th><th class="confluenceTh">', soy.$$escapeHtml("heading"), '</th></tr><tr><td class="confluenceTd">&#8203;</td><td class="confluenceTd">&#8203;</td></tr></tbody></table>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.h1Description = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<h1>', soy.$$escapeHtml("Heading"), '</h1>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.h3Description = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<h3>', soy.$$escapeHtml("Heading"), '</h3>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.bqDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<blockquote>', soy.$$escapeHtml("Quote"), '</blockquote>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.numberedListDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<ol><li>', soy.$$escapeHtml("list"), '</li></ol>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.Autoformat.bulletedListDescription = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<ul><li>', soy.$$escapeHtml("bullets"), '</li></ul>');
  if (!opt_sb) return output.toString();
};

// This file was automatically generated from help-dialog.soy.
// Please don't edit this file by hand.

if (typeof Confluence == 'undefined') { var Confluence = {}; }
if (typeof Confluence.Templates == 'undefined') { Confluence.Templates = {}; }
if (typeof Confluence.Templates.KeyboardShortcutsDialog == 'undefined') { Confluence.Templates.KeyboardShortcutsDialog = {}; }


Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutModule = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<div class="module"><div class="mod-header"><h3>', soy.$$escapeHtml(opt_data.title), '</h3></div><div class="mod-content"><ul class="mod-item"></ul></div></div>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutHelpLink = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<div class="dialog-help-link">');
  Confluence.Templates.Dialog.customHelpLink({href: soy.$$escapeHtml("http://docs.atlassian.com/confluence/docs-41/Keyboard+Shortcuts"), text: soy.$$escapeHtml("View All Shortcuts")}, output);
  output.append('</div>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutEnabledCheckbox = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<form name="shortcut-settings" id="shortcut-settings-form"><input type="checkbox" name="enabled" id="keyboard-shortcut-enabled-checkbox"><label for="keyboard-shortcut-enabled-checkbox">', soy.$$escapeHtml("Enable General Shortcuts"), '</label></form>');
  if (!opt_sb) return output.toString();
};


Confluence.Templates.KeyboardShortcutsDialog.keyboardShortcutPanel = function(opt_data, opt_sb) {
  var output = opt_sb || new soy.StringBuilder();
  output.append('<div id=', soy.$$escapeHtml(opt_data.panelId), '><div class="keyboard-shortcut-dialog-panel-header"></div><div class="shortcutsmenu"></div><div class="keyboard-shortcut-dialog-panel-footer"></div></div>');
  if (!opt_sb) return output.toString();
};


