diff options
-rw-r--r-- | js/components/contactImport/contactImport_directive.js | 10 | ||||
-rw-r--r-- | js/services/contact_service.js | 4 | ||||
-rw-r--r-- | templates/contactImport.html | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/js/components/contactImport/contactImport_directive.js b/js/components/contactImport/contactImport_directive.js index 6ebcb618..6990b151 100644 --- a/js/components/contactImport/contactImport_directive.js +++ b/js/components/contactImport/contactImport_directive.js @@ -1,8 +1,10 @@ angular.module('contactsApp') .directive('contactimport', function(ContactService) { return { - scope: {}, link: function(scope, element) { + var importText = t('contacts', 'Import'); + scope.importText = importText; + var input = element.find('input'); input.bind('change', function() { var file = input.get(0).files[0]; @@ -11,7 +13,11 @@ angular.module('contactsApp') reader.addEventListener('load', function () { scope.$apply(function() { ContactService.import.call(ContactService, reader.result, file.type, null, function(progress) { - element.find('label').text(progress); + if(progress===1) { + scope.importText = importText; + } else { + scope.importText = parseInt(Math.floor(progress*100))+'%'; + } }); }); }, false); diff --git a/js/services/contact_service.js b/js/services/contact_service.js index 5cf410df..01cd90d0 100644 --- a/js/services/contact_service.js +++ b/js/services/contact_service.js @@ -107,11 +107,13 @@ angular.module('contactsApp') var regexp = /BEGIN:VCARD[\s\S]*?END:VCARD/mgi; var singleVCards = data.match(regexp); + var num = 1; for(var i in singleVCards) { var newContact = new Contact(addressBook, {addressData: singleVCards[i]}); this.create(newContact, addressBook).then(function() { // Update the progress indicator - if (progressCallback) progressCallback(i); + if (progressCallback) progressCallback(num/singleVCards.length); + num++; }); } } diff --git a/templates/contactImport.html b/templates/contactImport.html index 59c8f86c..f8759c26 100644 --- a/templates/contactImport.html +++ b/templates/contactImport.html @@ -1,5 +1,5 @@ <input type="file" id="contact-import" class="hidden-visually"/> <label for="contact-import" class="button" id="upload"> - <span class="text">Import</span> + <span class="text">{{importText}}</span> <span class="icon-upload"></span> </label> |