<commit_before>@ConsiderIt.module "Franklin", (Franklin, App, Backbone, Marionette, $, _) ->

  class Franklin.Router extends Marionette.AppRouter
    appRoutes : 
      "" : "Root"      
      ":proposal": "Consider"
      ":proposal/results": "Aggregate"
      ":proposal/points/:point" : "PointDetails"
      ":proposal/positions/:user_id" : "StaticPosition"


  API =
    Root: -> 
      region = App.request "default:region"

      return if @franklin_controller && @franklin_controller instanceof Franklin.Root.RootController && region.controlled_by == @franklin_controller

      App.request "sticky_footer:close"

      if @franklin_controller && (region.controlled_by != @franklin_controller || !(@franklin_controller instanceof Franklin.Root.RootController))
        @franklin_controller.close()
        @franklin_controller = null

      @franklin_controller = new Franklin.Root.RootController
        region : region

      region.controlled_by = @franklin_controller      

      App.vent.trigger 'route:completed', [ ['homepage', '/'] ]
      App.request 'meta:change:default'


    _transitionProposal: (proposal, new_state, crumbs) ->

      region = App.request 'default:region'

      from_root = @franklin_controller instanceof Franklin.Root.RootController && region.controlled_by == @franklin_controller && proposal.get('published') 

      if proposal.get('published')
        try
          proposal_controller = App.request "proposal_controller:#{proposal.id}"
        catch

      use_existing_proposal_controller = from_root && proposal_controller && proposal_controller.region

      if use_existing_proposal_controller
        $pel = $(proposal_controller.region.el)
        @franklin_controller.region.hideAllExcept $pel

      App.execute 'when:fetched', proposal, =>

        proposal_controller.upRoot() if use_existing_proposal_controller

        if @franklin_controller && @franklin_controller != proposal_controller
          @franklin_controller.close()
          @franklin_controller = null

        if @franklin_controller && @franklin_controller == proposal_controller || use_existing_proposal_controller
          proposal_controller.plant region if from_root
          proposal_controller.changeState new_state
        else<commit_msg>fix problem if you navigate from proposal page to user page and back again<commit_after>@ConsiderIt.module "Franklin", (Franklin, App, Backbone, Marionette, $, _) ->

  class Franklin.Router extends Marionette.AppRouter
    appRoutes : 
      "" : "Root"      
      ":proposal": "Consider"
      ":proposal/results": "Aggregate"
      ":proposal/points/:point" : "PointDetails"
      ":proposal/positions/:user_id" : "StaticPosition"


  API =
    Root: -> 
      region = App.request "default:region"

      return if @franklin_controller && @franklin_controller instanceof Franklin.Root.RootController && region.controlled_by == @franklin_controller

      App.request "sticky_footer:close"

      if @franklin_controller && (region.controlled_by != @franklin_controller || !(@franklin_controller instanceof Franklin.Root.RootController))
        @franklin_controller.close()
        @franklin_controller = null

      @franklin_controller = new Franklin.Root.RootController
        region : region

      region.controlled_by = @franklin_controller      

      App.vent.trigger 'route:completed', [ ['homepage', '/'] ]
      App.request 'meta:change:default'


    _transitionProposal: (proposal, new_state, crumbs) ->

      region = App.request 'default:region'

      from_root = @franklin_controller instanceof Franklin.Root.RootController && region.controlled_by == @franklin_controller && proposal.get('published') 

      if proposal.get('published')
        try
          proposal_controller = App.request "proposal_controller:#{proposal.id}"
        catch

      use_existing_proposal_controller = from_root && proposal_controller && proposal_controller.region

      if use_existing_proposal_controller
        $pel = $(proposal_controller.region.el)
        @franklin_controller.region.hideAllExcept $pel

      App.execute 'when:fetched', proposal, =>

        proposal_controller.upRoot() if use_existing_proposal_controller

        if @franklin_controller && @franklin_controller != proposal_controller
          @franklin_controller.close()
          @franklin_controller = null

        if @franklin_controller && (@franklin_controller == proposal_controller && region.controlled_by == @franklin_controller) || use_existing_proposal_controller
          proposal_controller.plant region if from_root
          proposal_controller.changeState new_state
        else
{'fraction_non_alphanumeric': 0.09912036043767432, 'fraction_numerical': 0.0, 'mean_word_length': 3.557184750733138, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2276112', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1263, 'n_words': 240}