diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 2a09dbe4ff..a844fb2a5b 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -119,6 +119,8 @@ define [ @analyticsManager = new AnalyticsManager(@) if @userSettings.trackChanges @trackChangesManager = new TrackChangesManager(@) + else + @historyManager = new HistoryManager(@) @setLoadingMessage("Connecting") firstConnect = true @@ -186,7 +188,6 @@ define [ _.extend(Ide::, Backbone.Events) window.ide = ide = new Ide() - ide.historyManager = new HistoryManager ide ide.projectMembersManager = new ProjectMembersManager ide ide.settingsManager = new SettingsManager ide ide.helpManager = new HelpManager ide diff --git a/services/web/public/coffee/ide/TabManager.coffee b/services/web/public/coffee/ide/TabManager.coffee index a5b3748a5e..bd82376a38 100644 --- a/services/web/public/coffee/ide/TabManager.coffee +++ b/services/web/public/coffee/ide/TabManager.coffee @@ -12,26 +12,39 @@ define [ @state = "closed" $("#toolbar").on "mouseenter", () => @onMouseOver() $("#toolbar").on "mouseleave", (e) => @onMouseOut(e) + @tabs = [] addTab: (options) -> + @tabs.push options + tabEl = $(Mustache.to_html @templates.tab, options) tabEl.find("a").attr("href", "#" + options.id) - contentEl = $(Mustache.to_html @templates.content, options) - contentEl.append(options.content) + + if options.content? + contentEl = $(Mustache.to_html @templates.content, options) + contentEl.append(options.content) + $("#tab-content").append(contentEl) if options.active tabEl.addClass("active") - contentEl.addClass("active") + contentEl?.addClass("active") if options.after? tabEl.insertAfter($("##{options.after}-tab-li")) else $("#tabs").append(tabEl) - $("#tab-content").append(contentEl) + $("body").scrollTop(0) tabEl.on "shown", () => $("body").scrollTop(0) + options.onShown() if options.onShown? + for other_tab in @tabs + if other_tab.id != options.id and other_tab.active and other_tab.onHidden? + other_tab.onHidden() + other_tab.active = false + options.active = true + if options.lock @lockOpen() else @@ -40,6 +53,7 @@ define [ if options.contract @contract() + lockOpen: () -> @locked_open = true $("#toolbar").css({ diff --git a/services/web/public/coffee/track-changes/TrackChangesManager.coffee b/services/web/public/coffee/track-changes/TrackChangesManager.coffee index 4c12a2b4ec..52a4f2a4fa 100644 --- a/services/web/public/coffee/track-changes/TrackChangesManager.coffee +++ b/services/web/public/coffee/track-changes/TrackChangesManager.coffee @@ -17,6 +17,14 @@ define [ identifier: "trackChanges" element: @$el + @ide.tabManager.addTab + id: "history" + name: "History" + after: "code" + contract: true + onShown: () => @show() + onHidden: () => @hide() + @ide.editor.on "resize", () => @diffView?.resize() @@ -34,17 +42,6 @@ define [ @doc_id = doc_id @updateDiff() - @ide.fileTreeManager.on "contextmenu:beforeshow", (entity, entries) => - if entity instanceof Doc - entries.push { - divider: true - }, { - text: "History" - onClick: () => - @doc_id = entity.id - @show() - } - show: () -> @changes = new ChangeList([], project_id: @project_id, ide: @ide)