1(function ($, DataTable) { 2 "use strict"; 3 4 var _buildUrl = function(dt, action) { 5 var url = dt.ajax.url() || ''; 6 var params = dt.ajax.params(); 7 params.action = action; 8 9 delete params.columns; 10 11 var query = $.param(params); 12 13 return fixUrl(url.indexOf('?') >= 0 ? url + '&' + query : url + '?' + query); 14 }; 15 16 function fixUrl (url) { 17 return url.replace(/%5B/g, '[').replace(/%5D/g, ']'); 18 } 19 20 DataTable.ext.buttons.excel = { 21 className: 'buttons-excel', 22 23 text: function (dt) { 24 return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.excel', 'Excel'); 25 }, 26 27 action: function (e, dt, button, config) { 28 window.location = _buildUrl(dt, 'excel'); 29 } 30 }; 31 32 DataTable.ext.buttons.export = { 33 extend: 'collection', 34 35 className: 'buttons-export', 36 37 text: function (dt) { 38 return '<i class="fa fa-download"></i> ' + dt.i18n('buttons.export', 'Export') + ' <span class="caret"/>'; 39 }, 40 41 buttons: [ 'excel', 'ods', 'csv', 'pdf', 'json'] 42 }; 43 44 DataTable.ext.buttons.csv = { 45 className: 'buttons-csv', 46 47 text: function (dt) { 48 return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.csv', 'CSV'); 49 }, 50 51 action: function (e, dt, button, config) { 52 var url = _buildUrl(dt, 'csv'); 53 window.location = url; 54 } 55 }; 56 57 DataTable.ext.buttons.json = { 58 className: 'buttons-json', 59 60 text: function (dt) { 61 return '<i class="fa fa-file-text-o"></i> ' + dt.i18n('buttons.json', 'JSON'); 62 }, 63 64 action: function (e, dt, button, config) { 65 var url = _buildUrl(dt, 'json'); 66 window.location = url; 67 } 68 }; 69 70 DataTable.ext.buttons.ods = { 71 className: 'buttons-ods', 72 73 text: function (dt) { 74 return '<i class="fa fa-file-excel-o"></i> ' + dt.i18n('buttons.ods', 'ODS'); 75 }, 76 77 action: function (e, dt, button, config) { 78 var url = _buildUrl(dt, 'ods'); 79 window.location = url; 80 } 81 }; 82 83 DataTable.ext.buttons.pdf = { 84 className: 'buttons-pdf', 85 86 text: function (dt) { 87 return '<i class="fa fa-file-pdf-o"></i> ' + dt.i18n('buttons.pdf', 'PDF'); 88 }, 89 90 action: function (e, dt, button, config) { 91 var url = _buildUrl(dt, 'pdf'); 92 window.location = url; 93 } 94 }; 95 96 DataTable.ext.buttons.print = { 97 className: 'buttons-print', 98 99 text: function (dt) { 100 return '<i class="fa fa-print"></i> ' + dt.i18n('buttons.print', 'Print'); 101 }, 102 103 action: function (e, dt, button, config) { 104 var url = _buildUrl(dt, 'print'); 105 window.location = url; 106 } 107 }; 108 109 DataTable.ext.buttons.reset = { 110 className: 'buttons-reset', 111 112 text: function (dt) { 113 return '<i class="fa fa-undo"></i> ' + dt.i18n('buttons.reset', 'Reset'); 114 }, 115 116 action: function (e, dt, button, config) { 117 dt.search('').draw(); 118 } 119 }; 120 121 DataTable.ext.buttons.reload = { 122 className: 'buttons-reload', 123 124 text: function (dt) { 125 return '<i class="fa fa-refresh"></i> ' + dt.i18n('buttons.reload', 'Reload'); 126 }, 127 128 action: function (e, dt, button, config) { 129 dt.draw(false); 130 } 131 }; 132 133 DataTable.ext.buttons.create = { 134 className: 'buttons-create', 135 136 text: function (dt) { 137 return '<i class="fa fa-plus"></i> ' + dt.i18n('buttons.create', 'Create'); 138 }, 139 140 action: function (e, dt, button, config) { 141 window.location = window.location.href.replace(/\/+$/, "") + '/create'; 142 } 143 }; 144})(jQuery, jQuery.fn.dataTable);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.