From 7f7a2f6a7d283b86036ceaac4d0287f370679d3e Mon Sep 17 00:00:00 2001 From: babelouest Date: Mon, 5 May 2014 15:18:48 -0400 Subject: [PATCH 1/5] use ocdialog instead of bottom-left controls --- js/addressbooks.js | 593 +++++++++++++++++++++++++++++++++++++++-- js/loader.js | 2 +- templates/contacts.php | 56 ++-- 3 files changed, 611 insertions(+), 40 deletions(-) diff --git a/js/addressbooks.js b/js/addressbooks.js index 367db4b6..9e0f0a47 100644 --- a/js/addressbooks.js +++ b/js/addressbooks.js @@ -9,6 +9,11 @@ OC.Contacts = OC.Contacts || {}; this.storage = storage; this.book = book; this.$template = template; + this.addressBooks = new OC.Contacts.AddressBookList( + this.storage, + $('#app-settings-content'), + $('#addressBookTemplate') + ); }; AddressBook.prototype.render = function() { @@ -247,7 +252,7 @@ OC.Contacts = OC.Contacts || {}; this.$bookTemplate = bookTemplate; this.$bookList = this.$bookTemplate.find('.addressbooklist'); this.$bookItemTemplate = bookItemTemplate; - this.$importIntoSelect = this.$bookTemplate.find('#import_into'); + this.$importIntoSelect = $('#import_into'); this.$importFormatSelect = this.$bookTemplate.find('#import_format'); this.$importProgress = this.$bookTemplate.find('#import-status-progress'); this.$importStatusText = this.$bookTemplate.find('#import-status-text'); @@ -328,6 +333,35 @@ OC.Contacts = OC.Contacts || {}; $('.import-status').hide(); } }); + $('#import-contacts').on('click keypress', function() { + var $rightContent = $('#app-content'); + $rightContent.append('
'); + var $dlg = $('#contactsImportTemplate').octemplate(); + var $divDlg = $('#import-dialog'); + $divDlg.html($dlg).ocdialog({ + modal: true, + closeOnEscape: true, + title: t('contacts', 'Import contacts'), + height: '220', + width: 'auto', + buttons: [ + { + text: t('contacts', 'Close'), + click: function() { + $divDlg.ocdialog().ocdialog('close'); + $divDlg.ocdialog().ocdialog('destroy').remove(); + } + } + ], + close: function(/*event, ui*/) { + $divDlg.ocdialog().ocdialog('close'); + $divDlg.ocdialog().ocdialog('destroy').remove(); + }, + open: function(/*event, ui*/) { + self.buildImportSelect2(); + } + }); + }); }; AddressBookList.prototype.count = function() { @@ -454,23 +488,58 @@ OC.Contacts = OC.Contacts || {}; * Rebuild the select to choose which address book to import into. */ AddressBookList.prototype.buildImportSelect = function() { - console.log('buildImportSelect'); + console.log('buildImportSelect', this); var self = this; this.$importIntoSelect.find('option:not([value="-1"])').remove(); - var addressBooks = this.selectByPermission(OC.PERMISSION_UPDATE); - $.each(addressBooks, function(idx, book) { - var $opt = $('