APIs

Show:
  1. /**
  2. File menu / Top navigation control
  3. @class NavigationView
  4. @constructor
  5. @return {Object} instantiated FileMenu
  6. **/
  7. define(['jquery', 'backbone','TimelineMax', 'TweenMax', 'TutorialView'], function ($, Backbone, TimelineMax, TweenMax, TutorialView) {
  8.  
  9. BB.SERVICES.NAVIGATION_VIEW = 'NavigationView';
  10.  
  11. var NavigationView = BB.View.extend({
  12.  
  13. /**
  14. Constructor
  15. @method initialize all listeners on all navigation UI buttons
  16. **/
  17. initialize: function () {
  18. var self = this;
  19. self.m_limitedAccess = false;
  20. self.m_tutorialView = new TutorialView({el: Elements.LIVE_TUTORIAL});
  21.  
  22. this._render();
  23.  
  24. var appContentFaderView = BB.comBroker.getService(BB.SERVICES['APP_CONTENT_FADER_VIEW']);
  25. var appEntryFaderView = BB.comBroker.getService(BB.SERVICES['APP_ENTRY_FADER_VIEW']);
  26.  
  27. var appWidth = BB.comBroker.getService(BB.SERVICES.LAYOUT_ROUTER).getAppWidth();
  28. self._toggleIcons(appWidth);
  29.  
  30. BB.comBroker.listen(BB.EVENTS.APP_SIZED, $.proxy(self._onAppResized, self));
  31.  
  32. $(Elements.CLASS_NAV_SELECTION).on('click', function (e) {
  33. $(Elements.CLASS_NAV_SELECTION).removeClass(BB.lib.unclass(Elements.CLASS_NAV_ACTIVESEL));
  34. if ($(e.target.localName == 'span'))
  35. e.target = $(e.target).closest('li');
  36. e.target.addClass(BB.lib.unclass(Elements.CLASS_NAV_ACTIVESEL));
  37. });
  38.  
  39. $(Elements.CLASS_CAMPAIG_NMANAGER_VIEW).on('click', function () {
  40. self._checkLimitedAccess();
  41. appContentFaderView.selectView(Elements.CAMPAIGN_MANAGER_VIEW);
  42. self.resetPropertiesView();
  43. self._closeMobileNavigation();
  44. });
  45.  
  46. $(Elements.CLASS_RESOURCES_PANEL).on('click', function () {
  47. self._checkLimitedAccess();
  48. appContentFaderView.selectView(Elements.RESOURCES_PANEL);
  49. self.resetPropertiesView();
  50. self._closeMobileNavigation();
  51. });
  52.  
  53. $(Elements.CLASS_STATIONS_PANEL).on('click', function () {
  54. appContentFaderView.selectView(Elements.STATIONS_PANEL);
  55. self.resetPropertiesView();
  56. self._closeMobileNavigation();
  57. });
  58.  
  59. $(Elements.CLASS_SCENES_PANEL).on('click', function () {
  60. self._checkLimitedAccess();
  61. appContentFaderView.selectView(Elements.SCENES_PANEL);
  62. self.resetPropertiesView();
  63. self._closeMobileNavigation();
  64. });
  65.  
  66. $(Elements.CLASS_SETTINGS_PANEL).on('click', function () {
  67. appContentFaderView.selectView(Elements.SETTINGS_PANEL);
  68. self.resetPropertiesView();
  69. self._closeMobileNavigation();
  70. });
  71.  
  72. $(Elements.CLASS_FATSERQ_PANEL).on('click', function () {
  73. appContentFaderView.selectView(Elements.FASTERQ_PANEL);
  74. self.resetPropertiesView();
  75. self._closeMobileNavigation();
  76. });
  77.  
  78. $(Elements.CLASS_ADSTATS_PANEL).on('click', function () {
  79. appContentFaderView.selectView(Elements.AD_STATS_PANEL);
  80. self.resetPropertiesView();
  81. self._closeMobileNavigation();
  82. });
  83.  
  84. $(Elements.CLASSS_PRO_STUDIO_PANEL).on('click', function () {
  85. appContentFaderView.selectView(Elements.PRO_STUDIO_PANEL);
  86. self.resetPropertiesView();
  87. self._closeMobileNavigation();
  88. });
  89.  
  90. $(Elements.CLASS_HELP_PANEL).on('click', function () {
  91. appContentFaderView.selectView(Elements.HELP_PANEL);
  92. self.resetPropertiesView();
  93. self._closeMobileNavigation();
  94. });
  95.  
  96. $(Elements.CLASS_INSTALL_PANEL).on('click', function () {
  97. appContentFaderView.selectView(Elements.INSTALL_PANEL);
  98. self.resetPropertiesView();
  99. self._closeMobileNavigation();
  100. });
  101.  
  102. $(Elements.CLASS_LOGOUT_PANEL).on('click', function () {
  103. self.resetPropertiesView();
  104. appEntryFaderView.selectView(Elements.APP_LOGOUT);
  105. BB.comBroker.getService(BB.SERVICES['APP_AUTH']).logout();
  106. self._closeMobileNavigation();
  107. });
  108.  
  109. $(Elements.DASHBOARD).on('click', function () {
  110. self.resetPropertiesView();
  111. self._closeMobileNavigation();
  112. });
  113.  
  114. $(Elements.SAVE_CONFIG).on('click', function () {
  115. self.saveAndRestartPrompt(function () {
  116. });
  117. self._closeMobileNavigation();
  118. });
  119.  
  120. $(Elements.LIVE_CHAT).on('click', function () {
  121. window.open('http://www.digitalsignage.com/_html/live_chat.html', '_blank');
  122. self._closeMobileNavigation();
  123. });
  124.  
  125. $(Elements.LANGUAGE_PROMPT).on('click', function () {
  126. require(['LanguageSelectorView'], function (LanguageSelectorView) {
  127. var uniqueID = _.uniqueId('languagePrompt')
  128. var modal = bootbox.dialog({
  129. message: '<div id="' + uniqueID + '"></div>',
  130. title: $(Elements.MSG_BOOTBOX_COSTUME_TITLE).text(),
  131. show: false,
  132. buttons: {
  133. success: {
  134. label: '<i style="font-size: 1em" class="fa fa-forward "></i>',
  135. className: "btn-success",
  136. callback: function () {
  137. $('#' + uniqueID).empty();
  138. }
  139. }
  140. }
  141. });
  142. modal.modal("show");
  143. new LanguageSelectorView({appendTo: '#' + uniqueID});
  144. });
  145. });
  146. },
  147.  
  148. _closeMobileNavigation: function () {
  149. if ($('.navbar-header .navbar-toggle').css('display') != 'none') {
  150. $(".navbar-header .navbar-toggle").trigger("click");
  151. }
  152. },
  153.  
  154. /**
  155. Action on application resize
  156. @method _onAppResized
  157. @param {Event} e
  158. **/
  159. _onAppResized: function (e) {
  160. var self = this;
  161. self._toggleIcons(e.edata.width)
  162. },
  163.  
  164. /**
  165. Toggle visibility of navigation icons depending on app total width
  166. @method _toggleIcons
  167. @param {Number} i_size
  168. **/
  169. _toggleIcons: function (i_size) {
  170. if (i_size > 1500) {
  171. $(Elements.CLASS_NAV_ICONS).show();
  172. } else {
  173. $(Elements.CLASS_NAV_ICONS).hide();
  174. }
  175. },
  176.  
  177. /**
  178. Check is app is in limited access mode (station only) and if so show dialog model
  179. @method _checkLimitedAccess
  180. **/
  181. _checkLimitedAccess: function () {
  182. var self = this;
  183. if (self.m_limitedAccess) {
  184. self.forceStationOnlyViewAndDialog();
  185. }
  186. },
  187.  
  188. _render: function () {
  189. $('.navbar-nav').css({
  190. display: 'block'
  191. })
  192. },
  193.  
  194. /**
  195. Set the navigation as limited access since user authenticated with Pro credentials and not Lite credentials
  196. which allows access only to Stations module
  197. @method applyLimitedAccess
  198. **/
  199. applyLimitedAccess: function () {
  200. var self = this;
  201. self.m_limitedAccess = true;
  202. },
  203.  
  204. /**
  205. Force app into station only mode by showing dialog message to user and pushing back into Stations Panel
  206. @method forceStationOnlyViewAndDialog
  207. **/
  208. forceStationOnlyViewAndDialog: function () {
  209. var self = this;
  210. bootbox.dialog({
  211. message: $(Elements.MSG_BOOTBOX_LOGIN_WRONG_CRED).text(),
  212. title: $(Elements.MSG_BOOTBOX_LOGIN_PRO_CRED).text(),
  213. buttons: {
  214. info: {
  215. label: $(Elements.MSG_BOOTBOX_OK).text(),
  216. className: "btn-primary",
  217. callback: function () {
  218. self.selectNavigation(Elements.CLASS_STATIONS_PANEL);
  219. }
  220. }
  221. }
  222. });
  223. },
  224.  
  225. /**
  226. Reset back to default properties view which is the dashboard
  227. @method resetPropertiesView
  228. **/
  229. resetPropertiesView: function () {
  230. BB.comBroker.getService(BB.SERVICES['PROPERTIES_VIEW']).resetPropertiesView();
  231. },
  232.  
  233. /**
  234. Save and serialize configuration to remote mediaSERVER> Save and restart will check if
  235. the Stations module has been loaded and if no connected stations are present, it will NOT
  236. prompt for option to restart station on save, otherwise it will.
  237. @method saveAndRestartPrompt
  238. @param {Function} call back after save
  239. **/
  240. saveAndRestartPrompt: function (i_callBack) {
  241. var self = this;
  242. self.m_stationsListView = BB.comBroker.getService(BB.SERVICES['STATIONS_LIST_VIEW']);
  243. if (self.m_stationsListView != undefined) {
  244. var totalStations = self.m_stationsListView.getTotalActiveStation();
  245. if (totalStations == 0) {
  246. self.save(function () {
  247. });
  248. return;
  249. }
  250. }
  251.  
  252. bootbox.dialog({
  253. message: $(Elements.MSG_BOOTBOX_RESTART_STATIONS).text(),
  254. title: $(Elements.MSG_BOOTBOX_SAVE_REMOTE_SRV).text(),
  255. buttons: {
  256. success: {
  257. label: $(Elements.MSG_BOOTBOX_OK).text(),
  258. className: "btn-success",
  259. callback: function () {
  260. self.save(function () {
  261. });
  262. }
  263. },
  264. danger: {
  265. label: $(Elements.MSG_BOOTBOX_SAVE_RESTART).text(),
  266. className: "btn-success",
  267. callback: function () {
  268. self.save(function () {
  269. // reboot will reboot the PC or exits presentation android
  270. // pepper.sendCommand('rebootStation', -1, function () {});
  271. // reboot player exits player
  272. // pepper.sendCommand('rebootPlayer', -1, function () {
  273. // sync and restart does a fast / soft restart of player
  274. pepper.sendCommand('syncAndStart', -1, function () {
  275. });
  276.  
  277. });
  278. }
  279. },
  280. main: {
  281. label: $(Elements.MSG_BOOTBOX_CANCEL).text(),
  282. callback: function () {
  283. return;
  284. }
  285. }
  286. }
  287. });
  288. },
  289.  
  290. /**
  291. Save config to remote mediaSERVER
  292. @method save
  293. @params {Function} i_callBack
  294. **/
  295. save: function (i_callBack) {
  296. var self = this;
  297. var appEntryFaderView = BB.comBroker.getService(BB.SERVICES['APP_ENTRY_FADER_VIEW']);
  298. appEntryFaderView.selectView(Elements.WAITS_SCREEN_ENTRY_APP);
  299. pepper.stripScenePlayersIDs();
  300. pepper.save(function (i_status) {
  301. appEntryFaderView.selectView(Elements.APP_CONTENT);
  302. pepper.restoreScenesWithPlayersIDs();
  303. if (!i_status.status) {
  304. var msg;
  305. if (i_status.error.indexOf('There is no row') > -1) {
  306. msg = $(Elements.MSG_BOOTBOX_NEED_VERIFY_EMAIL).text()
  307. } else {
  308. msg = i_status.error;
  309. }
  310. bootbox.dialog({
  311. message: msg,
  312. title: $(Elements.MSG_BOOTBOX_PROBLEM_SAVING).text(),
  313. buttons: {
  314. danger: {
  315. label: $(Elements.MSG_BOOTBOX_OK).text(),
  316. className: "btn-danger",
  317. callback: function () {
  318. }
  319. }
  320. }
  321. });
  322. }
  323. BB.comBroker.fire(BB.EVENTS['SCENE_LIST_UPDATED'], self);
  324. i_callBack(i_status);
  325. });
  326. },
  327.  
  328. /**
  329. Select one of the navigation UI buttons by triggering a user click event thus allowing for soft navigation
  330. @method selectNavigation
  331. @param {String} elementID
  332. **/
  333. selectNavigation: function (elementID) {
  334. $(elementID).trigger('click');
  335. }
  336. });
  337.  
  338. return NavigationView;
  339. });
  340.  
  341.