/*! Tablesaw - v2.0.1 - 2015-10-09
* https://github.com/filamentgroup/tablesaw
* Copyright (c) 2015 Filament Group; Licensed MIT */
/*
* tablesaw: A set of plugins for responsive tables
* Stack and Column Toggle tables
* Copyright (c) 2013 Filament Group, Inc.
* MIT License
*/
"undefined"==typeof Tablesaw&&(Tablesaw={i18n:{modes:["Stack","Swipe","Toggle"],columns:'Col<span class="a11y-sm">umn</span>s',columnBtnText:"Columns",columnsDialogError:"No eligible columns.",sort:"Sort"},mustard:"querySelector"in document&&(!window.blackberry||window.WebKitPoint)&&!window.operamini}),Tablesaw.config||(Tablesaw.config={}),Tablesaw.mustard&&jQuery(document.documentElement).addClass("tablesaw-enhanced"),function(t){var e="tablesaw-bar",a="tablesawcreate",s="tablesawdestroy",i="tablesawrefresh",l=function(e){if(!e)throw new Error("Tablesaw requires an element.");this.table=e,this.$table=t(e),this.mode=this.$table.attr("data-tablesaw-mode")||"stack",this.init()};l.prototype.init=function(){this.$table.attr("id")||this.$table.attr("id","table-"+Math.round(1e4*Math.random())),this.createToolbar();var t=this._initCells();this.$table.trigger(a,[this,t])},l.prototype._initCells=function(){var e,a=this.table.querySelectorAll("thead tr"),s=this;return t(a).each(function(){var i=0;t(this).children().each(function(){var t=parseInt(this.getAttribute("colspan"),10),l=":nth-child("+(i+1)+")";if(e=i+1,t)for(var n=0;n<t-1;n++)l+=", :nth-child("+(++i+1)+")";this.cells=s.$table.find("tr").not(a[0]).not(this).children().filter(l),i++})}),e},l.prototype.refresh=function(){this._initCells(),this.$table.trigger(i)},l.prototype.createToolbar=function(){var a=this.$table.prev().filter("."+e);a.length||(a=t("<div>").addClass(e).insertBefore(this.$table)),this.$toolbar=a,this.mode&&this.$toolbar.addClass("mode-"+this.mode)},l.prototype.destroy=function(){this.$table.prev().filter("."+e).each(function(){this.className=this.className.replace(/\bmode\-\w*\b/gi,"")});var a=this.$table.attr("id");t(document).unbind("."+a),t(window).unbind("."+a),this.$table.trigger(s,[this]),this.$table.removeAttr("data-tablesaw-mode"),this.$table.removeData("table")},t.fn.table=function(){return this.each(function(){var e=t(this);if(!e.data("table")){var a=new l(this);e.data("table",a)}})},t(document).on("enhance.tablesaw",function(e){Tablesaw.mustard&&t(e.target).find("table[data-tablesaw-mode],table[data-tablesaw-sortable]").table()})}(jQuery),function(t,e,a){var s="tablesaw-stack",i="tablesaw-cell-label",l="tablesaw-cell-content",n="tablesaw-stack",r="data-tablesaw-no-labels",o="data-tablesaw-hide-empty",h=function(t){this.$table=e(t),this.labelless=this.$table.is("["+r+"]"),this.hideempty=this.$table.is("["+o+"]"),this.labelless||(this.allHeaders=this.$table.find("th")),this.$table.data(n,this)};h.prototype.init=function(t){if(this.$table.addClass(s),!this.labelless){var a=e(this.allHeaders),n=this.hideempty;a.each(function(){var a=e(this),s=e(this.cells).filter(function(){return!(e(this).parent().is("["+r+"]")||n&&e(this).is(":empty"))}),o=s.not(this).filter("thead th").length&&" tablesaw-cell-label-top",h=a.find(".tablesaw-sortable-btn"),b=h.length?h.html():a.html();if(""!==b)if(o){var d=parseInt(e(this).attr("colspan"),10),c="";d&&(c="td:nth-child("+d+"n + "+t+")"),s.filter(c).prepend("<p class='"+i+o+"'>"+b+"</p>")}else s.wrapInner("<span class='"+l+"'></span>"),s.prepend("<p class='"+i+"'>"+b+"</p>")})}},h.prototype.destroy=function(){this.$table.removeClass(s),this.$table.find("."+i).remove(),this.$table.find("."+l).each(function(){e(this).replaceWith(this.childNodes)})},e(document).on("tablesawcreate",function(t,e,a){"stack"===e.mode&&new h(e.table).init(a)}),e(document).on("tablesawdestroy",function(t,a){"stack"===a.mode&&e(a.table).data(n).destroy()})}(0,jQuery);