APIs

Show:
  1. /**
  2. Select a campaign name during new campaign creation wizard
  3. @class CampaignNameView
  4. @constructor
  5. @return {Object} instantiated CampaignNameView
  6. **/
  7. define(['jquery', 'backbone', 'video'], function ($, Backbone, video) {
  8.  
  9. BB.SERVICES.CAMPAIGN_NAME_SELECTOR_VIEW = 'CampaignNameSelectorView';
  10.  
  11. var CampaignNameSelectorView = Backbone.View.extend({
  12.  
  13. /**
  14. Constructor
  15. @method initialize
  16. **/
  17. initialize: function () {
  18. var self = this;
  19. self.m_campaignName = 'My campaign';
  20.  
  21. $(this.el).find(Elements.NEXT).on('click', function () {
  22. self.options.stackView.slideToPage(self.options.to, 'right');
  23. return false;
  24. });
  25. $(this.el).find(Elements.PREVIOUS).on('click', function () {
  26. self.options.stackView.slideToPage(self.options.from, 'left');
  27. return false;
  28. });
  29.  
  30. self._listenInputChange();
  31. },
  32.  
  33. /**
  34. Listen to changes in user campaign name input
  35. @method _listenInputChange
  36. @return none
  37. **/
  38. _listenInputChange: function () {
  39. var self = this;
  40. var onChange = _.debounce(function (e) {
  41. if (e.keyCode == 13) {
  42. self.options.stackView.slideToPage(self.options.to, 'right');
  43. return false;
  44. }
  45. self.m_campaignName = $(e.target).val();
  46. }, 150, false);
  47. $(Elements.NEW_CAMPAIGN_NAME).keyup(onChange);
  48. },
  49.  
  50. /**
  51. Returns the selected campaign name
  52. @method getCampaignName
  53. @return {String} campaign name
  54. **/
  55. getCampaignName: function () {
  56. var self = this;
  57. return self.m_campaignName;
  58. }
  59. });
  60.  
  61. return CampaignNameSelectorView;
  62.  
  63. });