');
- html.set (this.contentId);
-
- Event.observe (editId, 'click', this.add.bindAsEventListener (this));
- this.showVertical (elem);
-}
-
-Dragonfly.AddressBook.FakeFriendPopup.prototype.add = function ()
-{
- var AB = Dragonfly.AddressBook;
- this.serializeContact();
- this.elem.innerHTML = this.contact.fn;
-
- Dragonfly.notify (_('Saving changes...'), true);
- AB.saveContact (this.contact).addCallbacks (bind (
- function (result) {
- // update preferences with contact ID
- if (this.setMyContact) {
- var id = (this.myId == '') ? result.bongoId : this.myId;
- AB.Preferences.setMyContactId (id);
- }
-
- // Create sidebox element if this is a new contact
- if (result.bongoId) {
- this.contact.bongoId = result.bongoId;
- this.setElem (AB.sideboxPicker.addItem (this.contact.fn, result.bongoId));
- $(this.elem).scrollIntoView();
- }
-
- Dragonfly.notify (_('Changes saved.'));
- this.summarize ();
- this.shouldAutohide = true;
- callLater (2, bind ('autohide', this));
- return result;
- }, this), bind ('showError', this));
-};
-
// The ContactPopup manages the interaction for creating and editing contacts
Dragonfly.AddressBook.ContactPopup = function (elem)
{
@@ -482,14 +405,14 @@ Dragonfly.AddressBook.ContactPopup.prototype.loadContact = function ()
var form = $(this.formId);
form.fn.value = this.contact.fn;
- var myId = AB.Preferences.getMyContactId();
+ //var myId = AB.Preferences.getMyContactId();
- logDebug('myID: ' + myId);
+ //logDebug('myID: ' + myId);
logDebug('form id: ' + form);
logDebug('this.contact: ' + this.contact);
logDebug('this.contact.fn: ' + this.contact.fn);
- form.isMyContact.checked = myId && (myId == this.contact.bongoId);
+ //form.isMyContact.checked = myId && (myId == this.contact.bongoId);
for (var i = 0; i < Fields.props.length; i++) {
var prop = Fields.props[i];
@@ -515,13 +438,13 @@ Dragonfly.AddressBook.ContactPopup.prototype.serializeContact = function ()
var form = $(this.formId);
contact.fn = form.fn.value;
- if (form.isMyContact.checked) {
+ /*if (form.isMyContact.checked) {
this.setMyContact = true;
this.myId = this.contact.bongoId || '';
} else if (this.contact.bongoId == AB.Preferences.getMyContactId()) {
this.setMyContact = true;
this.myId = null;
- }
+ }*/
// clear out existing properties
forEach (props, function (prop) { delete contact[prop]; });
@@ -602,8 +525,7 @@ Dragonfly.AddressBook.ContactPopup.prototype.edit = function (evt, contact, elem
var form = [
''];
+ 'src="img/contact-unknown.png">
', notebook, ''];
var actions = [{ value: _('Cancel'), onclick: 'dispose'}, { value: _('Save'), onclick: 'save'}];
if (this.contact.bongoId) { // only add delete for pre-existing contacts
@@ -642,10 +564,10 @@ Dragonfly.AddressBook.ContactPopup.prototype.save = function ()
AB.saveContact (this.contact).addCallbacks (bind (
function (result) {
// update preferences with contact ID
- if (this.setMyContact) {
+ /*if (this.setMyContact) {
var id = (this.myId == '') ? result.bongoId : this.myId;
AB.Preferences.setMyContactId (id);
- }
+ }*/
// Create sidebox element if this is a new contact
if (result.bongoId) {
@@ -678,3 +600,153 @@ Dragonfly.AddressBook.ContactPopup.prototype.delConfirm = function ()
this.show();
};
+Dragonfly.AddressBook.UserProfile = function (elem)
+{
+ this.formId = elem;
+ this.bongoId = null;
+};
+
+Dragonfly.AddressBook.UserProfile.prototype = {};
+
+Dragonfly.AddressBook.UserProfile.prototype.build = function (contact)
+{
+ var d = Dragonfly;
+
+ this.contact = contact;
+
+ this.formNames = { };
+
+ var notebook = new d.Notebook();
+ for (var i = 0; i < Dragonfly.AddressBook.ContactPopup.prototype.Form.length; i++) {
+ var tab = d.AddressBook.ContactPopup.prototype.Form[i];
+ var page = notebook.appendPage (tab.category);
+ this.buildTab (new d.HtmlBuilder(), tab).set(page);
+ }
+
+ var html = new d.HtmlBuilder ();
+ html.push ('
');
+ d.HtmlBuilder.buildChild(html, notebook);
+
+ html.set(this.formId);
+
+ //var actions = [{ value: _('Save'), onclick: 'save'}];
+ //Dragonfly.Preferences.Editor.buildInterface (form, actions, this.belement);
+
+ if (this.contact != null)
+ {
+ this.loadContact();
+ }
+};
+
+Dragonfly.AddressBook.UserProfile.prototype.loadContact = function ()
+{
+ var AB = Dragonfly.AddressBook;
+ var Fields = AB.ContactPopup.prototype.FieldTypes;
+
+ var form = $(this.formId);
+ form.fn.value = this.contact.fn;
+
+ //logDebug('myID: ' + myId);
+
+ //form.isMyContact.checked = myId && (myId == this.contact.bongoId);
+
+ for (var i = 0; i < Fields.props.length; i++) {
+ var prop = Fields.props[i];
+ var values = this.contact[prop];
+ if (!values) {
+ continue;
+ }
+ for (var j = 0; j < values.length; j++) {
+ var value = values[j];
+ var input = this.getFreeField (AB.ContactPopup.prototype.getName (prop, value.type), false);
+ if (input) {
+ input.value = $V(value);
+ }
+ }
+ }
+};
+
+Dragonfly.AddressBook.UserProfile.prototype.getFreeField = function (name, asString)
+{
+ if (asString) {
+ var n = this.formNames[name];
+ n = (n == undefined) ? 0 : n + 1;
+ this.formNames[name] = n;
+ return name + String (n);
+ }
+ return $(this.formId)[name+'0'];
+};
+
+Dragonfly.AddressBook.UserProfile.prototype.buildTab = function (html, tab)
+{
+ var fields = tab.fields;
+ var formFields = this.formFields;
+
+ html.push ('
');
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+
+ var name = Dragonfly.AddressBook.ContactPopup.prototype.getName (field.prop, [tab.type, field.type]);
+ name = this.getFreeField (name, true);
+ html.push ('
');
- html.set ('content-iframe');
-
- // Come up with some magic tabs!
- var notebook = new d.Notebook();
- var userpage = notebook.appendPage('About Me');
- var composerpage = notebook.appendPage('Mail');
- var calendarpage = notebook.appendPage('Calendar');
-
- var userhtml = new d.HtmlBuilder ();
- userhtml.push ('
',
- '
',
- '
',
- '
',
- '
',
- '
');
- userhtml.set (userpage);
-
- var composerhtml = new d.HtmlBuilder ();
- composerhtml.push ('
',
- '
',
- '
',
- '
Please don\'t abuse the above feature for now.
',
- '
',
- '
',
- '
',
- '
',
- '',
- '
',
- '
',
- '
',
- '
',
- '
', _('items'), '
',
- '
',
- '
');
- composerhtml.set (composerpage);
-
- var calendarhtml = new d.HtmlBuilder ();
- calendarhtml.push ('
',
- '
',
- '
',
+ // Come up with some magic tabs!
+ var notebook = new d.Notebook();
+ var userpage = notebook.appendPage('General');
+ var mailpage = notebook.appendPage('Mail');
+ var calendarpage = notebook.appendPage('Calendar');
+ var composerpage = notebook.appendPage('Composer');
+
+ var userhtml = new d.HtmlBuilder ();
+ userhtml.push ('
',
+ '
',
+ '
',
+ '
',
+ '
');
+ userhtml.set (userpage);
+
+ var mailhtml = new d.HtmlBuilder ();
+ mailhtml.push ('
',
+ '
',
+ '
',
+ '
Please don\'t abuse the above feature for now.
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
', _('items'), '
',
+ '
',
+ '
');
+ mailhtml.set (mailpage);
+
+ var calendarhtml = new d.HtmlBuilder ();
+ calendarhtml.push ('
',
+ '
',
+ '
',
+ '
',
+ ' ',
+ '',
+ '
',
// '
',
// '
',
- '
');
- calendarhtml.set (calendarpage);
-
- var form = [
- ''];
-
- var actions = [{ value: _('Cancel'), onclick: 'dispose'}, { value: _('Save'), onclick: 'save'}];
-
- // Now, fill in the content with tabs & buttons.
- this.contentId = 'preferences-container';
- this.buildInterface (form, actions);
- logDebug('Created UI OK - setting up TzSelector widget...');
-
- // Setup timezone widget
- d.tzselector = new d.TzSelector (d.curTzid, 'tzpicker', true);
- }
+ '
');
+ calendarhtml.set (calendarpage);
+
+ var composerhtml = new d.HtmlBuilder();
+ composerhtml.push('
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
');
+ composerhtml.set(composerpage);
+
+ var form = [
+ ''];
+
+ var actions = [{ value: _('Cancel'), onclick: 'dispose'}, { value: _('Save'), onclick: 'save'}];
+
+ // Now, fill in the content with tabs & buttons.
+ this.buildInterface (form, actions, 'preferences-container');
+ logDebug('Created UI OK - setting up TzSelector widget...');
+
+ // Setup timezone widget
+ d.tzselector = new d.TzSelector (d.curTzid, 'tzpicker', true);
logDebug('We just got built.');
};
@@ -335,6 +335,11 @@ Dragonfly.Preferences.Editor.save = function ()
var d = Dragonfly;
var p = d.Preferences;
+ // User profile
+ Dragonfly.notify (_('Saving changes...'), true);
+ var result = this.profileEditor.save();
+ p.prefs.addressbook.me = this.profileEditor.bongoId;
+
// Timezone
d.setCurrentTzid (d.tzselector.getTzid());
@@ -349,9 +354,16 @@ Dragonfly.Preferences.Editor.save = function ()
// 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');
+ p.prefs.composer.lineWidth = $('linewidth');
// Finish up
p.save();
+ Dragonfly.notify (_('Changes saved.'));
this.dispose();
};
@@ -379,20 +391,40 @@ Dragonfly.Preferences.Editor.load = function (loc, jsob)
logWarning('You have no prefs. I should probably warn you, or.. something.');
}
- if (jsob.mail.autoBcc) { $('autobcc').value = jsob.mail.autoBcc; }
- if (jsob.mail.pageSize) { $('mailpagesize').value = jsob.mail.pageSize; }
- if (jsob.mail.signature) { $('signature').value = jsob.mail.signature; }
- if (jsob.mail.usesig) { $('usesig').checked = jsob.mail.usesig; }
- if (jsob.mail.colorQuotes) { $('colorquotes').checked = jsob.mail.colorQuotes; }
+ if (jsob.mail && jsob.mail.autoBcc) { $('autobcc').value = jsob.mail.autoBcc; }
+ if (jsob.mail && jsob.mail.pageSize) { $('mailpagesize').value = jsob.mail.pageSize; }
+ if (jsob.mail && jsob.mail.signature) { $('signature').value = jsob.mail.signature; }
+ if (jsob.mail && jsob.mail.usesig) { $('usesig').checked = jsob.mail.usesig; }
+ if (jsob.mail && jsob.mail.colorQuotes) { $('colorquotes').checked = jsob.mail.colorQuotes; }
// Calendar prefs
- if (jsob.calendar.defaultView) { $('defaultcalview').value = jsob.calendar.defaultView; }
+ if (jsob.calendar && jsob.calendar.defaultView) { $('defaultcalview').value = jsob.calendar.defaultView; }
+ if (jsob.calendar && jsob.calendar.sharePublicDefault) { $('calshareyes').checked = jsob.calendar.sharePublicDefault; $('calshareno').checked = !jsob.calendar.sharePublicDefault } else { $('calshareno').checked = true; }
//if (jsob.calendar.dayStart) { $('daystart').value = jsob.calendar.dayStart; }
+
+ // Composer prefs
+ if (jsob.composer && jsob.composer.messageType) { $('defaultcompose').value = jsob.composer.messageType; }
+ if (jsob.composer && jsob.composer.lineWidth) { $('linewidth').value = jsob.composer.lineWidth ; } else { $('linewidth').value = '80'; }
+ // Now, load up the profile editor!
+ var pe = new d.AddressBook.UserProfile('userprofile');
+ if (jsob.addressbook.me && jsob.addressbook.me != null)
+ {
+ // We've already setup our profile - load it!
+ d.AddressBook.loadContact(jsob.addressbook.me).addCallback(bind ('build', pe));
+ }
+ else
+ {
+ // Build empty profile editor UI.
+ pe.build(Dragonfly.AddressBook.buildNewContact());
+ }
+
+ this.profileEditor = pe;
+
logDebug('We just loaded.');
};
-Dragonfly.Preferences.Editor.buildInterface = function (children, actions, observer)
+Dragonfly.Preferences.Editor.buildInterface = function (children, actions, element)
{
var d = Dragonfly;
@@ -407,11 +439,11 @@ Dragonfly.Preferences.Editor.buildInterface = function (children, actions, obser
}
html.push ('');
- html.set (this.contentId);
+ html.set (element);
for (var i = 0; i < actions.length; i++){
logDebug('Setting up actions for ' + actions[i].value);
var clickHandler = actions[i].onclick;
- Event.observe (ids[i], 'click', bind (clickHandler, observer || this));
+ Event.observe (ids[i], 'click', bind (clickHandler, this));
logDebug('Done!');
}
};
diff --git a/src/www/js/Widgets.js b/src/www/js/Widgets.js
index 3f9cbc0..474f5a7 100644
--- a/src/www/js/Widgets.js
+++ b/src/www/js/Widgets.js
@@ -361,6 +361,7 @@ Dragonfly.PopupBuble.prototype.connectHtml = function (elem)
this.dispose();
}
}.bindAsEventListener(this));
+
return elem;
};
@@ -378,6 +379,7 @@ Dragonfly.PopupBuble.prototype.addPoppedOut = function ()
{
if (this.elem) {
addElementClass (this.elem, 'popped-out');
+ //Dragonfly.lastPopup = this;
}
};
@@ -560,7 +562,7 @@ Dragonfly.PopupBuble.prototype.show = function (elem, position)
}
if (!this.elem) {
return;
- }
+ }
this.addPoppedOut ();
@@ -621,7 +623,7 @@ Dragonfly.PopupBuble.prototype.show = function (elem, position)
}
$(this.id).style.visibility = 'visible';
-
+
return;
logDebug ('positioning summary:');
logDebug (' elemMetrics:', repr (elemMetrics));