|
@@ -1,797 +0,0 @@
|
|
|
-
|
|
|
- * Responsive Tables v5.2.6 (http:
|
|
|
- * This is an awesome solution for responsive tables with complex data.
|
|
|
- * Authors: Nadan Gergeo <nadan@blimp.se> (www.blimp.se), Lucas Wiener <lucas@blimp.se> & "Maggie Wachs (www.filamentgroup.com)"
|
|
|
- * Licensed under MIT (https:
|
|
|
- */
|
|
|
-(function ($) {
|
|
|
- 'use strict';
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var ResponsiveTable = function(element, options) {
|
|
|
-
|
|
|
-
|
|
|
- var that = this;
|
|
|
-
|
|
|
- this.options = options;
|
|
|
- this.$tableWrapper = null;
|
|
|
- this.$tableScrollWrapper = $(element);
|
|
|
- this.$table = $(element).find('table');
|
|
|
-
|
|
|
- if(this.$table.length !== 1) {
|
|
|
- throw new Error('Exactly one table is expected in a .table-responsive div.');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.$tableScrollWrapper.attr('data-pattern', this.options.pattern);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.id = this.$table.prop('id') || this.$tableScrollWrapper.prop('id') || 'id' + Math.random().toString(16).slice(2);
|
|
|
-
|
|
|
- this.$tableClone = null;
|
|
|
- this.$stickyTableHeader = null;
|
|
|
-
|
|
|
-
|
|
|
- this.$thead = this.$table.find('thead');
|
|
|
- this.$hdrCells = this.$thead.find("tr").first().find('th');
|
|
|
- this.$bodyRows = this.$table.find('tbody, tfoot').find('tr');
|
|
|
-
|
|
|
-
|
|
|
- this.$btnToolbar = null;
|
|
|
- this.$dropdownGroup = null;
|
|
|
- this.$dropdownBtn = null;
|
|
|
- this.$dropdownContainer = null;
|
|
|
-
|
|
|
- this.$displayAllBtn = null;
|
|
|
-
|
|
|
- this.$focusGroup = null;
|
|
|
- this.$focusBtn = null;
|
|
|
-
|
|
|
-
|
|
|
- this.displayAllTrigger = 'display-all-' + this.id + '.responsive-table';
|
|
|
- this.idPrefix = this.id + '-col-';
|
|
|
-
|
|
|
- this.headerColIndices = {};
|
|
|
- this.headerRowIndices = {};
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.wrapTable();
|
|
|
-
|
|
|
-
|
|
|
- this.createButtonToolbar();
|
|
|
-
|
|
|
-
|
|
|
- this.buildHeaderCellIndices();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.setupTableHeader();
|
|
|
-
|
|
|
-
|
|
|
- this.setupBodyRows();
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.stickyTableHeader){
|
|
|
- this.createStickyTableHeader();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(this.$dropdownContainer.is(':empty')){
|
|
|
- this.$dropdownGroup.hide();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $(window).bind('orientationchange resize ' + this.displayAllTrigger, function(){
|
|
|
-
|
|
|
-
|
|
|
- that.$dropdownContainer.find('input').trigger('updateCheck');
|
|
|
-
|
|
|
-
|
|
|
- $.proxy(that.updateSpanningCells(), that);
|
|
|
-
|
|
|
- }).trigger('resize');
|
|
|
-
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.DEFAULTS = {
|
|
|
- pattern: 'priority-columns',
|
|
|
- stickyTableHeader: true,
|
|
|
- fixedNavbar: '.navbar-fixed-top',
|
|
|
- addDisplayAllBtn: true,
|
|
|
- addFocusBtn: true,
|
|
|
- focusBtnIcon: 'glyphicon glyphicon-screenshot',
|
|
|
- mainContainer: window,
|
|
|
- i18n: {
|
|
|
- focus : 'Focus',
|
|
|
- display : 'Display',
|
|
|
- displayAll: 'Display all'
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.wrapTable = function() {
|
|
|
- this.$tableScrollWrapper.wrap('<div class="table-wrapper"/>');
|
|
|
- this.$tableWrapper = this.$tableScrollWrapper.parent();
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.createButtonToolbar = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
- this.$btnToolbar = $('<div class="btn-toolbar" />');
|
|
|
-
|
|
|
- this.$dropdownGroup = $('<div class="btn-group dropdown-btn-group pull-right" />');
|
|
|
- this.$dropdownBtn = $('<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">' + this.options.i18n.display + ' <span class="caret"></span></button>');
|
|
|
- this.$dropdownContainer = $('<ul class="dropdown-menu"/>');
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.addFocusBtn) {
|
|
|
-
|
|
|
- this.$focusGroup = $('<div class="btn-group focus-btn-group" />');
|
|
|
-
|
|
|
-
|
|
|
- this.$focusBtn = $('<button class="btn btn-default">' + this.options.i18n.focus + '</button>');
|
|
|
-
|
|
|
- if(this.options.focusBtnIcon) {
|
|
|
- this.$focusBtn.prepend('<span class="' + this.options.focusBtnIcon + '"></span> ');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.$focusGroup.append(this.$focusBtn);
|
|
|
-
|
|
|
- this.$btnToolbar.append(this.$focusGroup);
|
|
|
-
|
|
|
-
|
|
|
- this.$focusBtn.click(function(){
|
|
|
- $.proxy(that.activateFocus(), that);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- this.$bodyRows.click(function(){
|
|
|
- $.proxy(that.focusOnRow($(this)), that);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.addDisplayAllBtn) {
|
|
|
-
|
|
|
- this.$displayAllBtn = $('<button class="btn btn-default">' + this.options.i18n.displayAll + '</button>');
|
|
|
-
|
|
|
- this.$dropdownGroup.append(this.$displayAllBtn);
|
|
|
-
|
|
|
- if (this.$table.hasClass('display-all')) {
|
|
|
-
|
|
|
- this.$displayAllBtn.addClass('btn-primary');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.$displayAllBtn.click(function(){
|
|
|
- $.proxy(that.displayAll(null, true), that);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.$dropdownGroup.append(this.$dropdownBtn).append(this.$dropdownContainer);
|
|
|
-
|
|
|
-
|
|
|
- this.$btnToolbar.append(this.$dropdownGroup);
|
|
|
-
|
|
|
-
|
|
|
- this.$tableScrollWrapper.before(this.$btnToolbar);
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.clearAllFocus = function() {
|
|
|
- this.$bodyRows.removeClass('unfocused');
|
|
|
- this.$bodyRows.removeClass('focused');
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.activateFocus = function() {
|
|
|
-
|
|
|
- this.clearAllFocus();
|
|
|
-
|
|
|
- if(this.$focusBtn){
|
|
|
- this.$focusBtn.toggleClass('btn-primary');
|
|
|
- }
|
|
|
-
|
|
|
- this.$table.toggleClass('focus-on');
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.focusOnRow = function(row) {
|
|
|
-
|
|
|
- if(this.$table.hasClass('focus-on')) {
|
|
|
- var alreadyFocused = $(row).hasClass('focused');
|
|
|
-
|
|
|
-
|
|
|
- this.clearAllFocus();
|
|
|
-
|
|
|
- if(!alreadyFocused) {
|
|
|
- this.$bodyRows.addClass('unfocused');
|
|
|
- $(row).addClass('focused');
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- * @param activate Forces the displayAll to be active or not. If anything else than bool, it will not force the state so it will toggle as normal.
|
|
|
- * @param trigger Bool to indicate if the displayAllTrigger should be triggered.
|
|
|
- */
|
|
|
- ResponsiveTable.prototype.displayAll = function(activate, trigger) {
|
|
|
- if(this.$displayAllBtn){
|
|
|
-
|
|
|
- this.$displayAllBtn.toggleClass('btn-primary', activate);
|
|
|
- }
|
|
|
-
|
|
|
- this.$table.toggleClass('display-all', activate);
|
|
|
- if(this.$tableClone){
|
|
|
- this.$tableClone.toggleClass('display-all', activate);
|
|
|
- }
|
|
|
-
|
|
|
- if(trigger) {
|
|
|
- $(window).trigger(this.displayAllTrigger);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.preserveDisplayAll = function() {
|
|
|
- var displayProp = 'table-cell';
|
|
|
- if($('html').hasClass('lt-ie9')){
|
|
|
- displayProp = 'inline';
|
|
|
- }
|
|
|
-
|
|
|
- $(this.$table).find('th, td').css('display', displayProp);
|
|
|
- if(this.$tableClone){
|
|
|
- $(this.$tableClone).find('th, td').css('display', displayProp);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.createStickyTableHeader = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
-
|
|
|
- that.$tableClone = that.$table.clone();
|
|
|
-
|
|
|
-
|
|
|
- that.$tableClone.prop('id', this.id + '-clone');
|
|
|
- that.$tableClone.find('[id]').each(function() {
|
|
|
- $(this).prop('id', $(this).prop('id') + '-clone');
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- that.$tableClone.wrap('<div class="sticky-table-header"/>');
|
|
|
- that.$stickyTableHeader = that.$tableClone.parent();
|
|
|
-
|
|
|
-
|
|
|
- that.$stickyTableHeader.css('height', that.$thead.height() + 2);
|
|
|
-
|
|
|
-
|
|
|
- that.$table.before(that.$stickyTableHeader);
|
|
|
-
|
|
|
-
|
|
|
- $(this.options.mainContainer).bind('scroll', function(){
|
|
|
- $.proxy(that.updateStickyTableHeader(), that);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- $(window).bind('resize', function(e){
|
|
|
- $.proxy(that.updateStickyTableHeader(), that);
|
|
|
- });
|
|
|
-
|
|
|
- $(that.$tableScrollWrapper).bind('scroll', function(){
|
|
|
- $.proxy(that.updateStickyTableHeader(), that);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- that.useFixedSolution = !isIOS() || (getIOSVersion() >= 8);
|
|
|
-
|
|
|
- if(that.useFixedSolution) {
|
|
|
- that.$tableScrollWrapper.addClass('fixed-solution');
|
|
|
- } else {
|
|
|
- that.$tableScrollWrapper.addClass('absolute-solution');
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.updateStickyTableHeader = function() {
|
|
|
- var that = this,
|
|
|
- top = 0,
|
|
|
- offsetTop = that.$table.offset().top,
|
|
|
- scrollTop = $(this.options.mainContainer).scrollTop() -1,
|
|
|
- maxTop = that.$table.height() - that.$stickyTableHeader.height(),
|
|
|
- rubberBandOffset = (scrollTop + $(this.options.mainContainer).height()) - $(document).height(),
|
|
|
- navbarHeight = 0;
|
|
|
-
|
|
|
-
|
|
|
- if($(that.options.fixedNavbar).length) {
|
|
|
- var $navbar = $(that.options.fixedNavbar).first();
|
|
|
- navbarHeight = $navbar.height();
|
|
|
- scrollTop = scrollTop + navbarHeight;
|
|
|
- }
|
|
|
-
|
|
|
- var shouldBeVisible;
|
|
|
-
|
|
|
- if(this.options.mainContainer === window) {
|
|
|
- shouldBeVisible = (scrollTop > offsetTop) && (scrollTop < offsetTop + that.$table.height());
|
|
|
- } else {
|
|
|
- shouldBeVisible = (offsetTop <= 0) && (-offsetTop < that.$table.height());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(that.useFixedSolution) {
|
|
|
- that.$stickyTableHeader.scrollLeft(that.$tableScrollWrapper.scrollLeft());
|
|
|
-
|
|
|
-
|
|
|
- top = navbarHeight - 1;
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.mainContainer === window && ((scrollTop - offsetTop) > maxTop)){
|
|
|
-
|
|
|
- top -= ((scrollTop - offsetTop) - maxTop);
|
|
|
- that.$stickyTableHeader.addClass('border-radius-fix');
|
|
|
-
|
|
|
- } else if(this.options.mainContainer !== window && ((- offsetTop) > maxTop)){
|
|
|
-
|
|
|
- top -= ((- offsetTop) - maxTop);
|
|
|
- that.$stickyTableHeader.addClass('border-radius-fix');
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- that.$stickyTableHeader.removeClass('border-radius-fix');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (shouldBeVisible) {
|
|
|
-
|
|
|
- that.$stickyTableHeader.css({ 'visibility': 'visible', 'top': top + 'px', 'width': that.$tableScrollWrapper.innerWidth() + 'px'});
|
|
|
-
|
|
|
-
|
|
|
- return;
|
|
|
- } else {
|
|
|
-
|
|
|
- that.$stickyTableHeader.css({'visibility': 'hidden', 'width': 'auto' });
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- var animationDuration = 400;
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.mainContainer === window) {
|
|
|
- top = scrollTop - offsetTop - 1;
|
|
|
- } else {
|
|
|
- top = -offsetTop - 1;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(top < 0) {
|
|
|
- top = 0;
|
|
|
- } else if (top > maxTop) {
|
|
|
- top = maxTop;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(this.options.mainContainer === window) {
|
|
|
- if(rubberBandOffset > 0) {
|
|
|
- top = top - rubberBandOffset;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (shouldBeVisible) {
|
|
|
-
|
|
|
- that.$stickyTableHeader.css({ 'visibility': 'visible' });
|
|
|
- that.$stickyTableHeader.animate({ 'top': top + 'px' }, animationDuration);
|
|
|
-
|
|
|
-
|
|
|
- that.$thead.css({ 'visibility': 'hidden' });
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- that.$stickyTableHeader.animate({ 'top': '0' }, animationDuration, function(){
|
|
|
-
|
|
|
- that.$thead.css({ 'visibility': 'visible' });
|
|
|
-
|
|
|
-
|
|
|
- that.$stickyTableHeader.css({ 'visibility': 'hidden' });
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.setupTableHeader = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
-
|
|
|
- that.$hdrCells.each(function(i){
|
|
|
- var $th = $(this),
|
|
|
- id = $th.prop('id'),
|
|
|
- thText = $th.text();
|
|
|
-
|
|
|
-
|
|
|
- if (!id) {
|
|
|
- id = that.idPrefix + i;
|
|
|
- $th.prop('id', id);
|
|
|
- }
|
|
|
-
|
|
|
- if(thText === ''){
|
|
|
- thText = $th.attr('data-col-name');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if ( $th.is('[data-priority]') && $th.data('priority') !== -1 ) {
|
|
|
- var $toggle = $('<li class="checkbox-row"><input type="checkbox" name="toggle-'+id+'" id="toggle-'+id+'" value="'+id+'" /> <label for="toggle-'+id+'">'+ thText +'</label></li>');
|
|
|
- var $checkbox = $toggle.find('input');
|
|
|
-
|
|
|
- that.$dropdownContainer.append($toggle);
|
|
|
-
|
|
|
- $toggle.click(function(){
|
|
|
-
|
|
|
- $checkbox.prop('checked', !$checkbox.prop('checked'));
|
|
|
- $checkbox.trigger('change');
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- if ($('html').hasClass('lt-ie9')) {
|
|
|
- $checkbox.click(function() {
|
|
|
- $(this).trigger('change');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- $toggle.find('label').click(function(event){
|
|
|
- event.stopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
- $toggle.find('input')
|
|
|
- .click(function(event){
|
|
|
- event.stopPropagation();
|
|
|
- })
|
|
|
- .change(function(){
|
|
|
- var $checkbox = $(this),
|
|
|
- val = $checkbox.val(),
|
|
|
-
|
|
|
- $cells = that.$tableWrapper.find('#' + val + ', #' + val + '-clone, [data-columns~='+ val +']');
|
|
|
-
|
|
|
-
|
|
|
- if(that.$table.hasClass('display-all')){
|
|
|
-
|
|
|
- $.proxy(that.preserveDisplayAll(), that);
|
|
|
-
|
|
|
- that.$table.removeClass('display-all');
|
|
|
- if(that.$tableClone){
|
|
|
- that.$tableClone.removeClass('display-all');
|
|
|
- }
|
|
|
-
|
|
|
- that.$displayAllBtn.removeClass('btn-primary');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $cells.each(function(){
|
|
|
- var $cell = $(this);
|
|
|
-
|
|
|
-
|
|
|
- if ($checkbox.is(':checked')) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(!$cell.closest("thead").length && $cell.css('display') !== 'none'){
|
|
|
-
|
|
|
- var newColSpan = Math.min(parseInt($cell.prop('colSpan')) + 1, $cell.attr('data-org-colspan'));
|
|
|
-
|
|
|
- $cell.prop('colSpan', newColSpan);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $cell.show();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- else {
|
|
|
-
|
|
|
-
|
|
|
- if(!$cell.closest("thead").length && parseInt($cell.prop('colSpan'))>1){
|
|
|
- $cell.prop('colSpan', parseInt($cell.prop('colSpan')) - 1);
|
|
|
- }
|
|
|
-
|
|
|
- else {
|
|
|
- $cell.hide();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- })
|
|
|
- .bind('updateCheck', function(){
|
|
|
- if ( $th.css('display') !== 'none') {
|
|
|
- $(this).prop('checked', true);
|
|
|
- }
|
|
|
- else {
|
|
|
- $(this).prop('checked', false);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if(!$.isEmptyObject(this.headerRowIndices)) {
|
|
|
- that.setupRow(this.$thead.find("tr:eq(1)"), this.headerRowIndices);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.setupBodyRows = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
-
|
|
|
- that.$bodyRows.each(function(){
|
|
|
- that.setupRow($(this), that.headerColIndices);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.setupRow = function($row, indices) {
|
|
|
- var that = this;
|
|
|
-
|
|
|
-
|
|
|
- if($row.data('setup')){
|
|
|
-
|
|
|
- return;
|
|
|
- } else {
|
|
|
- $row.data('setup', true);
|
|
|
- }
|
|
|
-
|
|
|
- var idStart = 0;
|
|
|
-
|
|
|
-
|
|
|
- $row.find('th, td').each(function(){
|
|
|
- var $cell = $(this);
|
|
|
- var columnsAttr = '';
|
|
|
-
|
|
|
- var colSpan = $cell.prop('colSpan');
|
|
|
- $cell.attr('data-org-colspan', colSpan);
|
|
|
-
|
|
|
-
|
|
|
- if(colSpan > 1) {
|
|
|
-
|
|
|
- $cell.addClass('spn-cell');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- for (var k = idStart; k < (idStart + colSpan); k++) {
|
|
|
-
|
|
|
- columnsAttr = columnsAttr + ' ' + that.idPrefix + indices[k];
|
|
|
-
|
|
|
-
|
|
|
- var $colHdr = that.$table.find('#' + that.idPrefix + indices[k]);
|
|
|
-
|
|
|
-
|
|
|
- var dataPriority = $colHdr.attr('data-priority');
|
|
|
- if (dataPriority) { $cell.attr('data-priority', dataPriority); }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- columnsAttr = columnsAttr.substring(1);
|
|
|
-
|
|
|
-
|
|
|
- $cell.attr('data-columns', columnsAttr);
|
|
|
-
|
|
|
-
|
|
|
- idStart = idStart + colSpan;
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- ResponsiveTable.prototype.buildHeaderCellIndices = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
- var rowspansBeforeIndex = {};
|
|
|
-
|
|
|
- this.headerColIndices = {};
|
|
|
- this.headerRowIndices = {};
|
|
|
- var colPadding = 0;
|
|
|
- var rowPadding = 0;
|
|
|
-
|
|
|
- this.$thead.find("tr").first().find('th').each(function(i){
|
|
|
- var $th = $(this);
|
|
|
- var colSpan = $th.prop('colSpan');
|
|
|
- var rowSpan = $th.prop("rowSpan");
|
|
|
-
|
|
|
- for(var index = 0; index < colSpan; index++) {
|
|
|
- that.headerColIndices[colPadding + i + index] = i;
|
|
|
-
|
|
|
- if(colPadding + i + index >= 0) {
|
|
|
- rowspansBeforeIndex[colPadding + i + index - rowPadding] = rowPadding;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(rowSpan > 1) {
|
|
|
- rowPadding++;
|
|
|
- }
|
|
|
-
|
|
|
- colPadding += colSpan - 1;
|
|
|
- });
|
|
|
-
|
|
|
- if(this.$thead.find("tr").length > 2) {
|
|
|
- throw new Error("This plugin doesnt support more than two rows in thead.");
|
|
|
- }
|
|
|
-
|
|
|
- if(this.$thead.find("tr").length === 2) {
|
|
|
- var $row = $(this.$thead.find("tr")[1]);
|
|
|
- $row.find("th").each(function(cellIndex) {
|
|
|
- that.headerRowIndices[cellIndex] = that.headerColIndices[rowspansBeforeIndex[cellIndex] + cellIndex];
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.update = function() {
|
|
|
- this.$bodyRows = this.$table.find('tbody, tfoot').find('tr');
|
|
|
- this.setupBodyRows();
|
|
|
-
|
|
|
-
|
|
|
- this.$tableClone.find('tbody, tfoot').remove();
|
|
|
-
|
|
|
-
|
|
|
- var $tbodyClone = this.$table.find('tbody, tfoot').clone();
|
|
|
-
|
|
|
-
|
|
|
- $tbodyClone.find('[id]').each(function() {
|
|
|
- $(this).prop('id', $(this).prop('id') + '-clone');
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- $tbodyClone.appendTo(this.$tableClone);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.$dropdownContainer.find('input').trigger('change');
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- ResponsiveTable.prototype.updateSpanningCells = function() {
|
|
|
- var that = this;
|
|
|
-
|
|
|
-
|
|
|
- that.$table.find('.spn-cell').each( function(){
|
|
|
- var $cell = $(this);
|
|
|
- var columnsAttr = $cell.attr('data-columns').split(' ');
|
|
|
-
|
|
|
- var colSpan = columnsAttr.length;
|
|
|
- var numOfHidden = 0;
|
|
|
- for (var i = 0; i < colSpan; i++) {
|
|
|
- if($('#' + columnsAttr[i]).css('display')==='none'){
|
|
|
- numOfHidden++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(numOfHidden !== colSpan){
|
|
|
- $cell.show();
|
|
|
- } else {
|
|
|
- $cell.hide();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $cell.prop('colSpan',Math.max((colSpan - numOfHidden),1));
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var old = $.fn.responsiveTable;
|
|
|
-
|
|
|
- $.fn.responsiveTable = function (option) {
|
|
|
- return this.each(function () {
|
|
|
- var $this = $(this);
|
|
|
- var data = $this.data('responsiveTable');
|
|
|
- var options = $.extend({}, ResponsiveTable.DEFAULTS, $this.data(), typeof option === 'object' && option);
|
|
|
-
|
|
|
- if(options.pattern === '') {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (!data) {
|
|
|
- $this.data('responsiveTable', (data = new ResponsiveTable(this, options)));
|
|
|
- }
|
|
|
- if (typeof option === 'string') {
|
|
|
- data[option]();
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- $.fn.responsiveTable.Constructor = ResponsiveTable;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $.fn.responsiveTable.noConflict = function () {
|
|
|
- $.fn.responsiveTable = old;
|
|
|
- return this;
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $(document).on('ready.responsive-table.data-api', function () {
|
|
|
- $('[data-pattern]').each(function () {
|
|
|
- var $tableScrollWrapper = $(this);
|
|
|
- $tableScrollWrapper.responsiveTable($tableScrollWrapper.data());
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $(document).on('click.dropdown.data-api', '.dropdown-menu .checkbox-row', function (e) {
|
|
|
- e.stopPropagation();
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- function mediaQueriesSupported() {
|
|
|
- return (typeof window.matchMedia !== 'undefined' || typeof window.msMatchMedia !== 'undefined' || typeof window.styleMedia !== 'undefined');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function hasTouch() {
|
|
|
- return 'ontouchstart' in window;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function isIOS() {
|
|
|
- return !!(navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function getIOSVersion() {
|
|
|
- if(isIOS()){
|
|
|
- var iphone_version = parseFloat(('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1]).replace('undefined', '3_2').replace('_', '.').replace('_', ''));
|
|
|
- return iphone_version;
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $(document).ready(function() {
|
|
|
-
|
|
|
- $('html').removeClass('no-js').addClass('js');
|
|
|
-
|
|
|
-
|
|
|
- if(mediaQueriesSupported()) {
|
|
|
- $('html').addClass('mq');
|
|
|
- } else {
|
|
|
- $('html').addClass('no-mq');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(hasTouch()) {
|
|
|
- $('html').addClass('touch');
|
|
|
- } else {
|
|
|
- $('html').addClass('no-touch');
|
|
|
- }
|
|
|
- });
|
|
|
-})(jQuery);
|