/*! * Print button for Buttons and DataTables. * 2016 SpryMedia Ltd - datatables.net/license */ (function( factory ){ if ( typeof define === 'function' && define.amd ) { // AMD define( ['jquery', 'datatables.net', 'datatables.net-buttons'], function ( $ ) { return factory( $, window, document ); } ); } else if ( typeof exports === 'object' ) { // CommonJS module.exports = function (root, $) { if ( ! root ) { root = window; } if ( ! $ || ! $.fn.dataTable ) { $ = require('datatables.net')(root, $).$; } if ( ! $.fn.dataTable.Buttons ) { require('datatables.net-buttons')(root, $); } return factory( $, root, root.document ); }; } else { // Browser factory( jQuery, window, document ); } }(function( $, window, document, undefined ) { 'use strict'; var DataTable = $.fn.dataTable; var _link = document.createElement( 'a' ); /** * Convert a `link` tag's URL from a relative to an absolute address so it will * work correctly in the popup window which has no base URL. * * @param {node} el Element to convert */ var _relToAbs = function( el ) { var url; var clone = $(el).clone()[0]; var linkHost; if ( clone.nodeName.toLowerCase() === 'link' ) { _link.href = clone.href; linkHost = _link.host; // IE doesn't have a trailing slash on the host // Chrome has it on the pathname if ( linkHost.indexOf('/') === -1 && _link.pathname.indexOf('/') !== 0) { linkHost += '/'; } clone.href = _link.protocol+"//"+linkHost+_link.pathname+_link.search; } return clone.outerHTML; }; DataTable.ext.buttons.print = { className: 'buttons-print', text: function ( dt ) { return dt.i18n( 'buttons.print', 'Print' ); }, action: function ( e, dt, button, config ) { var data = dt.buttons.exportData( config.exportOptions ); var addRow = function ( d, tag ) { var str = '