├── README.md ├── examples ├── dt1.10 │ ├── ajax-bootstrap3.html │ ├── arrays.txt │ ├── dom-bootstrap3.html │ └── js │ │ ├── ajax-bootstrap3.js │ │ └── dom-bootstrap3.js └── dt1.9 │ ├── ajax-bootstrap2-recreate-table.html │ ├── ajax-bootstrap2.html │ ├── ajax-bootstrap3.html │ ├── arrays.txt │ ├── arrays2.txt │ ├── dom-bootstrap2-multiple-table.html │ ├── dom-bootstrap2.html │ └── js │ ├── ajax-bootstrap2-recreate-table.js │ ├── ajax-bootstrap2.js │ ├── ajax-bootstrap3.js │ ├── dom-bootstrap2-multiple-table.js │ └── dom-bootstrap2.js ├── files ├── 1.10 │ ├── css │ │ └── datatables.responsive.css │ ├── img │ │ ├── minus.png │ │ └── plus.png │ └── js │ │ └── datatables.responsive.js └── 1.9 │ ├── css │ └── datatables.responsive.css │ ├── img │ ├── minus.png │ └── plus.png │ └── js │ └── datatables.responsive.js ├── license-bsd.txt └── license-gpl2.txt /README.md: -------------------------------------------------------------------------------- 1 | # datatables-responsive 2 | 3 | ## Introduction 4 | [Datatables][1] is hands down the best [jQuery][2] table plugin. I have enjoyed using it over the years and highly recommend it to all. Recently, I have tried to use Datatables in an responsive web project. Datatables did everything brilliantly but was not responsive. After some research, I found [FooTable][3] which handles the responsive behavior perfectly. After tinkering around, I've come up with something that helps make Datatables respond like FooTable. 5 | 6 | Complete working [examples][4] are provided using [Bootstrap][5]. You may use any front-end framework you prefer. 7 | 8 | Below are the instructions on how to use the helper. 9 | 10 | ## Add Viewport Meta Tag For Mobile Support 11 | 12 | Add the following viewport meta tag to your HTML's head section: 13 | 14 | ```html 15 | 16 | ``` 17 | 18 | ## Include CSS files 19 | 20 | Add Bootstrap, Datatables-Bootstrap and responsive Datatables helper CSS files. 21 | 22 | **DataTables 1.9.x and Bootstrap 3.x** 23 | 24 | ```html 25 | 26 | 27 | 28 | 29 | ``` 30 | If you are using Bootstrap 2, see the `ajax-bootstrap2.html` example. 31 | 32 | **DataTables 1.10.x and Bootstrap 3.x** 33 | 34 | ```html 35 | 36 | 37 | 38 | 39 | ``` 40 | 41 | 42 | For more information on Datatables and Bootstrap 2, see 43 | [http://www.datatables.net/blog/Twitter_Bootstrap][6] 44 | [http://www.datatables.net/blog/Twitter_Bootstrap_2][7] 45 | 46 | For Bootstrap 3, see 47 | [https://github.com/DataTables/Plugins/tree/master/integration/bootstrap/3][8] 48 | 49 | ## Include JS files 50 | 51 | Add jQuery, Datatables, Datables-Bootstrap and the responsive Datatables helper scripts. 52 | 53 | **DataTables 1.9.x and Bootstrap 3.x** 54 | 55 | ```html 56 | 57 | 58 | 59 | 60 | ``` 61 | **DataTables 1.10.x and Bootstrap 3.x** 62 | 63 | ```html 64 | 65 | 66 | 67 | 68 | ``` 69 | 70 | ## Create variables and break point definitions. 71 | 72 | ```javascript 73 | var responsiveHelper; 74 | var breakpointDefinition = { 75 | tablet: 1024, 76 | phone : 480 77 | }; 78 | var tableElement = $('#example'); 79 | ``` 80 | 81 | 82 | ## Create Datatables Instance 83 | Create the datatables instance with the following 84 | 85 | ### DataTables 1.9.x 86 | 87 | - Set `bAutoWidth` to `false`. 88 | - Set `fnPreDrawCallback` to only initialize the responsive datatables helper once 89 | - Set `fnRowCallback` to create expand icon. 90 | - Set `fnDrawCallback` to respond to window `resize` events. 91 | 92 | **DataTables 1.9.x and Responsive Helper Initialization** 93 | 94 | ```javascript 95 | tableElement.dataTable({ 96 | 97 | // Setup for Bootstrap support. 98 | sPaginationType : 'bootstrap', 99 | oLanguage : { 100 | sLengthMenu: '_MENU_ records per page' 101 | }, 102 | 103 | // Setup for responsive datatables helper. 104 | bAutoWidth : false, 105 | fnPreDrawCallback: function () { 106 | // Initialize the responsive datatables helper once. 107 | if (!responsiveHelper) { 108 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 109 | } 110 | }, 111 | fnRowCallback : function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { 112 | responsiveHelper.createExpandIcon(nRow); 113 | }, 114 | fnDrawCallback : function (oSettings) { 115 | responsiveHelper.respond(); 116 | } 117 | 118 | }); 119 | ``` 120 | 121 | ### DataTables 1.10.x 122 | 123 | - Set `autoWidth` to `false`. 124 | - Set `preDrawCallback` to only initialize the responsive datatables helper once 125 | - Set `rowCallback` to create expand icon. 126 | - Set `drawCallback` to respond to window `resize` events. 127 | 128 | **DataTables 1.10.x and Responsive Helper Initialization** 129 | 130 | ```javascript 131 | tableElement.dataTable({ 132 | autoWidth : false, 133 | preDrawCallback: function () { 134 | // Initialize the responsive datatables helper once. 135 | if (!responsiveHelper) { 136 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 137 | } 138 | }, 139 | rowCallback : function (nRow) { 140 | responsiveHelper.createExpandIcon(nRow); 141 | }, 142 | drawCallback : function (oSettings) { 143 | responsiveHelper.respond(); 144 | } 145 | }); 146 | ``` 147 | 148 | 149 | ## Add Data Attributes to the Table Elements 150 | - Add the `data-class="expand"` attribute to the `th` element for the respective column that will you want to display the expand icon in. The `th` element cannot be for a column that will be hidden. 151 | 152 | - Add `data-hide="phone,tablet"` to the `th` element for the respective column that will you want to hide when the window is resized. 153 | 154 | - Add `data-name="Hidden Column Name"` to the `th` element for the respective column that will you would like its label to be set to when hidden. 155 | 156 | ```html 157 |
158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
EngineBrowserPlatform(s)Engine versionCSS grade
184 | 185 |
186 | ``` 187 | 188 | That's it! 189 | 190 | To see a working example, look in the `example` folder of the repository. 191 | 192 | ## How to Always Keep a Column Hidden 193 | If you want to always keep a column hidden, add the `data-hide="always"` attribute to that column's `th` element. Note that the `always` breakpoint is reserved. 194 | 195 | ## Destroying and Recreating a Data Table on the Same Element 196 | If you need to destroy and recreate a data table on the same table element, see the `ajax-bootstrap-recreate-table.html` example. 197 | 198 | ## Initializing Multiple Data Tables 199 | Each data table instance needs its own instance of a responsive helper. If you are initializing multiple tables using a single jQuery wrapped set, see the `dom-bootstrap-multiple-table.html` example. 200 | 201 | ## Options 202 | The responsive helper supports options via a third parameter in the constructor like this: 203 | ```javascript 204 | var tableElement = $('myTable'); 205 | var breakpointDefinition = { /* Break points here */ }; 206 | var responsiveHelper; 207 | // ... 208 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition, { 209 | hideEmptyColumnsInRowDetail: true 210 | }); 211 | ``` 212 | 213 | Currently supported options are: 214 | 215 | `hideEmptyColumnsInRowDetail` 216 | 217 | - Type: `Boolean` 218 | - Default: `false` 219 | - In responsive mode, clicking on the expand icon will only show hidden columns that actually have content. 220 | 221 | `clickOn` 222 | 223 | - Type: `String` 224 | - Acceptable values: `icon`, `cell` or `row` 225 | - Default: `icon` 226 | 227 | `showDetail` 228 | 229 | - Type: `Function` 230 | - Default: null 231 | - Function called when the detail row has been shown. Passes the jquery tr object for the detail row as an argument. 232 | 233 | `hideDetail` 234 | 235 | - Type: `Function` 236 | - Default: null 237 | - Function called when the detail row is going to be hidden. Passes the jquery tr object for the detail row as an argument. 238 | 239 | ## Thanks 240 | Thanks to Allan Jardine for making the best data table plugin for jQuery. Nothing out there comes close. 241 | 242 | Thanks to Brad Vincent and his friend Steve for making the awesome responsive [FooTable][9]. In my opinion, their implementation for a responsive table is the best to date. Much of what I have done here is borrowed from FooTable. Thanks again! 243 | 244 | 245 | [1]: http://datatables.net/ 246 | [2]: http://jquery.com/ 247 | [3]: http://themergency.com/footable/ 248 | [4]: https://github.com/Comanche/datatables-responsive/tree/master/examples 249 | [5]: http://getbootstrap.com/ 250 | [6]: http://www.datatables.net/blog/Twitter_Bootstrap 251 | [7]: http://www.datatables.net/blog/Twitter_Bootstrap_2 252 | [8]: https://github.com/DataTables/Plugins/tree/master/integration/bootstrap/3 253 | [9]: https://github.com/bradvin/FooTable 254 | -------------------------------------------------------------------------------- /examples/dt1.10/ajax-bootstrap3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DataTables Example 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | 24 |
25 |
26 |
Bootstrap v3.x Responsive Example Using AJAX
27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
NamePositionOfficeAgeStart dateSalary
NamePositionOfficeAgeStart dateSalary
55 |
56 | 57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /examples/dt1.10/arrays.txt: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | [ 4 | "Tiger Nixon", 5 | "System Architect", 6 | "Edinburgh", 7 | "5421", 8 | "2011\/04\/25", 9 | "$320,800" 10 | ], 11 | [ 12 | "Garrett Winters", 13 | "Accountant", 14 | "Tokyo", 15 | "8422", 16 | "2011\/07\/25", 17 | "$170,750" 18 | ], 19 | [ 20 | "Ashton Cox", 21 | "Junior Technical Author", 22 | "San Francisco", 23 | "1562", 24 | "2009\/01\/12", 25 | "$86,000" 26 | ], 27 | [ 28 | "Cedric Kelly", 29 | "Senior Javascript Developer", 30 | "Edinburgh", 31 | "6224", 32 | "2012\/03\/29", 33 | "$433,060" 34 | ], 35 | [ 36 | "Airi Satou", 37 | "Accountant", 38 | "Tokyo", 39 | "5407", 40 | "2008\/11\/28", 41 | "$162,700" 42 | ], 43 | [ 44 | "Brielle Williamson", 45 | "Integration Specialist", 46 | "New York", 47 | "4804", 48 | "2012\/12\/02", 49 | "$372,000" 50 | ], 51 | [ 52 | "Herrod Chandler", 53 | "Sales Assistant", 54 | "San Francisco", 55 | "9608", 56 | "2012\/08\/06", 57 | "$137,500" 58 | ], 59 | [ 60 | "Rhona Davidson", 61 | "Integration Specialist", 62 | "Tokyo", 63 | "6200", 64 | "2010\/10\/14", 65 | "$327,900" 66 | ], 67 | [ 68 | "Colleen Hurst", 69 | "Javascript Developer", 70 | "San Francisco", 71 | "2360", 72 | "2009\/09\/15", 73 | "$205,500" 74 | ], 75 | [ 76 | "Sonya Frost", 77 | "Software Engineer", 78 | "Edinburgh", 79 | "1667", 80 | "2008\/12\/13", 81 | "$103,600" 82 | ], 83 | [ 84 | "Jena Gaines", 85 | "Office Manager", 86 | "London", 87 | "3814", 88 | "2008\/12\/19", 89 | "$90,560" 90 | ], 91 | [ 92 | "Quinn Flynn", 93 | "Support Lead", 94 | "Edinburgh", 95 | "9497", 96 | "2013\/03\/03", 97 | "$342,000" 98 | ], 99 | [ 100 | "Charde Marshall", 101 | "Regional Director", 102 | "San Francisco", 103 | "6741", 104 | "2008\/10\/16", 105 | "$470,600" 106 | ], 107 | [ 108 | "Haley Kennedy", 109 | "Senior Marketing Designer", 110 | "London", 111 | "3597", 112 | "2012\/12\/18", 113 | "$313,500" 114 | ], 115 | [ 116 | "Tatyana Fitzpatrick", 117 | "Regional Director", 118 | "London", 119 | "1965", 120 | "2010\/03\/17", 121 | "$385,750" 122 | ], 123 | [ 124 | "Michael Silva", 125 | "Marketing Designer", 126 | "London", 127 | "1581", 128 | "2012\/11\/27", 129 | "$198,500" 130 | ], 131 | [ 132 | "Paul Byrd", 133 | "Chief Financial Officer (CFO)", 134 | "New York", 135 | "3059", 136 | "2010\/06\/09", 137 | "$725,000" 138 | ], 139 | [ 140 | "Gloria Little", 141 | "Systems Administrator", 142 | "New York", 143 | "1721", 144 | "2009\/04\/10", 145 | "$237,500" 146 | ], 147 | [ 148 | "Bradley Greer", 149 | "Software Engineer", 150 | "London", 151 | "2558", 152 | "2012\/10\/13", 153 | "$132,000" 154 | ], 155 | [ 156 | "Dai Rios", 157 | "Personnel Lead", 158 | "Edinburgh", 159 | "2290", 160 | "2012\/09\/26", 161 | "$217,500" 162 | ], 163 | [ 164 | "Jenette Caldwell", 165 | "Development Lead", 166 | "New York", 167 | "1937", 168 | "2011\/09\/03", 169 | "$345,000" 170 | ], 171 | [ 172 | "Yuri Berry", 173 | "Chief Marketing Officer (CMO)", 174 | "New York", 175 | "6154", 176 | "2009\/06\/25", 177 | "$675,000" 178 | ], 179 | [ 180 | "Caesar Vance", 181 | "Pre-Sales Support", 182 | "New York", 183 | "8330", 184 | "2011\/12\/12", 185 | "$106,450" 186 | ], 187 | [ 188 | "Doris Wilder", 189 | "Sales Assistant", 190 | "Sidney", 191 | "3023", 192 | "2010\/09\/20", 193 | "$85,600" 194 | ], 195 | [ 196 | "Angelica Ramos", 197 | "Chief Executive Officer (CEO)", 198 | "London", 199 | "5797", 200 | "2009\/10\/09", 201 | "$1,200,000" 202 | ], 203 | [ 204 | "Gavin Joyce", 205 | "Developer", 206 | "Edinburgh", 207 | "8822", 208 | "2010\/12\/22", 209 | "$92,575" 210 | ], 211 | [ 212 | "Jennifer Chang", 213 | "Regional Director", 214 | "Singapore", 215 | "9239", 216 | "2010\/11\/14", 217 | "$357,650" 218 | ], 219 | [ 220 | "Brenden Wagner", 221 | "Software Engineer", 222 | "San Francisco", 223 | "1314", 224 | "2011\/06\/07", 225 | "$206,850" 226 | ], 227 | [ 228 | "Fiona Green", 229 | "Chief Operating Officer (COO)", 230 | "San Francisco", 231 | "2947", 232 | "2010\/03\/11", 233 | "$850,000" 234 | ], 235 | [ 236 | "Shou Itou", 237 | "Regional Marketing", 238 | "Tokyo", 239 | "8899", 240 | "2011\/08\/14", 241 | "$163,000" 242 | ], 243 | [ 244 | "Michelle House", 245 | "Integration Specialist", 246 | "Sidney", 247 | "2769", 248 | "2011\/06\/02", 249 | "$95,400" 250 | ], 251 | [ 252 | "Suki Burks", 253 | "Developer", 254 | "London", 255 | "6832", 256 | "2009\/10\/22", 257 | "$114,500" 258 | ], 259 | [ 260 | "Prescott Bartlett", 261 | "Technical Author", 262 | "London", 263 | "3606", 264 | "2011\/05\/07", 265 | "$145,000" 266 | ], 267 | [ 268 | "Gavin Cortez", 269 | "Team Leader", 270 | "San Francisco", 271 | "2860", 272 | "2008\/10\/26", 273 | "$235,500" 274 | ], 275 | [ 276 | "Martena Mccray", 277 | "Post-Sales support", 278 | "Edinburgh", 279 | "8240", 280 | "2011\/03\/09", 281 | "$324,050" 282 | ], 283 | [ 284 | "Unity Butler", 285 | "Marketing Designer", 286 | "San Francisco", 287 | "5384", 288 | "2009\/12\/09", 289 | "$85,675" 290 | ], 291 | [ 292 | "Howard Hatfield", 293 | "Office Manager", 294 | "San Francisco", 295 | "7031", 296 | "2008\/12\/16", 297 | "$164,500" 298 | ], 299 | [ 300 | "Hope Fuentes", 301 | "Secretary", 302 | "San Francisco", 303 | "6318", 304 | "2010\/02\/12", 305 | "$109,850" 306 | ], 307 | [ 308 | "Vivian Harrell", 309 | "Financial Controller", 310 | "San Francisco", 311 | "9422", 312 | "2009\/02\/14", 313 | "$452,500" 314 | ], 315 | [ 316 | "Timothy Mooney", 317 | "Office Manager", 318 | "London", 319 | "7580", 320 | "2008\/12\/11", 321 | "$136,200" 322 | ], 323 | [ 324 | "Jackson Bradshaw", 325 | "Director", 326 | "New York", 327 | "1042", 328 | "2008\/09\/26", 329 | "$645,750" 330 | ], 331 | [ 332 | "Olivia Liang", 333 | "Support Engineer", 334 | "Singapore", 335 | "2120", 336 | "2011\/02\/03", 337 | "$234,500" 338 | ], 339 | [ 340 | "Bruno Nash", 341 | "Software Engineer", 342 | "London", 343 | "6222", 344 | "2011\/05\/03", 345 | "$163,500" 346 | ], 347 | [ 348 | "Sakura Yamamoto", 349 | "Support Engineer", 350 | "Tokyo", 351 | "9383", 352 | "2009\/08\/19", 353 | "$139,575" 354 | ], 355 | [ 356 | "Thor Walton", 357 | "Developer", 358 | "New York", 359 | "8327", 360 | "2013\/08\/11", 361 | "$98,540" 362 | ], 363 | [ 364 | "Finn Camacho", 365 | "Support Engineer", 366 | "San Francisco", 367 | "2927", 368 | "2009\/07\/07", 369 | "$87,500" 370 | ], 371 | [ 372 | "Serge Baldwin", 373 | "Data Coordinator", 374 | "Singapore", 375 | "8352", 376 | "2012\/04\/09", 377 | "$138,575" 378 | ], 379 | [ 380 | "Zenaida Frank", 381 | "Software Engineer", 382 | "New York", 383 | "7439", 384 | "2010\/01\/04", 385 | "$125,250" 386 | ], 387 | [ 388 | "Zorita Serrano", 389 | "Software Engineer", 390 | "San Francisco", 391 | "4389", 392 | "2012\/06\/01", 393 | "$115,000" 394 | ], 395 | [ 396 | "Jennifer Acosta", 397 | "Junior Javascript Developer", 398 | "Edinburgh", 399 | "3431", 400 | "2013\/02\/01", 401 | "$75,650" 402 | ], 403 | [ 404 | "Cara Stevens", 405 | "Sales Assistant", 406 | "New York", 407 | "3990", 408 | "2011\/12\/06", 409 | "$145,600" 410 | ], 411 | [ 412 | "Hermione Butler", 413 | "Regional Director", 414 | "London", 415 | "1016", 416 | "2011\/03\/21", 417 | "$356,250" 418 | ], 419 | [ 420 | "Lael Greer", 421 | "Systems Administrator", 422 | "London", 423 | "6733", 424 | "2009\/02\/27", 425 | "$103,500" 426 | ], 427 | [ 428 | "Jonas Alexander", 429 | "Developer", 430 | "San Francisco", 431 | "8196", 432 | "2010\/07\/14", 433 | "$86,500" 434 | ], 435 | [ 436 | "Shad Decker", 437 | "Regional Director", 438 | "Edinburgh", 439 | "6373", 440 | "2008\/11\/13", 441 | "$183,000" 442 | ], 443 | [ 444 | "Michael Bruce", 445 | "Javascript Developer", 446 | "Singapore", 447 | "5384", 448 | "2011\/06\/27", 449 | "$183,000" 450 | ], 451 | [ 452 | "Donna Snider", 453 | "Customer Support", 454 | "New York", 455 | "4226", 456 | "2011\/01\/25", 457 | "$112,000" 458 | ] 459 | ] 460 | } -------------------------------------------------------------------------------- /examples/dt1.10/dom-bootstrap3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | DataTables Example 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | 24 |
25 |
26 |
Bootstrap v3.x Responsive Example Using DOM
27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 |
NamePositionOfficeAgeStart dateSalary
NamePositionOfficeAgeStart dateSalary
Tiger NixonSystem ArchitectEdinburgh612011/04/25$320,800
Garrett WintersAccountantTokyo632011/07/25$170,750
Ashton CoxJunior Technical AuthorSan Francisco662009/01/12$86,000
Cedric KellySenior Javascript DeveloperEdinburgh222012/03/29$433,060
Airi SatouAccountantTokyo332008/11/28$162,700
Brielle WilliamsonIntegration SpecialistNew York612012/12/02$372,000
Herrod ChandlerSales AssistantSan Francisco592012/08/06$137,500
Rhona DavidsonIntegration SpecialistTokyo552010/10/14$327,900
Colleen HurstJavascript DeveloperSan Francisco392009/09/15$205,500
Sonya FrostSoftware EngineerEdinburgh232008/12/13$103,600
Jena GainesOffice ManagerLondon302008/12/19$90,560
Quinn FlynnSupport LeadEdinburgh222013/03/03$342,000
Charde MarshallRegional DirectorSan Francisco362008/10/16$470,600
Haley KennedySenior Marketing DesignerLondon432012/12/18$313,500
Tatyana FitzpatrickRegional DirectorLondon192010/03/17$385,750
Michael SilvaMarketing DesignerLondon662012/11/27$198,500
Paul ByrdChief Financial Officer (CFO)New York642010/06/09$725,000
Gloria LittleSystems AdministratorNew York592009/04/10$237,500
Bradley GreerSoftware EngineerLondon412012/10/13$132,000
Dai RiosPersonnel LeadEdinburgh352012/09/26$217,500
Jenette CaldwellDevelopment LeadNew York302011/09/03$345,000
Yuri BerryChief Marketing Officer (CMO)New York402009/06/25$675,000
Caesar VancePre-Sales SupportNew York212011/12/12$106,450
Doris WilderSales AssistantSidney232010/09/20$85,600
Angelica RamosChief Executive Officer (CEO)London472009/10/09$1,200,000
Gavin JoyceDeveloperEdinburgh422010/12/22$92,575
Jennifer ChangRegional DirectorSingapore282010/11/14$357,650
Brenden WagnerSoftware EngineerSan Francisco282011/06/07$206,850
Fiona GreenChief Operating Officer (COO)San Francisco482010/03/11$850,000
Shou ItouRegional MarketingTokyo202011/08/14$163,000
Michelle HouseIntegration SpecialistSidney372011/06/02$95,400
Suki BurksDeveloperLondon532009/10/22$114,500
Prescott BartlettTechnical AuthorLondon272011/05/07$145,000
Gavin CortezTeam LeaderSan Francisco222008/10/26$235,500
Martena MccrayPost-Sales supportEdinburgh462011/03/09$324,050
Unity ButlerMarketing DesignerSan Francisco472009/12/09$85,675
Howard HatfieldOffice ManagerSan Francisco512008/12/16$164,500
Hope FuentesSecretarySan Francisco412010/02/12$109,850
Vivian HarrellFinancial ControllerSan Francisco622009/02/14$452,500
Timothy MooneyOffice ManagerLondon372008/12/11$136,200
Jackson BradshawDirectorNew York652008/09/26$645,750
Olivia LiangSupport EngineerSingapore642011/02/03$234,500
Bruno NashSoftware EngineerLondon382011/05/03$163,500
Sakura YamamotoSupport EngineerTokyo372009/08/19$139,575
Thor WaltonDeveloperNew York612013/08/11$98,540
Finn CamachoSupport EngineerSan Francisco472009/07/07$87,500
Serge BaldwinData CoordinatorSingapore642012/04/09$138,575
Zenaida FrankSoftware EngineerNew York632010/01/04$125,250
Zorita SerranoSoftware EngineerSan Francisco562012/06/01$115,000
Jennifer AcostaJunior Javascript DeveloperEdinburgh432013/02/01$75,650
Cara StevensSales AssistantNew York462011/12/06$145,600
Hermione ButlerRegional DirectorLondon472011/03/21$356,250
Lael GreerSystems AdministratorLondon212009/02/27$103,500
Jonas AlexanderDeveloperSan Francisco302010/07/14$86,500
Shad DeckerRegional DirectorEdinburgh512008/11/13$183,000
Michael BruceJavascript DeveloperSingapore292011/06/27$183,000
Donna SniderCustomer SupportNew York272011/01/25$112,000
512 |
513 | 514 | 515 |
516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | -------------------------------------------------------------------------------- /examples/dt1.10/js/ajax-bootstrap3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElement = $('#example'); 10 | 11 | tableElement.dataTable({ 12 | autoWidth : false, 13 | ajax : './arrays.txt', 14 | preDrawCallback: function () { 15 | // Initialize the responsive datatables helper once. 16 | if (!responsiveHelper) { 17 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 18 | } 19 | }, 20 | rowCallback : function (nRow) { 21 | responsiveHelper.createExpandIcon(nRow); 22 | }, 23 | drawCallback : function (oSettings) { 24 | responsiveHelper.respond(); 25 | } 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /examples/dt1.10/js/dom-bootstrap3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElement = $('#example'); 10 | 11 | tableElement.dataTable({ 12 | autoWidth : false, 13 | preDrawCallback: function () { 14 | // Initialize the responsive datatables helper once. 15 | if (!responsiveHelper) { 16 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 17 | } 18 | }, 19 | rowCallback : function (nRow) { 20 | responsiveHelper.createExpandIcon(nRow); 21 | }, 22 | drawCallback : function (oSettings) { 23 | responsiveHelper.respond(); 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /examples/dt1.9/ajax-bootstrap2-recreate-table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |
24 |
25 |
26 | Bootstrap v2.x Responsive Example Using AJAX with Checkboxes: Recreating DataTable Instance Using 27 | the Same Tree Element. 28 |
29 |
30 |
31 |
32 |
33 |
34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
EngineBrowserPlatform(s)Engine versionCSS grade
69 |
70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/dt1.9/ajax-bootstrap2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |
24 |
25 |
Bootstrap v2.x Responsive Example Using AJAX with Checkboxes
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
EngineBrowserPlatform(s)Engine versionCSS grade
55 |
56 |
57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /examples/dt1.9/ajax-bootstrap3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | 24 |
25 |
26 |
Bootstrap v3.x Responsive Example Using AJAX with Checkboxes
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
EngineBrowserPlatform(s)Engine versionCSS grade
55 | 56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /examples/dt1.9/arrays.txt: -------------------------------------------------------------------------------- 1 | { 2 | "aaData":[ 3 | [ 4 | "1", 5 | "Trident", 6 | "Internet Explorer 4.0", 7 | "Win 95+", 8 | "4", 9 | "X" 10 | ], 11 | [ 12 | "2", 13 | "Trident", 14 | "Internet Explorer 5.0", 15 | "Win 95+", 16 | "5", 17 | "C" 18 | ], 19 | [ 20 | "3", 21 | "Trident", 22 | "Internet Explorer 5.5", 23 | "Win 95+", 24 | "5.5", 25 | "A" 26 | ], 27 | [ 28 | "4", 29 | "Trident", 30 | "Internet Explorer 6", 31 | "Win 98+", 32 | "6", 33 | "A" 34 | ], 35 | [ 36 | "5", 37 | "Trident", 38 | "Internet Explorer 7", 39 | "Win XP SP2+", 40 | "7", 41 | "A" 42 | ], 43 | [ 44 | "6", 45 | "Trident", 46 | "AOL browser (AOL desktop)", 47 | "Win XP", 48 | "6", 49 | "A" 50 | ], 51 | [ 52 | "7", 53 | "Gecko", 54 | "Firefox 1.0", 55 | "Win 98+ / OSX.2+", 56 | "1.7", 57 | "A" 58 | ], 59 | [ 60 | "8", 61 | "Gecko", 62 | "Firefox 1.5", 63 | "Win 98+ / OSX.2+", 64 | "1.8", 65 | "A" 66 | ], 67 | [ 68 | "9", 69 | "Gecko", 70 | "Firefox 2.0", 71 | "Win 98+ / OSX.2+", 72 | "1.8", 73 | "A" 74 | ], 75 | [ 76 | "10", 77 | "Gecko", 78 | "Firefox 3.0", 79 | "Win 2k+ / OSX.3+", 80 | "1.9", 81 | "A" 82 | ], 83 | [ 84 | "11", 85 | "Gecko", 86 | "Camino 1.0", 87 | "OSX.2+", 88 | "1.8", 89 | "A" 90 | ], 91 | [ 92 | "12", 93 | "Gecko", 94 | "Camino 1.5", 95 | "OSX.3+", 96 | "1.8", 97 | "A" 98 | ], 99 | [ 100 | "13", 101 | "Gecko", 102 | "Netscape 7.2", 103 | "Win 95+ / Mac OS 8.6-9.2", 104 | "1.7", 105 | "A" 106 | ], 107 | [ 108 | "14", 109 | "Gecko", 110 | "Netscape Browser 8", 111 | "Win 98SE+", 112 | "1.7", 113 | "A" 114 | ], 115 | [ 116 | "15", 117 | "Gecko", 118 | "Netscape Navigator 9", 119 | "Win 98+ / OSX.2+", 120 | "1.8", 121 | "A" 122 | ], 123 | [ 124 | "16", 125 | "Gecko", 126 | "Mozilla 1.0", 127 | "Win 95+ / OSX.1+", 128 | 1, 129 | "A" 130 | ], 131 | [ 132 | "17", 133 | "Gecko", 134 | "Mozilla 1.1", 135 | "Win 95+ / OSX.1+", 136 | 1.1, 137 | "A" 138 | ], 139 | [ 140 | "18", 141 | "Gecko", 142 | "Mozilla 1.2", 143 | "Win 95+ / OSX.1+", 144 | 1.2, 145 | "A" 146 | ], 147 | [ 148 | "19", 149 | "Gecko", 150 | "Mozilla 1.3", 151 | "Win 95+ / OSX.1+", 152 | 1.3, 153 | "A" 154 | ], 155 | [ 156 | "20", 157 | "Gecko", 158 | "Mozilla 1.4", 159 | "Win 95+ / OSX.1+", 160 | 1.4, 161 | "A" 162 | ], 163 | [ 164 | "21", 165 | "Gecko", 166 | "Mozilla 1.5", 167 | "Win 95+ / OSX.1+", 168 | 1.5, 169 | "A" 170 | ], 171 | [ 172 | "22", 173 | "Gecko", 174 | "Mozilla 1.6", 175 | "Win 95+ / OSX.1+", 176 | 1.6, 177 | "A" 178 | ], 179 | [ 180 | "23", 181 | "Gecko", 182 | "Mozilla 1.7", 183 | "Win 98+ / OSX.1+", 184 | 1.7, 185 | "A" 186 | ], 187 | [ 188 | "24", 189 | "Gecko", 190 | "Mozilla 1.8", 191 | "Win 98+ / OSX.1+", 192 | 1.8, 193 | "A" 194 | ], 195 | [ 196 | "25", 197 | "Gecko", 198 | "Seamonkey 1.1", 199 | "Win 98+ / OSX.2+", 200 | "1.8", 201 | "A" 202 | ], 203 | [ 204 | "26", 205 | "Gecko", 206 | "Epiphany 2.20", 207 | "Gnome", 208 | "1.8", 209 | "A" 210 | ], 211 | [ 212 | "27", 213 | "Webkit", 214 | "Safari 1.2", 215 | "OSX.3", 216 | "125.5", 217 | "A" 218 | ], 219 | [ 220 | "28", 221 | "Webkit", 222 | "Safari 1.3", 223 | "OSX.3", 224 | "312.8", 225 | "A" 226 | ], 227 | [ 228 | "29", 229 | "Webkit", 230 | "Safari 2.0", 231 | "OSX.4+", 232 | "419.3", 233 | "A" 234 | ], 235 | [ 236 | "30", 237 | "Webkit", 238 | "Safari 3.0", 239 | "OSX.4+", 240 | "522.1", 241 | "A" 242 | ], 243 | [ 244 | "31", 245 | "Webkit", 246 | "OmniWeb 5.5", 247 | "OSX.4+", 248 | "420", 249 | "A" 250 | ], 251 | [ 252 | "32", 253 | "Webkit", 254 | "iPod Touch / iPhone", 255 | "iPod", 256 | "420.1", 257 | "A" 258 | ], 259 | [ 260 | "33", 261 | "Webkit", 262 | "S60", 263 | "S60", 264 | "413", 265 | "A" 266 | ], 267 | [ 268 | "34", 269 | "Presto", 270 | "Opera 7.0", 271 | "Win 95+ / OSX.1+", 272 | "-", 273 | "A" 274 | ], 275 | [ 276 | "35", 277 | "Presto", 278 | "Opera 7.5", 279 | "Win 95+ / OSX.2+", 280 | "-", 281 | "A" 282 | ], 283 | [ 284 | "36", 285 | "Presto", 286 | "Opera 8.0", 287 | "Win 95+ / OSX.2+", 288 | "-", 289 | "A" 290 | ], 291 | [ 292 | "37", 293 | "Presto", 294 | "Opera 8.5", 295 | "Win 95+ / OSX.2+", 296 | "-", 297 | "A" 298 | ], 299 | [ 300 | "38", 301 | "Presto", 302 | "Opera 9.0", 303 | "Win 95+ / OSX.3+", 304 | "-", 305 | "A" 306 | ], 307 | [ 308 | "39", 309 | "Presto", 310 | "Opera 9.2", 311 | "Win 88+ / OSX.3+", 312 | "-", 313 | "A" 314 | ], 315 | [ 316 | "40", 317 | "Presto", 318 | "Opera 9.5", 319 | "Win 88+ / OSX.3+", 320 | "-", 321 | "A" 322 | ], 323 | [ 324 | "41", 325 | "Presto", 326 | "Opera for Wii", 327 | "Wii", 328 | "-", 329 | "A" 330 | ], 331 | [ 332 | "42", 333 | "Presto", 334 | "Nokia N800", 335 | "N800", 336 | "-", 337 | "A" 338 | ], 339 | [ 340 | "43", 341 | "Presto", 342 | "Nintendo DS browser", 343 | "Nintendo DS", 344 | "8.5", 345 | "C/A1" 346 | ], 347 | [ 348 | "44", 349 | "KHTML", 350 | "Konqureror 3.1", 351 | "KDE 3.1", 352 | "3.1", 353 | "C" 354 | ], 355 | [ 356 | "45", 357 | "KHTML", 358 | "Konqureror 3.3", 359 | "KDE 3.3", 360 | "3.3", 361 | "A" 362 | ], 363 | [ 364 | "46", 365 | "KHTML", 366 | "Konqureror 3.5", 367 | "KDE 3.5", 368 | "3.5", 369 | "A" 370 | ], 371 | [ 372 | "47", 373 | "Tasman", 374 | "Internet Explorer 4.5", 375 | "Mac OS 8-9", 376 | "-", 377 | "X" 378 | ], 379 | [ 380 | "48", 381 | "Tasman", 382 | "Internet Explorer 5.1", 383 | "Mac OS 7.6-9", 384 | "1", 385 | "C" 386 | ], 387 | [ 388 | "49", 389 | "Tasman", 390 | "Internet Explorer 5.2", 391 | "Mac OS 8-X", 392 | "1", 393 | "C" 394 | ], 395 | [ 396 | "50", 397 | "Misc", 398 | "NetFront 3.1", 399 | "Embedded devices", 400 | "-", 401 | "C" 402 | ], 403 | [ 404 | "51", 405 | "Misc", 406 | "NetFront 3.4", 407 | "Embedded devices", 408 | "-", 409 | "A" 410 | ], 411 | [ 412 | "52", 413 | "Misc", 414 | "Dillo 0.8", 415 | "Embedded devices", 416 | "-", 417 | "X" 418 | ], 419 | [ 420 | "53", 421 | "Misc", 422 | "Links", 423 | "Text only", 424 | "-", 425 | "X" 426 | ], 427 | [ 428 | "54", 429 | "Misc", 430 | "Lynx", 431 | "Text only", 432 | "-", 433 | "X" 434 | ], 435 | [ 436 | "55", 437 | "Misc", 438 | "IE Mobile", 439 | "Windows Mobile 6", 440 | "-", 441 | "C" 442 | ], 443 | [ 444 | "56", 445 | "Misc", 446 | "PSP browser", 447 | "PSP", 448 | "-", 449 | "C" 450 | ], 451 | [ 452 | "57", 453 | "Other browsers", 454 | "All others", 455 | "-", 456 | "-", 457 | "U" 458 | ] 459 | ] 460 | } -------------------------------------------------------------------------------- /examples/dt1.9/arrays2.txt: -------------------------------------------------------------------------------- 1 | { 2 | "aaData":[ 3 | [ 4 | "1", 5 | "Trident", 6 | "Internet Explorer 4.0", 7 | "Win 95+", 8 | "4", 9 | "X" 10 | ], 11 | [ 12 | "2", 13 | "Trident", 14 | "Internet Explorer 5.0", 15 | "Win 95+", 16 | "5", 17 | "C" 18 | ], 19 | [ 20 | "3", 21 | "Trident", 22 | "Internet Explorer 5.5", 23 | "Win 95+", 24 | "5.5", 25 | "A" 26 | ] 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /examples/dt1.9/dom-bootstrap2-multiple-table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |
24 |
25 |
Bootstrap v2.x Responsive Example Using DOM with Checkboxes
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
112 |
113 |
114 |
115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /examples/dt1.9/dom-bootstrap2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |
24 |
25 |
Bootstrap v2.x Responsive Example Using DOM with Checkboxes
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 |
Rendering engineBrowserPlatform(s)Engine versionCSS grade
TridentInternet Explorer 4.0Win 95+4X
TridentInternet Explorer 5.0Win 95+5C
TridentInternet Explorer 5.5Win 95+5.5A
TridentInternet Explorer 6Win 98+6A
TridentInternet Explorer 7Win XP SP2+7A
TridentAOL browser (AOL desktop)Win XP6A
GeckoFirefox 1.0Win 98+ / OSX.2+1.7A
GeckoFirefox 1.5Win 98+ / OSX.2+1.8A
GeckoFirefox 2.0Win 98+ / OSX.2+1.8A
GeckoFirefox 3.0Win 2k+ / OSX.3+1.9A
GeckoCamino 1.0OSX.2+1.8A
GeckoCamino 1.5OSX.3+1.8A
GeckoNetscape 7.2Win 95+ / Mac OS 8.6-9.21.7A
GeckoNetscape Browser 8Win 98SE+1.7A
GeckoNetscape Navigator 9Win 98+ / OSX.2+1.8A
GeckoMozilla 1.0Win 95+ / OSX.1+1A
GeckoMozilla 1.1Win 95+ / OSX.1+1.1A
GeckoMozilla 1.2Win 95+ / OSX.1+1.2A
GeckoMozilla 1.3Win 95+ / OSX.1+1.3A
GeckoMozilla 1.4Win 95+ / OSX.1+1.4A
GeckoMozilla 1.5Win 95+ / OSX.1+1.5A
GeckoMozilla 1.6Win 95+ / OSX.1+1.6A
GeckoMozilla 1.7Win 98+ / OSX.1+1.7A
GeckoMozilla 1.8Win 98+ / OSX.1+1.8A
GeckoSeamonkey 1.1Win 98+ / OSX.2+1.8A
GeckoEpiphany 2.20Gnome1.8A
WebkitSafari 1.2OSX.3125.5A
WebkitSafari 1.3OSX.3312.8A
WebkitSafari 2.0OSX.4+419.3A
WebkitSafari 3.0OSX.4+522.1A
WebkitOmniWeb 5.5OSX.4+420A
WebkitiPod Touch / iPhoneiPod420.1A
WebkitS60S60413A
PrestoOpera 7.0Win 95+ / OSX.1+-A
PrestoOpera 7.5Win 95+ / OSX.2+-A
PrestoOpera 8.0Win 95+ / OSX.2+-A
PrestoOpera 8.5Win 95+ / OSX.2+-A
PrestoOpera 9.0Win 95+ / OSX.3+-A
PrestoOpera 9.2Win 88+ / OSX.3+-A
PrestoOpera 9.5Win 88+ / OSX.3+-A
PrestoOpera for WiiWii-A
PrestoNokia N800N800-A
PrestoNintendo DS browserNintendo DS8.5C/A1
KHTMLKonqureror 3.1KDE 3.13.1C
KHTMLKonqureror 3.3KDE 3.33.3A
KHTMLKonqureror 3.5KDE 3.53.5A
TasmanInternet Explorer 4.5Mac OS 8-9-X
TasmanInternet Explorer 5.1Mac OS 7.6-91C
TasmanInternet Explorer 5.2Mac OS 8-X1C
MiscNetFront 3.1Embedded devices-C
MiscNetFront 3.4Embedded devices-A
MiscDillo 0.8Embedded devices-X
MiscLinksText only-X
MiscLynxText only-X
MiscIE MobileWindows Mobile 6-C
MiscPSP browserPSP-C
Other browsersAll others--U
441 | 442 |
443 |
444 |
445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | -------------------------------------------------------------------------------- /examples/dt1.9/js/ajax-bootstrap2-recreate-table.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | 10 | var tableElement; 11 | var destroyingDataTable = false; 12 | 13 | // Initialize buttons 14 | $('button').click(function (event) { 15 | var ajaxUrl = $(this).attr('data-ajax-url'); 16 | createDataTable(ajaxUrl); 17 | }); 18 | 19 | /** 20 | * Create the data table. 21 | * @param {String} ajaxUrl 22 | */ 23 | function createDataTable(ajaxUrl) { 24 | tableElement = $('#example'); 25 | 26 | // This next part helps to clean things up so we can recreate a data 27 | // table on the same table element. 28 | if ($.fn.DataTable.fnIsDataTable(tableElement[0])) { 29 | // Set the destroying flag to prevent the responsive table from 30 | // being initialized during this phase. 31 | destroyingDataTable = true; 32 | 33 | // Get data table instance 34 | tableElement.dataTable(); 35 | 36 | // Since we are destroying the table, let's clear it to speed things 37 | // up. 38 | tableElement.fnClearTable(false); 39 | 40 | // Disabling the helper will reset the the responsive changes to the 41 | // DOM. 42 | responsiveHelper.disable(true); 43 | 44 | // Remove the responsive helper. 45 | responsiveHelper = undefined; 46 | 47 | // Now that all things have been restored, let's destroy the table 48 | tableElement.fnDestroy(); 49 | 50 | // Clear flag 51 | destroyingDataTable = false; 52 | } 53 | 54 | 55 | // Create data table 56 | tableElement.dataTable({ 57 | sDom : '<"row"<"span6"l><"span6"f>r>t<"row"<"span6"i><"span6"p>>', 58 | sPaginationType : 'bootstrap', 59 | oLanguage : { 60 | sLengthMenu: '_MENU_ records per page' 61 | }, 62 | // disable sorting on the checkbox column 63 | aoColumnDefs : [ 64 | { 65 | aTargets : [ 0 ], // Column number which needs to be modified 66 | bSortable: false, // Column is not sortable 67 | // Custom render function - add checkbox 68 | mRender : function (data, type) { 69 | return ''; 70 | }, 71 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 72 | }, 73 | { 74 | aTargets: [ 4 ], // Column number which needs to be modified 75 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 76 | }, 77 | { 78 | aTargets: [ 5 ], // Column number which needs to be modified 79 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 80 | } 81 | ], 82 | bProcessing : true, 83 | bAutoWidth : false, 84 | sAjaxSource : ajaxUrl, 85 | bDestroy : true, 86 | // Custom call back for AJAX 87 | fnServerData : function (sSource, aoData, fnCallback, oSettings) { 88 | oSettings.jqXHR = $.ajax({ 89 | dataType: 'json', 90 | type : 'GET', 91 | url : sSource, 92 | data : aoData, 93 | success : function (data) { 94 | fnCallback(data); 95 | } 96 | }); 97 | }, 98 | fnPreDrawCallback: function () { 99 | // Initialize the responsive data table helper once. 100 | if (!responsiveHelper && !destroyingDataTable) { 101 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 102 | } 103 | }, 104 | fnRowCallback : function (nRow) { 105 | if (responsiveHelper) { 106 | responsiveHelper.createExpandIcon(nRow); 107 | } 108 | }, 109 | fnDrawCallback : function () { 110 | // This function will be called every the table redraws. 111 | // Specifically, we're interested when next/previous page 112 | // occurs. 113 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 114 | 115 | // Respond to windows resize. 116 | if (responsiveHelper) { 117 | responsiveHelper.respond(); 118 | } 119 | }, 120 | fnInitComplete : function (oSettings) { 121 | // Register event handlers 122 | initializeMasterCheckboxEventHandler(); 123 | initializeCheckboxEventHandlers(); 124 | initializeTableRowEventHandlers(); 125 | 126 | // Unregister event handlers when table is destroyed. 127 | oSettings.aoDestroyCallback.push({ 128 | 'sName': 'UnregisterEventHandlers', 129 | 'fn' : function () { 130 | initializeMasterCheckboxEventHandler(false); 131 | initializeCheckboxEventHandlers(false); 132 | initializeTableRowEventHandlers(false); 133 | } 134 | }); 135 | } 136 | }); 137 | } 138 | 139 | 140 | // NOTE: We did not add class="centered-cell" to the Engine version and CSS grade columns 141 | // as in other examples. 142 | 143 | 144 | /** 145 | * Enable master checkbox if there are more than one row in the data table. 146 | * 147 | * The enable parameter is used to enable/disable the element. 148 | * 149 | * Returns true if enable was successful. 150 | * 151 | * @param {Boolean} enable 152 | * @returns {Boolean} 153 | */ 154 | function enableMasterCheckbox (enable) { 155 | enable = enable === undefined ? true : enable; 156 | 157 | if (enable && $('tbody tr', tableElement).length) { 158 | $('#masterCheck', tableElement).prop('disabled', false); 159 | return true; 160 | } else { 161 | $('#masterCheck', tableElement).prop('disabled', true); 162 | return false; 163 | } 164 | } 165 | 166 | /** 167 | * Toggles the master checkbox if all checkboxes in the table that 168 | * are visible are checked. 169 | */ 170 | function toggleMasterCheckBasedOnAllOtherCheckboxes() { 171 | // What we need to do here is check to see if every checkbox is checked. 172 | // If it is, the master checkbox in the header should be checked as well. 173 | var allCheckboxes = $('tbody input:checkbox', tableElement); 174 | var totalCheckboxCount = allCheckboxes.length; 175 | if (totalCheckboxCount) { 176 | var checkedChecboxCount = allCheckboxes.filter(':checked').length; 177 | $('#masterCheck', tableElement).prop('checked', totalCheckboxCount === checkedChecboxCount); 178 | } 179 | } 180 | 181 | /** 182 | * Initialize master checkbox event handlers. 183 | * 184 | * The on parameter is used to register/unregister the event handler. The 185 | * default is true. 186 | * 187 | * @param {Boolean} on 188 | */ 189 | function initializeMasterCheckboxEventHandler(on) { 190 | on = on === undefined ? true : on; 191 | 192 | if (on) { 193 | // Enable master checkbox 194 | enableMasterCheckbox(); 195 | 196 | // Register master checkbox to check/uncheck all checkboxes 197 | $('#masterCheck', tableElement).on('click', function () { 198 | // Toggle all checkboxes by triggering a click event on them. The click 199 | // event will fire the changed event that we can handle. Directly changing 200 | // the checked property like this 201 | // 202 | // $('tbody input:checkbox', tableElement).not(this).prop('checked', this.checked); 203 | // 204 | // toggles all checkboxes but does not trigger click events. Because there's 205 | // no click event, there's no changed events on the checkboxes. We need the 206 | // changed events so that we can keep track of the checked checkboxes. 207 | if (this.checked) { 208 | $('tbody input:checkbox:not(:checked)', tableElement).not(this).trigger('click'); 209 | } else { 210 | $('tbody input:checkbox:checked', tableElement).not(this).trigger('click'); 211 | } 212 | }); 213 | } else { 214 | // Disable master checkbox 215 | enableMasterCheckbox(false); 216 | 217 | // Unregister master checkbox to check/uncheck all checkboxes 218 | $('#masterCheck', tableElement).off('click'); 219 | } 220 | } 221 | 222 | /** 223 | * Initialize checkbox event handlers. 224 | * 225 | * The on parameter is used to register/unregister the event handler. The 226 | * default is true. 227 | * 228 | * The elementCollection parameter can be one of the following: 229 | * - jQuery collection of checkbox elements 230 | * - jQuery selector 231 | * - undefined 232 | * 233 | * If elementCollection is undefined, all checkboxes in DataTable 234 | * will be selected. 235 | * 236 | * @param {Boolean} on 237 | * @param {Object|String|undefined} elementCollection 238 | */ 239 | function initializeCheckboxEventHandlers(on, elementCollection) { 240 | on = on === undefined ? true : on; 241 | 242 | if (elementCollection === undefined) { 243 | elementCollection = $('input:checkbox', tableElement.fnGetNodes()) 244 | } else if (elementCollection === 'string') { 245 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 246 | } 247 | 248 | if (on) { 249 | // Register elementCollection handlers 250 | elementCollection.on('change', function (event) { 251 | // Keep track of the checked checkboxes. 252 | if (event.target.checked) { 253 | // Do something with the checked item 254 | // callSomeFunction(event.target.name, event.target.value); 255 | console.log('Checkbox ' + event.target.name + ' checked', event.target.value); 256 | } else { 257 | // Do something with the unchecked item 258 | // callSomeFunction(event.target.name, event.target.value); 259 | console.log('Checkbox ' + event.target.name + ' unchecked', event.target.value); 260 | } 261 | 262 | // Affect the other parts of the table/page... 263 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 264 | }); 265 | } else { 266 | // Unregister elementCollection handlers 267 | elementCollection.off('change'); 268 | } 269 | } 270 | 271 | /** 272 | * Initialize table row event handler. 273 | * 274 | * The on parameter is used to register/unregister the event handler. The 275 | * default is true. 276 | * 277 | * The elementCollection can be one of the following: 278 | * - jQuery collection of checkbox elements 279 | * - jQuery selector 280 | * - undefined 281 | * 282 | * If elementCollection is undefined, all table rows in DataTable 283 | * will be selected. 284 | * 285 | * @param {Boolean} on 286 | * @param {Object|String|undefined} elementCollection 287 | */ 288 | function initializeTableRowEventHandlers(on, elementCollection) { 289 | on = on === undefined ? true : on; 290 | 291 | if (elementCollection === undefined) { 292 | elementCollection = $(tableElement.fnGetNodes()) 293 | } else if (elementCollection === 'string') { 294 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 295 | } 296 | 297 | if (on) { 298 | // Register elementCollection handlers as needed. 299 | } else { 300 | // Unregister elementCollection handlers as needed. 301 | } 302 | } 303 | }); 304 | -------------------------------------------------------------------------------- /examples/dt1.9/js/ajax-bootstrap2.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElement = $('#example'); 10 | 11 | tableElement.dataTable({ 12 | sDom : '<"row"<"span6"l><"span6"f>r>t<"row"<"span6"i><"span6"p>>', 13 | sPaginationType: 'bootstrap', 14 | oLanguage : { 15 | sLengthMenu: '_MENU_ records per page' 16 | }, 17 | // disable sorting on the checkbox column 18 | aoColumnDefs : [ 19 | { 20 | aTargets : [ 0 ], // Column number which needs to be modified 21 | bSortable: false, // Column is not sortable 22 | // Custom render function - add checkbox 23 | mRender : function (data, type) { 24 | return ''; 25 | }, 26 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 27 | }, 28 | { 29 | aTargets: [ 4 ], // Column number which needs to be modified 30 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 31 | }, 32 | { 33 | aTargets: [ 5 ], // Column number which needs to be modified 34 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 35 | } 36 | ], 37 | bProcessing : true, 38 | bAutoWidth : false, 39 | sAjaxSource : './arrays.txt', 40 | // Custom call back for AJAX 41 | fnServerData : function (sSource, aoData, fnCallback, oSettings) { 42 | oSettings.jqXHR = $.ajax({ 43 | dataType: 'json', 44 | type : 'GET', 45 | url : sSource, 46 | data : aoData, 47 | success : function (data) { 48 | fnCallback(data); 49 | } 50 | }); 51 | }, 52 | fnPreDrawCallback: function () { 53 | // Initialize the responsive datatables helper once. 54 | if (!responsiveHelper) { 55 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 56 | } 57 | }, 58 | fnRowCallback : function (nRow) { 59 | responsiveHelper.createExpandIcon(nRow); 60 | }, 61 | fnDrawCallback : function () { 62 | // This function will be called every the table redraws. 63 | // Specifically, we're interested when next/previous page 64 | // occurs. 65 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 66 | 67 | // Respond to windows resize. 68 | responsiveHelper.respond(); 69 | }, 70 | fnInitComplete : function (oSettings) { 71 | initializeMasterCheckboxEventHandler(); 72 | initializeCheckboxEventHandlers(); 73 | initializeTableRowEventHandlers(); 74 | 75 | oSettings.aoDestroyCallback.push({ 76 | 'sName': 'UnregisterEventHandlers', 77 | 'fn': function () { 78 | initializeMasterCheckboxEventHandler(false); 79 | initializeCheckboxEventHandlers(false); 80 | initializeTableRowEventHandlers(false); 81 | } 82 | }); 83 | } 84 | }); 85 | 86 | // NOTE: We did not add class="centered-cell" to the Engine version and CSS grade columns 87 | // as in other examples. 88 | 89 | 90 | /** 91 | * Enable master checkbox if there are more than one row in the data table. 92 | * 93 | * The enable parameter is used to enable/disable the element. 94 | * 95 | * Returns true if enable was successful. 96 | * 97 | * @param {Boolean} enable 98 | * @returns {Boolean} 99 | */ 100 | function enableMasterCheckbox (enable) { 101 | enable = enable === undefined ? true : enable; 102 | 103 | if (enable && $('tbody tr', tableElement).length) { 104 | $('#masterCheck', tableElement).prop('disabled', false); 105 | return true; 106 | } else { 107 | $('#masterCheck', tableElement).prop('disabled', true); 108 | return false; 109 | } 110 | } 111 | 112 | /** 113 | * Toggles the master checkbox if all checkboxes in the table that 114 | * are visible are checked. 115 | */ 116 | function toggleMasterCheckBasedOnAllOtherCheckboxes() { 117 | // What we need to do here is check to see if every checkbox is checked. 118 | // If it is, the master checkbox in the header should be checked as well. 119 | var allCheckboxes = $('tbody input:checkbox', tableElement); 120 | var totalCheckboxCount = allCheckboxes.length; 121 | if (totalCheckboxCount) { 122 | var checkedChecboxCount = allCheckboxes.filter(':checked').length; 123 | $('#masterCheck', tableElement).prop('checked', totalCheckboxCount === checkedChecboxCount); 124 | } 125 | } 126 | 127 | /** 128 | * Initialize master checkbox event handlers. 129 | * 130 | * The on parameter is used to register/unregister the event handler. The 131 | * default is true. 132 | * 133 | * @param {Boolean} on 134 | */ 135 | function initializeMasterCheckboxEventHandler(on) { 136 | on = on === undefined ? true : on; 137 | 138 | if (on) { 139 | // Enable master checkbox 140 | enableMasterCheckbox(); 141 | 142 | // Register master checkbox to check/uncheck all checkboxes 143 | $('#masterCheck', tableElement).on('click', function () { 144 | // Toggle all checkboxes by triggering a click event on them. The click 145 | // event will fire the changed event that we can handle. Directly changing 146 | // the checked property like this 147 | // 148 | // $('tbody input:checkbox', tableElement).not(this).prop('checked', this.checked); 149 | // 150 | // toggles all checkboxes but does not trigger click events. Because there's 151 | // no click event, there's no changed events on the checkboxes. We need the 152 | // changed events so that we can keep track of the checked checkboxes. 153 | if (this.checked) { 154 | $('tbody input:checkbox:not(:checked)', tableElement).not(this).trigger('click'); 155 | } else { 156 | $('tbody input:checkbox:checked', tableElement).not(this).trigger('click'); 157 | } 158 | }); 159 | } else { 160 | // Disable master checkbox 161 | enableMasterCheckbox(false); 162 | 163 | // Unregister master checkbox to check/uncheck all checkboxes 164 | $('#masterCheck', tableElement).off('click'); 165 | } 166 | } 167 | 168 | /** 169 | * Initialize checkbox event handlers. 170 | * 171 | * The on parameter is used to register/unregister the event handler. The 172 | * default is true. 173 | * 174 | * The elementCollection parameter can be one of the following: 175 | * - jQuery collection of checkbox elements 176 | * - jQuery selector 177 | * - undefined 178 | * 179 | * If elementCollection is undefined, all checkboxes in DataTable 180 | * will be selected. 181 | * 182 | * @param {Boolean} on 183 | * @param {Object|String|undefined} elementCollection 184 | */ 185 | function initializeCheckboxEventHandlers(on, elementCollection) { 186 | on = on === undefined ? true : on; 187 | 188 | if (elementCollection === undefined) { 189 | elementCollection = $('input:checkbox', tableElement.fnGetNodes()) 190 | } else if (elementCollection === 'string') { 191 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 192 | } 193 | 194 | if (on) { 195 | // Register elementCollection handlers 196 | elementCollection.on('change', function (event) { 197 | // Keep track of the checked checkboxes. 198 | if (event.target.checked) { 199 | // Do something with the checked item 200 | // callSomeFunction(event.target.name, event.target.value); 201 | console.log('Checkbox ' + event.target.name + ' checked', event.target.value); 202 | } else { 203 | // Do something with the unchecked item 204 | // callSomeFunction(event.target.name, event.target.value); 205 | console.log('Checkbox ' + event.target.name + ' unchecked', event.target.value); 206 | } 207 | 208 | // Affect the other parts of the table/page... 209 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 210 | }); 211 | } else { 212 | // Unregister elementCollection handlers 213 | elementCollection.off('change'); 214 | } 215 | } 216 | 217 | /** 218 | * Initialize table row event handler. 219 | * 220 | * The on parameter is used to register/unregister the event handler. The 221 | * default is true. 222 | * 223 | * The elementCollection can be one of the following: 224 | * - jQuery collection of checkbox elements 225 | * - jQuery selector 226 | * - undefined 227 | * 228 | * If elementCollection is undefined, all table rows in DataTable 229 | * will be selected. 230 | * 231 | * @param {Boolean} on 232 | * @param {Object|String|undefined} elementCollection 233 | */ 234 | function initializeTableRowEventHandlers(on, elementCollection) { 235 | on = on === undefined ? true : on; 236 | 237 | if (elementCollection === undefined) { 238 | elementCollection = $(tableElement.fnGetNodes()) 239 | } else if (elementCollection === 'string') { 240 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 241 | } 242 | 243 | if (on) { 244 | // Register elementCollection handlers as needed. 245 | } else { 246 | // Unregister elementCollection handlers as needed. 247 | } 248 | } 249 | }); 250 | -------------------------------------------------------------------------------- /examples/dt1.9/js/ajax-bootstrap3.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElement = $('#example'); 10 | 11 | tableElement.dataTable({ 12 | sPaginationType: 'bootstrap', 13 | oLanguage : { 14 | sLengthMenu: '_MENU_ records per page' 15 | }, 16 | // disable sorting on the checkbox column 17 | aoColumnDefs : [ 18 | { 19 | aTargets : [ 0 ], // Column number which needs to be modified 20 | bSortable: false, // Column is not sortable 21 | // Custom render function - add checkbox 22 | mRender : function (data, type) { 23 | return ''; 24 | }, 25 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 26 | }, 27 | { 28 | aTargets: [ 4 ], // Column number which needs to be modified 29 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 30 | }, 31 | { 32 | aTargets: [ 5 ], // Column number which needs to be modified 33 | sClass : 'centered-cell' // Optional - class to be applied to this table cell 34 | } 35 | ], 36 | bProcessing : true, 37 | bAutoWidth : false, 38 | sAjaxSource : './arrays.txt', 39 | // Custom call back for AJAX 40 | fnServerData : function (sSource, aoData, fnCallback, oSettings) { 41 | oSettings.jqXHR = $.ajax({ 42 | dataType: 'json', 43 | type : 'GET', 44 | url : sSource, 45 | data : aoData, 46 | success : function (data) { 47 | fnCallback(data); 48 | } 49 | }); 50 | }, 51 | fnPreDrawCallback: function () { 52 | // Initialize the responsive datatables helper once. 53 | if (!responsiveHelper) { 54 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 55 | } 56 | }, 57 | fnRowCallback : function (nRow) { 58 | responsiveHelper.createExpandIcon(nRow); 59 | }, 60 | fnDrawCallback : function () { 61 | // This function will be called every the table redraws. 62 | // Specifically, we're interested when next/previous page 63 | // occurs. 64 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 65 | 66 | // Respond to windows resize. 67 | responsiveHelper.respond(); 68 | }, 69 | fnInitComplete : function (oSettings) { 70 | initializeMasterCheckboxEventHandler(); 71 | initializeCheckboxEventHandlers(); 72 | initializeTableRowEventHandlers(); 73 | 74 | oSettings.aoDestroyCallback.push({ 75 | 'sName': 'UnregisterEventHandlers', 76 | 'fn': function () { 77 | initializeMasterCheckboxEventHandler(false); 78 | initializeCheckboxEventHandlers(false); 79 | initializeTableRowEventHandlers(false); 80 | } 81 | }); 82 | 83 | // Add form-control class to elements to give rounded effect 84 | $('div.dataTables_length select').addClass('form-control'); 85 | $('div.dataTables_filter input').addClass('form-control'); 86 | } 87 | }); 88 | 89 | // NOTE: We did not add class="centered-cell" to the Engine version and CSS grade columns 90 | // as in other examples. 91 | 92 | 93 | /** 94 | * Enable master checkbox if there are more than one row in the data table. 95 | * 96 | * The enable parameter is used to enable/disable the element. 97 | * 98 | * Returns true if enable was successful. 99 | * 100 | * @param {Boolean} enable 101 | * @returns {Boolean} 102 | */ 103 | function enableMasterCheckbox (enable) { 104 | enable = enable === undefined ? true : enable; 105 | 106 | if (enable && $('tbody tr', tableElement).length) { 107 | $('#masterCheck', tableElement).prop('disabled', false); 108 | return true; 109 | } else { 110 | $('#masterCheck', tableElement).prop('disabled', true); 111 | return false; 112 | } 113 | } 114 | 115 | /** 116 | * Toggles the master checkbox if all checkboxes in the table that 117 | * are visible are checked. 118 | */ 119 | function toggleMasterCheckBasedOnAllOtherCheckboxes() { 120 | // What we need to do here is check to see if every checkbox is checked. 121 | // If it is, the master checkbox in the header should be checked as well. 122 | var allCheckboxes = $('tbody input:checkbox', tableElement); 123 | var totalCheckboxCount = allCheckboxes.length; 124 | if (totalCheckboxCount) { 125 | var checkedChecboxCount = allCheckboxes.filter(':checked').length; 126 | $('#masterCheck', tableElement).prop('checked', totalCheckboxCount === checkedChecboxCount); 127 | } 128 | } 129 | 130 | /** 131 | * Initialize master checkbox event handlers. 132 | * 133 | * The on parameter is used to register/unregister the event handler. The 134 | * default is true. 135 | * 136 | * @param {Boolean} on 137 | */ 138 | function initializeMasterCheckboxEventHandler(on) { 139 | on = on === undefined ? true : on; 140 | 141 | if (on) { 142 | // Enable master checkbox 143 | enableMasterCheckbox(); 144 | 145 | // Register master checkbox to check/uncheck all checkboxes 146 | $('#masterCheck', tableElement).on('click', function () { 147 | // Toggle all checkboxes by triggering a click event on them. The click 148 | // event will fire the changed event that we can handle. Directly changing 149 | // the checked property like this 150 | // 151 | // $('tbody input:checkbox', tableElement).not(this).prop('checked', this.checked); 152 | // 153 | // toggles all checkboxes but does not trigger click events. Because there's 154 | // no click event, there's no changed events on the checkboxes. We need the 155 | // changed events so that we can keep track of the checked checkboxes. 156 | if (this.checked) { 157 | $('tbody input:checkbox:not(:checked)', tableElement).not(this).trigger('click'); 158 | } else { 159 | $('tbody input:checkbox:checked', tableElement).not(this).trigger('click'); 160 | } 161 | }); 162 | } else { 163 | // Disable master checkbox 164 | enableMasterCheckbox(false); 165 | 166 | // Unregister master checkbox to check/uncheck all checkboxes 167 | $('#masterCheck', tableElement).off('click'); 168 | } 169 | } 170 | 171 | /** 172 | * Initialize checkbox event handlers. 173 | * 174 | * The on parameter is used to register/unregister the event handler. The 175 | * default is true. 176 | * 177 | * The elementCollection parameter can be one of the following: 178 | * - jQuery collection of checkbox elements 179 | * - jQuery selector 180 | * - undefined 181 | * 182 | * If elementCollection is undefined, all checkboxes in DataTable 183 | * will be selected. 184 | * 185 | * @param {Boolean} on 186 | * @param {Object|String|undefined} elementCollection 187 | */ 188 | function initializeCheckboxEventHandlers(on, elementCollection) { 189 | on = on === undefined ? true : on; 190 | 191 | if (elementCollection === undefined) { 192 | elementCollection = $('input:checkbox', tableElement.fnGetNodes()) 193 | } else if (elementCollection === 'string') { 194 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 195 | } 196 | 197 | if (on) { 198 | // Register elementCollection handlers 199 | elementCollection.on('change', function (event) { 200 | // Keep track of the checked checkboxes. 201 | if (event.target.checked) { 202 | // Do something with the checked item 203 | // callSomeFunction(event.target.name, event.target.value); 204 | console.log('Checkbox ' + event.target.name + ' checked', event.target.value); 205 | } else { 206 | // Do something with the unchecked item 207 | // callSomeFunction(event.target.name, event.target.value); 208 | console.log('Checkbox ' + event.target.name + ' unchecked', event.target.value); 209 | } 210 | 211 | // Affect the other parts of the table/page... 212 | toggleMasterCheckBasedOnAllOtherCheckboxes(); 213 | }); 214 | } else { 215 | // Unregister elementCollection handlers 216 | elementCollection.off('change'); 217 | } 218 | } 219 | 220 | /** 221 | * Initialize table row event handler. 222 | * 223 | * The on parameter is used to register/unregister the event handler. The 224 | * default is true. 225 | * 226 | * The elementCollection can be one of the following: 227 | * - jQuery collection of checkbox elements 228 | * - jQuery selector 229 | * - undefined 230 | * 231 | * If elementCollection is undefined, all table rows in DataTable 232 | * will be selected. 233 | * 234 | * @param {Boolean} on 235 | * @param {Object|String|undefined} elementCollection 236 | */ 237 | function initializeTableRowEventHandlers(on, elementCollection) { 238 | on = on === undefined ? true : on; 239 | 240 | if (elementCollection === undefined) { 241 | elementCollection = $(tableElement.fnGetNodes()) 242 | } else if (elementCollection === 'string') { 243 | elementCollection = $(elementCollection, tableElement.fnGetNodes()) 244 | } 245 | 246 | if (on) { 247 | // Register elementCollection handlers as needed. 248 | } else { 249 | // Unregister elementCollection handlers as needed. 250 | } 251 | } 252 | }); 253 | -------------------------------------------------------------------------------- /examples/dt1.9/js/dom-bootstrap2-multiple-table.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElements = $('table'); 10 | 11 | tableElements.dataTable({ 12 | sDom : '<"row"<"span6"l><"span6"f>r>t<"row"<"span6"i><"span6"p>>', 13 | sPaginationType: 'bootstrap', 14 | oLanguage : { 15 | sLengthMenu: '_MENU_ records per page' 16 | }, 17 | bAutoWidth : false, 18 | fnPreDrawCallback: function () { 19 | // Initialize the responsive datatables helper once. 20 | if (!this.responsiveHelper) { 21 | this.responsiveHelper = new ResponsiveDatatablesHelper(this, breakpointDefinition); 22 | } 23 | }, 24 | fnRowCallback : function (nRow) { 25 | this.responsiveHelper.createExpandIcon(nRow); 26 | }, 27 | fnDrawCallback : function (oSettings) { 28 | this.responsiveHelper.respond(); 29 | } 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /examples/dt1.9/js/dom-bootstrap2.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | $(document).ready(function () { 4 | var responsiveHelper = undefined; 5 | var breakpointDefinition = { 6 | tablet: 1024, 7 | phone : 480 8 | }; 9 | var tableElement = $('#example'); 10 | 11 | tableElement.dataTable({ 12 | sDom : '<"row"<"span6"l><"span6"f>r>t<"row"<"span6"i><"span6"p>>', 13 | sPaginationType: 'bootstrap', 14 | oLanguage : { 15 | sLengthMenu: '_MENU_ records per page' 16 | }, 17 | bAutoWidth : false, 18 | fnPreDrawCallback: function () { 19 | // Initialize the responsive datatables helper once. 20 | if (!responsiveHelper) { 21 | responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); 22 | } 23 | }, 24 | fnRowCallback : function (nRow) { 25 | responsiveHelper.createExpandIcon(nRow); 26 | }, 27 | fnDrawCallback : function (oSettings) { 28 | responsiveHelper.respond(); 29 | } 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /files/1.10/css/datatables.responsive.css: -------------------------------------------------------------------------------- 1 | table.has-columns-hidden > tbody > tr > td > span.responsiveExpander { 2 | background: url('../img/plus.png') no-repeat 5px center; 3 | padding-left: 32px; 4 | cursor: pointer; 5 | } 6 | 7 | table.has-columns-hidden > tbody > tr.detail-show > td span.responsiveExpander { 8 | background: url('../img/minus.png') no-repeat 5px center; 9 | } 10 | 11 | table.has-columns-hidden > tbody > tr.row-detail > td { 12 | background: #eee; 13 | } 14 | 15 | table.has-columns-hidden > tbody > tr.row-detail > td > ul { 16 | list-style: none; 17 | margin: 0; 18 | padding: 0; 19 | } 20 | 21 | table.has-columns-hidden > tbody > tr.row-detail > td > ul > li > span.columnTitle { 22 | font-weight: bold; 23 | } 24 | -------------------------------------------------------------------------------- /files/1.10/img/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comanche/datatables-responsive/bbb1aa223a83159977e6917aeb570296d4d2a6a2/files/1.10/img/minus.png -------------------------------------------------------------------------------- /files/1.10/img/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comanche/datatables-responsive/bbb1aa223a83159977e6917aeb570296d4d2a6a2/files/1.10/img/plus.png -------------------------------------------------------------------------------- /files/1.10/js/datatables.responsive.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File: datatables.responsive.js 3 | * Version: 0.2.0 4 | * Author: Seen Sai Yang 5 | * Info: https://github.com/Comanche/datatables-responsive 6 | * 7 | * Copyright 2013 Seen Sai Yang, all rights reserved. 8 | * 9 | * This source file is free software, under either the GPL v2 license or a 10 | * BSD style license. 11 | * 12 | * This source file is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. 15 | * 16 | * You should have received a copy of the GNU General Public License and the 17 | * BSD license along with this program. These licenses are also available at: 18 | * https://raw.github.com/Comanche/datatables-responsive/master/license-gpl2.txt 19 | * https://raw.github.com/Comanche/datatables-responsive/master/license-bsd.txt 20 | */ 21 | 22 | 'use strict'; 23 | 24 | /** 25 | * Constructor for responsive datables helper. 26 | * 27 | * This helper class makes datatables responsive to the window size. 28 | * 29 | * The parameter, breakpoints, is an object for each breakpoint key/value pair 30 | * with the following format: { breakpoint_name: pixel_width_at_breakpoint }. 31 | * 32 | * An example is as follows: 33 | * 34 | * { 35 | * tablet: 1024, 36 | * phone: 480 37 | * } 38 | * 39 | * These breakpoint name may be used as possible values for the data-hide 40 | * attribute. The data-hide attribute is optional and may be defined for each 41 | * th element in the table header. 42 | * 43 | * The parameter, options, is an object of options supported by the responsive 44 | * helper. The following options are supported: 45 | * 46 | * { 47 | * hideEmptyColumnsInRowDetail - Boolean, default: false. 48 | * clickOn - icon|cell|row, default: icon 49 | * showDetail - function called when detail row shown 50 | * hideDetail - function called when detail row hidden 51 | * } 52 | * 53 | * @param {Object|string} tableSelector jQuery wrapped set or selector for 54 | * datatables container element. 55 | * @param {Object} breakpoints Object defining the responsive 56 | * breakpoint for datatables. 57 | * @param {Object} options Object of options. 58 | */ 59 | function ResponsiveDatatablesHelper(tableSelector, breakpoints, options) { 60 | if (typeof tableSelector === 'string') { 61 | this.tableElement = $(tableSelector); 62 | } else { 63 | this.tableElement = tableSelector; 64 | } 65 | 66 | // Get data table API. 67 | this.api = this.tableElement.dataTable().api(); 68 | 69 | // State of column indexes and which are shown or hidden. 70 | this.columnIndexes = []; 71 | this.columnsShownIndexes = []; 72 | this.columnsHiddenIndexes = []; 73 | this.currentBreakpoint = ''; 74 | this.lastBreakpoint = ''; 75 | this.lastColumnsHiddenIndexes = []; 76 | 77 | // Save state 78 | var fileName = window.location.pathname.split("/").pop(); 79 | var context = this.api.settings().context[0]; 80 | 81 | this.tableId = context.sTableId; 82 | this.saveState = context.oInit.bStateSave; 83 | this.cookieName = 'DataTablesResponsiveHelper_' + this.tableId + (fileName ? '_' + fileName : ''); 84 | this.lastStateExists = false; 85 | 86 | // Index of the th in the header tr that stores where the attribute 87 | // data-class="expand" 88 | // is defined. 89 | this.expandColumn = undefined; 90 | // Stores original breakpoint defitions 91 | this.origBreakpointsDefs = undefined; 92 | // Stores the break points defined in the table header. 93 | // Each th in the header tr may contain an optional attribute like 94 | // data-hide="phone,tablet" 95 | // These attributes and the breakpoints object will be used to create this 96 | // object. 97 | this.breakpoints = { 98 | /** 99 | * We will be generating data in the following format: 100 | * phone : { 101 | * lowerLimit : undefined, 102 | * upperLimit : 320, 103 | * columnsToHide: [] 104 | * }, 105 | * tablet: { 106 | * lowerLimit : 320, 107 | * upperLimit : 724, 108 | * columnsToHide: [] 109 | * } 110 | */ 111 | }; 112 | 113 | // Store default options 114 | this.options = { 115 | hideEmptyColumnsInRowDetail: false, 116 | clickOn: 'icon', 117 | showDetail: null, 118 | hideDetail: null 119 | }; 120 | 121 | // Expand icon template 122 | this.expandIconTemplate = ''; 123 | 124 | // Row template 125 | this.rowTemplate = ''; 126 | this.rowLiTemplate = '
  • :
  • '; 127 | 128 | // Responsive behavior on/off flag 129 | this.disabled = true; 130 | 131 | // Skip next windows width change flag 132 | this.skipNextWindowsWidthChange = false; 133 | 134 | // Initialize settings 135 | this.init(breakpoints, options); 136 | } 137 | 138 | /** 139 | * Responsive datatables helper init function. 140 | * Builds breakpoint limits for columns and begins to listen to window resize 141 | * event. 142 | * 143 | * See constructor for the breakpoints parameter. 144 | * 145 | * @param {Object} breakpoints 146 | * @param {Object} options 147 | */ 148 | ResponsiveDatatablesHelper.prototype.init = function (breakpoints, options) { 149 | this.origBreakpointsDefs = breakpoints; 150 | this.initBreakpoints(); 151 | 152 | // Enable responsive behavior. 153 | this.disable(false); 154 | 155 | // Extend options 156 | $.extend(this.options, options); 157 | }; 158 | 159 | ResponsiveDatatablesHelper.prototype.initBreakpoints = function () { 160 | // Get last state if it exists 161 | if (this.saveState) { 162 | this.getState(); 163 | } 164 | 165 | if (!this.lastStateExists) { 166 | /** Generate breakpoints in the format we need. ***********************/ 167 | // First, we need to create a sorted array of the breakpoints given. 168 | var breakpointsSorted = []; 169 | 170 | for (var prop in this.origBreakpointsDefs) { 171 | breakpointsSorted.push({ 172 | name: prop, 173 | upperLimit: this.origBreakpointsDefs[prop], 174 | columnsToHide: [] 175 | }); 176 | } 177 | 178 | breakpointsSorted.sort(function (a, b) { 179 | return a.upperLimit - b.upperLimit; 180 | }); 181 | 182 | // Set lower and upper limits for each breakpoint. 183 | var lowerLimit = 0; 184 | for (var i = 0; i < breakpointsSorted.length; i++) { 185 | breakpointsSorted[i].lowerLimit = lowerLimit; 186 | lowerLimit = breakpointsSorted[i].upperLimit; 187 | } 188 | 189 | // Add the default breakpoint which shows all (has no upper limit). 190 | breakpointsSorted.push({ 191 | name : 'always', 192 | lowerLimit : lowerLimit, 193 | upperLimit : Infinity, 194 | columnsToHide: [] 195 | }); 196 | 197 | // Copy the sorted breakpoint array into the breakpoints object using the 198 | // name as the key. 199 | this.breakpoints = {}; 200 | var i, l; 201 | for (i = 0, l = breakpointsSorted.length; i < l; i++) { 202 | this.breakpoints[breakpointsSorted[i].name] = breakpointsSorted[i]; 203 | } 204 | 205 | /** Create range of visible columns and their indexes *****************/ 206 | // We need the range of all visible column indexes to calculate the 207 | // columns to show: 208 | // Columns to show = all visible columns - columns to hide 209 | var columns = this.api.columns().header(); 210 | var visibleColumnsHeadersTds = []; 211 | for (i = 0, l = columns.length; i < l; i++) { 212 | if (this.api.column(i).visible()) { 213 | this.columnIndexes.push(i); 214 | visibleColumnsHeadersTds.push(columns[i]); 215 | } 216 | } 217 | 218 | /** Sort columns into breakpoints respectively ************************/ 219 | // Read column headers' attributes and get needed info 220 | for (var index = 0; index < visibleColumnsHeadersTds.length; index++) { 221 | // Get the column with the attribute data-class="expand" so we know 222 | // where to display the expand icon. 223 | var col = $(visibleColumnsHeadersTds[index]); 224 | 225 | if (col.attr('data-class') === 'expand') { 226 | this.expandColumn = this.columnIndexes[index]; 227 | } 228 | 229 | // The data-hide attribute has the breakpoints that this column 230 | // is associated with. 231 | // If it's defined, get the data-hide attribute and sort this 232 | // column into the appropriate breakpoint's columnsToHide array. 233 | var dataHide = col.attr('data-hide'); 234 | if (dataHide !== undefined) { 235 | var splitBreakingPoints = dataHide.split(/,\s*/); 236 | for (var i = 0; i < splitBreakingPoints.length; i++) { 237 | var bp = splitBreakingPoints[i]; 238 | if (bp === 'always') { 239 | // A column with an 'always' breakpoint is always hidden. 240 | // Loop through all breakpoints and add it to each except the 241 | // default breakpoint. 242 | for (var prop in this.breakpoints) { 243 | if (this.breakpoints[prop].name !== 'default') { 244 | this.breakpoints[prop].columnsToHide.push(this.columnIndexes[index]); 245 | } 246 | } 247 | } else if (this.breakpoints[bp] !== undefined) { 248 | // Translate visible column index to internal column index. 249 | this.breakpoints[bp].columnsToHide.push(this.columnIndexes[index]); 250 | } 251 | } 252 | } 253 | } 254 | } 255 | }; 256 | 257 | /** 258 | * Sets or removes window resize handler. 259 | * 260 | * @param {Boolean} bindFlag 261 | */ 262 | ResponsiveDatatablesHelper.prototype.setWindowsResizeHandler = function(bindFlag) { 263 | if (bindFlag === undefined) { 264 | bindFlag = true; 265 | } 266 | 267 | if (bindFlag) { 268 | var that = this; 269 | $(window).bind("resize", function () { 270 | that.respond(); 271 | }); 272 | } else { 273 | $(window).unbind("resize"); 274 | } 275 | }; 276 | 277 | /** 278 | * Respond window size change. This helps make datatables responsive. 279 | */ 280 | ResponsiveDatatablesHelper.prototype.respond = function () { 281 | if (this.disabled) { 282 | return; 283 | } 284 | var that = this; 285 | 286 | // Get new windows width 287 | var newWindowWidth = $(window).width(); 288 | 289 | // Loop through breakpoints to see which columns need to be shown/hidden. 290 | var newColumnsToHide = []; 291 | 292 | for (var prop in this.breakpoints) { 293 | var element = this.breakpoints[prop]; 294 | if ((!element.lowerLimit || newWindowWidth > element.lowerLimit) && (!element.upperLimit || newWindowWidth <= element.upperLimit)) { 295 | this.currentBreakpoint = element.name; 296 | newColumnsToHide = element.columnsToHide; 297 | } 298 | } 299 | 300 | // Find out if a column show/hide should happen. 301 | // Skip column show/hide if this window width change follows immediately 302 | // after a previous column show/hide. This will help prevent a loop. 303 | var columnShowHide = false; 304 | if (!this.skipNextWindowsWidthChange) { 305 | // Check difference in length 306 | if (this.lastBreakpoint.length === 0 && newColumnsToHide.length) { 307 | // No previous breakpoint and new breakpoint 308 | columnShowHide = true; 309 | } else if (this.lastBreakpoint != this.currentBreakpoint) { 310 | // Different breakpoints 311 | columnShowHide = true; 312 | } else if (this.columnsHiddenIndexes.length !== newColumnsToHide.length) { 313 | // Difference in number of hidden columns 314 | columnShowHide = true; 315 | } else { 316 | // Possible same number of columns but check for difference in columns 317 | var d1 = this.difference(this.columnsHiddenIndexes, newColumnsToHide).length; 318 | var d2 = this.difference(newColumnsToHide, this.columnsHiddenIndexes).length; 319 | columnShowHide = d1 + d2 > 0; 320 | } 321 | } 322 | 323 | if (columnShowHide) { 324 | // Showing/hiding a column at breakpoint may cause a windows width 325 | // change. Let's flag to skip the column show/hide that may be 326 | // caused by the next windows width change. 327 | this.skipNextWindowsWidthChange = true; 328 | this.columnsHiddenIndexes = newColumnsToHide; 329 | this.columnsShownIndexes = this.difference(this.columnIndexes, this.columnsHiddenIndexes); 330 | this.showHideColumns(); 331 | this.lastBreakpoint = this.currentBreakpoint; 332 | this.setState(); 333 | this.skipNextWindowsWidthChange = false; 334 | } 335 | 336 | 337 | // We don't skip this part. 338 | // If one or more columns have been hidden, add the has-columns-hidden class to table. 339 | // This class will show what state the table is in. 340 | if (this.columnsHiddenIndexes.length) { 341 | this.tableElement.addClass('has-columns-hidden'); 342 | 343 | // Show details for each row that is tagged with the class .detail-show. 344 | $('tr.detail-show', this.tableElement).each(function (index, element) { 345 | var tr = $(element); 346 | if (tr.next('.row-detail').length === 0) { 347 | ResponsiveDatatablesHelper.prototype.showRowDetail(that, tr); 348 | } 349 | }); 350 | } else { 351 | this.tableElement.removeClass('has-columns-hidden'); 352 | $('tr.row-detail', this.tableElement).each(function (event) { 353 | ResponsiveDatatablesHelper.prototype.hideRowDetail(that, $(this).prev()); 354 | }); 355 | } 356 | }; 357 | 358 | /** 359 | * Show/hide datatables columns. 360 | */ 361 | ResponsiveDatatablesHelper.prototype.showHideColumns = function () { 362 | // Calculate the columns to show 363 | // Show columns that may have been previously hidden. 364 | for (var i = 0, l = this.columnsShownIndexes.length; i < l; i++) { 365 | this.api.column(this.columnsShownIndexes[i]).visible(true); 366 | } 367 | 368 | // Hide columns that may have been previously shown. 369 | for (var i = 0, l = this.columnsHiddenIndexes.length; i < l; i++) { 370 | this.api.column(this.columnsHiddenIndexes[i]).visible(false); 371 | } 372 | 373 | // Rebuild details to reflect shown/hidden column changes. 374 | var that = this; 375 | $('tr.row-detail', this.tableElement).each(function () { 376 | ResponsiveDatatablesHelper.prototype.hideRowDetail(that, $(this).prev()); 377 | }); 378 | if (this.tableElement.hasClass('has-columns-hidden')) { 379 | $('tr.detail-show', this.tableElement).each(function (index, element) { 380 | ResponsiveDatatablesHelper.prototype.showRowDetail(that, $(element)); 381 | }); 382 | } 383 | }; 384 | 385 | /** 386 | * Create the expand icon on the column with the data-class="expand" attribute 387 | * defined for it's header. 388 | * 389 | * @param {Object} tr table row object 390 | */ 391 | ResponsiveDatatablesHelper.prototype.createExpandIcon = function (tr) { 392 | if (this.disabled) { 393 | return; 394 | } 395 | 396 | // Get the td for tr with the same index as the th in the header tr 397 | // that has the data-class="expand" attribute defined. 398 | var tds = $('td', tr); 399 | // Loop through tds and create an expand icon on the td that has a column 400 | // index equal to the expand column given. 401 | for (var i = 0, l = tds.length; i < l; i++) { 402 | var td = tds[i]; 403 | var tdIndex = this.api.cell(td).index().column; 404 | td = $(td); 405 | if (tdIndex === this.expandColumn) { 406 | // Create expand icon if there isn't one already. 407 | if ($('span.responsiveExpander', td).length == 0) { 408 | td.prepend(this.expandIconTemplate); 409 | 410 | // Respond to click event on expander icon. 411 | switch (this.options.clickOn) { 412 | case 'cell': 413 | td.on('click', {responsiveDatatablesHelperInstance: this}, this.showRowDetailEventHandler); 414 | break; 415 | case 'row': 416 | $(tr).on('click', {responsiveDatatablesHelperInstance: this}, this.showRowDetailEventHandler); 417 | break; 418 | default: 419 | td.on('click', 'span.responsiveExpander', {responsiveDatatablesHelperInstance: this}, this.showRowDetailEventHandler); 420 | break; 421 | } 422 | } 423 | break; 424 | } 425 | } 426 | }; 427 | 428 | /** 429 | * Show row detail event handler. 430 | * 431 | * This handler is used to handle the click event of the expand icon defined in 432 | * the table row data element. 433 | * 434 | * @param {Object} event jQuery event object 435 | */ 436 | ResponsiveDatatablesHelper.prototype.showRowDetailEventHandler = function (event) { 437 | var responsiveDatatablesHelperInstance = event.data.responsiveDatatablesHelperInstance; 438 | if (responsiveDatatablesHelperInstance.disabled) { 439 | return; 440 | } 441 | 442 | var td = $(this); 443 | 444 | // Nothing to do if there are no columns hidden. 445 | if (!td.closest('table').hasClass('has-columns-hidden')) { 446 | return; 447 | } 448 | 449 | // Get the parent tr of which this td belongs to. 450 | var tr = td.closest('tr'); 451 | 452 | // Show/hide row details 453 | if (tr.hasClass('detail-show')) { 454 | ResponsiveDatatablesHelper.prototype.hideRowDetail(responsiveDatatablesHelperInstance, tr); 455 | } else { 456 | ResponsiveDatatablesHelper.prototype.showRowDetail(responsiveDatatablesHelperInstance, tr); 457 | } 458 | 459 | tr.toggleClass('detail-show'); 460 | 461 | // Prevent click event from bubbling up to higher-level DOM elements. 462 | event.stopPropagation(); 463 | }; 464 | 465 | /** 466 | * Show row details. 467 | * 468 | * @param {ResponsiveDatatablesHelper} responsiveDatatablesHelperInstance instance of ResponsiveDatatablesHelper 469 | * @param {Object} tr jQuery wrapped set 470 | */ 471 | ResponsiveDatatablesHelper.prototype.showRowDetail = function (responsiveDatatablesHelperInstance, tr) { 472 | // Get column because we need their titles. 473 | var api = responsiveDatatablesHelperInstance.api; 474 | var columns = api.columns().header(); 475 | 476 | // Create the new tr. 477 | var newTr = $(responsiveDatatablesHelperInstance.rowTemplate); 478 | 479 | // Get the ul that we'll insert li's into. 480 | var ul = $('ul', newTr); 481 | 482 | // Loop through hidden columns and create an li for each of them. 483 | for (var i = 0; i < responsiveDatatablesHelperInstance.columnsHiddenIndexes.length; i++) { 484 | var index = responsiveDatatablesHelperInstance.columnsHiddenIndexes[i]; 485 | 486 | // Get row td 487 | var rowIndex = api.row(tr).index(); 488 | var td = api.cell(rowIndex, index).node(); 489 | 490 | // Don't create li if contents are empty (depends on hideEmptyColumnsInRowDetail option). 491 | if (!responsiveDatatablesHelperInstance.options.hideEmptyColumnsInRowDetail || td.innerHTML.trim().length) { 492 | var li = $(responsiveDatatablesHelperInstance.rowLiTemplate); 493 | var hiddenColumnName = $(columns[index]).attr('data-name'); 494 | $('.columnTitle', li).html(hiddenColumnName !== undefined ? hiddenColumnName : columns[index].innerHTML); 495 | var contents = $(td).contents(); 496 | var clonedContents = contents.clone(); 497 | 498 | // Select elements' selectedIndex are not cloned. Do it manually. 499 | for (var n = 0, m = contents.length; n < m; n++) { 500 | var node = contents[n]; 501 | if (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'SELECT') { 502 | clonedContents[n].selectedIndex = node.selectedIndex 503 | } 504 | } 505 | 506 | // Set the column contents and save the original td source. 507 | $('.columnValue', li).append(clonedContents).data('originalTdSource', td); 508 | 509 | // Copy index to data attribute, so we'll know where to put the value when the tr.row-detail is removed. 510 | li.attr('data-column', index); 511 | 512 | // Copy td class to new li. 513 | var tdClass = $(td).attr('class'); 514 | if (tdClass !== 'undefined' && tdClass !== false && tdClass !== '') { 515 | li.addClass(tdClass) 516 | } 517 | 518 | ul.append(li); 519 | } 520 | } 521 | 522 | // Create tr colspan attribute. 523 | var colspan = responsiveDatatablesHelperInstance.columnIndexes.length - responsiveDatatablesHelperInstance.columnsHiddenIndexes.length; 524 | newTr.find('> td').attr('colspan', colspan); 525 | 526 | // Append the new tr after the current tr. 527 | tr.after(newTr); 528 | 529 | // call the showDetail function if needbe 530 | if (responsiveDatatablesHelperInstance.options.showDetail){ 531 | responsiveDatatablesHelperInstance.options.showDetail(newTr); 532 | } 533 | }; 534 | 535 | /** 536 | * Hide row details. 537 | * 538 | * @param {ResponsiveDatatablesHelper} responsiveDatatablesHelperInstance instance of ResponsiveDatatablesHelper 539 | * @param {Object} tr jQuery wrapped set 540 | */ 541 | ResponsiveDatatablesHelper.prototype.hideRowDetail = function (responsiveDatatablesHelperInstance, tr) { 542 | // If the value of an input has changed while in row detail, we need to copy its state back 543 | // to the DataTables object so that value will persist when the tr.row-detail is removed. 544 | var rowDetail = tr.next('.row-detail'); 545 | if (responsiveDatatablesHelperInstance.options.hideDetail){ 546 | responsiveDatatablesHelperInstance.options.hideDetail(rowDetail); 547 | } 548 | rowDetail.find('li').each(function () { 549 | var columnValueContainer = $(this).find('span.columnValue'); 550 | var tdContents = columnValueContainer.contents(); 551 | var td = columnValueContainer.data('originalTdSource'); 552 | $(td).empty().append(tdContents); 553 | }); 554 | rowDetail.remove(); 555 | }; 556 | 557 | /** 558 | * Enable/disable responsive behavior and restores changes made. 559 | * 560 | * @param {Boolean} disable, default is true 561 | */ 562 | ResponsiveDatatablesHelper.prototype.disable = function (disable) { 563 | this.disabled = (disable === undefined) || disable; 564 | 565 | if (this.disabled) { 566 | // Remove windows resize handler. 567 | this.setWindowsResizeHandler(false); 568 | 569 | // Remove all trs that have row details. 570 | $('tbody tr.row-detail', this.tableElement).remove(); 571 | 572 | // Remove all trs that are marked to have row details shown. 573 | $('tbody tr', this.tableElement).removeClass('detail-show'); 574 | 575 | // Remove all expander icons. 576 | $('tbody tr span.responsiveExpander', this.tableElement).remove(); 577 | 578 | this.columnsHiddenIndexes = []; 579 | this.columnsShownIndexes = this.columnIndexes; 580 | this.showHideColumns(); 581 | this.tableElement.removeClass('has-columns-hidden'); 582 | 583 | this.tableElement.off('click', 'span.responsiveExpander', this.showRowDetailEventHandler); 584 | } else { 585 | // Add windows resize handler. 586 | this.setWindowsResizeHandler(); 587 | } 588 | }; 589 | 590 | /** 591 | * Get state from cookie. 592 | */ 593 | ResponsiveDatatablesHelper.prototype.getState = function () { 594 | if (typeof(Storage)) { 595 | // Use local storage 596 | var value = JSON.parse(localStorage.getItem(this.cookieName)); 597 | if (value) { 598 | this.columnIndexes = value.columnIndexes; 599 | this.breakpoints = value.breakpoints; 600 | this.expandColumn = value.expandColumn; 601 | this.lastBreakpoint = value.lastBreakpoint; 602 | this.lastStateExists = true; 603 | } 604 | } else { 605 | // No local storage. 606 | } 607 | }; 608 | 609 | /** 610 | * Saves state to cookie. 611 | */ 612 | ResponsiveDatatablesHelper.prototype.setState = function () { 613 | if (typeof(Storage)) { 614 | // Use local storage 615 | var d1 = this.difference(this.lastColumnsHiddenIndexes, this.columnsHiddenIndexes).length; 616 | var d2 = this.difference(this.columnsHiddenIndexes, this.lastColumnsHiddenIndexes).length; 617 | 618 | if (d1 + d2 > 0) { 619 | var tt; 620 | var value = { 621 | columnIndexes: this.columnIndexes, // array 622 | columnsHiddenIndexes: this.columnsHiddenIndexes, // array 623 | breakpoints: this.breakpoints, // object 624 | expandColumn: this.expandColumn, // int|undefined 625 | lastBreakpoint: this.lastBreakpoint // string 626 | }; 627 | 628 | localStorage.setItem(this.cookieName, JSON.stringify(value)); 629 | this.lastColumnsHiddenIndexes = this.columnsHiddenIndexes.slice(0); 630 | } 631 | } else { 632 | // No local storage. 633 | } 634 | }; 635 | 636 | /** 637 | * Get Difference. 638 | */ 639 | ResponsiveDatatablesHelper.prototype.difference = function (a, b) { 640 | var arr = [], i, hash = {}; 641 | for (i = b.length - 1; i >= 0; i--) { 642 | hash[b[i]] = true; 643 | } 644 | for (i = a.length - 1; i >= 0; i--) { 645 | if (hash[a[i]] !== true) { 646 | arr.push(a[i]); 647 | } 648 | } 649 | return arr; 650 | }; 651 | -------------------------------------------------------------------------------- /files/1.9/css/datatables.responsive.css: -------------------------------------------------------------------------------- 1 | table.has-columns-hidden > tbody > tr > td > span.responsiveExpander { 2 | background: url('../img/plus.png') no-repeat 5px center; 3 | padding-left: 32px; 4 | cursor: pointer; 5 | } 6 | 7 | table.has-columns-hidden > tbody > tr.detail-show > td span.responsiveExpander { 8 | background: url('../img/minus.png') no-repeat 5px center; 9 | } 10 | 11 | table.has-columns-hidden > tbody > tr.row-detail > td { 12 | background: #eee; 13 | } 14 | 15 | table.has-columns-hidden > tbody > tr.row-detail > td > ul { 16 | list-style: none; 17 | margin: 0; 18 | padding: 0; 19 | } 20 | 21 | table.has-columns-hidden > tbody > tr.row-detail > td > ul > li > span.columnTitle { 22 | font-weight: bold; 23 | } 24 | -------------------------------------------------------------------------------- /files/1.9/img/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comanche/datatables-responsive/bbb1aa223a83159977e6917aeb570296d4d2a6a2/files/1.9/img/minus.png -------------------------------------------------------------------------------- /files/1.9/img/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/comanche/datatables-responsive/bbb1aa223a83159977e6917aeb570296d4d2a6a2/files/1.9/img/plus.png -------------------------------------------------------------------------------- /files/1.9/js/datatables.responsive.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File: datatables.responsive.js 3 | * Version: 0.1.5 4 | * Author: Seen Sai Yang 5 | * Info: https://github.com/Comanche/datatables-responsive 6 | * 7 | * Copyright 2013 Seen Sai Yang, all rights reserved. 8 | * 9 | * This source file is free software, under either the GPL v2 license or a 10 | * BSD style license. 11 | * 12 | * This source file is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. 15 | * 16 | * You should have received a copy of the GNU General Public License and the 17 | * BSD license along with this program. These licenses are also available at: 18 | * https://raw.github.com/Comanche/datatables-responsive/master/license-gpl2.txt 19 | * https://raw.github.com/Comanche/datatables-responsive/master/license-bsd.txt 20 | */ 21 | 22 | 'use strict'; 23 | 24 | /** 25 | * Constructor for responsive datables helper. 26 | * 27 | * This helper class makes datatables responsive to the window size. 28 | * 29 | * The parameter, breakpoints, is an object for each breakpoint key/value pair 30 | * with the following format: { breakpoint_name: pixel_width_at_breakpoint }. 31 | * 32 | * An example is as follows: 33 | * 34 | * { 35 | * tablet: 1024, 36 | * phone: 480 37 | * } 38 | * 39 | * These breakpoint name may be used as possible values for the data-hide 40 | * attribute. The data-hide attribute is optional and may be defined for each 41 | * th element in the table header. 42 | * 43 | * The parameter, options, is an object of options supported by the responsive 44 | * helper. The following options are supported: 45 | * 46 | * { 47 | * hideEmptyColumnsInRowDetail - Boolean, default: false. 48 | * clickOn - icon|cell|row, default: icon 49 | * showDetail - function called when detail row shown 50 | * hideDetail - function called when detail row hidden 51 | * } 52 | * 53 | * @param {Object|string} tableSelector jQuery wrapped set or selector for 54 | * datatables container element. 55 | * @param {Object} breakpoints Object defining the responsive 56 | * breakpoint for datatables. 57 | * @param {Object} options Object of options. 58 | */ 59 | function ResponsiveDatatablesHelper(tableSelector, breakpoints, options) { 60 | if (typeof tableSelector === 'string') { 61 | this.tableElement = $(tableSelector); 62 | } else { 63 | this.tableElement = tableSelector; 64 | } 65 | 66 | // State of column indexes and which are shown or hidden. 67 | this.columnIndexes = []; 68 | this.columnsShownIndexes = []; 69 | this.columnsHiddenIndexes = []; 70 | this.currentBreakpoint = ''; 71 | this.lastBreakpoint = ''; 72 | this.lastColumnsHiddenIndexes = []; 73 | 74 | // Save state 75 | var fileName = window.location.pathname.split("/").pop(); 76 | var oSettings = this.tableElement.fnSettings(); 77 | this.tableId = oSettings.sTableId; 78 | this.saveState = oSettings.oInit.bStateSave; 79 | this.cookieName = this.tableElement.fnSettings().sCookiePrefix 80 | + 'ResponsiveHelper_' + this.tableId + (fileName ? '_' + fileName : ''); 81 | this.lastStateExists = false; 82 | 83 | // Index of the th in the header tr that stores where the attribute 84 | // data-class="expand" 85 | // is defined. 86 | this.expandColumn = undefined; 87 | // Stores original breakpoint defitions 88 | this.origBreakpointsDefs = undefined; 89 | // Stores the break points defined in the table header. 90 | // Each th in the header tr may contain an optional attribute like 91 | // data-hide="phone,tablet" 92 | // These attributes and the breakpoints object will be used to create this 93 | // object. 94 | this.breakpoints = { 95 | /** 96 | * We will be generating data in the following format: 97 | * phone : { 98 | * lowerLimit : undefined, 99 | * upperLimit : 320, 100 | * columnsToHide: [] 101 | * }, 102 | * tablet: { 103 | * lowerLimit : 320, 104 | * upperLimit : 724, 105 | * columnsToHide: [] 106 | * } 107 | */ 108 | }; 109 | 110 | // Store default options 111 | this.options = { 112 | hideEmptyColumnsInRowDetail: false, 113 | clickOn: 'icon', 114 | showDetail: null, 115 | hideDetail: null 116 | }; 117 | 118 | // Expand icon template 119 | this.expandIconTemplate = ''; 120 | 121 | // Row template 122 | this.rowTemplate = ''; 123 | this.rowLiTemplate = '
  • :
  • '; 124 | 125 | // Responsive behavior on/off flag 126 | this.disabled = true; 127 | 128 | // Skip next windows width change flag 129 | this.skipNextWindowsWidthChange = false; 130 | 131 | // Initialize settings 132 | this.init(breakpoints, options); 133 | } 134 | 135 | /** 136 | * Responsive datatables helper init function. 137 | * Builds breakpoint limits for columns and begins to listen to window resize 138 | * event. 139 | * 140 | * See constructor for the breakpoints parameter. 141 | * 142 | * @param {Object} breakpoints 143 | * @param {Object} options 144 | */ 145 | ResponsiveDatatablesHelper.prototype.init = function (breakpoints, options) { 146 | this.origBreakpointsDefs = breakpoints; 147 | this.initBreakpoints(); 148 | 149 | // Enable responsive behavior. 150 | this.disable(false); 151 | 152 | // Extend options 153 | $.extend(this.options, options); 154 | }; 155 | 156 | ResponsiveDatatablesHelper.prototype.initBreakpoints = function () { 157 | // Get last state if it exists 158 | if (this.saveState) { 159 | this.getState(); 160 | } 161 | 162 | if (!this.lastStateExists) { 163 | /** Generate breakpoints in the format we need. ***********************/ 164 | // First, we need to create a sorted array of the breakpoints given. 165 | var breakpointsSorted = []; 166 | 167 | for (var prop in this.origBreakpointsDefs) { 168 | breakpointsSorted.push({ 169 | name: prop, 170 | upperLimit: this.origBreakpointsDefs[prop], 171 | columnsToHide: [] 172 | }); 173 | } 174 | 175 | breakpointsSorted.sort(function (a, b) { 176 | return a.upperLimit - b.upperLimit; 177 | }); 178 | 179 | // Set lower and upper limits for each breakpoint. 180 | var lowerLimit = 0; 181 | for (var i = 0; i < breakpointsSorted.length; i++) { 182 | breakpointsSorted[i].lowerLimit = lowerLimit; 183 | lowerLimit = breakpointsSorted[i].upperLimit; 184 | } 185 | 186 | // Add the default breakpoint which shows all (has no upper limit). 187 | breakpointsSorted.push({ 188 | name: 'always', 189 | lowerLimit: lowerLimit, 190 | upperLimit: Infinity, 191 | columnsToHide: [] 192 | }); 193 | 194 | // Copy the sorted breakpoint array into the breakpoints object using the 195 | // name as the key. 196 | this.breakpoints = {}; 197 | var i, l; 198 | for (i = 0, l = breakpointsSorted.length; i < l; i++) { 199 | this.breakpoints[breakpointsSorted[i].name] = breakpointsSorted[i]; 200 | } 201 | 202 | /** Create range of visible columns and their indexes *****************/ 203 | // We need the range of all visible column indexes to calculate the 204 | // columns to show: 205 | // Columns to show = all visible columns - columns to hide 206 | var columns = this.tableElement.fnSettings().aoColumns; 207 | var visibleColumnsHeadersTds = []; 208 | for (i = 0, l = columns.length; i < l; i++) { 209 | if (columns[i].bVisible) { 210 | this.columnIndexes.push(i); 211 | visibleColumnsHeadersTds.push(columns[i]); 212 | } 213 | } 214 | 215 | /** Sort columns into breakpoints respectively ************************/ 216 | // Read column headers' attributes and get needed info 217 | for (var index = 0; index < visibleColumnsHeadersTds.length; index++) { 218 | // Get the column with the attribute data-class="expand" so we know 219 | // where to display the expand icon. 220 | var col = $(visibleColumnsHeadersTds[index].nTh); 221 | if (col.attr('data-class') === 'expand') { 222 | this.expandColumn = this.columnIndexes[index]; 223 | } 224 | 225 | // The data-hide attribute has the breakpoints that this column 226 | // is associated with. 227 | // If it's defined, get the data-hide attribute and sort this 228 | // column into the appropriate breakpoint's columnsToHide array. 229 | var dataHide = col.attr('data-hide'); 230 | if (dataHide !== undefined) { 231 | var splitBreakingPoints = dataHide.split(/,\s*/); 232 | for (var i = 0; i < splitBreakingPoints.length; i++) { 233 | var bp = splitBreakingPoints[i]; 234 | if (bp === 'always') { 235 | // A column with an 'always' breakpoint is always hidden. 236 | // Loop through all breakpoints and add it to each except the 237 | // default breakpoint. 238 | for (var prop in this.breakpoints) { 239 | if (this.breakpoints[prop].name !== 'default') { 240 | this.breakpoints[prop].columnsToHide.push(this.columnIndexes[index]); 241 | } 242 | } 243 | } else if (this.breakpoints[bp] !== undefined) { 244 | // Translate visible column index to internal column index. 245 | this.breakpoints[bp].columnsToHide.push(this.columnIndexes[index]); 246 | } 247 | } 248 | } 249 | } 250 | } 251 | }; 252 | 253 | /** 254 | * Sets or removes window resize handler. 255 | * 256 | * @param {Boolean} bindFlag 257 | */ 258 | ResponsiveDatatablesHelper.prototype.setWindowsResizeHandler = function (bindFlag) { 259 | if (bindFlag === undefined) { 260 | bindFlag = true; 261 | } 262 | 263 | if (bindFlag) { 264 | var that = this; 265 | $(window).bind("resize", function () { 266 | that.respond(); 267 | }); 268 | } else { 269 | $(window).unbind("resize"); 270 | } 271 | }; 272 | 273 | /** 274 | * Respond window size change. This helps make datatables responsive. 275 | */ 276 | ResponsiveDatatablesHelper.prototype.respond = function () { 277 | if (this.disabled) { 278 | return; 279 | } 280 | var that = this; 281 | 282 | // Get new windows width 283 | var newWindowWidth = $(window).width(); 284 | 285 | // Loop through breakpoints to see which columns need to be shown/hidden. 286 | var newColumnsToHide = []; 287 | 288 | for (var prop in this.breakpoints) { 289 | var element = this.breakpoints[prop]; 290 | if ((!element.lowerLimit || newWindowWidth > element.lowerLimit) && (!element.upperLimit || newWindowWidth <= element.upperLimit)) { 291 | this.currentBreakpoint = element.name; 292 | newColumnsToHide = element.columnsToHide; 293 | } 294 | } 295 | 296 | // Find out if a column show/hide should happen. 297 | // Skip column show/hide if this window width change follows immediately 298 | // after a previous column show/hide. This will help prevent a loop. 299 | var columnShowHide = false; 300 | if (!this.skipNextWindowsWidthChange) { 301 | // Check difference in length 302 | if (this.lastBreakpoint.length === 0 && newColumnsToHide.length) { 303 | // No previous breakpoint and new breakpoint 304 | columnShowHide = true; 305 | } else if (this.lastBreakpoint != this.currentBreakpoint) { 306 | // Different breakpoints 307 | columnShowHide = true; 308 | } else if (this.columnsHiddenIndexes.length !== newColumnsToHide.length) { 309 | // Difference in number of hidden columns 310 | columnShowHide = true; 311 | } else { 312 | // Possible same number of columns but check for difference in columns 313 | var d1 = this.difference(this.columnsHiddenIndexes, newColumnsToHide).length; 314 | var d2 = this.difference(newColumnsToHide, this.columnsHiddenIndexes).length; 315 | columnShowHide = d1 + d2 > 0; 316 | } 317 | } 318 | 319 | if (columnShowHide) { 320 | // Showing/hiding a column at breakpoint may cause a windows width 321 | // change. Let's flag to skip the column show/hide that may be 322 | // caused by the next windows width change. 323 | this.skipNextWindowsWidthChange = true; 324 | this.columnsHiddenIndexes = newColumnsToHide; 325 | this.columnsShownIndexes = this.difference(this.columnIndexes, this.columnsHiddenIndexes); 326 | this.showHideColumns(); 327 | this.lastBreakpoint = this.currentBreakpoint; 328 | this.setState(); 329 | this.skipNextWindowsWidthChange = false; 330 | } 331 | 332 | 333 | // We don't skip this part. 334 | // If one or more columns have been hidden, add the has-columns-hidden class to table. 335 | // This class will show what state the table is in. 336 | if (this.columnsHiddenIndexes.length) { 337 | this.tableElement.addClass('has-columns-hidden'); 338 | 339 | // Show details for each row that is tagged with the class .detail-show. 340 | $('tr.detail-show', this.tableElement).each(function (index, element) { 341 | var tr = $(element); 342 | if (tr.next('.row-detail').length === 0) { 343 | ResponsiveDatatablesHelper.prototype.showRowDetail(that, tr); 344 | } 345 | }); 346 | } else { 347 | this.tableElement.removeClass('has-columns-hidden'); 348 | $('tr.row-detail', this.tableElement).each(function (event) { 349 | ResponsiveDatatablesHelper.prototype.hideRowDetail(that, $(this).prev()); 350 | }); 351 | } 352 | }; 353 | 354 | /** 355 | * Show/hide datatables columns. 356 | */ 357 | ResponsiveDatatablesHelper.prototype.showHideColumns = function () { 358 | // Calculate the columns to show 359 | // Show columns that may have been previously hidden. 360 | for (var i = 0, l = this.columnsShownIndexes.length; i < l; i++) { 361 | this.tableElement.fnSetColumnVis(this.columnsShownIndexes[i], true, false); 362 | } 363 | 364 | // Hide columns that may have been previously shown. 365 | for (var i = 0, l = this.columnsHiddenIndexes.length; i < l; i++) { 366 | this.tableElement.fnSetColumnVis(this.columnsHiddenIndexes[i], false, false); 367 | } 368 | 369 | // Rebuild details to reflect shown/hidden column changes. 370 | var that = this; 371 | $('tr.row-detail', this.tableElement).each(function () { 372 | ResponsiveDatatablesHelper.prototype.hideRowDetail(that, $(this).prev()); 373 | }); 374 | if (this.tableElement.hasClass('has-columns-hidden')) { 375 | $('tr.detail-show', this.tableElement).each(function (index, element) { 376 | ResponsiveDatatablesHelper.prototype.showRowDetail(that, $(element)); 377 | }); 378 | } 379 | }; 380 | 381 | /** 382 | * Create the expand icon on the column with the data-class="expand" attribute 383 | * defined for it's header. 384 | * 385 | * @param {Object} tr table row object 386 | */ 387 | ResponsiveDatatablesHelper.prototype.createExpandIcon = function (tr) { 388 | if (this.disabled) { 389 | return; 390 | } 391 | 392 | // Get the td for tr with the same index as the th in the header tr 393 | // that has the data-class="expand" attribute defined. 394 | var tds = $('td', tr); 395 | // Loop through tds and create an expand icon on the td that has a column 396 | // index equal to the expand column given. 397 | for (var i = 0, l = tds.length; i < l; i++) { 398 | var td = tds[i]; 399 | var tdIndex = this.tableElement.fnGetPosition(td)[2]; 400 | td = $(td); 401 | if (tdIndex === this.expandColumn) { 402 | // Create expand icon if there isn't one already. 403 | if ($('span.responsiveExpander', td).length == 0) { 404 | td.prepend(this.expandIconTemplate); 405 | 406 | // Respond to click event on expander icon. 407 | switch (this.options.clickOn) { 408 | case 'cell': 409 | td.on('click', { responsiveDatatablesHelperInstance: this }, this.showRowDetailEventHandler); 410 | break; 411 | case 'row': 412 | $(tr).on('click', { responsiveDatatablesHelperInstance: this }, this.showRowDetailEventHandler); 413 | break; 414 | default: 415 | td.on('click', 'span.responsiveExpander', { responsiveDatatablesHelperInstance: this }, this.showRowDetailEventHandler); 416 | break; 417 | } 418 | } 419 | break; 420 | } 421 | } 422 | }; 423 | 424 | /** 425 | * Show row detail event handler. 426 | * 427 | * This handler is used to handle the click event of the expand icon defined in 428 | * the table row data element. 429 | * 430 | * @param {Object} event jQuery event object 431 | */ 432 | ResponsiveDatatablesHelper.prototype.showRowDetailEventHandler = function (event) { 433 | var responsiveDatatablesHelperInstance = event.data.responsiveDatatablesHelperInstance; 434 | if (responsiveDatatablesHelperInstance.disabled) { 435 | return; 436 | } 437 | 438 | var td = $(this); 439 | 440 | // Nothing to do if there are no columns hidden. 441 | if (!td.closest('table').hasClass('has-columns-hidden')) { 442 | return; 443 | } 444 | 445 | // Get the parent tr of which this td belongs to. 446 | var tr = td.closest('tr'); 447 | 448 | // Show/hide row details 449 | if (tr.hasClass('detail-show')) { 450 | ResponsiveDatatablesHelper.prototype.hideRowDetail(responsiveDatatablesHelperInstance, tr); 451 | } else { 452 | ResponsiveDatatablesHelper.prototype.showRowDetail(responsiveDatatablesHelperInstance, tr); 453 | } 454 | 455 | tr.toggleClass('detail-show'); 456 | 457 | // Prevent click event from bubbling up to higher-level DOM elements. 458 | event.stopPropagation(); 459 | }; 460 | 461 | /** 462 | * Show row details. 463 | * 464 | * @param {ResponsiveDatatablesHelper} responsiveDatatablesHelperInstance instance of ResponsiveDatatablesHelper 465 | * @param {Object} tr jQuery wrapped set 466 | */ 467 | ResponsiveDatatablesHelper.prototype.showRowDetail = function (responsiveDatatablesHelperInstance, tr) { 468 | // Get column because we need their titles. 469 | var tableElement = responsiveDatatablesHelperInstance.tableElement; 470 | var columns = tableElement.fnSettings().aoColumns; 471 | 472 | // Create the new tr. 473 | var newTr = $(responsiveDatatablesHelperInstance.rowTemplate); 474 | 475 | // Get the ul that we'll insert li's into. 476 | var ul = $('ul', newTr); 477 | 478 | // Loop through hidden columns and create an li for each of them. 479 | for (var i = 0; i < responsiveDatatablesHelperInstance.columnsHiddenIndexes.length; i++) { 480 | var index = responsiveDatatablesHelperInstance.columnsHiddenIndexes[i]; 481 | 482 | // Get row td 483 | var rowIndex = tableElement.fnGetPosition(tr[0]); 484 | var td = tableElement.fnGetTds(rowIndex)[index]; 485 | 486 | // Don't create li if contents are empty (depends on hideEmptyColumnsInRowDetail option). 487 | if (!responsiveDatatablesHelperInstance.options.hideEmptyColumnsInRowDetail || td.innerHTML.trim().length) { 488 | var li = $(responsiveDatatablesHelperInstance.rowLiTemplate); 489 | var hiddenColumnName = $(columns[index].nTh).attr('data-name'); 490 | $('.columnTitle', li).html(hiddenColumnName !== undefined ? hiddenColumnName : columns[index].nTh.innerHTML); 491 | var contents = $(td).contents(); 492 | var clonedContents = contents.clone(); 493 | 494 | // Select elements' selectedIndex are not cloned. Do it manually. 495 | for (var n = 0, m = contents.length; n < m; n++) { 496 | var node = contents[n]; 497 | if (node.nodeType === Node.ELEMENT_NODE && node.tagName === 'SELECT') { 498 | clonedContents[n].selectedIndex = node.selectedIndex 499 | } 500 | } 501 | 502 | // Set the column contents. 503 | $('.columnValue', li).append(clonedContents).data('originalTdSource', td); 504 | 505 | // Copy index to data attribute, so we'll know where to put the value when the tr.row-detail is removed. 506 | li.attr('data-column', index); 507 | 508 | // Copy td class to new li. 509 | var tdClass = $(td).attr('class'); 510 | if (tdClass !== 'undefined' && tdClass !== false && tdClass !== '') { 511 | li.addClass(tdClass) 512 | } 513 | 514 | ul.append(li); 515 | } 516 | } 517 | 518 | // Create tr colspan attribute. 519 | var colspan = responsiveDatatablesHelperInstance.columnIndexes.length - responsiveDatatablesHelperInstance.columnsHiddenIndexes.length; 520 | newTr.find('> td').attr('colspan', colspan); 521 | 522 | // Append the new tr after the current tr. 523 | tr.after(newTr); 524 | 525 | // call the showDetail function if needbe 526 | if (responsiveDatatablesHelperInstance.options.showDetail){ 527 | responsiveDatatablesHelperInstance.options.showDetail(newTr); 528 | } 529 | }; 530 | 531 | /** 532 | * Hide row details. 533 | * 534 | * @param {ResponsiveDatatablesHelper} responsiveDatatablesHelperInstance instance of ResponsiveDatatablesHelper 535 | * @param {Object} tr jQuery wrapped set 536 | */ 537 | ResponsiveDatatablesHelper.prototype.hideRowDetail = function (responsiveDatatablesHelperInstance, tr) { 538 | // If the value of an input has changed while in row detail, we need to copy its state back 539 | // to the DataTables object so that value will persist when the tr.row-detail is removed. 540 | var rowDetail = tr.next('.row-detail'); 541 | if (responsiveDatatablesHelperInstance.options.hideDetail){ 542 | responsiveDatatablesHelperInstance.options.hideDetail(rowDetail); 543 | } 544 | rowDetail.find('li').each(function () { 545 | var columnValueContainer = $(this).find('span.columnValue'); 546 | var tdContents = columnValueContainer.contents(); 547 | var td = columnValueContainer.data('originalTdSource'); 548 | $(td).empty().append(tdContents); 549 | }); 550 | rowDetail.remove(); 551 | }; 552 | 553 | /** 554 | * Enable/disable responsive behavior and restores changes made. 555 | * 556 | * @param {Boolean} disable, default is true 557 | */ 558 | ResponsiveDatatablesHelper.prototype.disable = function (disable) { 559 | this.disabled = (disable === undefined) || disable; 560 | 561 | if (this.disabled) { 562 | // Remove windows resize handler. 563 | this.setWindowsResizeHandler(false); 564 | 565 | // Remove all trs that have row details. 566 | $('tbody tr.row-detail', this.tableElement).remove(); 567 | 568 | // Remove all trs that are marked to have row details shown. 569 | $('tbody tr', this.tableElement).removeClass('detail-show'); 570 | 571 | // Remove all expander icons. 572 | $('tbody tr span.responsiveExpander', this.tableElement).remove(); 573 | 574 | this.columnsHiddenIndexes = []; 575 | this.columnsShownIndexes = this.columnIndexes; 576 | this.showHideColumns(); 577 | this.tableElement.removeClass('has-columns-hidden'); 578 | 579 | this.tableElement.off('click', 'span.responsiveExpander', this.showRowDetailEventHandler); 580 | } else { 581 | // Add windows resize handler. 582 | this.setWindowsResizeHandler(); 583 | } 584 | }; 585 | 586 | /** 587 | * Get state from cookie. 588 | */ 589 | ResponsiveDatatablesHelper.prototype.getState = function () { 590 | try { 591 | var value = JSON.parse(decodeURIComponent(this.getCookie(this.cookieName))); 592 | if (value) { 593 | this.columnIndexes = value.columnIndexes; 594 | this.breakpoints = value.breakpoints; 595 | this.expandColumn = value.expandColumn; 596 | this.lastBreakpoint = value.lastBreakpoint; 597 | this.lastStateExists = true; 598 | } 599 | } catch (e) { 600 | } 601 | }; 602 | 603 | /** 604 | * Saves state to cookie. 605 | */ 606 | ResponsiveDatatablesHelper.prototype.setState = function () { 607 | var d1 = this.difference(this.lastColumnsHiddenIndexes, this.columnsHiddenIndexes).length; 608 | var d2 = this.difference(this.columnsHiddenIndexes, this.lastColumnsHiddenIndexes).length; 609 | 610 | if (d1 + d2 > 0) { 611 | var value = encodeURIComponent(JSON.stringify({ 612 | columnIndexes: this.columnIndexes, 613 | columnsHiddenIndexes: this.columnsHiddenIndexes, 614 | breakpoints: this.breakpoints, 615 | expandColumn: this.expandColumn, 616 | lastBreakpoint: this.lastBreakpoint 617 | })); 618 | 619 | this.setCookie(this.cookieName, value, 2 * 60 * 60 * 1000); 620 | this.lastColumnsHiddenIndexes = this.columnsHiddenIndexes.slice(0); 621 | } 622 | }; 623 | 624 | /** 625 | * Get cookie. 626 | */ 627 | ResponsiveDatatablesHelper.prototype.getCookie = function (cname) { 628 | var name = cname + "="; 629 | var ca = document.cookie.split(';'); 630 | for (var i = 0; i < ca.length; i++) { 631 | var c = ca[i].trim(); 632 | if (c.indexOf(name) == 0) return c.substring(name.length, c.length); 633 | } 634 | return ""; 635 | }; 636 | 637 | /** 638 | * Set cookie. 639 | */ 640 | ResponsiveDatatablesHelper.prototype.setCookie = function (cname, cvalue, cexp) { 641 | var d = new Date(); 642 | d.setTime(d.getTime() + cexp); 643 | var expires = "expires=" + d.toGMTString(); 644 | document.cookie = cname + "=" + cvalue + "; " + expires; 645 | }; 646 | 647 | /** 648 | * Get Difference. 649 | */ 650 | ResponsiveDatatablesHelper.prototype.difference = function (a, b) { 651 | var arr = [], i, hash = {}; 652 | for (i = b.length - 1; i >= 0; i--) { 653 | hash[b[i]] = true; 654 | } 655 | for (i = a.length - 1; i >= 0; i--) { 656 | if (hash[a[i]] !== true) { 657 | arr.push(a[i]); 658 | } 659 | } 660 | return arr; 661 | }; 662 | 663 | 664 | (function ($) { 665 | /** 666 | * Get an array of TD nodes from DataTables for a given row, including any column elements which are hidden. 667 | * 668 | * Author: Allan Jardine 669 | * http://datatables.net/plug-ins/api 670 | * 671 | * @param {Object} oSettings DataTables settings object 672 | * @param {node} mTr TR node or aoData index 673 | */ 674 | $.fn.dataTableExt.oApi.fnGetTds = function (oSettings, mTr) { 675 | var anTds = []; 676 | var anVisibleTds = []; 677 | var iCorrector = 0; 678 | var nTd, iColumn, iColumns; 679 | 680 | /* Take either a TR node or aoData index as the mTr property */ 681 | var iRow = (typeof mTr == 'object') ? 682 | oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr; 683 | var nTr = oSettings.aoData[iRow].nTr; 684 | 685 | /* Get an array of the visible TD elements */ 686 | for (iColumn = 0, iColumns = nTr.childNodes.length; iColumn < iColumns ; iColumn++) { 687 | nTd = nTr.childNodes[iColumn]; 688 | if (nTd.nodeName.toUpperCase() == "TD") { 689 | anVisibleTds.push(nTd); 690 | } 691 | } 692 | 693 | /* Construct and array of the combined elements */ 694 | for (iColumn = 0, iColumns = oSettings.aoColumns.length; iColumn < iColumns ; iColumn++) { 695 | if (oSettings.aoColumns[iColumn].bVisible) { 696 | anTds.push(anVisibleTds[iColumn - iCorrector]); 697 | } 698 | else { 699 | anTds.push(oSettings.aoData[iRow]._anHidden[iColumn]); 700 | iCorrector++; 701 | } 702 | } 703 | 704 | return anTds; 705 | }; 706 | })(jQuery); 707 | -------------------------------------------------------------------------------- /license-bsd.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Seen Sai Yang 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | * Neither the name of Allan Jardine nor SpryMedia UK may be used to endorse or promote products derived from this software without specific prior written permission. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /license-gpl2.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------