PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://mobileshop.codeplex.com
JavaScript | 62 lines | 55 code | 7 blank | 0 comment | 2 complexity | 5b76e28f6bfc37dd4b7d4bd796d08d17 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. window.DispatchMode = Backbone.Model.extend({});
  2. window.DispatchModeList = Backbone.Collection.extend({
  3. model: DispatchMode,
  4. urlRoot: 'api/dispatchmode',
  5. url: function () {
  6. return this.urlRoot;
  7. }
  8. });
  9. window.DispatchView = Backbone.View.extend({
  10. el: '#jqt',
  11. initialize: function () {
  12. this.template = $('#DispatchModeListTemplate').html();
  13. this.dispatchList = new DispatchModeList();
  14. },
  15. events: {
  16. 'click .dispatchmodeList ul li': 'setDispatchMode'
  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 ($('#hideDispatchModeList').length > 0) {
  25. $('#DispatchModeList .dispatchmodeList').html($('#hideDispatchModeList').show());
  26. pageView.resizeScroll();
  27. } else {
  28. this.fetchDispatchModeList();
  29. }
  30. return this;
  31. },
  32. fetchDispatchModeList: function () {
  33. var that = this;
  34. this.dispatchList.fetch({
  35. success: function () {
  36. var template = $('#DispatchModeListContentTemplate').html(),
  37. data = { dispatchmodes: that.dispatchList.toJSON() };
  38. $('#DispatchModeList .dispatchmodeList').html(Mustache.render(template, data, []));
  39. $('#hideDispatchModeList').show();
  40. pageView.resizeScroll();
  41. }
  42. });
  43. },
  44. setDispatchMode: function (e) {
  45. var target = $(e.currentTarget),
  46. dispatchmodeid = target.attr('dispatchmodeid');
  47. localStorage.setItem('dispatchmodeid', dispatchmodeid);
  48. pageView.goBack();
  49. }
  50. }, {
  51. renderDispatchHidden: function (dispatchmodes) {
  52. var template = $('#DispatchModeListContentTemplate').html();
  53. $('#OrderMake').append(Mustache.render(template, { dispatchmodes: dispatchmodes }, []));
  54. }
  55. });