DebugMetricsLayoutView.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. define([ "require", "backbone", "hbs!tmpl/dev_debug/DebugMetricsLayoutView_tmpl", "utils/Utils" ], function(require, Backbone, DebugMetricsLayoutView_tmpl, Utils) {
  2. "use strict";
  3. var DebugMetricsLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "DebugMetricsLayoutView",
  5. template: DebugMetricsLayoutView_tmpl,
  6. regions: {
  7. RDebugMetricsLayoutView: "#r_debugMetricsLayoutView"
  8. },
  9. ui: {
  10. tablist: '[data-id="tab-list"] li'
  11. },
  12. events: function() {
  13. var events = {};
  14. return events["click " + this.ui.tablist] = function(e) {
  15. var tabValue = $(e.currentTarget).attr("role");
  16. Utils.setUrl({
  17. url: Utils.getUrlState.getQueryUrl().queyParams[0],
  18. urlParams: {
  19. tabActive: tabValue || "properties"
  20. },
  21. mergeBrowserUrl: !1,
  22. trigger: !1,
  23. updateTabState: !0
  24. });
  25. }, events;
  26. },
  27. initialize: function(options) {
  28. _.extend(this, _.pick(options, "value"));
  29. },
  30. onShow: function() {
  31. this.value && this.value.tabActive && (this.$(".nav.nav-tabs").find('[role="' + this.value.tabActive + '"]').addClass("active").siblings().removeClass("active"),
  32. this.$(".tab-content").find('[role="' + this.value.tabActive + '"]').addClass("active").siblings().removeClass("active"),
  33. $("html, body").animate({
  34. scrollTop: this.$(".tab-content").offset().top + 1200
  35. }, 1e3));
  36. },
  37. bindEvents: function() {},
  38. onRender: function() {
  39. this.metrice2LayoutView(), this.bindEvents();
  40. },
  41. metrice2LayoutView: function(obj) {
  42. var that = this;
  43. require([ "views/site/DebugMetricsTableLayoutView" ], function(DebugMetricsTableLayoutView) {
  44. that.RDebugMetricsLayoutView.show(new DebugMetricsTableLayoutView());
  45. });
  46. }
  47. });
  48. return DebugMetricsLayoutView;
  49. });