From 03a1d880d059a14d0e128d0b709a5ed0b95735d6 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 13 Aug 2014 13:20:53 +0200 Subject: [PATCH] Fixed lost tab after setting has changed. --- .../_application_controller_generic.js.coffee | 15 +++++++++++++-- .../javascripts/app/views/generic/tabs.jst.eco | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 784fefe1f..259554e34 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -269,14 +269,17 @@ class App.ControllerLevel2 extends App.ControllerContent # window.scrollTo(0,0) class App.ControllerTabs extends App.Controller + events: + 'click .nav-tabs [data-toggle="tab"]': 'tabRemember', + constructor: -> super render: -> + @html App.view('generic/tabs')( tabs: @tabs ) - @el.find('.nav-tabs li:first').addClass('active') for tab in @tabs @el.find('.tab-content').append('
') @@ -285,7 +288,15 @@ class App.ControllerTabs extends App.Controller params.el = @el.find( '#' + tab.target ) new tab.controller( params ) - @el.find('.tab-content .tab-pane:first').addClass('active') + @lastActiveTab = @Config.get('lastTab') + if @lastActiveTab && @el.find('.nav-tabs li a[href="' + @lastActiveTab + '"]')[0] + @el.find('.nav-tabs li a[href="' + @lastActiveTab + '"]').tab('show') + else + @el.find('.nav-tabs li:first a').tab('show') + + tabRemember: (e) => + @lastActiveTab = $(e.target).attr('href') + @Config.set('lastTab', @lastActiveTab) class App.ControllerNavSidbar extends App.ControllerContent constructor: (params) -> diff --git a/app/assets/javascripts/app/views/generic/tabs.jst.eco b/app/assets/javascripts/app/views/generic/tabs.jst.eco index 03a62d8a1..d8042c453 100644 --- a/app/assets/javascripts/app/views/generic/tabs.jst.eco +++ b/app/assets/javascripts/app/views/generic/tabs.jst.eco @@ -1,6 +1,6 @@ -