Sha256: dc6349c9956f6e1c958dc4a1b7fb5db19d807e764a83529fc33009f2a0bb1c98

Contents?: true

Size: 1.82 KB

Versions: 16

Compression:

Stored size: 1.82 KB

Contents

Dashboard.DaterangepickerView = Ember.View.extend Em.I18n.TranslateableProperties,
  templateName: 'daterangepicker'
  classNames: ['form-group']
  attributeBindings: [
    'start'
    'end'
  ]
  start: null
  end: null
  format: 'MMMM D, YYYY'
  serverFormat: 'YYYY-MM-DD'
  didInsertElement: ->
    format = @get('format')
    @$('.daterangepicker-input').daterangepicker
      locale: { cancelLabel: 'Clear' }
      format: format
      startDate: @get('start')
      endDate: @get('end')
      ranges:
        Today: [
          moment()
          moment()
        ]
        Yesterday: [
          moment().subtract('days', 1)
          moment().subtract('days', 1)
        ]
        'Last 7 Days': [
          moment().subtract('days', 6)
          moment()
        ]
        'Last 30 Days': [
          moment().subtract('days', 29)
          moment()
        ]
        'This Month': [
          moment().startOf('month')
          moment().endOf('month')
        ]
        'Last Month': [
          moment().subtract('month', 1).startOf('month')
          moment().subtract('month', 1).endOf('month')
        ]
    , (start, end) =>
      @set 'start', start.format(@get('serverFormat'))
      @set 'end', end.format(@get('serverFormat'))

    @$('.daterangepicker-input').on 'cancel.daterangepicker', (ev, picker) =>
      @$('.daterangepicker-input').val ''
      @set('start', '')
      @set('end', '')

    @$('.daterangepicker-input').on 'show.daterangepicker', (ev, picker) =>
      if Ember.isEmpty(@get('start')) && Ember.isEmpty(@get('end'))
        picker.setStartDate moment()
        picker.setEndDate moment()

    if !Ember.isEmpty(@get('start')) && !Ember.isEmpty(@get('end'))
      visibleDate = "#{moment(@get('start')).format(format)} - #{moment(@get('end')).format(format)}"
      @$('.daterangepicker-input').attr 'value', visibleDate

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dune-dashboard-1.1.5 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.1.4 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.1.3 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.1.2 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.1.1 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.1.0 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.9 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.8 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.7 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.6 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.5 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.4 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.3 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.2 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.1 app/assets/javascripts/views/daterangepicker.coffee
dune-dashboard-1.0.0 app/assets/javascripts/views/daterangepicker.coffee