hand-detection/assets/plugin/RWD-table-pattern/js/rwd-table.min.js

7 lines
9.1 KiB
JavaScript
Raw Normal View History

2024-05-29 03:18:12 +00:00
/*!
* Responsive Tables v5.0.4 (http://gergeo.se/RWD-Table-Patterns)
* This is an awesome solution for responsive tables with complex data.
* Authors: Nadan Gergeo <nadan.gergeo@gmail.com> (www.gergeo.se) & Maggie Wachs (www.filamentgroup.com)
* Licensed under MIT (https://github.com/nadangergeo/RWD-Table-Patterns/blob/master/LICENSE-MIT)
*/
!function(a){"use strict";function b(){return"undefined"!=typeof window.matchMedia||"undefined"!=typeof window.msMatchMedia||"undefined"!=typeof window.styleMedia}function c(){return"ontouchstart"in window}function d(){return!!(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i))}var e=function(b,c){var e=this;if(this.options=c,this.$tableWrapper=null,this.$tableScrollWrapper=a(b),this.$table=a(b).find("table"),1!==this.$table.length)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.$tbody=this.$table.find("tbody"),this.$hdrCells=this.$thead.find("th"),this.$bodyRows=this.$tbody.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.iOS=d(),this.wrapTable(),this.createButtonToolbar(),this.setupHdrCells(),this.setupStandardCells(),this.options.stickyTableHeader&&this.createStickyTableHeader(),this.$dropdownContainer.is(":empty")&&this.$dropdownGroup.hide(),a(window).bind("orientationchange resize "+this.displayAllTrigger,function(){e.$dropdownContainer.find("input").trigger("updateCheck"),a.proxy(e.updateSpanningCells(),e)})};e.DEFAULTS={pattern:"priority-columns",stickyTableHeader:!0,fixedNavbar:".navbar-fixed-top",addDisplayAllBtn:!0,addFocusBtn:!0,focusBtnIcon:"glyphicon glyphicon-screenshot"},e.prototype.wrapTable=function(){this.$tableScrollWrapper.wrap('<div class="table-wrapper"/>'),this.$tableWrapper=this.$tableScrollWrapper.parent()},e.prototype.createButtonToolbar=function(){var b=this;this.$btnToolbar=a('<div class="btn-toolbar" />'),this.$dropdownGroup=a('<div class="btn-group dropdown-btn-group pull-right" />'),this.$dropdownBtn=a('<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Display <span class="caret"></span></button>'),this.$dropdownContainer=a('<ul class="dropdown-menu"/>'),this.options.addFocusBtn&&(this.$focusGroup=a('<div class="btn-group focus-btn-group" />'),this.$focusBtn=a('<button class="btn btn-default">Focus</button>'),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(){a.proxy(b.activateFocus(),b)}),this.$bodyRows.click(function(){a.proxy(b.focusOnRow(a(this)),b)})),this.options.addDisplayAllBtn&&(this.$displayAllBtn=a('<button class="btn btn-default">Display all</button>'),this.$dropdownGroup.append(this.$displayAllBtn),this.$table.hasClass("display-all")&&this.$displayAllBtn.addClass("btn-primary"),this.$displayAllBtn.click(function(){a.proxy(b.displayAll(null,!0),b)})),this.$dropdownGroup.append(this.$dropdownBtn).append(this.$dropdownContainer),this.$btnToolbar.append(this.$dropdownGroup),this.$tableScrollWrapper.before(this.$btnToolbar)},e.prototype.clearAllFocus=function(){this.$bodyRows.removeClass("unfocused"),this.$bodyRows.removeClass("focused")},e.prototype.activateFocus=function(){this.clearAllFocus(),this.$focusBtn&&this.$focusBtn.toggleClass("btn-primary"),this.$table.toggleClass("focus-on")},e.prototype.focusOnRow=function(b){if(this.$table.hasClass("focus-on")){var c=a(b).hasClass("focused");this.clearAllFocus(),c||(this.$bodyRows.addClass("unfocused"),a(b).addClass("focused"))}},e.prototype.displayAll=function(b,c){this.$displayAllBtn&&this.$displayAllBtn.toggleClass("btn-primary",b),this.$table.toggleClass("display-all",b),this.$tableClone&&this.$tableClone.toggleClass("display-all",b),c&&a(window).trigger(this.displayAllTrigger)},e.prototype.preserveDisplayAll=function(){var b="table-cell";a("html").hasClass("lt-ie9")