mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: SSF-168 refactoring print button so that it opens print view in a new window. This is useful for debugging and also useful for when someone wants to use the print view not for printing, but for viewing a clean version of a gridfield without the surrounding CMS, using the view for copying and pasting into another app, for example.
This commit is contained in:
parent
206c61fcd5
commit
14c3fd75a1
@ -119,15 +119,7 @@
|
||||
this.setUUID(new Date().getTime());
|
||||
},
|
||||
onclick: function(e){
|
||||
var self = this, iframeID = 'gridfield-print-iframe' + this.getUUID();
|
||||
var printIframe = $('#' + iframeID);
|
||||
|
||||
if(!printIframe.length){
|
||||
printIframe = $('<IFRAME id="'+iframeID+'" class="ss-gridfield-print-iframe">');
|
||||
$(document.body).append(printIframe);
|
||||
}
|
||||
|
||||
var self = this, btn = this.closest(':button'), grid = this.getGridField(),
|
||||
var btn = this.closest(':button'), grid = this.getGridField(),
|
||||
form = this.closest('form'), data = form.find(':input').serialize();
|
||||
|
||||
// Add current button
|
||||
@ -138,7 +130,8 @@
|
||||
if(window.location.search) data = window.location.search.replace(/^\?/, '') + '&' + data;
|
||||
|
||||
var url = $.path.makeUrlAbsolute(grid.data('url') + '?' + data, $('base').attr('href'));
|
||||
printIframe.attr('src', url);
|
||||
var newWindow = window.open(url);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
|
||||
<% if $Title %><title>$Title</title><% end_if %>
|
||||
</head>
|
||||
<body>
|
||||
<body onload="window.print();">
|
||||
<% if $Title %><h3>$Title</h3><% end_if %>
|
||||
<table>
|
||||
<thead>
|
||||
@ -21,4 +21,5 @@
|
||||
<% _t('GridField.PRINTEDBY', 'Printed by') %> $Member.Name
|
||||
</p>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user