Sha256: 253c2148e64cbbd72a49f01cbc5bc29dd70c87a31403e700683e02c69ed0a02e

Contents?: true

Size: 1.69 KB

Versions: 225

Compression:

Stored size: 1.69 KB

Contents

var GiftCardsController = function(params) { this.init(params); };

GiftCardsController.prototype = {

  cc: false,  
      
  init: function(params)
  {
    var that = this;
    for (var i in params)
      that[i] = params[i];
  },
    
  print: function()
  {
    var that = this;
    $('#gift_cards_container').empty();
  },
  
  edit: function()
  {    
    var that = this;
    var div = $('<div/>')
      .append($('<form/>')
        .attr('method', 'post')
        .submit(function(e) { that.apply_code($('#gift_card_code').val()); return false; })        
        .append($('<p/>')
          .append($('<input/>').attr('type', 'submit').attr('id', 'redeem_code_btn').val('Redeem Code'))
          .append($('<input/>').attr('type', 'text'  ).attr('id', 'gift_card_code').attr('placeholder', 'Gift card code'))          
        )
        .append($('<div/>').attr('id', 'gift_card_message'))
        .append($('<div/>').attr('id', 'gift_card_spacer'))
      );
    $('#gift_cards_container').empty().append(div);
  },
  
  apply_code: function(code)
  {
    var that = this;
    $('#gift_card_message').html("<p class='loading'>...</p>");    
    $.ajax({
      url: '/cart/gift-cards',
      type: 'post',
      data: { code: code },
      success: function(resp) {
        if (resp.error) $('#gift_card_message').html("<p class='note error'>" + resp.error + "</p>");
        if (resp.success)
        {          
          that.cc.invoice.total = parseFloat(resp.invoice_total);
          that.cc.refresh_cart();
          that.cc.payment_method_controller.print();                      
          $('#gift_card_code').val('');
          $('#gift_card_message').empty();
        }
      }        
    });    
  }
};

Version data entries

225 entries across 225 versions & 1 rubygems

Version Path
caboose-cms-0.9.154 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.153 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.152 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.151 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.150 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.149 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.148 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.147 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.146 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.145 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.144 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.143 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.142 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.141 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.140 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.139 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.138 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.137 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.136 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.135 app/assets/javascripts/caboose/checkout/gift_cards_controller.js