| 9 |
lars |
1 |
/*! DataTables jQuery UI integration
|
|
|
2 |
* ©2011-2014 SpryMedia Ltd - datatables.net/license
|
|
|
3 |
*/
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
* DataTables integration for jQuery UI. This requires jQuery UI and
|
|
|
7 |
* DataTables 1.10 or newer.
|
|
|
8 |
*
|
|
|
9 |
* This file sets the defaults and adds options to DataTables to style its
|
|
|
10 |
* controls using jQuery UI. See http://datatables.net/manual/styling/jqueryui
|
|
|
11 |
* for further information.
|
|
|
12 |
*/
|
|
|
13 |
(function(window, document, undefined){
|
|
|
14 |
|
|
|
15 |
var factory = function( $, DataTable ) {
|
|
|
16 |
"use strict";
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
var sort_prefix = 'css_right ui-icon ui-icon-';
|
|
|
20 |
var toolbar_prefix = 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-';
|
|
|
21 |
|
|
|
22 |
/* Set the defaults for DataTables initialisation */
|
|
|
23 |
$.extend( true, DataTable.defaults, {
|
|
|
24 |
dom:
|
|
|
25 |
'<"'+toolbar_prefix+'tl ui-corner-tr"lfr>'+
|
|
|
26 |
't'+
|
|
|
27 |
'<"'+toolbar_prefix+'bl ui-corner-br"ip>',
|
|
|
28 |
renderer: 'jqueryui'
|
|
|
29 |
} );
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
$.extend( DataTable.ext.classes, {
|
|
|
33 |
"sWrapper": "dataTables_wrapper dt-jqueryui",
|
|
|
34 |
|
|
|
35 |
/* Full numbers paging buttons */
|
|
|
36 |
"sPageButton": "fg-button ui-button ui-state-default",
|
|
|
37 |
"sPageButtonActive": "ui-state-disabled",
|
|
|
38 |
"sPageButtonDisabled": "ui-state-disabled",
|
|
|
39 |
|
|
|
40 |
/* Features */
|
|
|
41 |
"sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
|
|
|
42 |
"ui-buttonset-multi paging_", /* Note that the type is postfixed */
|
|
|
43 |
|
|
|
44 |
/* Sorting */
|
|
|
45 |
"sSortAsc": "ui-state-default sorting_asc",
|
|
|
46 |
"sSortDesc": "ui-state-default sorting_desc",
|
|
|
47 |
"sSortable": "ui-state-default sorting",
|
|
|
48 |
"sSortableAsc": "ui-state-default sorting_asc_disabled",
|
|
|
49 |
"sSortableDesc": "ui-state-default sorting_desc_disabled",
|
|
|
50 |
"sSortableNone": "ui-state-default sorting_disabled",
|
|
|
51 |
"sSortIcon": "DataTables_sort_icon",
|
|
|
52 |
|
|
|
53 |
/* Scrolling */
|
|
|
54 |
"sScrollHead": "dataTables_scrollHead "+"ui-state-default",
|
|
|
55 |
"sScrollFoot": "dataTables_scrollFoot "+"ui-state-default",
|
|
|
56 |
|
|
|
57 |
/* Misc */
|
|
|
58 |
"sHeaderTH": "ui-state-default",
|
|
|
59 |
"sFooterTH": "ui-state-default"
|
|
|
60 |
} );
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
DataTable.ext.renderer.header.jqueryui = function ( settings, cell, column, classes ) {
|
|
|
64 |
// Calculate what the unsorted class should be
|
|
|
65 |
var noSortAppliedClass = sort_prefix+'carat-2-n-s';
|
|
|
66 |
var asc = $.inArray('asc', column.asSorting) !== -1;
|
|
|
67 |
var desc = $.inArray('desc', column.asSorting) !== -1;
|
|
|
68 |
|
|
|
69 |
if ( !column.bSortable || (!asc && !desc) ) {
|
|
|
70 |
noSortAppliedClass = '';
|
|
|
71 |
}
|
|
|
72 |
else if ( asc && !desc ) {
|
|
|
73 |
noSortAppliedClass = sort_prefix+'carat-1-n';
|
|
|
74 |
}
|
|
|
75 |
else if ( !asc && desc ) {
|
|
|
76 |
noSortAppliedClass = sort_prefix+'carat-1-s';
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
// Setup the DOM structure
|
|
|
80 |
$('<div/>')
|
|
|
81 |
.addClass( 'DataTables_sort_wrapper' )
|
|
|
82 |
.append( cell.contents() )
|
|
|
83 |
.append( $('<span/>')
|
|
|
84 |
.addClass( classes.sSortIcon+' '+noSortAppliedClass )
|
|
|
85 |
)
|
|
|
86 |
.appendTo( cell );
|
|
|
87 |
|
|
|
88 |
// Attach a sort listener to update on sort
|
|
|
89 |
$(settings.nTable).on( 'order.dt', function ( e, ctx, sorting, columns ) {
|
|
|
90 |
if ( settings !== ctx ) {
|
|
|
91 |
return;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
var colIdx = column.idx;
|
|
|
95 |
|
|
|
96 |
cell
|
|
|
97 |
.removeClass( classes.sSortAsc +" "+classes.sSortDesc )
|
|
|
98 |
.addClass( columns[ colIdx ] == 'asc' ?
|
|
|
99 |
classes.sSortAsc : columns[ colIdx ] == 'desc' ?
|
|
|
100 |
classes.sSortDesc :
|
|
|
101 |
column.sSortingClass
|
|
|
102 |
);
|
|
|
103 |
|
|
|
104 |
cell
|
|
|
105 |
.find( 'span.'+classes.sSortIcon )
|
|
|
106 |
.removeClass(
|
|
|
107 |
sort_prefix+'triangle-1-n' +" "+
|
|
|
108 |
sort_prefix+'triangle-1-s' +" "+
|
|
|
109 |
sort_prefix+'carat-2-n-s' +" "+
|
|
|
110 |
sort_prefix+'carat-1-n' +" "+
|
|
|
111 |
sort_prefix+'carat-1-s'
|
|
|
112 |
)
|
|
|
113 |
.addClass( columns[ colIdx ] == 'asc' ?
|
|
|
114 |
sort_prefix+'triangle-1-n' : columns[ colIdx ] == 'desc' ?
|
|
|
115 |
sort_prefix+'triangle-1-s' :
|
|
|
116 |
noSortAppliedClass
|
|
|
117 |
);
|
|
|
118 |
} );
|
|
|
119 |
};
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
/*
|
|
|
123 |
* TableTools jQuery UI compatibility
|
|
|
124 |
* Required TableTools 2.1+
|
|
|
125 |
*/
|
|
|
126 |
if ( DataTable.TableTools ) {
|
|
|
127 |
$.extend( true, DataTable.TableTools.classes, {
|
|
|
128 |
"container": "DTTT_container ui-buttonset ui-buttonset-multi",
|
|
|
129 |
"buttons": {
|
|
|
130 |
"normal": "DTTT_button ui-button ui-state-default"
|
|
|
131 |
},
|
|
|
132 |
"collection": {
|
|
|
133 |
"container": "DTTT_collection ui-buttonset ui-buttonset-multi"
|
|
|
134 |
}
|
|
|
135 |
} );
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
}; // /factory
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
// Define as an AMD module if possible
|
|
|
142 |
if ( typeof define === 'function' && define.amd ) {
|
|
|
143 |
define( ['jquery', 'datatables'], factory );
|
|
|
144 |
}
|
|
|
145 |
else if ( typeof exports === 'object' ) {
|
|
|
146 |
// Node/CommonJS
|
|
|
147 |
factory( require('jquery'), require('datatables') );
|
|
|
148 |
}
|
|
|
149 |
else if ( jQuery ) {
|
|
|
150 |
// Otherwise simply initialise as normal, stopping multiple evaluation
|
|
|
151 |
factory( jQuery, jQuery.fn.dataTable );
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
})(window, document);
|
|
|
156 |
|