/** * 全屏展示 * @description 点击全屏后以全屏方式展示内容 */ define(function(require, exports, module) { require('./fullscreengrid.css'); //var FullScreenChart = require('views/pages/fullscreenwindow/fullscreenchart'); this.args; function FullScreenWindow(args, callback) { var self = this; self.args = args; this.callback = callback; this.id = 'fullscreen_' + createGuid(); this.create(); window.onresize = function() { self.$container.css({ 'position': 'absolute', 'top': window.scrollY + 'px', 'left': '0px', 'background': 'white', 'height': function() { return window.innerHeight; }, 'width': function() { return window.innerWidth; }, 'display': '-webkit-flex', '-webkit-flex-direction': 'column', 'z-index': $.fn.window.defaults.zIndex + 1 }); self.resize(); }; } FullScreenWindow.prototype.create = function() { var self = this; $('body').append('
'); self.$container = $('#' + self.id); } FullScreenWindow.prototype.init = function() { }; FullScreenWindow.prototype.open = function() { var self = this; this.focusObj = document.activeElement; this.init(); self.$container.css({ 'position': 'absolute', 'top': window.scrollY + 'px', 'left': '0px', 'background':'white', 'height': function() { return window.innerHeight; }, 'width': function() { return window.innerWidth; }, 'display': '-webkit-flex', '-webkit-flex-direction': 'column', 'z-index': $.fn.window.defaults.zIndex + 1 }); $('body').width(self.$container.width()) .height(self.$container.height()) .css('overflow', 'hidden'); self.fillBody(); this.customerize(); this.resize(); }; FullScreenWindow.prototype.fillBody = function() { var self = this; this.toolbarContainer = $('
'); this.mainBodyContainer = $('
'); self.$container .append(this.toolbarContainer) .append(this.mainBodyContainer); } FullScreenWindow.prototype.close = function () { var self = this; if (this.focusObj) { $(this.focusObj).focus(); } var grid = self.args.gridfullscreenArgs.grid; if (grid) { var datagrid = grid.find('.report-grid'); if (datagrid) { datagrid.datagrid('resize', { height: 'auto' }); } } self.args.gridfullscreenArgs.toolbar.css('display','none'); if(self.callback && typeof self.callback === 'function') { self.callback(); } $('.page-container') .append(self.args.gridContainer) .append(self.args.paginationContainer) .append(self.args.toolContainerFullScreen); self.$container.remove(); $('body').css({ 'overflow': 'auto', 'width': 'auto' }); } FullScreenWindow.prototype.customerize = function() { var self = this; this.initToolbar(); this.initMain(); }; FullScreenWindow.prototype.initToolbar = function() { var self = this; self.args.gridfullscreenArgs.toolbar.css('display','-webkit-flex'); self.toolbarContainer.append(self.args.gridfullscreenArgs.toolbar); var closeButton = self.args.gridfullscreenArgs.toolbar.find('.fdpr-button-closeFullScreen'); if(closeButton) { closeButton.off('click').on('click', function(e) { self.close(); }); } var switchButton = self.args.gridfullscreenArgs.toolbar.find('.fdpr-button-switchtochart'); if(switchButton) { switchButton.off('click').on('click', function(e) { self.switch(); }); } }; FullScreenWindow.prototype.switch = function () { var self = this; self.close(); var fullScreenChart = new self.args.fullScreenChart(self.args, function() { }); fullScreenChart.open(); } FullScreenWindow.prototype.initMain = function() { var self = this; var grid = self.args.gridfullscreenArgs.grid, pagination = self.args.gridfullscreenArgs.pagination; self.mainBodyContainer .append(grid) .append(pagination); } FullScreenWindow.prototype.resize = function() { var self = this; self.mainBodyContainer.css({ "height": window.innerHeight - self.toolbarContainer.height() - self.args.gridfullscreenArgs.pagination.height() - 10 }); var grid = self.args.gridfullscreenArgs.grid; if (grid) { var datagrid = grid.find('.report-grid'); if (datagrid) { datagrid.datagrid('resize', { height: self.mainBodyContainer.height() }); } } } return FullScreenWindow; });