PageRenderTime 25ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/client/scripts/modules/ui.module.js

https://bitbucket.org/Fenchurch/isoel
JavaScript | 109 lines | 78 code | 20 blank | 11 comment | 1 complexity | 98c6e30be4fbdbd559c0663bc67271f5 MD5 | raw file
Possible License(s): GPL-2.0, WTFPL, MIT, BSD-3-Clause, Apache-2.0, 0BSD
  1. // welcome module
  2. /*
  3. Provides the first contact with the client. Prepares UI and prepares access to the applications' features
  4. */
  5. //
  6. define([
  7. 'jquery',
  8. 'underscore',
  9. 'backbone',
  10. 'views/splash.view',
  11. 'views/end.view',
  12. 'views/target.view',
  13. 'views/ui.basic.view',
  14. 'models/targetmark.model',
  15. ], function($, _, Backbone, SplashView, endView, targetView, UiBasicView, targetmarkModel){
  16. var module = Backbone.Collection.extend({
  17. views: new Backbone.Collection(),
  18. description: "ui-module",
  19. defaults: {},
  20. localStorage: null,
  21. initialize: function(items, options){
  22. this.socket = options.socket;
  23. this.ludare = options.ludare;
  24. // loading basic ui elements for the given DOM node or element: body
  25. this.ui = new UiBasicView({socket:this.socket, ui: this});
  26. this.ui.render();
  27. //display splashscreen
  28. // console.log("slots", this.ui.slots.popups);
  29. this.splashscreen = new SplashView({el: this.ui.slots.popups});
  30. this.endView = new endView({el: this.ui.slots.popups, model: this.ludare.data });
  31. this.targetView = new targetView({el: this.ui.slots.top, model: this.ludare.data });
  32. this.marker = new targetmarkModel();
  33. },
  34. message: function(data){
  35. this.noty({text:data});
  36. },
  37. displayFUN: function(){
  38. this.targetView.render()
  39. },
  40. displayEND: function(){
  41. this.endView.render();
  42. this.endView.$el.show(1000);
  43. },
  44. update:function(){
  45. var self = this;
  46. _.each(this.views.models, function(item){
  47. item.view.uiUpdate();
  48. });
  49. },
  50. targetMarker: function(item){
  51. this.marker.view && this.marker.view.unpin();
  52. this.marker.view.pin(item.mesh.position);
  53. },
  54. //takes a model and pins its inactive UI onto its view
  55. displayInformation: function(item){
  56. console.log(item);
  57. item.view.pin(item.view.mesh.position);
  58. },
  59. initNoty: function(){
  60. $.noty.defaultOptions = {
  61. layout : 'top', // (top, topLeft, topCenter, topRight, bottom, center, bottomLeft, bottomRight)
  62. theme : 'noty_theme_default', // theme name (accessable with CSS)
  63. animateOpen : {height: 'toggle'}, // opening animation
  64. animateClose : {height: 'toggle'}, // closing animation
  65. easing : 'swing', // easing
  66. text : '', // notification text
  67. type : 'alert', // noty type (alert, success, error)
  68. speed : 500, // opening & closing animation speed
  69. timeout : 5000, // delay for closing event. Set false for sticky notifications
  70. closeButton : false, // enables the close button when set to true
  71. closeOnSelfClick : true, // close the noty on self click when set to true
  72. closeOnSelfHover : false, // close the noty on self mouseover when set to true
  73. force : false, // adds notification to the beginning of queue when set to true
  74. onShow : false, // callback for on show
  75. onClose : false, // callback for on close
  76. buttons : false, // an array of buttons
  77. modal : false, // adds modal layer when set to true
  78. template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
  79. cssPrefix: 'noty_', // this variable will be a type and layout prefix.
  80. custom: {
  81. container: this.ui.slots.top // $('.custom_container')
  82. }
  83. };
  84. }
  85. });
  86. return module;
  87. });