Recherche des tweets de réponse avec l'API Tweeter
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
/*!
|
||||
* Column visibility buttons for Buttons and DataTables.
|
||||
* © 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
|
||||
var jq = require('jquery');
|
||||
var cjsRequires = function (root, $) {
|
||||
if ( ! $.fn.dataTable ) {
|
||||
require('datatables.net')(root, $);
|
||||
}
|
||||
|
||||
if ( ! $.fn.dataTable.Buttons ) {
|
||||
require('datatables.net-buttons')(root, $);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
// CommonJS environments without a window global must pass a
|
||||
// root. This will give an error otherwise
|
||||
root = window;
|
||||
}
|
||||
|
||||
if ( ! $ ) {
|
||||
$ = jq( root );
|
||||
}
|
||||
|
||||
cjsRequires( root, $ );
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
cjsRequires( window, jq );
|
||||
module.exports = factory( jq, window, window.document );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
|
||||
|
||||
|
||||
$.extend(DataTable.ext.buttons, {
|
||||
// A collection of column visibility buttons
|
||||
colvis: function (dt, conf) {
|
||||
var node = null;
|
||||
var buttonConf = {
|
||||
extend: 'collection',
|
||||
init: function (dt, n) {
|
||||
node = n;
|
||||
},
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.colvis', 'Column visibility');
|
||||
},
|
||||
className: 'buttons-colvis',
|
||||
closeButton: false,
|
||||
buttons: [
|
||||
{
|
||||
extend: 'columnsToggle',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Rebuild the collection with the new column structure if columns are reordered
|
||||
dt.on('column-reorder.dt' + conf.namespace, function () {
|
||||
dt.button(null, dt.button(null, node).node()).collectionRebuild([
|
||||
{
|
||||
extend: 'columnsToggle',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
return buttonConf;
|
||||
},
|
||||
|
||||
// Selected columns with individual buttons - toggle column visibility
|
||||
columnsToggle: function (dt, conf) {
|
||||
var columns = dt
|
||||
.columns(conf.columns)
|
||||
.indexes()
|
||||
.map(function (idx) {
|
||||
return {
|
||||
extend: 'columnToggle',
|
||||
columns: idx,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
|
||||
return columns;
|
||||
},
|
||||
|
||||
// Single button to toggle column visibility
|
||||
columnToggle: function (dt, conf) {
|
||||
return {
|
||||
extend: 'columnVisibility',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
},
|
||||
|
||||
// Selected columns with individual buttons - set column visibility
|
||||
columnsVisibility: function (dt, conf) {
|
||||
var columns = dt
|
||||
.columns(conf.columns)
|
||||
.indexes()
|
||||
.map(function (idx) {
|
||||
return {
|
||||
extend: 'columnVisibility',
|
||||
columns: idx,
|
||||
visibility: conf.visibility,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
|
||||
return columns;
|
||||
},
|
||||
|
||||
// Single button to set column visibility
|
||||
columnVisibility: {
|
||||
columns: undefined, // column selector
|
||||
text: function (dt, button, conf) {
|
||||
return conf._columnText(dt, conf);
|
||||
},
|
||||
className: 'buttons-columnVisibility',
|
||||
action: function (e, dt, button, conf) {
|
||||
var col = dt.columns(conf.columns);
|
||||
var curr = col.visible();
|
||||
|
||||
col.visible(
|
||||
conf.visibility !== undefined ? conf.visibility : !(curr.length ? curr[0] : false)
|
||||
);
|
||||
},
|
||||
init: function (dt, button, conf) {
|
||||
var that = this;
|
||||
button.attr('data-cv-idx', conf.columns);
|
||||
|
||||
dt.on('column-visibility.dt' + conf.namespace, function (e, settings) {
|
||||
if (!settings.bDestroying && settings.nTable == dt.settings()[0].nTable) {
|
||||
that.active(dt.column(conf.columns).visible());
|
||||
}
|
||||
}).on('column-reorder.dt' + conf.namespace, function () {
|
||||
// Button has been removed from the DOM
|
||||
if (conf.destroying) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dt.columns(conf.columns).count() !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This button controls the same column index but the text for the column has
|
||||
// changed
|
||||
that.text(conf._columnText(dt, conf));
|
||||
|
||||
// Since its a different column, we need to check its visibility
|
||||
that.active(dt.column(conf.columns).visible());
|
||||
});
|
||||
|
||||
this.active(dt.column(conf.columns).visible());
|
||||
},
|
||||
destroy: function (dt, button, conf) {
|
||||
dt.off('column-visibility.dt' + conf.namespace).off(
|
||||
'column-reorder.dt' + conf.namespace
|
||||
);
|
||||
},
|
||||
|
||||
_columnText: function (dt, conf) {
|
||||
if (typeof conf.text === 'string') {
|
||||
return conf.text;
|
||||
}
|
||||
|
||||
var title = dt.column(conf.columns).title();
|
||||
var idx = dt.column(conf.columns).index();
|
||||
|
||||
title = title
|
||||
.replace(/\n/g, ' ') // remove new lines
|
||||
.replace(/<br\s*\/?>/gi, ' ') // replace line breaks with spaces
|
||||
.replace(/<select(.*?)<\/select\s*>/gi, ''); // remove select tags, including options text
|
||||
|
||||
// Strip HTML comments
|
||||
title = DataTable.Buttons.stripHtmlComments(title);
|
||||
|
||||
// Use whatever HTML stripper DataTables is configured for
|
||||
title = DataTable.util.stripHtml(title).trim();
|
||||
|
||||
return conf.columnText ? conf.columnText(dt, idx, title) : title;
|
||||
}
|
||||
},
|
||||
|
||||
colvisRestore: {
|
||||
className: 'buttons-colvisRestore',
|
||||
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.colvisRestore', 'Restore visibility');
|
||||
},
|
||||
|
||||
init: function (dt, button, conf) {
|
||||
// Use a private parameter on the column. This gets moved around with the
|
||||
// column if ColReorder changes the order
|
||||
dt.columns().every(function () {
|
||||
var init = this.init();
|
||||
|
||||
if (init.__visOriginal === undefined) {
|
||||
init.__visOriginal = this.visible();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
action: function (e, dt, button, conf) {
|
||||
dt.columns().every(function (i) {
|
||||
var init = this.init();
|
||||
|
||||
this.visible(init.__visOriginal);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
colvisGroup: {
|
||||
className: 'buttons-colvisGroup',
|
||||
|
||||
action: function (e, dt, button, conf) {
|
||||
dt.columns(conf.show).visible(true, false);
|
||||
dt.columns(conf.hide).visible(false, false);
|
||||
|
||||
dt.columns.adjust();
|
||||
},
|
||||
|
||||
show: [],
|
||||
|
||||
hide: []
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return DataTable;
|
||||
}));
|
||||
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Column visibility buttons for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
!function(i){var o,e;"function"==typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(n){return i(n,window,document)}):"object"==typeof exports?(o=require("jquery"),e=function(n,t){t.fn.dataTable||require("datatables.net")(n,t),t.fn.dataTable.Buttons||require("datatables.net-buttons")(n,t)},"undefined"==typeof window?module.exports=function(n,t){return n=n||window,t=t||o(n),e(n,t),i(t,0,n.document)}:(e(window,o),module.exports=i(o,window,window.document))):i(jQuery,window,document)}(function(n,t,i){"use strict";var e=n.fn.dataTable;return n.extend(e.ext.buttons,{colvis:function(n,t){var i=null,o={extend:"collection",init:function(n,t){i=t},text:function(n){return n.i18n("buttons.colvis","Column visibility")},className:"buttons-colvis",closeButton:!1,buttons:[{extend:"columnsToggle",columns:t.columns,columnText:t.columnText}]};return n.on("column-reorder.dt"+t.namespace,function(){n.button(null,n.button(null,i).node()).collectionRebuild([{extend:"columnsToggle",columns:t.columns,columnText:t.columnText}])}),o},columnsToggle:function(n,t){return n.columns(t.columns).indexes().map(function(n){return{extend:"columnToggle",columns:n,columnText:t.columnText}}).toArray()},columnToggle:function(n,t){return{extend:"columnVisibility",columns:t.columns,columnText:t.columnText}},columnsVisibility:function(n,t){return n.columns(t.columns).indexes().map(function(n){return{extend:"columnVisibility",columns:n,visibility:t.visibility,columnText:t.columnText}}).toArray()},columnVisibility:{columns:void 0,text:function(n,t,i){return i._columnText(n,i)},className:"buttons-columnVisibility",action:function(n,t,i,o){var t=t.columns(o.columns),e=t.visible();t.visible(void 0!==o.visibility?o.visibility:!(e.length&&e[0]))},init:function(i,n,o){var e=this;n.attr("data-cv-idx",o.columns),i.on("column-visibility.dt"+o.namespace,function(n,t){t.bDestroying||t.nTable!=i.settings()[0].nTable||e.active(i.column(o.columns).visible())}).on("column-reorder.dt"+o.namespace,function(){o.destroying||1===i.columns(o.columns).count()&&(e.text(o._columnText(i,o)),e.active(i.column(o.columns).visible()))}),this.active(i.column(o.columns).visible())},destroy:function(n,t,i){n.off("column-visibility.dt"+i.namespace).off("column-reorder.dt"+i.namespace)},_columnText:function(n,t){var i,o;return"string"==typeof t.text?t.text:(o=n.column(t.columns).title(),i=n.column(t.columns).index(),o=o.replace(/\n/g," ").replace(/<br\s*\/?>/gi," ").replace(/<select(.*?)<\/select\s*>/gi,""),o=e.Buttons.stripHtmlComments(o),o=e.util.stripHtml(o).trim(),t.columnText?t.columnText(n,i,o):o)}},colvisRestore:{className:"buttons-colvisRestore",text:function(n){return n.i18n("buttons.colvisRestore","Restore visibility")},init:function(n,t,i){n.columns().every(function(){var n=this.init();void 0===n.__visOriginal&&(n.__visOriginal=this.visible())})},action:function(n,t,i,o){t.columns().every(function(n){var t=this.init();this.visible(t.__visOriginal)})}},colvisGroup:{className:"buttons-colvisGroup",action:function(n,t,i,o){t.columns(o.show).visible(!0,!1),t.columns(o.hide).visible(!1,!1),t.columns.adjust()},show:[],hide:[]}}),e});
|
||||
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Column visibility buttons for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
import jQuery from"jquery";import DataTable from"datatables.net";import Buttons from"datatables.net-buttons";let $=jQuery;$.extend(DataTable.ext.buttons,{colvis:function(n,t){var i=null,o={extend:"collection",init:function(n,t){i=t},text:function(n){return n.i18n("buttons.colvis","Column visibility")},className:"buttons-colvis",closeButton:!1,buttons:[{extend:"columnsToggle",columns:t.columns,columnText:t.columnText}]};return n.on("column-reorder.dt"+t.namespace,function(){n.button(null,n.button(null,i).node()).collectionRebuild([{extend:"columnsToggle",columns:t.columns,columnText:t.columnText}])}),o},columnsToggle:function(n,t){return n.columns(t.columns).indexes().map(function(n){return{extend:"columnToggle",columns:n,columnText:t.columnText}}).toArray()},columnToggle:function(n,t){return{extend:"columnVisibility",columns:t.columns,columnText:t.columnText}},columnsVisibility:function(n,t){return n.columns(t.columns).indexes().map(function(n){return{extend:"columnVisibility",columns:n,visibility:t.visibility,columnText:t.columnText}}).toArray()},columnVisibility:{columns:void 0,text:function(n,t,i){return i._columnText(n,i)},className:"buttons-columnVisibility",action:function(n,t,i,o){var t=t.columns(o.columns),e=t.visible();t.visible(void 0!==o.visibility?o.visibility:!(e.length&&e[0]))},init:function(i,n,o){var e=this;n.attr("data-cv-idx",o.columns),i.on("column-visibility.dt"+o.namespace,function(n,t){t.bDestroying||t.nTable!=i.settings()[0].nTable||e.active(i.column(o.columns).visible())}).on("column-reorder.dt"+o.namespace,function(){o.destroying||1===i.columns(o.columns).count()&&(e.text(o._columnText(i,o)),e.active(i.column(o.columns).visible()))}),this.active(i.column(o.columns).visible())},destroy:function(n,t,i){n.off("column-visibility.dt"+i.namespace).off("column-reorder.dt"+i.namespace)},_columnText:function(n,t){var i,o;return"string"==typeof t.text?t.text:(o=n.column(t.columns).title(),i=n.column(t.columns).index(),o=o.replace(/\n/g," ").replace(/<br\s*\/?>/gi," ").replace(/<select(.*?)<\/select\s*>/gi,""),o=DataTable.Buttons.stripHtmlComments(o),o=DataTable.util.stripHtml(o).trim(),t.columnText?t.columnText(n,i,o):o)}},colvisRestore:{className:"buttons-colvisRestore",text:function(n){return n.i18n("buttons.colvisRestore","Restore visibility")},init:function(n,t,i){n.columns().every(function(){var n=this.init();void 0===n.__visOriginal&&(n.__visOriginal=this.visible())})},action:function(n,t,i,o){t.columns().every(function(n){var t=this.init();this.visible(t.__visOriginal)})}},colvisGroup:{className:"buttons-colvisGroup",action:function(n,t,i,o){t.columns(o.show).visible(!0,!1),t.columns(o.hide).visible(!1,!1),t.columns.adjust()},show:[],hide:[]}});export default DataTable;
|
||||
@@ -0,0 +1,212 @@
|
||||
/*!
|
||||
* Column visibility buttons for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
import jQuery from 'jquery';
|
||||
import DataTable from 'datatables.net';
|
||||
import Buttons from 'datatables.net-buttons';
|
||||
|
||||
// Allow reassignment of the $ variable
|
||||
let $ = jQuery;
|
||||
|
||||
|
||||
$.extend(DataTable.ext.buttons, {
|
||||
// A collection of column visibility buttons
|
||||
colvis: function (dt, conf) {
|
||||
var node = null;
|
||||
var buttonConf = {
|
||||
extend: 'collection',
|
||||
init: function (dt, n) {
|
||||
node = n;
|
||||
},
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.colvis', 'Column visibility');
|
||||
},
|
||||
className: 'buttons-colvis',
|
||||
closeButton: false,
|
||||
buttons: [
|
||||
{
|
||||
extend: 'columnsToggle',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// Rebuild the collection with the new column structure if columns are reordered
|
||||
dt.on('column-reorder.dt' + conf.namespace, function () {
|
||||
dt.button(null, dt.button(null, node).node()).collectionRebuild([
|
||||
{
|
||||
extend: 'columnsToggle',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
return buttonConf;
|
||||
},
|
||||
|
||||
// Selected columns with individual buttons - toggle column visibility
|
||||
columnsToggle: function (dt, conf) {
|
||||
var columns = dt
|
||||
.columns(conf.columns)
|
||||
.indexes()
|
||||
.map(function (idx) {
|
||||
return {
|
||||
extend: 'columnToggle',
|
||||
columns: idx,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
|
||||
return columns;
|
||||
},
|
||||
|
||||
// Single button to toggle column visibility
|
||||
columnToggle: function (dt, conf) {
|
||||
return {
|
||||
extend: 'columnVisibility',
|
||||
columns: conf.columns,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
},
|
||||
|
||||
// Selected columns with individual buttons - set column visibility
|
||||
columnsVisibility: function (dt, conf) {
|
||||
var columns = dt
|
||||
.columns(conf.columns)
|
||||
.indexes()
|
||||
.map(function (idx) {
|
||||
return {
|
||||
extend: 'columnVisibility',
|
||||
columns: idx,
|
||||
visibility: conf.visibility,
|
||||
columnText: conf.columnText
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
|
||||
return columns;
|
||||
},
|
||||
|
||||
// Single button to set column visibility
|
||||
columnVisibility: {
|
||||
columns: undefined, // column selector
|
||||
text: function (dt, button, conf) {
|
||||
return conf._columnText(dt, conf);
|
||||
},
|
||||
className: 'buttons-columnVisibility',
|
||||
action: function (e, dt, button, conf) {
|
||||
var col = dt.columns(conf.columns);
|
||||
var curr = col.visible();
|
||||
|
||||
col.visible(
|
||||
conf.visibility !== undefined ? conf.visibility : !(curr.length ? curr[0] : false)
|
||||
);
|
||||
},
|
||||
init: function (dt, button, conf) {
|
||||
var that = this;
|
||||
button.attr('data-cv-idx', conf.columns);
|
||||
|
||||
dt.on('column-visibility.dt' + conf.namespace, function (e, settings) {
|
||||
if (!settings.bDestroying && settings.nTable == dt.settings()[0].nTable) {
|
||||
that.active(dt.column(conf.columns).visible());
|
||||
}
|
||||
}).on('column-reorder.dt' + conf.namespace, function () {
|
||||
// Button has been removed from the DOM
|
||||
if (conf.destroying) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dt.columns(conf.columns).count() !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This button controls the same column index but the text for the column has
|
||||
// changed
|
||||
that.text(conf._columnText(dt, conf));
|
||||
|
||||
// Since its a different column, we need to check its visibility
|
||||
that.active(dt.column(conf.columns).visible());
|
||||
});
|
||||
|
||||
this.active(dt.column(conf.columns).visible());
|
||||
},
|
||||
destroy: function (dt, button, conf) {
|
||||
dt.off('column-visibility.dt' + conf.namespace).off(
|
||||
'column-reorder.dt' + conf.namespace
|
||||
);
|
||||
},
|
||||
|
||||
_columnText: function (dt, conf) {
|
||||
if (typeof conf.text === 'string') {
|
||||
return conf.text;
|
||||
}
|
||||
|
||||
var title = dt.column(conf.columns).title();
|
||||
var idx = dt.column(conf.columns).index();
|
||||
|
||||
title = title
|
||||
.replace(/\n/g, ' ') // remove new lines
|
||||
.replace(/<br\s*\/?>/gi, ' ') // replace line breaks with spaces
|
||||
.replace(/<select(.*?)<\/select\s*>/gi, ''); // remove select tags, including options text
|
||||
|
||||
// Strip HTML comments
|
||||
title = DataTable.Buttons.stripHtmlComments(title);
|
||||
|
||||
// Use whatever HTML stripper DataTables is configured for
|
||||
title = DataTable.util.stripHtml(title).trim();
|
||||
|
||||
return conf.columnText ? conf.columnText(dt, idx, title) : title;
|
||||
}
|
||||
},
|
||||
|
||||
colvisRestore: {
|
||||
className: 'buttons-colvisRestore',
|
||||
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.colvisRestore', 'Restore visibility');
|
||||
},
|
||||
|
||||
init: function (dt, button, conf) {
|
||||
// Use a private parameter on the column. This gets moved around with the
|
||||
// column if ColReorder changes the order
|
||||
dt.columns().every(function () {
|
||||
var init = this.init();
|
||||
|
||||
if (init.__visOriginal === undefined) {
|
||||
init.__visOriginal = this.visible();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
action: function (e, dt, button, conf) {
|
||||
dt.columns().every(function (i) {
|
||||
var init = this.init();
|
||||
|
||||
this.visible(init.__visOriginal);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
colvisGroup: {
|
||||
className: 'buttons-colvisGroup',
|
||||
|
||||
action: function (e, dt, button, conf) {
|
||||
dt.columns(conf.show).visible(true, false);
|
||||
dt.columns(conf.hide).visible(false, false);
|
||||
|
||||
dt.columns.adjust();
|
||||
},
|
||||
|
||||
show: [],
|
||||
|
||||
hide: []
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default DataTable;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,300 @@
|
||||
/*!
|
||||
* Print button for Buttons and DataTables.
|
||||
* © 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
|
||||
var jq = require('jquery');
|
||||
var cjsRequires = function (root, $) {
|
||||
if ( ! $.fn.dataTable ) {
|
||||
require('datatables.net')(root, $);
|
||||
}
|
||||
|
||||
if ( ! $.fn.dataTable.Buttons ) {
|
||||
require('datatables.net-buttons')(root, $);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
module.exports = function (root, $) {
|
||||
if ( ! root ) {
|
||||
// CommonJS environments without a window global must pass a
|
||||
// root. This will give an error otherwise
|
||||
root = window;
|
||||
}
|
||||
|
||||
if ( ! $ ) {
|
||||
$ = jq( root );
|
||||
}
|
||||
|
||||
cjsRequires( root, $ );
|
||||
return factory( $, root, root.document );
|
||||
};
|
||||
}
|
||||
else {
|
||||
cjsRequires( window, jq );
|
||||
module.exports = factory( jq, window, window.document );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Browser
|
||||
factory( jQuery, window, document );
|
||||
}
|
||||
}(function( $, window, document ) {
|
||||
'use strict';
|
||||
var DataTable = $.fn.dataTable;
|
||||
|
||||
|
||||
|
||||
var _link = document.createElement('a');
|
||||
|
||||
/**
|
||||
* Clone link and style tags, taking into account the need to change the source
|
||||
* path.
|
||||
*
|
||||
* @param {node} el Element to convert
|
||||
*/
|
||||
var _styleToAbs = function (el) {
|
||||
var clone = $(el).clone()[0];
|
||||
|
||||
if (clone.nodeName.toLowerCase() === 'link') {
|
||||
clone.href = _relToAbs(clone.href);
|
||||
}
|
||||
|
||||
return clone.outerHTML;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a URL from a relative to an absolute address so it will work
|
||||
* correctly in the popup window which has no base URL.
|
||||
*
|
||||
* @param {string} href URL
|
||||
*/
|
||||
var _relToAbs = function (href) {
|
||||
// Assign to a link on the original page so the browser will do all the
|
||||
// hard work of figuring out where the file actually is
|
||||
_link.href = href;
|
||||
var 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 += '/';
|
||||
}
|
||||
|
||||
return _link.protocol + '//' + linkHost + _link.pathname + _link.search;
|
||||
};
|
||||
|
||||
DataTable.ext.buttons.print = {
|
||||
className: 'buttons-print',
|
||||
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.print', 'Print');
|
||||
},
|
||||
|
||||
action: function (e, dt, button, config, cb) {
|
||||
var data = dt.buttons.exportData(
|
||||
$.extend({ decodeEntities: false }, config.exportOptions) // XSS protection
|
||||
);
|
||||
var exportInfo = dt.buttons.exportInfo(config);
|
||||
|
||||
// Get the classes for the columns from the header cells
|
||||
var columnClasses = dt
|
||||
.columns(config.exportOptions.columns)
|
||||
.nodes()
|
||||
.map(function (n) {
|
||||
return n.className;
|
||||
})
|
||||
.toArray();
|
||||
|
||||
var addRow = function (d, tag) {
|
||||
var str = '<tr>';
|
||||
|
||||
for (var i = 0, ien = d.length; i < ien; i++) {
|
||||
// null and undefined aren't useful in the print output
|
||||
var dataOut = d[i] === null || d[i] === undefined ? '' : d[i];
|
||||
var classAttr = columnClasses[i]
|
||||
? 'class="' + columnClasses[i] + '"'
|
||||
: '';
|
||||
|
||||
str +=
|
||||
'<' +
|
||||
tag +
|
||||
' ' +
|
||||
classAttr +
|
||||
'>' +
|
||||
dataOut +
|
||||
'</' +
|
||||
tag +
|
||||
'>';
|
||||
}
|
||||
|
||||
return str + '</tr>';
|
||||
};
|
||||
|
||||
// Construct a table for printing
|
||||
var html = '<table class="' + dt.table().node().className + '">';
|
||||
|
||||
if (config.header) {
|
||||
var headerRows = data.headerStructure.map(function (row) {
|
||||
return (
|
||||
'<tr>' +
|
||||
row
|
||||
.map(function (cell) {
|
||||
return cell
|
||||
? '<th colspan="' +
|
||||
cell.colspan +
|
||||
'" rowspan="' +
|
||||
cell.rowspan +
|
||||
'">' +
|
||||
cell.title +
|
||||
'</th>'
|
||||
: '';
|
||||
})
|
||||
.join('') +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
|
||||
html += '<thead>' + headerRows.join('') + '</thead>';
|
||||
}
|
||||
|
||||
html += '<tbody>';
|
||||
for (var i = 0, ien = data.body.length; i < ien; i++) {
|
||||
html += addRow(data.body[i], 'td');
|
||||
}
|
||||
html += '</tbody>';
|
||||
|
||||
if (config.footer && data.footer) {
|
||||
var footerRows = data.footerStructure.map(function (row) {
|
||||
return (
|
||||
'<tr>' +
|
||||
row
|
||||
.map(function (cell) {
|
||||
return cell
|
||||
? '<th colspan="' +
|
||||
cell.colspan +
|
||||
'" rowspan="' +
|
||||
cell.rowspan +
|
||||
'">' +
|
||||
cell.title +
|
||||
'</th>'
|
||||
: '';
|
||||
})
|
||||
.join('') +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
|
||||
html += '<tfoot>' + footerRows.join('') + '</tfoot>';
|
||||
}
|
||||
html += '</table>';
|
||||
|
||||
// Open a new window for the printable table
|
||||
var win = window.open('', '');
|
||||
|
||||
if (!win) {
|
||||
dt.buttons.info(
|
||||
dt.i18n('buttons.printErrorTitle', 'Unable to open print view'),
|
||||
dt.i18n(
|
||||
'buttons.printErrorMsg',
|
||||
'Please allow popups in your browser for this site to be able to view the print view.'
|
||||
),
|
||||
5000
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
win.document.close();
|
||||
|
||||
// Inject the title and also a copy of the style and link tags from this
|
||||
// document so the table can retain its base styling. Note that we have
|
||||
// to use string manipulation as IE won't allow elements to be created
|
||||
// in the host document and then appended to the new window.
|
||||
var head = '<title>' + exportInfo.title + '</title>';
|
||||
$('style, link').each(function () {
|
||||
head += _styleToAbs(this);
|
||||
});
|
||||
|
||||
try {
|
||||
win.document.head.innerHTML = head; // Work around for Edge
|
||||
} catch (e) {
|
||||
$(win.document.head).html(head); // Old IE
|
||||
}
|
||||
|
||||
// Add any custom scripts (for example for paged.js)
|
||||
if (config.customScripts) {
|
||||
config.customScripts.forEach(function (script) {
|
||||
var tag = win.document.createElement("script");
|
||||
tag.src = script;
|
||||
win.document.getElementsByTagName("head")[0].appendChild(tag);
|
||||
});
|
||||
}
|
||||
|
||||
// Inject the table and other surrounding information
|
||||
win.document.body.innerHTML =
|
||||
'<h1>' +
|
||||
exportInfo.title +
|
||||
'</h1>' +
|
||||
'<div>' +
|
||||
(exportInfo.messageTop || '') +
|
||||
'</div>' +
|
||||
html +
|
||||
'<div>' +
|
||||
(exportInfo.messageBottom || '') +
|
||||
'</div>';
|
||||
|
||||
$(win.document.body).addClass('dt-print-view');
|
||||
|
||||
$('img', win.document.body).each(function (i, img) {
|
||||
img.setAttribute('src', _relToAbs(img.getAttribute('src')));
|
||||
});
|
||||
|
||||
if (config.customize) {
|
||||
config.customize(win, config, dt);
|
||||
}
|
||||
|
||||
// Allow stylesheets time to load
|
||||
var autoPrint = function () {
|
||||
if (config.autoPrint) {
|
||||
win.print(); // blocking - so close will not
|
||||
win.close(); // execute until this is done
|
||||
}
|
||||
};
|
||||
|
||||
win.setTimeout(autoPrint, 1000);
|
||||
|
||||
cb();
|
||||
},
|
||||
|
||||
async: 100,
|
||||
|
||||
title: '*',
|
||||
|
||||
messageTop: '*',
|
||||
|
||||
messageBottom: '*',
|
||||
|
||||
exportOptions: {},
|
||||
|
||||
header: true,
|
||||
|
||||
footer: true,
|
||||
|
||||
autoPrint: true,
|
||||
|
||||
customize: null
|
||||
};
|
||||
|
||||
|
||||
return DataTable;
|
||||
}));
|
||||
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Print button for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
!function(n){var o,r;"function"==typeof define&&define.amd?define(["jquery","datatables.net","datatables.net-buttons"],function(t){return n(t,window,document)}):"object"==typeof exports?(o=require("jquery"),r=function(t,e){e.fn.dataTable||require("datatables.net")(t,e),e.fn.dataTable.Buttons||require("datatables.net-buttons")(t,e)},"undefined"==typeof window?module.exports=function(t,e){return t=t||window,e=e||o(t),r(t,e),n(e,t,t.document)}:(r(window,o),module.exports=n(o,window,window.document))):n(jQuery,window,document)}(function(f,m,t){"use strict";function b(t){return n.href=t,-1===(t=n.host).indexOf("/")&&0!==n.pathname.indexOf("/")&&(t+="/"),n.protocol+"//"+t+n.pathname+n.search}var e=f.fn.dataTable,n=t.createElement("a");return e.ext.buttons.print={className:"buttons-print",text:function(t){return t.i18n("buttons.print","Print")},action:function(t,e,n,o,r){var i=e.buttons.exportData(f.extend({decodeEntities:!1},o.exportOptions)),a=e.buttons.exportInfo(o),u=e.columns(o.exportOptions.columns).nodes().map(function(t){return t.className}).toArray(),s='<table class="'+e.table().node().className+'">';o.header&&(s+="<thead>"+i.headerStructure.map(function(t){return"<tr>"+t.map(function(t){return t?'<th colspan="'+t.colspan+'" rowspan="'+t.rowspan+'">'+t.title+"</th>":""}).join("")+"</tr>"}).join("")+"</thead>"),s+="<tbody>";for(var c=0,d=i.body.length;c<d;c++)s+=function(t,e){for(var n="<tr>",o=0,r=t.length;o<r;o++){var i=null===t[o]||void 0===t[o]?"":t[o];n+="<"+e+" "+(u[o]?'class="'+u[o]+'"':"")+">"+i+"</"+e+">"}return n+"</tr>"}(i.body[c],"td");s+="</tbody>",o.footer&&i.footer&&(s+="<tfoot>"+i.footerStructure.map(function(t){return"<tr>"+t.map(function(t){return t?'<th colspan="'+t.colspan+'" rowspan="'+t.rowspan+'">'+t.title+"</th>":""}).join("")+"</tr>"}).join("")+"</tfoot>"),s+="</table>";var l=m.open("","");if(l){l.document.close();var p="<title>"+a.title+"</title>";f("style, link").each(function(){p+=function(t){t=f(t).clone()[0];return"link"===t.nodeName.toLowerCase()&&(t.href=b(t.href)),t.outerHTML}(this)});try{l.document.head.innerHTML=p}catch(t){f(l.document.head).html(p)}o.customScripts&&o.customScripts.forEach(function(t){var e=l.document.createElement("script");e.src=t,l.document.getElementsByTagName("head")[0].appendChild(e)}),l.document.body.innerHTML="<h1>"+a.title+"</h1><div>"+(a.messageTop||"")+"</div>"+s+"<div>"+(a.messageBottom||"")+"</div>",f(l.document.body).addClass("dt-print-view"),f("img",l.document.body).each(function(t,e){e.setAttribute("src",b(e.getAttribute("src")))}),o.customize&&o.customize(l,o,e);l.setTimeout(function(){o.autoPrint&&(l.print(),l.close())},1e3),r()}else e.buttons.info(e.i18n("buttons.printErrorTitle","Unable to open print view"),e.i18n("buttons.printErrorMsg","Please allow popups in your browser for this site to be able to view the print view."),5e3)},async:100,title:"*",messageTop:"*",messageBottom:"*",exportOptions:{},header:!0,footer:!0,autoPrint:!0,customize:null},e});
|
||||
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Print button for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
import jQuery from"jquery";import DataTable from"datatables.net";import Buttons from"datatables.net-buttons";let $=jQuery;var _link=document.createElement("a"),_styleToAbs=function(t){t=$(t).clone()[0];return"link"===t.nodeName.toLowerCase()&&(t.href=_relToAbs(t.href)),t.outerHTML},_relToAbs=function(t){_link.href=t;t=_link.host;return-1===t.indexOf("/")&&0!==_link.pathname.indexOf("/")&&(t+="/"),_link.protocol+"//"+t+_link.pathname+_link.search};DataTable.ext.buttons.print={className:"buttons-print",text:function(t){return t.i18n("buttons.print","Print")},action:function(t,e,o,n,r){var a=e.buttons.exportData($.extend({decodeEntities:!1},n.exportOptions)),i=e.buttons.exportInfo(n),s=e.columns(n.exportOptions.columns).nodes().map(function(t){return t.className}).toArray(),u='<table class="'+e.table().node().className+'">';n.header&&(u+="<thead>"+a.headerStructure.map(function(t){return"<tr>"+t.map(function(t){return t?'<th colspan="'+t.colspan+'" rowspan="'+t.rowspan+'">'+t.title+"</th>":""}).join("")+"</tr>"}).join("")+"</thead>"),u+="<tbody>";for(var l=0,c=a.body.length;l<c;l++)u+=function(t,e){for(var o="<tr>",n=0,r=t.length;n<r;n++){var a=null===t[n]||void 0===t[n]?"":t[n];o+="<"+e+" "+(s[n]?'class="'+s[n]+'"':"")+">"+a+"</"+e+">"}return o+"</tr>"}(a.body[l],"td");u+="</tbody>",n.footer&&a.footer&&(u+="<tfoot>"+a.footerStructure.map(function(t){return"<tr>"+t.map(function(t){return t?'<th colspan="'+t.colspan+'" rowspan="'+t.rowspan+'">'+t.title+"</th>":""}).join("")+"</tr>"}).join("")+"</tfoot>"),u+="</table>";var p=window.open("","");if(p){p.document.close();var d="<title>"+i.title+"</title>";$("style, link").each(function(){d+=_styleToAbs(this)});try{p.document.head.innerHTML=d}catch(t){$(p.document.head).html(d)}n.customScripts&&n.customScripts.forEach(function(t){var e=p.document.createElement("script");e.src=t,p.document.getElementsByTagName("head")[0].appendChild(e)}),p.document.body.innerHTML="<h1>"+i.title+"</h1><div>"+(i.messageTop||"")+"</div>"+u+"<div>"+(i.messageBottom||"")+"</div>",$(p.document.body).addClass("dt-print-view"),$("img",p.document.body).each(function(t,e){e.setAttribute("src",_relToAbs(e.getAttribute("src")))}),n.customize&&n.customize(p,n,e);p.setTimeout(function(){n.autoPrint&&(p.print(),p.close())},1e3),r()}else e.buttons.info(e.i18n("buttons.printErrorTitle","Unable to open print view"),e.i18n("buttons.printErrorMsg","Please allow popups in your browser for this site to be able to view the print view."),5e3)},async:100,title:"*",messageTop:"*",messageBottom:"*",exportOptions:{},header:!0,footer:!0,autoPrint:!0,customize:null};export default DataTable;
|
||||
@@ -0,0 +1,256 @@
|
||||
/*!
|
||||
* Print button for Buttons and DataTables.
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
|
||||
import jQuery from 'jquery';
|
||||
import DataTable from 'datatables.net';
|
||||
import Buttons from 'datatables.net-buttons';
|
||||
|
||||
// Allow reassignment of the $ variable
|
||||
let $ = jQuery;
|
||||
|
||||
|
||||
var _link = document.createElement('a');
|
||||
|
||||
/**
|
||||
* Clone link and style tags, taking into account the need to change the source
|
||||
* path.
|
||||
*
|
||||
* @param {node} el Element to convert
|
||||
*/
|
||||
var _styleToAbs = function (el) {
|
||||
var clone = $(el).clone()[0];
|
||||
|
||||
if (clone.nodeName.toLowerCase() === 'link') {
|
||||
clone.href = _relToAbs(clone.href);
|
||||
}
|
||||
|
||||
return clone.outerHTML;
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a URL from a relative to an absolute address so it will work
|
||||
* correctly in the popup window which has no base URL.
|
||||
*
|
||||
* @param {string} href URL
|
||||
*/
|
||||
var _relToAbs = function (href) {
|
||||
// Assign to a link on the original page so the browser will do all the
|
||||
// hard work of figuring out where the file actually is
|
||||
_link.href = href;
|
||||
var 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 += '/';
|
||||
}
|
||||
|
||||
return _link.protocol + '//' + linkHost + _link.pathname + _link.search;
|
||||
};
|
||||
|
||||
DataTable.ext.buttons.print = {
|
||||
className: 'buttons-print',
|
||||
|
||||
text: function (dt) {
|
||||
return dt.i18n('buttons.print', 'Print');
|
||||
},
|
||||
|
||||
action: function (e, dt, button, config, cb) {
|
||||
var data = dt.buttons.exportData(
|
||||
$.extend({ decodeEntities: false }, config.exportOptions) // XSS protection
|
||||
);
|
||||
var exportInfo = dt.buttons.exportInfo(config);
|
||||
|
||||
// Get the classes for the columns from the header cells
|
||||
var columnClasses = dt
|
||||
.columns(config.exportOptions.columns)
|
||||
.nodes()
|
||||
.map(function (n) {
|
||||
return n.className;
|
||||
})
|
||||
.toArray();
|
||||
|
||||
var addRow = function (d, tag) {
|
||||
var str = '<tr>';
|
||||
|
||||
for (var i = 0, ien = d.length; i < ien; i++) {
|
||||
// null and undefined aren't useful in the print output
|
||||
var dataOut = d[i] === null || d[i] === undefined ? '' : d[i];
|
||||
var classAttr = columnClasses[i]
|
||||
? 'class="' + columnClasses[i] + '"'
|
||||
: '';
|
||||
|
||||
str +=
|
||||
'<' +
|
||||
tag +
|
||||
' ' +
|
||||
classAttr +
|
||||
'>' +
|
||||
dataOut +
|
||||
'</' +
|
||||
tag +
|
||||
'>';
|
||||
}
|
||||
|
||||
return str + '</tr>';
|
||||
};
|
||||
|
||||
// Construct a table for printing
|
||||
var html = '<table class="' + dt.table().node().className + '">';
|
||||
|
||||
if (config.header) {
|
||||
var headerRows = data.headerStructure.map(function (row) {
|
||||
return (
|
||||
'<tr>' +
|
||||
row
|
||||
.map(function (cell) {
|
||||
return cell
|
||||
? '<th colspan="' +
|
||||
cell.colspan +
|
||||
'" rowspan="' +
|
||||
cell.rowspan +
|
||||
'">' +
|
||||
cell.title +
|
||||
'</th>'
|
||||
: '';
|
||||
})
|
||||
.join('') +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
|
||||
html += '<thead>' + headerRows.join('') + '</thead>';
|
||||
}
|
||||
|
||||
html += '<tbody>';
|
||||
for (var i = 0, ien = data.body.length; i < ien; i++) {
|
||||
html += addRow(data.body[i], 'td');
|
||||
}
|
||||
html += '</tbody>';
|
||||
|
||||
if (config.footer && data.footer) {
|
||||
var footerRows = data.footerStructure.map(function (row) {
|
||||
return (
|
||||
'<tr>' +
|
||||
row
|
||||
.map(function (cell) {
|
||||
return cell
|
||||
? '<th colspan="' +
|
||||
cell.colspan +
|
||||
'" rowspan="' +
|
||||
cell.rowspan +
|
||||
'">' +
|
||||
cell.title +
|
||||
'</th>'
|
||||
: '';
|
||||
})
|
||||
.join('') +
|
||||
'</tr>'
|
||||
);
|
||||
});
|
||||
|
||||
html += '<tfoot>' + footerRows.join('') + '</tfoot>';
|
||||
}
|
||||
html += '</table>';
|
||||
|
||||
// Open a new window for the printable table
|
||||
var win = window.open('', '');
|
||||
|
||||
if (!win) {
|
||||
dt.buttons.info(
|
||||
dt.i18n('buttons.printErrorTitle', 'Unable to open print view'),
|
||||
dt.i18n(
|
||||
'buttons.printErrorMsg',
|
||||
'Please allow popups in your browser for this site to be able to view the print view.'
|
||||
),
|
||||
5000
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
win.document.close();
|
||||
|
||||
// Inject the title and also a copy of the style and link tags from this
|
||||
// document so the table can retain its base styling. Note that we have
|
||||
// to use string manipulation as IE won't allow elements to be created
|
||||
// in the host document and then appended to the new window.
|
||||
var head = '<title>' + exportInfo.title + '</title>';
|
||||
$('style, link').each(function () {
|
||||
head += _styleToAbs(this);
|
||||
});
|
||||
|
||||
try {
|
||||
win.document.head.innerHTML = head; // Work around for Edge
|
||||
} catch (e) {
|
||||
$(win.document.head).html(head); // Old IE
|
||||
}
|
||||
|
||||
// Add any custom scripts (for example for paged.js)
|
||||
if (config.customScripts) {
|
||||
config.customScripts.forEach(function (script) {
|
||||
var tag = win.document.createElement("script");
|
||||
tag.src = script;
|
||||
win.document.getElementsByTagName("head")[0].appendChild(tag);
|
||||
});
|
||||
}
|
||||
|
||||
// Inject the table and other surrounding information
|
||||
win.document.body.innerHTML =
|
||||
'<h1>' +
|
||||
exportInfo.title +
|
||||
'</h1>' +
|
||||
'<div>' +
|
||||
(exportInfo.messageTop || '') +
|
||||
'</div>' +
|
||||
html +
|
||||
'<div>' +
|
||||
(exportInfo.messageBottom || '') +
|
||||
'</div>';
|
||||
|
||||
$(win.document.body).addClass('dt-print-view');
|
||||
|
||||
$('img', win.document.body).each(function (i, img) {
|
||||
img.setAttribute('src', _relToAbs(img.getAttribute('src')));
|
||||
});
|
||||
|
||||
if (config.customize) {
|
||||
config.customize(win, config, dt);
|
||||
}
|
||||
|
||||
// Allow stylesheets time to load
|
||||
var autoPrint = function () {
|
||||
if (config.autoPrint) {
|
||||
win.print(); // blocking - so close will not
|
||||
win.close(); // execute until this is done
|
||||
}
|
||||
};
|
||||
|
||||
win.setTimeout(autoPrint, 1000);
|
||||
|
||||
cb();
|
||||
},
|
||||
|
||||
async: 100,
|
||||
|
||||
title: '*',
|
||||
|
||||
messageTop: '*',
|
||||
|
||||
messageBottom: '*',
|
||||
|
||||
exportOptions: {},
|
||||
|
||||
header: true,
|
||||
|
||||
footer: true,
|
||||
|
||||
autoPrint: true,
|
||||
|
||||
customize: null
|
||||
};
|
||||
|
||||
|
||||
export default DataTable;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user