\\r\\n\\r\\n\";","import Split from \"split.js\";\r\nimport { autoinject,bindable } from 'aurelia-framework';\r\n\r\nimport {EventAggregator, Subscription} from \"aurelia-event-aggregator\";\r\nimport { Three_Sel } from \"../base-viewer-three-d/Three_Sel\";\r\n//import { Three_Sel } from \"app/project/quantity-takeoff/takeoff-viewer/takeoff-viewer\";\r\n\r\n@autoinject\r\nexport class BaseViewerCombined {\r\n\t@bindable threeSel:Three_Sel|undefined;\r\n\r\n\ttwoD_enabled:boolean = true;\r\n\r\n\t// (Note that we are NOT setting the @bindable decorator on this one.)\r\n\tBVC_openBimMode:boolean = true; // This is ONLY used in viewer-menu.html (we might even move it there.)\r\n\r\n private isViewerLoaded:boolean = false;\r\n private isSettingsVisible:boolean = false;\r\n\r\n private split: Split.Instance | undefined;\r\n private subscriptions: Subscription[] = [];\r\n\r\n\tprivate self:BaseViewerCombined;\r\n\r\n constructor(public events: EventAggregator) { this.self = this; }\r\n\r\n bind() {\r\n\t\tconsole.log('BaseViewerCombined.bind');\r\n this.subscriptions = [\r\n this.events.subscribe('WorkAreaContainer:ViewerSettingsPressed', () => { this.switchSettingsVisibility()}),\r\n this.events.subscribe('WorkAreaContainer:Move2d', () => { this.move2dViewDown()}),\r\n this.events.subscribe('base-viewer-combined:move2dView', () => { this.move2dView('event:_base-viewer-combined:move2dView',this.twoD_enabled)}),\r\n this.events.subscribe('base-viewer-combined:hide2d', () => { this.hide2dView()}),\r\n\r\n this.events.subscribe('base-viewer-combined:openBimModeToggled', (openBim:boolean) => { this.openBimModeToggled(openBim)}),\r\n ]\r\n }\r\n\topenBimModeToggled(openBim: boolean) { // (the subscribed event base-viewer-combined:openBimModeToggled)\r\n\t\tconsole.log('BVC.openBimModeToggled, event claims:', openBim, ', state BVC_openBimMode claims:', this.BVC_openBimMode);\r\n\t}\r\n\r\n hide2dView() { // a misguided? experiment.\r\n\t\tconsole.log('BaseViewerCombined.hide2dView, will now try to hide the 2d view. - twoD_enabled');\r\n\t\tthis.twoD_enabled = false;\r\n\r\n\t\t// Ser ikke ud til at virke.. is tied to concrete splitter IDs.\r\n\t\t//this.splitViewerResizeService.hide2dView();\t\t\r\n\r\n let smalldiv_2d: HTMLElement | null = document.getElementById('small-2d-view');\r\n let viewer_2d: HTMLElement | null = document.getElementById('viewer2d');\r\n if (!smalldiv_2d || !viewer_2d) { \r\n\t\t\tconsole.log('(nothing to hide)'); //'missing either', smalldiv_2d, viewer_2d)\r\n\t\t\treturn; \r\n\t\t} // can this work?\r\n\r\n\t\tconst is_viewerInSmallDiv:boolean = (smalldiv_2d.contains(viewer_2d));\r\n\t\tconsole.warn('was 2dviewer in smallDiv?', is_viewerInSmallDiv);\r\n\r\n if (!is_viewerInSmallDiv) { // ONLY do this, IFF viewer is NOT ALREADY a child of smallDiv!\r\n smalldiv_2d.style.visibility = \"none\"; // why not collapse?\r\n this.split?.setSizes([100,0]); \r\n console.log(`does split exist? [${this.split}]`,this.split );\r\n this.split?.destroy(); // her doer den for thomas. den bliver sur over, at den gutter den vil removeChild for ikke er i den forventede parent, eller omvendt.\r\n smalldiv_2d.appendChild(viewer_2d); // jeg har byttet om her, for at se om det hjaelper.\r\n // function destroy(preserveStyles, preserveGutter) \r\n }\r\n\r\n\t\t// both of these cause damage now - it refuses to resize..\r\n\t\t//this.move2dView('at end of hide2dView', true); //this.twoD_enabled);\r\n\t\t//this.move2dViewDown();//'at end of hide2dView'); // gav problemer\r\n\t\twindow.dispatchEvent(new Event('resize')); // THIS hack seems to work\r\n\t\tconsole.log('end of hide2dView');\r\n\t}\r\n\r\n move2dView(who:string, twoD_enabled:boolean) {\r\n let viewer_2d: HTMLElement | null = document.getElementById('viewer2d');\r\n let topView_3d: HTMLElement | null = document.getElementById('three-d-top');\r\n let bigDiv_2d: HTMLElement | null = document.getElementById('two-d-bottom');\r\n let smalldiv_2d: HTMLElement | null = document.getElementById('small-2d-view');\r\n\r\n\t\tconsole.log('BaseViewerCombined.move2dView, who:', who, 'twoD_enabled?', this.twoD_enabled, !!viewer_2d, !!topView_3d, !!bigDiv_2d, !!smalldiv_2d);\r\n\t\t//if (!this.twoD_enabled) { return; }\r\n\t\tif (!twoD_enabled) { return; }\r\n\r\n if (!smalldiv_2d || !viewer_2d || !bigDiv_2d) { return; } // (bah, forget about the resize-event below then.)\r\n\r\n\t\tif (smalldiv_2d.contains(viewer_2d)) {\r\n\t\t\tconsole.log('move2dView triggers handleDockTooBigDiv');\r\n\t\t\tthis.handleDockTooBigDiv(bigDiv_2d,viewer_2d,smalldiv_2d);\r\n\t\t} else { // (viewer_2d NOT currently in the smalldiv_2d)\r\n\t\t\tconsole.log('move2dView triggers destroySplit');\r\n\t\t\t// Make viewer_2d an inset overlayed on viewer3d, and let viewer3d take over all:\r\n\t\t\tsmalldiv_2d.style.visibility = \"visible\";\r\n\t\t\tsmalldiv_2d.appendChild(viewer_2d);\r\n\t\t\tthis.split?.setSizes([100,0]); \r\n\t\t\tthis.split?.destroy();\r\n\t\t} \r\n\r\n window.dispatchEvent(new Event('resize')); // hmm, why does that make sense, what does it do?\r\n }\r\n\r\n handleDockTooBigDiv(bigDiv: HTMLElement,viewer: HTMLElement,smalldiv: HTMLElement) {\r\n\t\tconsole.log('BaseViewerCombined.handleDockTooBigDiv');\r\n this.setupSplitter();\r\n bigDiv.appendChild(viewer);\r\n smalldiv.style.visibility = \"hidden\";\r\n this.split?.setSizes([50,50]); \r\n }\r\n\r\n move2dViewDown() {\r\n let viewer2d: HTMLElement | null = document.getElementById('viewer2d');\r\n let bigDiv: HTMLElement | null = document.getElementById('two-d-bottom');\r\n let smalldiv: HTMLElement | null = document.getElementById('small-2d-view');\r\n\r\n\t\tconst contains:boolean = !!(smalldiv && smalldiv.contains(viewer2d));\r\n if (smalldiv) {\r\n if (contains && bigDiv && viewer2d) {\r\n this.handleDockTooBigDiv(bigDiv,viewer2d,smalldiv);\r\n window.dispatchEvent(new Event('resize'));\r\n }\r\n }\r\n\t\tconsole.log('BaseViewerCombined.move2dViewDown, (smalldiv,contain,big,2d):', !!smalldiv, contains, !!bigDiv, !!viewer2d);\r\n }\r\n\r\n unbind() {\r\n\t\tconsole.log('BaseViewerCombined.unbind');\r\n this.subscriptions.forEach(subscription => subscription.dispose());\r\n }\r\n\r\n async attached() {\r\n console.log('base-viewer-combined:attached');\r\n await this.setupSplitter();\r\n this.move2dView('attached',this.twoD_enabled); //In quantity-takeoff it was wanted to start with the 2d-view docked to the 3d-view.\r\n }\r\n\r\n async switchSettingsVisibility() {\r\n\t\tconsole.log('BaseViewerCombined.switchSettingsVisibility');\r\n this.isViewerLoaded = true;\r\n this.isSettingsVisible = !this.isSettingsVisible;\r\n }\r\n\r\n async setupSplitter(): Promise {\r\n\t\tconsole.log('BaseViewerCombined.setupSplitter');\r\n\r\n if (document.getElementById('three-d-top') == null || document.getElementById('two-d-bottom') == null) { return; }\r\n\r\n\t\tthis.split = Split(['#three-d-top','#two-d-bottom'], {\r\n\t\t\tminSize: 0,\r\n\t\t\tgutterSize: 13,\r\n\t\t\tdirection: 'vertical',\r\n\t\t\tonDrag: function (sizes: any) {\r\n\t\t\t\twindow.dispatchEvent(new Event('resize'));\r\n\t\t\t},\r\n\t\t\tsizes:[50,50]\r\n\t\t});\r\n \r\n }\r\n \r\n}\r\n"],"names":["___CSS_LOADER_EXPORT___","push","module","id","exports","BaseViewerCombined","constructor","events","twoD_enabled","BVC_openBimMode","isViewerLoaded","isSettingsVisible","subscriptions","this","self","bind","console","log","subscribe","switchSettingsVisibility","move2dViewDown","move2dView","hide2dView","openBim","openBimModeToggled","smalldiv_2d","document","getElementById","viewer_2d","is_viewerInSmallDiv","contains","warn","style","visibility","split","setSizes","destroy","appendChild","window","dispatchEvent","Event","who","topView_3d","bigDiv_2d","handleDockTooBigDiv","bigDiv","viewer","smalldiv","setupSplitter","viewer2d","unbind","forEach","subscription","dispose","async","minSize","gutterSize","direction","onDrag","sizes","bindable","autoinject"],"sourceRoot":""}