Auto hide sidebar if mobile

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-08-14 17:36:26 +02:00
parent db3843566f
commit 391b2f4d48
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
3 changed files with 15 additions and 4 deletions

View File

@ -11,7 +11,7 @@ angular.module('contactsApp')
ctrl.import = ContactService.import.bind(ContactService);
ctrl.loading = true;
ctrl.importText = ctrl.t.importText;
ctrl.status = '';
ctrl.importing = false;
ctrl.loadingClass = 'icon-upload';
AddressBookService.getAll().then(function(addressBooks) {

View File

@ -9,17 +9,28 @@ angular.module('contactsApp')
reader.addEventListener('load', function () {
scope.$apply(function () {
// Indicate the user we started something
ctrl.importText = ctrl.t.importingText;
ctrl.loadingClass = 'icon-loading-small';
ctrl.importing = true;
ContactService.import.call(ContactService, reader.result, file.type, ctrl.selectedAddressBook, function (progress, user) {
if (progress === 1) {
ctrl.importText = ctrl.t.importText;
ctrl.loadingClass = 'icon-upload';
ctrl.importing = false;
ImportService.importPercent = 0;
ImportService.importing = false;
ImportService.importedUser = '';
ImportService.selectedAddressBook = '';
} else {
ctrl.importText = ctrl.t.importingText;
ctrl.loadingClass = 'icon-loading-small';
// Ugly hack, hide sidebar on import & mobile
// Simulate click since we can't directly access snapper
if($(window).width() <= 768 && $('body').hasClass('snapjs-left')) {
$('#app-navigation-toggle').click();
$('body').removeClass('snapjs-left');
}
ImportService.importPercent = parseInt(Math.floor(progress * 100));
ImportService.importing = true;
ImportService.importedUser = user;

View File

@ -1,7 +1,7 @@
<input type="file" id="contact-import" class="hidden-visually" multiple/>
<label for="contact-import" class="button {{ctrl.loadingClass}}" ng-class="{'no-select': ctrl.addressBooks.length === 1}" id="upload">
{{ctrl.importText}}
<span ng-if="ctrl.addressBooks.length === 1">{{ctrl.addressBooks[0].displayName}}</span>
<span ng-if="ctrl.addressBooks.length === 1 && !ctrl.importing" ng-class="{'icon-loading-small': ctrl.loading}">{{ctrl.selectedAddressBook.displayName}}</span>
</label>
<ui-select ng-model="ctrl.selectedAddressBook" ng-if="ctrl.addressBooks.length > 1" search-enabled="ctrl.addressBooks.length > 4"
theme="select2" class="form-control" title="{{ctrl.t.selectAddressbook}}"