Remember last active tab. Fixes #97

This commit is contained in:
brantje 2017-06-27 19:19:33 +02:00
Родитель 5ed9d572df
Коммит cdc5def939
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 5FF1D117F918687F
2 изменённых файлов: 24 добавлений и 9 удалений

Просмотреть файл

@ -22,10 +22,10 @@
<body>
<div id="password_picker">
<div class="tabs">
<div class="tab add"><span class="fa fa-plus" aria-hidden="true" t="[add_account, title]"></span></div>
<div class="tab list active"><span class="fa fa-list" aria-hidden="true" t="[accounts, title]"></span></div>
<div class="tab search"><span class="fa fa-search" aria-hidden="true" t="[search, title]"></span></div>
<div class="tab generate"><span class="fa fa-refresh" aria-hidden="true" t="[password_generator, title]"></span>
<div class="tab add" data-name="add"><span class="fa fa-plus" aria-hidden="true" t="[add_account, title]"></span></div>
<div class="tab list" data-name="list"><span class="fa fa-list" aria-hidden="true" t="[accounts, title]"></span></div>
<div class="tab search" data-name="search"><span class="fa fa-search" aria-hidden="true" t="[search, title]"></span></div>
<div class="tab generate" data-name="generate"><span class="fa fa-refresh" aria-hidden="true" t="[password_generator, title]"></span>
</div>
<div class="tab close pull-right"><span class="fa fa-times" aria-hidden="true" t="[close, title]" title="Close"></span></div>
</div>
@ -58,7 +58,7 @@
<button class="btn btn-success" id="savepw-save" t="save"></button>
<button class="btn" id="savepw-cancel" t="cancel"></button>
</div>
<div class="tab-list-content">
<div class="tab-list-content" style="display: none">
<div class="no-credentials">
<div class="btn btn-secondary save" t="btn_save_site"></div>
<div class="clearfix"></div>

Просмотреть файл

@ -199,12 +199,27 @@ $(document).ready(function () {
}
var picker = $('#password_picker');
picker.find('.tab').click(function () {
var target = $(this).attr('class').replace('active', '').replace('tab', '').trim();
var makeTabActive = function (name) {
picker.find('.tab').removeClass('active');
picker.find('.tab-content').children().hide();
picker.find('.tab-' + target + '-content').show();
picker.find('.tab.' + target).addClass('active');
picker.find('.tab-' + name + '-content').show();
picker.find('.tab.' + name).addClass('active');
};
picker.find('.tab').click(function () {
var name = $(this).attr('data-name');
storage.set('activeTab', name).then(function (r) {
makeTabActive(name)
});
});
storage.get('activeTab').then(function (name) {
if(name) {
makeTabActive(name);
} else {
makeTabActive('list');
}
});
$('.tab.close').click(function () {