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.74 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.73 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.72 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.71 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.70 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.69 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.68 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.67 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.66 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.65 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.64 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.63 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.62 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.61 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.60 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.59 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.58 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.57 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.56 app/assets/javascripts/caboose/checkout/gift_cards_controller.js
caboose-cms-0.9.55 app/assets/javascripts/caboose/checkout/gift_cards_controller.js