Skip to content

Commit

Permalink
Bug 1229155 - Summary and event dialog: Persisted dimensions are not …
Browse files Browse the repository at this point in the history
…applied when opening again;r=philipp
  • Loading branch information
make-my-day committed Jan 24, 2016
1 parent 239defd commit eb5e524
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions calendar/base/content/dialogs/calendar-dialog-utils.js
Expand Up @@ -32,6 +32,7 @@ function dispose() {
function setDialogId(aDialog, aNewId) {
aDialog.setAttribute("originalId", aDialog.getAttribute("id"));
aDialog.setAttribute("id", aNewId);
applyPersitedProperties(aDialog);
}

/**
Expand All @@ -48,6 +49,30 @@ function resetDialogId(aDialog) {
aDialog.removeAttribute("originalId");
}

/**
* Apply the persisted properties from xulstore.json on a dialog based on the current dialog id.
* This needs to be invoked after changing a dialog id while loading to apply the values for the
* new dialog id.
*
* @param aDialog The Dialog to apply the property values for
*/
function applyPersitedProperties(aDialog) {
let xulStore = Components.classes["@mozilla.org/xul/xulstore;1"]
.getService(Components.interfaces.nsIXULStore);
// first we need to detect which properties are persisted
let persistedProps = aDialog.getAttribute("persist") || "";
if (persistedProps == "") {
return;
}
let propNames = persistedProps.split(" ");
// now let's apply persisted values if applicable
for (let propName of propNames) {
if (xulStore.hasValue(aDialog.baseURI, aDialog.id, propName)) {
aDialog.setAttribute(propName, xulStore.getValue(aDialog.baseURI, aDialog.id, propName));
}
}
}

/**
* Create a calIAlarm from the given menuitem. The menuitem must have the
* following attributes: unit, length, origin, relation.
Expand Down

0 comments on commit eb5e524

Please sign in to comment.