APIs

Show:
  1. /**
  2. Orientation selector used to select new campaign orientation
  3. @class OrientationSelectorView
  4. @constructor
  5. @return {Object} instantiated OrientationSelectorView
  6. **/
  7. define(['jquery', 'backbone'], function ($, Backbone) {
  8.  
  9. BB.SERVICES.ORIENTATION_SELECTOR_VIEW = 'OrientationSelectorView';
  10. BB.CONSTS.VERTICAL = 'VERTICAL';
  11. BB.CONSTS.HORIZONTAL = 'HORIZONTAL';
  12. BB.CONSTS.ORIENTATION = 'ORIENTATION';
  13.  
  14. var OrientationSelectorView = BB.View.extend({
  15.  
  16. /**
  17. Constructor
  18. @method initialize
  19. **/
  20. initialize: function () {
  21. var self = this;
  22.  
  23. $(this.el).find(Elements.PREVIOUS).on('click',function(e){
  24. self.options.stackView.slideToPage(self.options.from, 'left');
  25. return false;
  26. });
  27.  
  28. $(Elements.IMG_HORIZONTAL).on('click', function () {
  29. self._selectOrientation(BB.CONSTS.HORIZONTAL);
  30. });
  31.  
  32. $(Elements.IMG_VERTICAL).on('click', function () {
  33. self._selectOrientation(BB.CONSTS.VERTICAL);
  34. });
  35. },
  36.  
  37. /**
  38. Select a particular orientation and optionally move to the next selection views through
  39. the ScreenArrowSelector instance.
  40. @method _selectOrientation
  41. @param {String} i_orientation
  42. **/
  43. _selectOrientation: function (i_orientation) {
  44. var self = this;
  45.  
  46. switch (i_orientation) {
  47. case BB.CONSTS.HORIZONTAL:
  48. {
  49. $(Elements.IMG_HORIZONTAL).css('opacity', '1');
  50. $(Elements.IMG_VERTICAL).css('opacity', '0.6');
  51. break;
  52. }
  53.  
  54. case BB.CONSTS.VERTICAL:
  55. {
  56. $(Elements.IMG_HORIZONTAL).css('opacity', '0.6');
  57. $(Elements.IMG_VERTICAL).css('opacity', '1');
  58. break;
  59. }
  60. }
  61.  
  62. self.model.set(BB.CONSTS.ORIENTATION, i_orientation);
  63. self.resolutionSelector = BB.comBroker.getService(BB.SERVICES.RESOLUTION_SELECTOR_VIEW);
  64. self.resolutionSelector.render();
  65. setTimeout(function () {
  66. self.options.stackView.slideToPage(self.options.to, 'right');
  67. }, 500);
  68. },
  69.  
  70. setOrientation: function(i_orientation){
  71. this.model.set(BB.CONSTS.ORIENTATION, i_orientation);
  72. },
  73.  
  74. getOrientation: function(){
  75. return this.model.get(BB.CONSTS.ORIENTATION);
  76. }
  77. });
  78.  
  79. return OrientationSelectorView;
  80.  
  81. });
  82.  
  83.