Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[Widgets] Extend zones more gracefully

Looking for parent zone with the same name. If found, extend it
with descendant zone, otherwize add a new zone.
  • Loading branch information...
commit de6b6526cec02c07a8fa2601f4eb3fbff3255cc0 1 parent 3f9bb5e
@zhizhangchen zhizhangchen authored grgustaf committed
Showing with 22 additions and 2 deletions.
  1. +1 −1  index.html
  2. +21 −1 src/js/widgets.js
View
2  index.html
@@ -25,6 +25,7 @@
<body class="vbox fullsize">
<script src="lib/jquery-1.6.4.min.js"></script>
<script src="lib/jquery-ui-1.8.16.custom.min.js"></script>
+ <script src="src/js/jquery-workarounds.js"></script>
<script src="src/js/msg-box.js"></script>
<script src="src/js/events.js"></script>
<script src="src/js/widgets.js"></script>
@@ -35,7 +36,6 @@
<script src="src/js/projects.js"></script>
<script src="src/js/serialize.js"></script>
<!-- New stuff from here ... -->
- <script src="src/js/jquery-workarounds.js"></script>
<script src="src/js/jquery-plugins.js"></script>
<script src="src/js/views/base.js"></script>
<script src="src/js/views/tree.js"></script>
View
22 src/js/widgets.js
@@ -2619,7 +2619,7 @@ var BWidget = {
init: function () {
// effects: add the type and displayLabel properties to widget
// registry objects
- var type, parentName;
+ var type, parentName, newZones, descendantZone, descendantZoneIndex;
for (type in BWidgetRegistry) {
if (BWidgetRegistry.hasOwnProperty(type)) {
BWidgetRegistry[type].type = type;
@@ -2657,6 +2657,26 @@ var BWidget = {
}
parentName = BWidgetRegistry[type].parent;
while (parentName) {
+ if (BWidgetRegistry[parentName].zones) {
+ newZones = [];
+ $.each(BWidgetRegistry[parentName].zones, function (i, pZone) {
+ descendantZone = null;
+ if (BWidgetRegistry[type].zones)
+ $.each(BWidgetRegistry[type].zones, function (i, zone) {
+ if (pZone.name === zone.name) {
+ descendantZone = zone;
+ descendantZoneIndex = i;
+ return false;
+ }
+ });
+ if (descendantZone)
+ BWidgetRegistry[type].zones[descendantZoneIndex] = $.extend(true, true, {}, pZone, descendantZone);
+ else
+ newZones.push(pZone);
+ });
+ if(BWidgetRegistry[type].zones)
+ $.merge(BWidgetRegistry[type].zones, newZones);
+ }
BWidgetRegistry[type] = $.extend(true, true, {}, BWidgetRegistry[parentName], BWidgetRegistry[type]);
parentName = BWidgetRegistry[parentName].parent;
}
Please sign in to comment.
Something went wrong with that request. Please try again.