Daniel@0: "use strict"; Daniel@0: Daniel@0: App.module("MainRegionModule", function (MainRegionModule, App, Backbone, Marionette, $, _, Logger) { Daniel@0: Daniel@0: MainRegionModule.ConfigGridView = Backbone.View.extend({ Daniel@0: Daniel@0: options: { Daniel@0: state: null, Daniel@0: configGrid: null, Daniel@0: parentState: null, Daniel@0: parentContainerElement: null Daniel@0: }, Daniel@0: Daniel@0: _cachedConfigGridType: null, Daniel@0: Daniel@0: initialize: function(options) { Daniel@0: var _this = this; Daniel@0: _this.options = _.defaults(options || {}, this.options); Daniel@0: Daniel@0: _this._cachedConfigGridType = _this.options.configGrid.getType(); Daniel@0: _this.$el.setMod("config-grid", "type", _this._cachedConfigGridType); Daniel@0: Daniel@0: // Remove the loader and other utility text Daniel@0: _this.$(".config-grid__utils").empty(); Daniel@0: Daniel@0: // Set up the header Daniel@0: _this._$header = _this.$(".config-grid__header"); Daniel@0: _this._$header.html($("#config-grid__header_type_" + _this._cachedConfigGridType).text()); Daniel@0: _this._$header.click(function() { Daniel@0: _this.options.configGrid.set({ Daniel@0: selectedEntityConfigClientId: null, Daniel@0: selectedViewConfigClientId: null Daniel@0: }); Daniel@0: }); Daniel@0: Daniel@0: // Generate a ghost (an object that is shown when the view is being flipped) Daniel@0: _this.$ghost = _this.$el.clone(); Daniel@0: Daniel@0: // Init child views Daniel@0: _this.cellsView = new MainRegionModule.ConfigGridCellsView({ Daniel@0: state: _this.options.state, Daniel@0: configGrid: _this.options.configGrid, Daniel@0: el: _this.$(".config-grid-cells"), Daniel@0: parentConfigGridView: _this Daniel@0: }); Daniel@0: Daniel@0: _this.entityPanelView = new MainRegionModule.ConfigGridPanelView({ Daniel@0: el: _this.$(".config-grid-panel_dimension_entity"), Daniel@0: state: _this.options.state, Daniel@0: configGrid: _this.options.configGrid, Daniel@0: dimension: "entity", Daniel@0: parentConfigGridView: _this Daniel@0: }); Daniel@0: Daniel@0: _this.viewPanelView = new MainRegionModule.ConfigGridPanelView({ Daniel@0: el: _this.$(".config-grid-panel_dimension_view"), Daniel@0: state: _this.options.state, Daniel@0: configGrid: _this.options.configGrid, Daniel@0: dimension: "view", Daniel@0: parentConfigGridView: _this Daniel@0: }); Daniel@0: Daniel@0: _this.cellsView.on("change-positions-of-selected-headers", _.throttle(function(entityHeaderLeft, entityHeaderWidth, viewHeaderTop, viewHeaderHeight) { Daniel@0: _this.entityPanelView.updateRadiusFixer(entityHeaderLeft, entityHeaderWidth); Daniel@0: _this.viewPanelView .updateRadiusFixer(viewHeaderTop, viewHeaderHeight); Daniel@0: }, 100)); Daniel@0: }, Daniel@0: Daniel@0: render: function (deep, instant) { Daniel@0: var _this = this; Daniel@0: Daniel@0: if (deep) { Daniel@0: _this.cellsView.render(deep, instant); Daniel@0: _this.entityPanelView.render(deep, instant); Daniel@0: _this.viewPanelView.render(deep, instant); Daniel@0: } Daniel@0: }, Daniel@0: Daniel@0: isVisible: function() { Daniel@0: return !!this.el.getAttribute("data-active"); Daniel@0: }, Daniel@0: Daniel@0: scrollAccordingToSelection: function(deep, instant) { Daniel@0: this.cellsView.scrollAccordingToSelection(deep, instant); Daniel@0: }, Daniel@0: Daniel@0: ignoreAxisOnNextScroll: function(x, y) { Daniel@0: this.cellsView._ignoreXOnNextScroll = !!x; Daniel@0: this.cellsView._ignoreYOnNextScroll = !!y; Daniel@0: } Daniel@0: }); Daniel@0: }, Logger);