def __init__(self, unique_str, content_element): """ Construct a content container, which is needed by iScroll for nice scrolling. Both the outer and inner container are required and they both must have unique ids for iScroll to work. Required: str unique_str the unique identifier of this content Element content_element the element that should be scrollable """ super(ContentWrapper, self).__init__() outer_container_id = "{}-{}".format( unique_str, self.OUTER_CONTAINER_CLASS) inner_container_id = "{}-{}".format( unique_str, self.INNER_CONTAINER_CLASS) self.set_id(outer_container_id) self.append_class(self.OUTER_CONTAINER_CLASS) inner_container = Div() inner_container.set_id(inner_container_id) inner_container.append_class(self.INNER_CONTAINER_CLASS) inner_container.append_child(content_element) self.append_child(inner_container)
def __init__(self, game): """ Construct a section with BoxscoreMedia. Required: Game game the game to create the boxscore from """ super(BoxscoreMedia, self).__init__() self.append_class(self.BOXSCORE_MEDIA_CLASS) # to allow the outer object to fit the screen width and still # wrap the inner floats floatable = FloatContainer() game_overview = Div() game_overview.append_class(self.GAME_OVERVIEW_CLASS) final = Span() final.set_text(Copy.final) game_overview.append_child(final) game_overview.append_child(SportComponent(game.sport)) floatable.append_child(game_overview) # FIXME: get_opponents breaks the contract that the view doesnt get # access to non-property methods in model.api.Game. # Generate Opponent groups. if game.is_rivalry: floatable.append_child(OpponentsResultGroup( game.get_opponents(game.winner_ids), Copy.won)) floatable.append_child(OpponentsResultGroup( game.get_opponents(game.loser_ids), Copy.lost)) else: floatable.append_child(OpponentsResultGroup( game.get_opponents(game.camaraderie_ids), Copy.played)) self.append_child(floatable)