diff options
Diffstat (limited to 'js/components')
35 files changed, 0 insertions, 1433 deletions
diff --git a/js/components/addressBook/addressBook_controller.js b/js/components/addressBook/addressBook_controller.js deleted file mode 100644 index 6b8a0f0c..00000000 --- a/js/components/addressBook/addressBook_controller.js +++ /dev/null @@ -1,202 +0,0 @@ -angular.module('contactsApp') -.controller('addressbookCtrl', function($scope, AddressBookService) { - var ctrl = this; - - ctrl.t = { - download: t('contacts', 'Download'), - copyURL: t('contacts', 'Copy link'), - clickToCopy: t('contacts', 'Click to copy the link to your clipboard'), - shareAddressbook: t('contacts', 'Toggle sharing'), - deleteAddressbook: t('contacts', 'Delete'), - renameAddressbook: t('contacts', 'Rename'), - shareInputPlaceHolder: t('contacts', 'Share with users or groups'), - delete: t('contacts', 'Delete'), - canEdit: t('contacts', 'can edit'), - close: t('contacts', 'Close'), - enabled: t('contacts', 'Enabled'), - disabled: t('contacts', 'Disabled') - }; - - ctrl.editing = false; - ctrl.enabled = ctrl.addressBook.enabled; - - ctrl.tooltipIsOpen = false; - ctrl.tooltipTitle = ctrl.t.clickToCopy; - ctrl.showInputUrl = false; - - ctrl.clipboardSuccess = function() { - ctrl.tooltipIsOpen = true; - ctrl.tooltipTitle = t('core', 'Copied!'); - _.delay(function() { - ctrl.tooltipIsOpen = false; - ctrl.tooltipTitle = ctrl.t.clickToCopy; - }, 3000); - }; - - ctrl.clipboardError = function() { - ctrl.showInputUrl = true; - if (/iPhone|iPad/i.test(navigator.userAgent)) { - ctrl.InputUrlTooltip = t('core', 'Not supported!'); - } else if (/Mac/i.test(navigator.userAgent)) { - ctrl.InputUrlTooltip = t('core', 'Press ⌘-C to copy.'); - } else { - ctrl.InputUrlTooltip = t('core', 'Press Ctrl-C to copy.'); - } - $('#addressBookUrl_'+ctrl.addressBook.ctag).select(); - }; - - ctrl.renameAddressBook = function() { - AddressBookService.rename(ctrl.addressBook, ctrl.addressBook.displayName); - ctrl.editing = false; - }; - - ctrl.edit = function() { - ctrl.editing = true; - }; - - ctrl.closeMenus = function() { - $scope.$parent.ctrl.openedMenu = false; - }; - - ctrl.openMenu = function(index) { - ctrl.closeMenus(); - $scope.$parent.ctrl.openedMenu = index; - }; - - ctrl.toggleMenu = function(index) { - if ($scope.$parent.ctrl.openedMenu === index) { - ctrl.closeMenus(); - } else { - ctrl.openMenu(index); - } - }; - - ctrl.toggleSharesEditor = function() { - ctrl.editingShares = !ctrl.editingShares; - ctrl.selectedSharee = null; - }; - - /* From Calendar-Rework - js/app/controllers/calendarlistcontroller.js */ - ctrl.findSharee = function (val) { - return $.get( - OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', - { - format: 'json', - search: val.trim(), - perPage: 200, - itemType: 'principals' - } - ).then(function(result) { - var users = result.ocs.data.exact.users.concat(result.ocs.data.users); - var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups); - - var userShares = ctrl.addressBook.sharedWith.users; - var userSharesLength = userShares.length; - - var groupsShares = ctrl.addressBook.sharedWith.groups; - var groupsSharesLength = groupsShares.length; - var i, j; - - // Filter out current user - for (i = 0 ; i < users.length; i++) { - if (users[i].value.shareWith === OC.currentUser) { - users.splice(i, 1); - break; - } - } - - // Now filter out all sharees that are already shared with - for (i = 0; i < userSharesLength; i++) { - var shareUser = userShares[i]; - for (j = 0; j < users.length; j++) { - if (users[j].value.shareWith === shareUser.id) { - users.splice(j, 1); - break; - } - } - } - - // Now filter out all groups that are already shared with - for (i = 0; i < groupsSharesLength; i++) { - var sharedGroup = groupsShares[i]; - for (j = 0; j < groups.length; j++) { - if (groups[j].value.shareWith === sharedGroup.id) { - groups.splice(j, 1); - break; - } - } - } - - // Combine users and groups - users = users.map(function(item) { - return { - display: _.escape(item.value.shareWith), - type: OC.Share.SHARE_TYPE_USER, - identifier: item.value.shareWith - }; - }); - - groups = groups.map(function(item) { - return { - display: _.escape(item.value.shareWith) + ' (group)', - type: OC.Share.SHARE_TYPE_GROUP, - identifier: item.value.shareWith - }; - }); - - return groups.concat(users); - }); - }; - - ctrl.onSelectSharee = function (item) { - // Prevent settings to slide down - $('#app-settings-header > button').data('apps-slide-toggle', false); - _.delay(function() { - $('#app-settings-header > button').data('apps-slide-toggle', '#app-settings-content'); - }, 500); - - ctrl.selectedSharee = null; - AddressBookService.share(ctrl.addressBook, item.type, item.identifier, false, false).then(function() { - $scope.$apply(); - }); - - }; - - ctrl.updateExistingUserShare = function(userId, writable) { - AddressBookService.share(ctrl.addressBook, OC.Share.SHARE_TYPE_USER, userId, writable, true).then(function() { - $scope.$apply(); - }); - }; - - ctrl.updateExistingGroupShare = function(groupId, writable) { - AddressBookService.share(ctrl.addressBook, OC.Share.SHARE_TYPE_GROUP, groupId, writable, true).then(function() { - $scope.$apply(); - }); - }; - - ctrl.unshareFromUser = function(userId) { - AddressBookService.unshare(ctrl.addressBook, OC.Share.SHARE_TYPE_USER, userId).then(function() { - $scope.$apply(); - }); - }; - - ctrl.unshareFromGroup = function(groupId) { - AddressBookService.unshare(ctrl.addressBook, OC.Share.SHARE_TYPE_GROUP, groupId).then(function() { - $scope.$apply(); - }); - }; - - ctrl.deleteAddressBook = function() { - AddressBookService.delete(ctrl.addressBook).then(function() { - $scope.$apply(); - }); - }; - - ctrl.toggleState = function() { - AddressBookService.toggleState(ctrl.addressBook).then(function(addressBook) { - ctrl.enabled = addressBook.enabled; - $scope.$apply(); - }); - }; - -}); diff --git a/js/components/addressBook/addressBook_directive.js b/js/components/addressBook/addressBook_directive.js deleted file mode 100644 index c62141db..00000000 --- a/js/components/addressBook/addressBook_directive.js +++ /dev/null @@ -1,14 +0,0 @@ -angular.module('contactsApp') -.directive('addressbook', function() { - return { - restrict: 'A', // has to be an attribute to work with core css - scope: {}, - controller: 'addressbookCtrl', - controllerAs: 'ctrl', - bindToController: { - addressBook: '=data', - list: '=' - }, - templateUrl: OC.linkTo('contacts', 'templates/addressBook.html') - }; -}); diff --git a/js/components/addressBookList/addressBookList_controller.js b/js/components/addressBookList/addressBookList_controller.js deleted file mode 100644 index 092f9f0b..00000000 --- a/js/components/addressBookList/addressBookList_controller.js +++ /dev/null @@ -1,39 +0,0 @@ -angular.module('contactsApp') -.controller('addressbooklistCtrl', function($scope, AddressBookService) { - var ctrl = this; - - ctrl.loading = true; - ctrl.openedMenu = false; - ctrl.addressBookRegex = /^[a-zA-Z0-9À-ÿ\s-_.!?#|()]+$/i; - - AddressBookService.getAll().then(function(addressBooks) { - ctrl.addressBooks = addressBooks; - ctrl.loading = false; - if(ctrl.addressBooks.length === 0) { - AddressBookService.create(t('contacts', 'Contacts')).then(function() { - AddressBookService.getAddressBook(t('contacts', 'Contacts')).then(function(addressBook) { - ctrl.addressBooks.push(addressBook); - $scope.$apply(); - }); - }); - } - }); - - ctrl.t = { - addressBookName : t('contacts', 'Address book name'), - regexError : t('contacts', 'Only these special characters are allowed: -_.!?#|()') - }; - - ctrl.createAddressBook = function() { - if(ctrl.newAddressBookName) { - AddressBookService.create(ctrl.newAddressBookName).then(function() { - AddressBookService.getAddressBook(ctrl.newAddressBookName).then(function(addressBook) { - ctrl.addressBooks.push(addressBook); - $scope.$apply(); - }); - }).catch(function() { - OC.Notification.showTemporary(t('contacts', 'Address book could not be created.')); - }); - } - }; -}); diff --git a/js/components/addressBookList/addressBookList_directive.js b/js/components/addressBookList/addressBookList_directive.js deleted file mode 100644 index a68ac10b..00000000 --- a/js/components/addressBookList/addressBookList_directive.js +++ /dev/null @@ -1,11 +0,0 @@ -angular.module('contactsApp') -.directive('addressbooklist', function() { - return { - restrict: 'EA', // has to be an attribute to work with core css - scope: {}, - controller: 'addressbooklistCtrl', - controllerAs: 'ctrl', - bindToController: {}, - templateUrl: OC.linkTo('contacts', 'templates/addressBookList.html') - }; -}); diff --git a/js/components/avatar/avatar_controller.js b/js/components/avatar/avatar_controller.js deleted file mode 100644 index 04e4bf04..00000000 --- a/js/components/avatar/avatar_controller.js +++ /dev/null @@ -1,66 +0,0 @@ -angular.module('contactsApp') -.controller('avatarCtrl', function(ContactService) { - var ctrl = this; - - ctrl.import = ContactService.import.bind(ContactService); - - ctrl.removePhoto = function() { - ctrl.contact.removeProperty('photo', ctrl.contact.getProperty('photo')); - ContactService.update(ctrl.contact); - $('avatar').removeClass('maximized'); - }; - - ctrl.downloadPhoto = function() { - /* globals ArrayBuffer, Uint8Array */ - var img = document.getElementById('contact-avatar'); - // atob to base64_decode the data-URI - var imageSplit = img.src.split(','); - // "data:image/png;base64" -> "png" - var extension = '.' + imageSplit[0].split(';')[0].split('/')[1]; - var imageData = atob(imageSplit[1]); - // Use typed arrays to convert the binary data to a Blob - var arrayBuffer = new ArrayBuffer(imageData.length); - var view = new Uint8Array(arrayBuffer); - for (var i=0; i<imageData.length; i++) { - view[i] = imageData.charCodeAt(i) & 0xff; - } - var blob = new Blob([arrayBuffer], {type: 'application/octet-stream'}); - - // Use the URL object to create a temporary URL - var url = (window.webkitURL || window.URL).createObjectURL(blob); - - var a = document.createElement('a'); - document.body.appendChild(a); - a.style = 'display: none'; - a.href = url; - a.download = ctrl.contact.uid() + extension; - a.click(); - window.URL.revokeObjectURL(url); - a.remove(); - }; - - ctrl.openPhoto = function() { - $('avatar').toggleClass('maximized'); - }; - - ctrl.t = { - uploadNewPhoto : t('contacts', 'Upload new image'), - deletePhoto : t('contacts', 'Delete'), - closePhoto : t('contacts', 'Close'), - downloadPhoto : t('contacts', 'Download') - }; - - // Quit avatar preview - $('avatar').click(function() { - $('avatar').removeClass('maximized'); - }); - $('avatar img, avatar .avatar-options').click(function(e) { - e.stopPropagation(); - }); - $(document).keyup(function(e) { - if (e.keyCode === 27) { - $('avatar').removeClass('maximized'); - } - }); - -}); diff --git a/js/components/avatar/avatar_directive.js b/js/components/avatar/avatar_directive.js deleted file mode 100644 index 542f0702..00000000 --- a/js/components/avatar/avatar_directive.js +++ /dev/null @@ -1,36 +0,0 @@ -angular.module('contactsApp') -.directive('avatar', function(ContactService) { - return { - scope: { - contact: '=data' - }, - controller: 'avatarCtrl', - controllerAs: 'ctrl', - bindToController: { - contact: '=data' - }, - link: function(scope, element) { - var input = element.find('input'); - input.bind('change', function() { - var file = input.get(0).files[0]; - if (file.size > 1024*1024) { // 1 MB - OC.Notification.showTemporary(t('contacts', 'The selected image is too big (max 1MB)')); - } else { - var reader = new FileReader(); - - reader.addEventListener('load', function () { - scope.$apply(function() { - scope.contact.photo(reader.result); - ContactService.update(scope.contact); - }); - }, false); - - if (file) { - reader.readAsDataURL(file); - } - } - }); - }, - templateUrl: OC.linkTo('contacts', 'templates/avatar.html') - }; -}); diff --git a/js/components/contact/contact_controller.js b/js/components/contact/contact_controller.js deleted file mode 100644 index aa3dcd4a..00000000 --- a/js/components/contact/contact_controller.js +++ /dev/null @@ -1,35 +0,0 @@ -angular.module('contactsApp') -.controller('contactCtrl', function($route, $routeParams, SortByService) { - var ctrl = this; - - ctrl.t = { - errorMessage : t('contacts', 'This card is corrupted and has been fixed. Please check the data and trigger a save to make the changes permanent.'), - }; - - ctrl.getName = function() { - // If lastName equals to firstName then none of them is set - if (ctrl.contact.lastName() === ctrl.contact.firstName()) { - return ctrl.contact.displayName(); - } - - if (SortByService.getSortByKey() === 'sortLastName') { - return ( - ctrl.contact.lastName() - + (ctrl.contact.firstName() ? ', ' : '') - + ctrl.contact.firstName() + ' ' - + ctrl.contact.additionalNames() - ).trim(); - } - - if (SortByService.getSortByKey() === 'sortFirstName') { - return ( - ctrl.contact.firstName() + ' ' - + ctrl.contact.additionalNames() + ' ' - + ctrl.contact.lastName() - ).trim(); - } - - return ctrl.contact.displayName(); - }; -}); - diff --git a/js/components/contact/contact_directive.js b/js/components/contact/contact_directive.js deleted file mode 100644 index d5dd07aa..00000000 --- a/js/components/contact/contact_directive.js +++ /dev/null @@ -1,12 +0,0 @@ -angular.module('contactsApp') -.directive('contact', function() { - return { - scope: {}, - controller: 'contactCtrl', - controllerAs: 'ctrl', - bindToController: { - contact: '=data' - }, - templateUrl: OC.linkTo('contacts', 'templates/contact.html') - }; -}); diff --git a/js/components/contactDetails/contactDetails_controller.js b/js/components/contactDetails/contactDetails_controller.js deleted file mode 100644 index a5b1fdd0..00000000 --- a/js/components/contactDetails/contactDetails_controller.js +++ /dev/null @@ -1,120 +0,0 @@ -angular.module('contactsApp') -.controller('contactdetailsCtrl', function(ContactService, AddressBookService, vCardPropertiesService, $route, $routeParams, $scope) { - - var ctrl = this; - - ctrl.init = true; - ctrl.loading = false; - ctrl.show = false; - - ctrl.clearContact = function() { - $route.updateParams({ - gid: $routeParams.gid, - uid: undefined - }); - ctrl.show = false; - ctrl.contact = undefined; - }; - - ctrl.uid = $routeParams.uid; - ctrl.t = { - noContacts : t('contacts', 'No contacts in here'), - placeholderName : t('contacts', 'Name'), - placeholderOrg : t('contacts', 'Organization'), - placeholderTitle : t('contacts', 'Title'), - selectField : t('contacts', 'Add field …'), - download : t('contacts', 'Download'), - delete : t('contacts', 'Delete'), - save : t('contacts', 'Save changes'), - addressBook : t('contacts', 'Address book'), - loading : t('contacts', 'Loading contacts …') - }; - - ctrl.fieldDefinitions = vCardPropertiesService.fieldDefinitions; - ctrl.focus = undefined; - ctrl.field = undefined; - ctrl.addressBooks = []; - - AddressBookService.getAll().then(function(addressBooks) { - ctrl.addressBooks = addressBooks; - - if (!angular.isUndefined(ctrl.contact)) { - ctrl.addressBook = _.find(ctrl.addressBooks, function(book) { - return book.displayName === ctrl.contact.addressBookId; - }); - } - ctrl.init = false; - // Start watching for ctrl.uid when we have addressBooks, as they are needed for fetching - // full details. - $scope.$watch('ctrl.uid', function(newValue) { - ctrl.changeContact(newValue); - }); - }); - - - ctrl.changeContact = function(uid) { - if (typeof uid === 'undefined') { - ctrl.show = false; - $('#app-navigation-toggle').removeClass('showdetails'); - $('.app-content-list').removeClass('showdetails'); - return; - } - ctrl.loading = true; - ContactService.getById(ctrl.addressBooks, uid).then(function(contact) { - if (angular.isUndefined(contact)) { - ctrl.clearContact(); - return; - } - ctrl.contact = contact; - ctrl.show = true; - ctrl.loading = false; - $('#app-navigation-toggle').addClass('showdetails'); - $('.app-content-list').addClass('showdetails'); - - ctrl.addressBook = _.find(ctrl.addressBooks, function(book) { - return book.displayName === ctrl.contact.addressBookId; - }); - }); - }; - - ctrl.deleteContact = function() { - ContactService.delete(ctrl.addressBook, ctrl.contact); - }; - - ctrl.addField = function(field) { - var defaultValue = vCardPropertiesService.getMeta(field).defaultValue || {value: ''}; - ctrl.contact.addProperty(field, defaultValue); - ctrl.focus = field; - ctrl.field = ''; - }; - - ctrl.deleteField = function (field, prop) { - ctrl.contact.removeProperty(field, prop); - ctrl.focus = undefined; - }; - - ctrl.changeAddressBook = function (addressBook, oldAddressBook) { - ContactService.moveContact(ctrl.contact, addressBook, oldAddressBook); - }; - - ctrl.updateContact = function() { - ContactService.queueUpdate(ctrl.contact); - }; - - ctrl.closeMenus = function() { - ctrl.openedMenu = false; - }; - - ctrl.openMenu = function(index) { - ctrl.closeMenus(); - ctrl.openedMenu = index; - }; - - ctrl.toggleMenu = function(index) { - if (ctrl.openedMenu === index) { - ctrl.closeMenus(); - } else { - ctrl.openMenu(index); - } - }; -}); diff --git a/js/components/contactDetails/contactDetails_directive.js b/js/components/contactDetails/contactDetails_directive.js deleted file mode 100644 index 23c67eb6..00000000 --- a/js/components/contactDetails/contactDetails_directive.js +++ /dev/null @@ -1,11 +0,0 @@ -angular.module('contactsApp') -.directive('contactdetails', function() { - return { - priority: 1, - scope: {}, - controller: 'contactdetailsCtrl', - controllerAs: 'ctrl', - bindToController: {}, - templateUrl: OC.linkTo('contacts', 'templates/contactDetails.html') - }; -}); diff --git a/js/components/contactFilter/contactFilter_controller.js b/js/components/contactFilter/contactFilter_controller.js deleted file mode 100644 index 323be238..00000000 --- a/js/components/contactFilter/contactFilter_controller.js +++ /dev/null @@ -1,5 +0,0 @@ -angular.module('contactsApp') -.controller('contactfilterCtrl', function() { - // eslint-disable-next-line no-unused-vars - var ctrl = this; -}); diff --git a/js/components/contactFilter/contactFilter_directive.js b/js/components/contactFilter/contactFilter_directive.js deleted file mode 100644 index 98a5e34e..00000000 --- a/js/components/contactFilter/contactFilter_directive.js +++ /dev/null @@ -1,13 +0,0 @@ -angular.module('contactsApp') -.directive('contactFilter', function() { - return { - restrict: 'A', // has to be an attribute to work with core css - scope: {}, - controller: 'contactfilterCtrl', - controllerAs: 'ctrl', - bindToController: { - contactFilter: '=contactFilter' - }, - templateUrl: OC.linkTo('contacts', 'templates/contactFilter.html') - }; -}); diff --git a/js/components/contactImport/contactImport_controller.js b/js/components/contactImport/contactImport_controller.js deleted file mode 100644 index 8901cf93..00000000 --- a/js/components/contactImport/contactImport_controller.js +++ /dev/null @@ -1,42 +0,0 @@ -angular.module('contactsApp') -.controller('contactimportCtrl', function(ContactService, AddressBookService, $timeout, $scope) { - var ctrl = this; - - ctrl.t = { - importText : t('contacts', 'Import into'), - importingText : t('contacts', 'Importing...'), - selectAddressbook : t('contacts', 'Select your addressbook'), - importdisabled : t('contacts', 'Import is disabled because no writable address book had been found.') - }; - - ctrl.import = ContactService.import.bind(ContactService); - ctrl.loading = true; - ctrl.importText = ctrl.t.importText; - ctrl.importing = false; - ctrl.loadingClass = 'icon-upload'; - - AddressBookService.getAll().then(function(addressBooks) { - ctrl.addressBooks = addressBooks; - ctrl.loading = false; - ctrl.selectedAddressBook = AddressBookService.getDefaultAddressBook(); - }); - - AddressBookService.registerObserverCallback(function() { - $timeout(function() { - $scope.$apply(function() { - ctrl.selectedAddressBook = AddressBookService.getDefaultAddressBook(); - }); - }); < |