Skip to content

Commit

Permalink
Array mods in layout structure. #47
Browse files Browse the repository at this point in the history
  • Loading branch information
jvalkeal committed Dec 31, 2011
1 parent 22b27ff commit e6d05a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions dojo-release-1.5.0-src/hyperic/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ hyperic.util.Util.zeroMinInsets = function(/*Object*/obj){
right: Math.max(obj.right,0)
};
};

hyperic.util.Util.toArray = function(t){
// summary:
// Converts object to array of size 1. If it's
// already an array, return it unmodified.
return dojo.isArray(t) ? t : [t];
};
13 changes: 10 additions & 3 deletions dojo-release-1.5.0-src/hyperic/wallmount/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
dojo.provide("hyperic.wallmount.Player");

dojo.require("hyperic.wallmount.WindowUtil");
dojo.require("hyperic.util.Util");
dojo.require("hyperic.data.MetricStore");

hyperic.wallmount.Player.loadLayout = function(/*String*/url, /*Boolean*/ sendAnim, /*String*/node) {
Expand Down Expand Up @@ -84,7 +85,11 @@ hyperic.wallmount.Player.createLayout = function(/*jsondata*/data, /*String*/nod
dojo.style(wallmountPane,'width',data.w||9999);
dojo.style(wallmountPane,'height',data.h||9999);

var items = data.items;
// items should be a list (items:[{},{}...]
// if it's an object, we assume list with one object
// -> make conversion
var items = hyperic.util.Util.toArray(data.items);

for(var i=0; i<items.length; i++) {
var args = {
x: items[i].x,
Expand Down Expand Up @@ -119,8 +124,10 @@ hyperic.wallmount.Player.createLayout = function(/*jsondata*/data, /*String*/nod
source = hyperic.wallmount.WindowUtil.newWindow(args, wallmountPane);
}

for(var j = 0; j<items[i].items.length; j++){
var witem = items[i].items[j];
var widgetItems = hyperic.util.Util.toArray(items[i].items);

for(var j = 0; j<widgetItems.length; j++){
var witem = widgetItems[j];
source.insertNodes(false, [witem]);
}
}
Expand Down

0 comments on commit e6d05a6

Please sign in to comment.