1 | /*! Foundation integration for DataTables' Responsive
|
---|
2 | * ©2015 SpryMedia Ltd - datatables.net/license
|
---|
3 | */
|
---|
4 |
|
---|
5 | (function( factory ){
|
---|
6 | if ( typeof define === 'function' && define.amd ) {
|
---|
7 | // AMD
|
---|
8 | define( ['jquery', 'datatables.net-zf', 'datatables.net-responsive'], function ( $ ) {
|
---|
9 | return factory( $, window, document );
|
---|
10 | } );
|
---|
11 | }
|
---|
12 | else if ( typeof exports === 'object' ) {
|
---|
13 | // CommonJS
|
---|
14 | module.exports = function (root, $) {
|
---|
15 | if ( ! root ) {
|
---|
16 | root = window;
|
---|
17 | }
|
---|
18 |
|
---|
19 | if ( ! $ || ! $.fn.dataTable ) {
|
---|
20 | $ = require('datatables.net-zf')(root, $).$;
|
---|
21 | }
|
---|
22 |
|
---|
23 | if ( ! $.fn.dataTable.Responsive ) {
|
---|
24 | require('datatables.net-responsive')(root, $);
|
---|
25 | }
|
---|
26 |
|
---|
27 | return factory( $, root, root.document );
|
---|
28 | };
|
---|
29 | }
|
---|
30 | else {
|
---|
31 | // Browser
|
---|
32 | factory( jQuery, window, document );
|
---|
33 | }
|
---|
34 | }(function( $, window, document, undefined ) {
|
---|
35 | 'use strict';
|
---|
36 | var DataTable = $.fn.dataTable;
|
---|
37 |
|
---|
38 |
|
---|
39 | var _display = DataTable.Responsive.display;
|
---|
40 | var _original = _display.modal;
|
---|
41 |
|
---|
42 | _display.modal = function ( options ) {
|
---|
43 | return function ( row, update, render ) {
|
---|
44 | if ( ! $.fn.foundation ) {
|
---|
45 | _original( row, update, render );
|
---|
46 | }
|
---|
47 | else {
|
---|
48 | if ( ! update ) {
|
---|
49 | $( '<div class="reveal-modal" data-reveal/>' )
|
---|
50 | .append( '<a class="close-reveal-modal" aria-label="Close">×</a>' )
|
---|
51 | .append( options && options.header ? '<h4>'+options.header( row )+'</h4>' : null )
|
---|
52 | .append( render() )
|
---|
53 | .appendTo( 'body' )
|
---|
54 | .foundation( 'reveal', 'open' );
|
---|
55 | }
|
---|
56 | }
|
---|
57 | };
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 | return DataTable.Responsive;
|
---|
62 | }));
|
---|