APIs

Show:
  1. /**
  2. Help Backbone > View
  3. @class Help
  4. @constructor
  5. @return {Object} instantiated Help
  6. **/
  7. define(['jquery', 'backbone', 'video'], function ($, Backbone, videojs) {
  8.  
  9. var HelpView = Backbone.View.extend({
  10.  
  11. /**
  12. Constructor
  13. @method initialize
  14. **/
  15. initialize: function () {
  16. var self = this;
  17. self._listenStopVideo();
  18. self._listenHelpLinks();
  19. self._listenWatchIntro();
  20. self._initVideo();
  21. },
  22.  
  23. /**
  24. Listen to watch intro button
  25. @method _listenWatchIntro
  26. **/
  27. _listenWatchIntro: function(){
  28. var self = this;
  29. $(Elements.CLASS_VIDEOS).click(function (e) {
  30. bootbox.hideAll();
  31. var videoName = $(e.target).attr('name');
  32. if (_.isUndefined(videoName))
  33. videoName = $(e.target).closest('button').attr('name');
  34.  
  35. $(Elements.VIDEO_INTRO).find('video:nth-child(1)').attr("src",videoName);
  36. $(Elements.VIDEO_MODAL).modal('show');
  37. var w = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppWidth() - 100;
  38. var h = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppHeight() - 200;;
  39. $(Elements.VIDEO_INTRO).width(w).height(h);
  40. });
  41. },
  42.  
  43. /**
  44. init HTML5 video.js component
  45. @method _initVideo
  46. **/
  47. _initVideo: function(){
  48. var self = this;
  49. videojs(BB.lib.unhash(Elements.VIDEO_INTRO)).ready(function () {
  50. self.m_videoPlayer = this;
  51. //var w = $(Elements.VIDEO_MODAL).width();
  52. //var h = $(Elements.VIDEO_MODAL).height() - 100;
  53. var w = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppWidth() - 100;
  54. var h = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppHeight() - 200;;
  55. $(Elements.VIDEO_INTRO).width(w).height(h);
  56. self.m_videoPlayer.load();
  57. //self.m_videoPlayer.play();
  58.  
  59. BB.comBroker.listen(BB.EVENTS.APP_SIZED, function(){
  60. var w = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppWidth() - 100;
  61. var h = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppHeight() - 200;;
  62. $(Elements.VIDEO_INTRO).width(w).height(h);
  63. });
  64. });
  65. },
  66.  
  67. /**
  68. Listen to help links clicks
  69. @method _listenHelpLinks
  70. **/
  71. _listenHelpLinks: function(){
  72. var self = this;
  73. $(Elements.CLASS_HELP_LINKS, self.$el).on('click', function (e) {
  74. var url = $(e.target).attr('href');
  75. window.open(url, '_blank');
  76. return false;
  77. });
  78. },
  79.  
  80. /**
  81. Listen to stop video clicks
  82. @method _listenStopVideo
  83. **/
  84. _listenStopVideo: function(){
  85. var self = this;
  86. var stopVideo = function(){
  87. self.m_videoPlayer.pause();
  88. self.m_videoPlayer.load();
  89. };
  90. $('.close').on('click',function(){
  91. stopVideo();
  92. });
  93. $(Elements.CLOSE_MODAL).on('click',function(){
  94. stopVideo();
  95. });
  96. }
  97. });
  98.  
  99. return HelpView;
  100. });
  101.  
  102.