Sha256: 2c1181d08a74df83ece0c4ffe19c25888d3f621ea4a46d3973100d11b29f8ef5

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

$(function(){
  if($('.js-zones-form').length){
    Spree.Views.Zones.FormZipBased = Backbone.View.extend({
      events: {
        'click [name="zone[kind]"]': 'render'
      },

      render: function() {
        var kind = this.$('[name="zone[kind]"]:checked').val() || 'state';

        $('#zip_members').toggleClass('hidden', kind !== 'zip');
        $('#zip_members :input').prop('disabled', kind !== 'zip');
      }
    })

    var view = new Spree.Views.Zones.FormZipBased({
      el: $('.js-zones-form')
    });
    view.render()
  } else {
    $('#country_based, #state_based').click(function(){
      $('#zip_members #zone_zipcodes').prop('disabled', true)
      $('#zip_members').hide()
    })

    $('#zip_based').click(function(){
      $('#zip_members #zone_zipcodes').prop('disabled', false)
      $('#zip_members').show()

      $('#country_members :input, #state_members :input').each(function(){
        $(this).prop('disabled', true)
      })
      $('#country_members, #state_members').hide()
    })

    if($('#zone_zipcodes').val() != ''){
      $('#zip_based').click()
    } else {
      $('#zip_members').hide()
    }
  }

  $(".select2-taggable").select2({
    tags: true,
    tokenSeparators: [',', ' ']
  })
})

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_zip_zones-0.1.0 app/assets/javascripts/spree/backend/views/zones/form_zip_based.js