From 51a8b612dbac419d7fd68a6894e8f4abd30fbd99 Mon Sep 17 00:00:00 2001 From: halex Date: Sun, 26 Aug 2007 00:54:28 +0000 Subject: [PATCH] Wooh, preference editor! \o/ --- src/www/js/AddressBook.js | 24 +---------- src/www/js/Preferences.js | 72 ++++++++++++++++++-------------- src/www/js/eArea/editableArea.js | 3 +- 3 files changed, 44 insertions(+), 55 deletions(-) diff --git a/src/www/js/AddressBook.js b/src/www/js/AddressBook.js index 429a5b9..2aef373 100644 --- a/src/www/js/AddressBook.js +++ b/src/www/js/AddressBook.js @@ -81,24 +81,6 @@ Dragonfly.AddressBook.saveContact = function (contact) }); }; -Dragonfly.AddressBook.saveContactBlocking = function (contact) -{ - var d = Dragonfly, loc, request; - if (contact.bongoId) { - loc = new d.Location ({ tab: 'addressbook', contact: contact.bongoId }); - request = d.request ('PUT', loc.getServerUrl(), contact); - } else { - loc = new d.Location ({ tab: 'addressbook'}); - request = d.requestJSONRPC ('createContact', loc, contact); - } - - var result = request.result; - - contact.bongoId = result.bongoId; - Dragonfly.AddressBook.contactMap[result.bongoId] = contact; - return result; -}; - Dragonfly.AddressBook.delContact = function (bongoId) { var d = Dragonfly; @@ -724,10 +706,8 @@ Dragonfly.AddressBook.UserProfile.prototype.save = function () this.serializeContact(); this.fname = this.contact.fn; - var r = Dragonfly.AddressBook.saveContactBlocking (this.contact); - this.bongoId = r.bongoId; - - return r; + var AB = Dragonfly.AddressBook; + return AB.saveContact (this.contact); }; Dragonfly.AddressBook.UserProfile.prototype.serializeContact = function () diff --git a/src/www/js/Preferences.js b/src/www/js/Preferences.js index 1f6bd14..4264159 100644 --- a/src/www/js/Preferences.js +++ b/src/www/js/Preferences.js @@ -337,41 +337,49 @@ Dragonfly.Preferences.Editor.save = function () // User profile Dragonfly.notify (_('Saving changes...'), true); - var result = this.profileEditor.save(); - - // User prefs - p.prefs.addressbook.me = this.profileEditor.bongoId || this.oldId || 0; + var result = this.profileEditor.save().addCallbacks(bind( + function (result) { + // User prefs + p.prefs.addressbook.me = result.bongoId || this.oldId || 0; - // Mail prefs - p.prefs.mail.from = $('from').value; - p.prefs.mail.sender = this.profileEditor.fname || 'BUG!'; - p.prefs.mail.autoBcc = $('autobcc').value; - p.prefs.mail.pageSize = $('mailpagesize').value; - p.prefs.mail.signature = $('signature').value; - p.prefs.mail.usesig = $('usesig').checked; - p.prefs.mail.colorQuotes = $('colorquotes').checked; - - // Calendar prefs - p.prefs.calendar.defaultView = $('defaultcalview').value; - p.prefs.calendar.dayStart = 7; // Yes, hardwire this one (for now)! - p.prefs.calendar.sharePublicDefault = $('calshareyes').checked; - - // Composer prefs - p.prefs.composer = {}; - p.prefs.composer.messageType = $('defaultcompose').value; - p.prefs.composer.lineWidth = $('linewidth').value; - - // Finish up - p.save(); - - // Timezone - d.setCurrentTzid (d.tzselector.getTzid()); - - Dragonfly.notify (_('Changes saved.')); - - this.dispose(); + // Mail prefs + p.prefs.mail.from = $('from').value; + p.prefs.mail.sender = this.profileEditor.fname || 'BUG!'; + p.prefs.mail.autoBcc = $('autobcc').value; + p.prefs.mail.pageSize = $('mailpagesize').value; + p.prefs.mail.signature = $('signature').value; + p.prefs.mail.usesig = $('usesig').checked; + p.prefs.mail.colorQuotes = $('colorquotes').checked; + + // Calendar prefs + p.prefs.calendar.defaultView = $('defaultcalview').value; + p.prefs.calendar.dayStart = 7; // Yes, hardwire this one (for now)! + p.prefs.calendar.sharePublicDefault = $('calshareyes').checked; + + // Composer prefs + p.prefs.composer = {}; + p.prefs.composer.messageType = $('defaultcompose').value; + p.prefs.composer.lineWidth = $('linewidth').value; + + // Finish up + p.save(); + + // Timezone + d.setCurrentTzid (d.tzselector.getTzid()); + + Dragonfly.notify (_('Changes saved.')); + + this.dispose(); + }, this), bind('showError', this)); }; +Dragonfly.Preferences.Editor.showError = function (req) +{ + var d = Dragonfly; + d.notifyError("We had a woopsie when we tried to save your prefs.", null, false); + this.dispose(); +} + Dragonfly.Preferences.Editor.dispose = function () { var d = Dragonfly; diff --git a/src/www/js/eArea/editableArea.js b/src/www/js/eArea/editableArea.js index 0d7f08a..98914db 100644 --- a/src/www/js/eArea/editableArea.js +++ b/src/www/js/eArea/editableArea.js @@ -1,6 +1,7 @@ /* eArea - a simple web-based text editor - Copyright (C) 2006 Oliver Moran + Copyright (C) 2006 Oliver Moran + Major modifications by Alexander Hixon This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public