Api - some basic support for printing popups

This commit is contained in:
nathangray 2019-03-15 16:01:25 -06:00
parent e7b06de719
commit c6f2f7f85e
3 changed files with 58 additions and 10 deletions

View File

@ -21,7 +21,7 @@
* *
* @augments et2_valueWidget * @augments et2_valueWidget
*/ */
var et2_tabbox = (function(){ "use strict"; return et2_valueWidget.extend([et2_IInput,et2_IResizeable], var et2_tabbox = (function(){ "use strict"; return et2_valueWidget.extend([et2_IInput,et2_IResizeable,et2_IPrint],
{ {
attributes: { attributes: {
'tabs': { 'tabs': {
@ -451,7 +451,7 @@ var et2_tabbox = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
}, },
getDOMNode: function(_sender) { getDOMNode: function(_sender) {
if (_sender == this) if (_sender === this || typeof _sender === 'undefined')
{ {
return this.container[0]; return this.container[0];
} }
@ -518,6 +518,43 @@ var et2_tabbox = (function(){ "use strict"; return et2_valueWidget.extend([et2_I
{ {
this.set_height(this.tabContainer.height()); this.set_height(this.tabContainer.height());
} }
},
/**
* Set up for printing
*
* @return {undefined|Deferred} Return a jQuery Deferred object if not done setting up
* (waiting for data)
*/
beforePrint: function()
{
// Remove the "active" flag from all tabs-flags
jQuery(".et2_tabflag", this.flagContainer).removeClass("active");
// Remove height limit
this.tabContainer.css("height", '');
// Show all enabled tabs
for (var i = 0; i < this.tabData.length; i++)
{
var entry = this.tabData[i];
if(entry.hidden) continue;
entry.flagDiv.insertBefore(entry.contentDiv);
entry.contentDiv.show();
}
},
/**
* Reset after printing
*/
afterPrint: function()
{
for (var i = 0; i < this.tabData.length; i++)
{
var entry = this.tabData[i];
entry.flagDiv.appendTo(this.flagContainer);
}
this.setActiveTab(this.get_active_tab());
} }
});}).call(this); });}).call(this);
et2_register_widget(et2_tabbox, ["tabbox"]); et2_register_widget(et2_tabbox, ["tabbox"]);

View File

@ -1090,13 +1090,15 @@ var fw_base = (function(){ "use strict"; return Class.extend(
}, },
/** /**
* Print function prints the active window * Print function prints the active window, or the provided window
*/ */
print: function() print: function(_window)
{ {
if (this.activeApp && this.activeApp.appName != 'manual') if (_window || this.activeApp && this.activeApp.appName != 'manual')
{ {
var appWindow = this.egw_appWindow(this.activeApp.appName); var appWindow = _window || this.egw_appWindow(this.activeApp.appName);
var content = (_window && appWindow === _window) ?
_window.document : this.activeApp.tab.contentDiv;
if (appWindow) if (appWindow)
{ {
appWindow.focus(); appWindow.focus();
@ -1104,8 +1106,8 @@ var fw_base = (function(){ "use strict"; return Class.extend(
// et2 available, let its widgets prepare // et2 available, let its widgets prepare
var deferred = []; var deferred = [];
var et2_list = []; var et2_list = [];
jQuery('.et2_container',this.activeApp.tab.contentDiv).each(function() { jQuery('.et2_container',content).each(function() {
var et2 = etemplate2.getById(this.id); var et2 = appWindow.etemplate2.getById(this.id);
if(et2 && jQuery(et2.DOMContainer).filter(':visible').length) if(et2 && jQuery(et2.DOMContainer).filter(':visible').length)
{ {
deferred = deferred.concat(et2.print()); deferred = deferred.concat(et2.print());
@ -1124,12 +1126,12 @@ var fw_base = (function(){ "use strict"; return Class.extend(
egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner'); egw.loading_prompt(app.appName,true,egw.lang('please wait...'),app.browser.baseDiv, egwIsMobile()?'horizental':'spinner');
// Give framework a chance to deal, then reset the etemplates // Give framework a chance to deal, then reset the etemplates
window.setTimeout(function() { appWindow.setTimeout(function() {
for(var i = 0; i < et2_list.length; i++) for(var i = 0; i < et2_list.length; i++)
{ {
et2_list[i].widgetContainer.iterateOver(function(_widget) { et2_list[i].widgetContainer.iterateOver(function(_widget) {
_widget.afterPrint(); _widget.afterPrint();
},et2_list[i],et2_IPrint); },et2_list[i],appWindow.et2_IPrint);
} }
egw.loading_prompt(app.appName,false); egw.loading_prompt(app.appName,false);
},100); },100);

View File

@ -1833,6 +1833,15 @@ ul[id$='favorites_popup_state'] span.filter_value {
height: auto !important; height: auto !important;
width: auto !important; width: auto !important;
} }
/** Show tab labels full width, with a little extra space */
.et2_tabbox .et2_tabflag {
width: 100%;
padding-top: 1em;
margin-bottom: 0.5em;
}
.et2_tabs {
overflow: visible;
}
} }
/** /**
* Grid / nextmatch Hierarchy * Grid / nextmatch Hierarchy