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

  class Proposals.ProposalsRegionLayout extends App.Views.Layout
    template: '#tpl_proposals_region_layout'
    className: 'proposals_region_layout'

    regions: 
      activeRegion : '#active_proposals_region'
      pastRegion : '#past_proposals_region'

  class Proposals.ProposalsLayout extends App.Views.Layout
    template: '#tpl_proposals_layout'
    className: 'proposals_layout'

    regions: 
      createRegion : '.proposals_create_region'
      proposalsRegion : '.proposals_list_region'
      sortRegion : '.sort_proposals_region'
      paginationRegion : '.proposals_pagination_region'

  class Proposals.CreateNewProposalView extends App.Views.ItemView
    template: '#tpl_create_new_proposal'
    className : 'new_proposal_view'

    events :
      'click .new-proposal-submit' : 'createNewProposal'

    createNewProposal : (ev) ->
      @trigger 'proposals:please_create_new'


  class Proposals.SortProposalsView extends App.Views.ItemView
    template: '#tpl_sort_proposals'
    sort_by : 'activity'
    className : 'proposals_sort_view'

    initialize : (options = {}) ->
      super options
      @listenTo @collection, 'reset', =>
        @applySortOrder()

      @listenTo App.vent, 'proposals:just_fetched_from_server', =>
        @render() 

    serializeData : ->
      sortable_fields : [ 
        {name: 'Most active', target: 'activity'}, 
        {name: 'Newness', target: 'created_at'} ]
      data_loaded : App.request "proposals:fetched_from_server?"

    applySortOrder : ->
      @$el.find(".sort_proposals_by.selected").removeClass 'selected'    
      @$el.find("[action='#{@sort_by}']").addClass 'selected'

    onShow : ->
      @applySortOrder()      

    events :
      'click .sort_proposals_by' : 'sortProposalsTo'

    sortProposalsTo : (ev) ->  
      @sort_by = $(ev.target).attr('action')
      @trigger 'proposals:please_sort', @sort_by
      @$el.moveToBottom()


  class Proposals.PaginationView extends App.Views.ItemView
    template: '#tpl_proposals_pagination'
    className: 'proposals_pagination_view'

    initialize : (options = {} ) ->
      super options
      @listenTo @collection, 'reset add remove', => @render()<commit_msg>proposals sorting newness => newest<commit_after>@ConsiderIt.module "Franklin.Proposals", (Proposals, App, Backbone, Marionette, $, _) ->

  class Proposals.ProposalsRegionLayout extends App.Views.Layout
    template: '#tpl_proposals_region_layout'
    className: 'proposals_region_layout'

    regions: 
      activeRegion : '#active_proposals_region'
      pastRegion : '#past_proposals_region'

  class Proposals.ProposalsLayout extends App.Views.Layout
    template: '#tpl_proposals_layout'
    className: 'proposals_layout'

    regions: 
      createRegion : '.proposals_create_region'
      proposalsRegion : '.proposals_list_region'
      sortRegion : '.sort_proposals_region'
      paginationRegion : '.proposals_pagination_region'

  class Proposals.CreateNewProposalView extends App.Views.ItemView
    template: '#tpl_create_new_proposal'
    className : 'new_proposal_view'

    events :
      'click .new-proposal-submit' : 'createNewProposal'

    createNewProposal : (ev) ->
      @trigger 'proposals:please_create_new'


  class Proposals.SortProposalsView extends App.Views.ItemView
    template: '#tpl_sort_proposals'
    sort_by : 'activity'
    className : 'proposals_sort_view'

    initialize : (options = {}) ->
      super options
      @listenTo @collection, 'reset', =>
        @applySortOrder()

      @listenTo App.vent, 'proposals:just_fetched_from_server', =>
        @render() 

    serializeData : ->
      sortable_fields : [ 
        {name: 'Most active', target: 'activity'}, 
        {name: 'Newest', target: 'created_at'} ]
      data_loaded : App.request "proposals:fetched_from_server?"

    applySortOrder : ->
      @$el.find(".sort_proposals_by.selected").removeClass 'selected'    
      @$el.find("[action='#{@sort_by}']").addClass 'selected'

    onShow : ->
      @applySortOrder()      

    events :
      'click .sort_proposals_by' : 'sortProposalsTo'

    sortProposalsTo : (ev) ->  
      @sort_by = $(ev.target).attr('action')
      @trigger 'proposals:please_sort', @sort_by
      @$el.moveToBottom()


  class Proposals.PaginationView extends App.Views.ItemView
    template: '#tpl_proposals_pagination'
    className: 'proposals_pagination_view'

    initialize : (options = {} ) ->
      super options
      @listenTo @collection, 'reset add remove', => @render()
{'fraction_non_alphanumeric': 0.11782542776694824, 'fraction_numerical': 0.0, 'mean_word_length': 3.5141739980449658, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '4226457', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1466, 'n_words': 252}