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