external.datatables.responsive-3.0.2.js.responsive.bootstrap.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ph-oton-bootstrap3-uictrls Show documentation
Show all versions of ph-oton-bootstrap3-uictrls Show documentation
Library wrapping Bootstrap 3 controls as Java web application components
The newest version!
/*! Bootstrap integration for DataTables' Responsive
* © SpryMedia Ltd - datatables.net/license
*/
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery', 'datatables.net-bs', 'datatables.net-responsive'], 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-bs')(root, $);
}
if ( ! $.fn.dataTable.Responsive ) {
require('datatables.net-responsive')(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 _display = DataTable.Responsive.display;
var _original = _display.modal;
var _modal = $(
'' +
'' +
'' +
' ' +
''
);
_display.modal = function (options) {
return function (row, update, render, closeCallback) {
if (!$.fn.modal) {
return _original(row, update, render, closeCallback);
}
else {
var rendered = render();
if (rendered === false) {
return false;
}
if (!update) {
if (options && options.header) {
var header = _modal.find('div.modal-header');
var button = header.find('button').detach();
header
.empty()
.append('' + options.header(row) + '
')
.prepend(button);
}
_modal.find('div.modal-body').empty().append(rendered);
_modal
.data('dtr-row-idx', row.index())
.one('hidden.bs.modal', closeCallback)
.appendTo('body')
.modal();
}
else {
if ($.contains(document, _modal[0]) && row.index() === _modal.data('dtr-row-idx')) {
_modal.find('div.modal-body').empty().append(rendered);
}
else {
// Modal not shown - do nothing
return null;
}
}
return true;
}
};
};
return DataTable;
}));