From 078f6ddfa7443fdf7212b51dee3316c269d27b9b Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 3 Nov 2011 22:02:08 +0000 Subject: [PATCH] Fixing display of controlled sites. --- .../src/main/webapp/js/jCardGroup.js | 28 ++++++++++--------- .../src/main/webapp/js/jCards.js | 7 +++++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js index da00a163d..eb773b015 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js @@ -154,10 +154,10 @@ var NormalCardGroup = CardGroup.extend({ var totalWidth = 0; for (var cardId in cardsToLayout) { var cardData = cardsToLayout[cardId].data("card"); - var cardWidth = cardData.getWidthForHeight(this.height); + var cardWidth = cardData.getWidthForMaxDimension(this.height); var attachmentWidths = 0; for (var i = 0; i < cardData.attachedCards.length; i++) - attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(this.height) * 0.2; + attachmentWidths += cardData.attachedCards[i].data("card").getWidthForMaxDimension(this.height) * 0.2; var cardWidthWithAttachments = cardWidth + attachmentWidths; totalWidth += cardWidthWithAttachments; } @@ -177,10 +177,10 @@ var NormalCardGroup = CardGroup.extend({ var row = 0; for (var cardId in cardsToLayout) { var cardData = cardsToLayout[cardId].data("card"); - var cardWidth = cardData.getWidthForHeight(rowHeight); + var cardWidth = cardData.getWidthForMaxDimension(rowHeight); var attachmentWidths = 0; for (var i = 0; i < cardData.attachedCards.length; i++) - attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(rowHeight) * 0.2; + attachmentWidths += cardData.attachedCards[i].data("card").getWidthForMaxDimension(rowHeight) * 0.2; var cardWidthWithAttachments = cardWidth + attachmentWidths; totalWidth += cardWidthWithAttachments; if (totalWidth > this.width) { @@ -205,15 +205,16 @@ var NormalCardGroup = CardGroup.extend({ var index = 10; var cardElem = cardsToLayout[cardId]; var cardData = cardsToLayout[cardId].data("card"); - var cardWidth = cardData.getWidthForHeight(height); + var cardWidth = cardData.getWidthForMaxDimension(height); for (var i = 0; i < cardData.attachedCards.length; i++) { - var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(height); - this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, height, index); + var attachedCardData = cardData.attachedCards[i].data("card"); + var attachedCardWidth = attachedCardData.getWidthForMaxDimension(height); + this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, attachedCardData.getHeightForWidth(attachedCardWidth), index); x += Math.floor(attachedCardWidth * 0.2); index++; } - this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, height, index); + this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), index); x += cardWidth; x += this.padding; } @@ -232,11 +233,11 @@ var NormalCardGroup = CardGroup.extend({ var index = 10; var cardElem = cardsToLayout[cardId]; var cardData = cardsToLayout[cardId].data("card"); - var cardWidth = cardData.getWidthForHeight(rowHeight); + var cardWidth = cardData.getWidthForMaxDimension(rowHeight); var attachmentWidths = 0; for (var i = 0; i < cardData.attachedCards.length; i++) - attachmentWidths += cardData.attachedCards[i].data("card").getWidthForHeight(rowHeight) * 0.2; + attachmentWidths += cardData.attachedCards[i].data("card").getWidthForMaxDimension(rowHeight) * 0.2; var cardWidthWithAttachments = cardWidth + attachmentWidths; if (x + cardWidthWithAttachments > this.width) { row++; @@ -245,12 +246,13 @@ var NormalCardGroup = CardGroup.extend({ } for (var i = 0; i < cardData.attachedCards.length; i++) { - var attachedCardWidth = cardData.attachedCards[i].data("card").getWidthForHeight(rowHeight); - this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, rowHeight, index); + var attachedCardData = cardData.attachedCards[i].data("card"); + var attachedCardWidth = attachedCardData.getWidthForMaxDimension(rowHeight); + this.layoutCard(cardData.attachedCards[i], this.x + x, this.y + y, attachedCardWidth, attachedCardData.getHeightForWidth(attachedCardWidth), index); x += Math.floor(attachedCardWidth * 0.2); index++; } - this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, rowHeight, index); + this.layoutCard(cardElem, this.x + x, this.y + y, cardWidth, cardData.getHeightForWidth(cardWidth), index); x += cardWidth; if (x > this.width) return false; diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCards.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCards.js index 17ea86114..6bec6f425 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCards.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCards.js @@ -107,6 +107,13 @@ var Card = Class.extend({ return Math.floor(height / cardScale); else return Math.floor(height * cardScale); + }, + + getWidthForMaxDimension: function(maxDimension) { + if (this.horizontal) + return maxDimension; + else + return Math.floor(maxDimension * cardScale); } });