changeset in labs/bespinclient: Make the order of "elementAppend...

0 views
Skip to first unread message

Patrick Walton

unread,
Sep 24, 2010, 10:48:12 AM9/24/10
to bespin-...@googlegroups.com
changeset 675c99acdf51 in /repo/hg/mozilla/labs/bespinclient
details: http://hg.mozilla.org/labs/bespinclient?cmd=changeset;node=675c99acdf51
description:
Make the order of "elementAppended" slightly more correct in the presence of resizable toolbars

diffstat:

plugins/supported/appconfig/index.js | 85 +++++++++++++++++++----------------
1 files changed, 45 insertions(+), 40 deletions(-)

diffs (102 lines):

diff --git a/plugins/supported/appconfig/index.js b/plugins/supported/appconfig/index.js
--- a/plugins/supported/appconfig/index.js
+++ b/plugins/supported/appconfig/index.js
@@ -337,53 +337,58 @@ var generateGUI = function(catalog, conf
util.addClass(element, 'bespin');
element.appendChild(container);

- var elementAppendedQueue = [];
+ try {
+ // this shouldn't be necessary, but it looks like Firefox has an issue
+ // with the box-ordinal-group CSS property
+ ['north', 'west', 'center', 'east', 'south'].forEach(function(place) {
+ var descriptor = config.gui[place];
+ if (!descriptor) {
+ return;
+ }

- // this shouldn't be necessary, but it looks like Firefox has an issue
- // with the box-ordinal-group CSS property
- ['north', 'west', 'center', 'east', 'south'].forEach(function(place) {
- var descriptor = config.gui[place];
- if (!descriptor) {
- return;
- }
+ var component = catalog.getObject(descriptor.component);
+ if (!component) {
+ throw 'Cannot find object ' + descriptor.component +
+ ' to attach to the Bespin UI';
+ }

- var component = catalog.getObject(descriptor.component);
- if (!component) {
- error = 'Cannot find object ' + descriptor.component +
- ' to attach to the Bespin UI';
- console.error(error);
- pr.reject(error);
- return;
- }
+ element = component.element;
+ if (!element) {
+ throw 'Component ' + descriptor.component + ' does not ' +
+ 'have an "element" attribute to attach to the ' +
+ 'Bespin UI';
+ }

- element = component.element;
- if (!element) {
- error = 'Component ' + descriptor.component + ' does not have' +
- ' an "element" attribute to attach to the Bespin UI';
- console.error(error);
- pr.reject(error);
- return;
- }
+ $(element).addClass(place);

- $(element).addClass(place);
+ if (place == 'west' || place == 'east' || place == 'center') {
+ if (!centerAdded) {
+ container.appendChild(centerContainer);
+ centerAdded = true;
+ }
+ centerContainer.appendChild(element);
+ } else {
+ container.appendChild(element);
+ }
+ });

- if (place == 'west' || place == 'east' || place == 'center') {
- if (!centerAdded) {
- container.appendChild(centerContainer);
- centerAdded = true;
+ // Call the "elementAppended" callbacks.
+ ['north', 'west', 'east', 'south', 'center'].forEach(function(place) {
+ var descriptor = config.gui[place];
+ if (!descriptor) {
+ return;
}
- centerContainer.appendChild(element);
- } else {
- container.appendChild(element);
- }

- // Queue up the "elementAppended" event, if the component has one.
- if (component.elementAppended != null) {
- elementAppendedQueue.push(component);
- }
- });
+ var component = catalog.getObject(descriptor.component);
+ if (component.elementAppended != null) {
+ component.elementAppended();
+ }
+ });

- _(elementAppendedQueue).invoke('elementAppended');
+ pr.resolve();
+ } catch (e) {
+ console.error(e);
+ pr.reject(e);
+ }

- pr.resolve();
};

Reply all
Reply to author
Forward
0 new messages