source: main/trunk/model-sites-dev/cambridge-museum/collect/waikato-independent/pre-import/EditableDatabaseTable/WebContent/header-media/DataTables-1.10.22/js/dataTables.jqueryui.js@ 34511

Last change on this file since 34511 was 34511, checked in by davidb, 4 years ago

Evolution of code away from Company model to one that uses RecordHashmap to represent the rows coming out of the JDBC database

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