PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Src/WS.EKA.Portal/Scripts/models/order/payment.js

http://mobileshop.codeplex.com
JavaScript | 63 lines | 56 code | 7 blank | 0 comment | 2 complexity | 94a4329a6c6cf2c7882e6faaea765b34 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. window.PaymentStyle = Backbone.Model.extend({});
  2. window.PaymentList = Backbone.Collection.extend({
  3. model: PaymentStyle,
  4. urlRoot: 'api/payment/',
  5. url: function () {
  6. return this.urlRoot;
  7. }
  8. });
  9. window.PaymentView = Backbone.View.extend({
  10. el: '#jqt',
  11. initialize: function () {
  12. this.template = $('#PaymentListTemplate').html();
  13. this.paymentList = new PaymentList();
  14. },
  15. events: {
  16. 'click .paymentList ul li': 'setPaymentStyle'
  17. },
  18. render: function () {
  19. var partial = { header: $('#HeaderTemplate').html(), footer: $('#FooterTemplate').html(),
  20. innerFooter: $('#InnerFooterTemplate').html()
  21. };
  22. var data = { hasBack: true, title: "??", btnListR: [{ name: 'home'}] };
  23. this.$el.append(Mustache.render(this.template, data, partial));
  24. if ($('#hidePaymentList').length > 0) {
  25. $('#PaymentList .paymentList').html($('#hidePaymentList').show());
  26. pageView.resizeScroll();
  27. } else {
  28. this.fetchPaymentList();
  29. }
  30. return this;
  31. },
  32. fetchPaymentList: function () {
  33. var that = this;
  34. this.paymentList.fetch({
  35. success: function () {
  36. var template = $('#PaymentListContentTemplate').html(),
  37. data = { payments: that.paymentList.toJSON() };
  38. $('#PaymentList .paymentList').html(Mustache.render(template, data, []));
  39. $('#hidePaymentList').show();
  40. pageView.resizeScroll();
  41. }
  42. });
  43. },
  44. setPaymentStyle: function (e) {
  45. var target = $(e.currentTarget),
  46. paymentid = target.attr('paymentid'),
  47. paymentstyle = target.text().trim();
  48. localStorage.setItem('paymentid', paymentid);
  49. pageView.goBack();
  50. }
  51. }, {
  52. renderPaymentHidden: function (payments) {
  53. var template = $('#PaymentListContentTemplate').html();
  54. $('#OrderMake').append(Mustache.render(template, { payments: payments }, []));
  55. }
  56. });