Guest User

Untitled

a guest
Jan 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. var minimumHeight = 350,
  2. minimumWidth = 550,
  3. wnd = $(window),
  4. body = $('body'),
  5. verticalSplit = $('#verticalSplit'),
  6. unitSelectionContainer = $('#unitSelectionContainer'),
  7. mapContainer = $('#mapContainer').
  8. unitPickerContainer = $('#unitPickerContainer'),
  9. selectedUnits = $('#selectedUnits'),
  10. map = $('#map'),
  11. clock = $('#clock'),
  12. // save some lookups and assume top/right/bottom/left margins are the same
  13. bodyMargin = parseInt(body.css('margin-left'), 10),
  14. // innerWidth/Height doesn't work in IE, width()/height() doesn't include scrollbars in Chrome
  15. bodyWidth,
  16. bodyHeight,
  17. selectedUnitsHeight,
  18. mapWidth,
  19. toolbar,
  20. toolbarLeft,
  21. mapTop;
  22. console.log(unitPickerContainer);
  23. console.log(unitPickerContainer.height);
  24. // innerWidth/Height doesn't work in IE, width()/height() doesn't include scrollbars in Chrome
  25. bodyWidth = (wnd.attr('innerWidth') || wnd.width()) - (bodyMargin * 2);
  26. bodyHeight = (wnd.attr('innerHeight') || wnd.height()) - (bodyMargin * 2),
  27.  
  28. // constrain the width of the layout
  29. bodyWidth = (bodyWidth < minimumWidth) ? minimumWidth : bodyWidth;
  30. body.width(bodyWidth);
  31.  
  32. // constrain the height of the layout, taking the clock into account
  33. bodyHeight = (bodyHeight < minimumHeight) ? minimumHeight : bodyHeight;
  34. bodyHeight = ((clock.is(':visible') === true) ? bodyHeight - clock.outerHeight(true) : bodyHeight);
  35.  
  36. // IE7 fix (doesn't harm other browsers, so no conditional)
  37. bodyHeight -= 2;
  38.  
  39. verticalSplit.height(bodyHeight);
  40. mapContainer.height(bodyHeight);
  41. unitSelectionContainer.height(bodyHeight);
  42.  
  43. // the the unit picker minus the selected groups bucket should do the same
  44. selectedUnitsHeight = selectedUnits.outerHeight(true);
  45. console.log(unitPickerContainer);
  46. console.log(unitPickerContainer.height);
  47. unitPickerContainer.height(bodyHeight - selectedUnitsHeight - 1 /* extra pixel from unitPicker border-bottom */);
  48. unitSelectionContainer.width($('#verticalSplit > .splitter-bar-vertical').position().left);
  49. unitPickerContainer.width(unitSelectionContainer.width());
  50. selectedUnits.width(unitSelectionContainer.width());
  51.  
  52. // the map should fill out the available space
  53. map.height(bodyHeight - 2 /* 2px for borders? */);
  54. mapWidth = body.width() - /*$('#separator').width() - $('#separator').position().left*/ + 3;
  55. map.width(mapWidth);
  56.  
  57. // position the menu relative to the map
  58. toolbar = $('#toolbar');
  59. toolbarLeft = (bodyWidth - toolbar.width() - bodyMargin * 3);
  60. mapTop = map.position().top;
  61. toolbar.offset({ top: mapTop, left: toolbarLeft });
  62.  
  63. // dynamically set top/bottom borders on the unit picker
  64. unitPickerContainer.trigger('scroll');
  65. }
Add Comment
Please, Sign In to add comment