comparison src/DML/MainVisBundle/Resources/assets/marionette/modules/MainRegionModule/MainRegionModule.02-ConfigGridView.js @ 0:493bcb69166c

added public content
author Daniel Wolff
date Tue, 09 Feb 2016 20:54:02 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:493bcb69166c
1 "use strict";
2
3 App.module("MainRegionModule", function (MainRegionModule, App, Backbone, Marionette, $, _, Logger) {
4
5 MainRegionModule.ConfigGridView = Backbone.View.extend({
6
7 options: {
8 state: null,
9 configGrid: null,
10 parentState: null,
11 parentContainerElement: null
12 },
13
14 _cachedConfigGridType: null,
15
16 initialize: function(options) {
17 var _this = this;
18 _this.options = _.defaults(options || {}, this.options);
19
20 _this._cachedConfigGridType = _this.options.configGrid.getType();
21 _this.$el.setMod("config-grid", "type", _this._cachedConfigGridType);
22
23 // Remove the loader and other utility text
24 _this.$(".config-grid__utils").empty();
25
26 // Set up the header
27 _this._$header = _this.$(".config-grid__header");
28 _this._$header.html($("#config-grid__header_type_" + _this._cachedConfigGridType).text());
29 _this._$header.click(function() {
30 _this.options.configGrid.set({
31 selectedEntityConfigClientId: null,
32 selectedViewConfigClientId: null
33 });
34 });
35
36 // Generate a ghost (an object that is shown when the view is being flipped)
37 _this.$ghost = _this.$el.clone();
38
39 // Init child views
40 _this.cellsView = new MainRegionModule.ConfigGridCellsView({
41 state: _this.options.state,
42 configGrid: _this.options.configGrid,
43 el: _this.$(".config-grid-cells"),
44 parentConfigGridView: _this
45 });
46
47 _this.entityPanelView = new MainRegionModule.ConfigGridPanelView({
48 el: _this.$(".config-grid-panel_dimension_entity"),
49 state: _this.options.state,
50 configGrid: _this.options.configGrid,
51 dimension: "entity",
52 parentConfigGridView: _this
53 });
54
55 _this.viewPanelView = new MainRegionModule.ConfigGridPanelView({
56 el: _this.$(".config-grid-panel_dimension_view"),
57 state: _this.options.state,
58 configGrid: _this.options.configGrid,
59 dimension: "view",
60 parentConfigGridView: _this
61 });
62
63 _this.cellsView.on("change-positions-of-selected-headers", _.throttle(function(entityHeaderLeft, entityHeaderWidth, viewHeaderTop, viewHeaderHeight) {
64 _this.entityPanelView.updateRadiusFixer(entityHeaderLeft, entityHeaderWidth);
65 _this.viewPanelView .updateRadiusFixer(viewHeaderTop, viewHeaderHeight);
66 }, 100));
67 },
68
69 render: function (deep, instant) {
70 var _this = this;
71
72 if (deep) {
73 _this.cellsView.render(deep, instant);
74 _this.entityPanelView.render(deep, instant);
75 _this.viewPanelView.render(deep, instant);
76 }
77 },
78
79 isVisible: function() {
80 return !!this.el.getAttribute("data-active");
81 },
82
83 scrollAccordingToSelection: function(deep, instant) {
84 this.cellsView.scrollAccordingToSelection(deep, instant);
85 },
86
87 ignoreAxisOnNextScroll: function(x, y) {
88 this.cellsView._ignoreXOnNextScroll = !!x;
89 this.cellsView._ignoreYOnNextScroll = !!y;
90 }
91 });
92 }, Logger);