tablesorter/dist/js/jquery.tablesorter.widgets.min.js

4 lines
39 KiB
JavaScript
Raw Normal View History

2015-02-20 22:16:52 +00:00
/*! tablesorter (FORK) widgets - updated 02-20-2015 (v2.19.1)*/
/*! Widget: storage */
2015-02-20 22:16:52 +00:00
!function(a,b,c){"use strict";var d=a.tablesorter=a.tablesorter||{};d.storage=function(d,e,f,g){d=a(d)[0];var h,i,j,k=!1,l={},m=d.config,n=a(d),o=g&&g.id||n.attr(g&&g.group||"data-table-group")||d.id||a(".tablesorter").index(n),p=g&&g.url||n.attr(g&&g.page||"data-table-page")||m&&m.fixedUrl||b.location.pathname;if("localStorage"in b)try{b.localStorage.setItem("_tmptest","temp"),k=!0,b.localStorage.removeItem("_tmptest")}catch(q){}return a.parseJSON&&(k?l=a.parseJSON(localStorage[e]||"null")||{}:(i=c.cookie.split(/[;\s|=]/),h=a.inArray(e,i)+1,l=0!==h?a.parseJSON(i[h]||"null")||{}:{})),(f||""===f)&&b.JSON&&JSON.hasOwnProperty("stringify")?(l[p]||(l[p]={}),l[p][o]=f,k?localStorage[e]=JSON.stringify(l):(j=new Date,j.setTime(j.getTime()+31536e6),c.cookie=e+"="+JSON.stringify(l).replace(/\"/g,'"')+"; expires="+j.toGMTString()+"; path=/"),void 0):l&&l[p]?l[p][o]:""}}(jQuery,window,document),function(a){"use strict";var b=a.tablesorter=a.tablesorter||{};b.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"icon-chevron-up glyphicon glyphicon-chevron-up",iconSortDesc:"icon-chevron-down glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s",iconSortAsc:"ui-icon-carat-1-n",iconSortDesc:"ui-icon-carat-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},a.extend(b.css,{wrapper:"tablesorter-wrapper"}),b.addWidget({id:"uitheme",priority:10,format:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r=b.themes,s=d.$table.add(d.$extraTables),t=d.$headers.add(d.$extraHeaders),u=d.theme||"jui",v=r[u]||{},w=a.trim([v.sortNone,v.sortDesc,v.sortAsc,v.active].join(" ")),x=a.trim([v.iconSortNone,v.iconSortDesc,v.iconSortAsc].join(" "));for(d.debug&&(i=new Date),s.hasClass("tablesorter-"+u)&&d.theme===d.appliedTheme&&e.uitheme_applied||(e.uitheme_applied=!0,n=r[d.appliedTheme]||{},q=!a.isEmptyObject(n),o=q?[n.sortNone,n.sortDesc,n.sortAsc,n.active].join(" "):"",p=q?[n.iconSortNone,n.iconSortDesc,n.iconSortAsc].join(" "):"",q&&(e.zebra[0]=a.trim(" "+e.zebra[0].replace(" "+n.even,"")),e.zebra[1]=a.trim(" "+e.zebra[1].replace(" "+n.odd,"")),d.$tbodies.children().removeClass([n.even,n.odd].join(" "))),v.even&&(e.zebra[0]+=" "+v.even),v.odd&&(e.zebra[1]+=" "+v.odd),s.children("caption").removeClass(n.caption||"").addClass(v.caption),l=s.removeClass((d.appliedTheme?"tablesorter-"+(d.appliedTheme||""):"")+" "+(n.table||"")).addClass("tablesorter-"+u+" "+(v.table||"")).children("tfoot"),d.appliedTheme=d.theme,l.length&&l.children("tr").removeClass(n.footerRow||"").addClass(v.footerRow).children("th, td").removeClass(n.footerCells||"").addClass(v.footerCells),t.removeClass((q?[n.header,n.hover,o].join(" "):"")||"").addClass(v.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(b){a(this)["mouseenter"===b.type?"addClass":"removeClass"](v.hover||"")}),t.each(function(){var c=a(this);c.find("."+b.css.wrapper).length||c.wrapInner('<div class="'+b.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),d.cssIcon&&t.find("."+b.css.icon).removeClass(q?[n.icons,p].join(" "):"").addClass(v.icons||""),s.hasClass("hasFilters")&&s.children("thead").children("."+b.css.filterRow).removeClass(q?n.filterRow||"":"").addClass(v.filterRow||"")),f=0;f<d.columns;f++)j=d.$headers.add(d.$extraHeaders).not(".sorter-false").filter('[data-column="'+f+'"]'),k=b.css.icon?j.find("."+b.css.icon):a(),m=t.not(".sorter-false").filter('[data-column="'+f+'"]:last'),m.length&&(j.removeClass(w),k.removeClass(x),m[0].sortDisabled?k.removeClass(v.icons||""):(g=v.sortNone,h=v.iconSort
"border-box"===h.css("box-sizing")?e=h.outerWidth():"collapse"===g.css("border-collapse")?b.getComputedStyle?e=parseFloat(b.getComputedStyle(this,null).width):(f=parseFloat(h.css("border-width")),e=h.outerWidth()-parseFloat(h.css("padding-left"))-parseFloat(h.css("padding-right"))-f):e=h.width(),g.css({"min-width":e,"max-width":e})})},z=function(){q=p.length?p.height()||0:parseInt(f.stickyHeaders_offset,10)||0,x=0,u.css({left:i.length?parseInt(i.css("padding-left"),10)||0:h.offset().left-parseInt(h.css("margin-left"),10)-l.scrollLeft()-x,width:h.outerWidth()}),y(h,t),y(n,g)};e.$extraTables&&e.$extraTables.length?e.$extraTables.add(t):e.$extraTables=t,t.attr("id")&&(t[0].id+=f.stickyHeaders_cloneId),t.find("thead:gt(0), tr.sticky-false").hide(),t.find("tbody, tfoot").remove(),t.find("caption").toggle(f.stickyHeaders_includeCaption),g=v.children().children(),t.css({height:0,width:0,margin:0}),g.find("."+c.css.resizer).remove(),h.addClass("hasStickyHeaders").bind("pagerComplete"+j,function(){z()}),c.bindEvents(d,v.children().children(".tablesorter-header")),h.after(u),e.onRenderHeader&&v.children("tr").children().each(function(b){e.onRenderHeader.apply(a(this),[b,e,t])}),l.add(k).unbind("scroll resize ".split(" ").join(j).replace(/\s+/g," ")).bind("scroll resize ".split(" ").join(j),function(b){if(h.is(":visible")){s=r.length?r.offset().top-k.scrollTop()+r.height():0;var c="tablesorter-sticky-",d=h.offset(),e=a.isWindow(k[0]),f=a.isWindow(l[0]),g=(i.length?e?k.scrollTop():k.offset().top:k.scrollTop())+q+s,j=h.height()-(u.height()+(o.height()||0)),m=g>d.top&&g<d.top+j?"visible":"hidden",n={visibility:m};i.length&&(n.top=e?g:i.scrollTop()),f&&(n.left=h.offset().left-parseInt(h.css("margin-left"),10)-l.scrollLeft()-x),r.length&&(n.top=(n.top||0)+q+s),u.removeClass(c+"visible "+c+"hidden").addClass(c+m).css(n),(m!==w||"resize"===b.type)&&(z(),w=m)}}),f.stickyHeaders_addResizeEvent&&c.addHeaderResizeEvent(d),h.hasClass("hasFilters")&&f.filter_columnFilters&&(h.bind("filterEnd"+j,function(){var d=a(document.activeElement).closest("td"),g=d.parent().children().index(d);u.hasClass(c.css.stickyVis)&&f.stickyHeaders_filteredToTop&&(b.scrollTo(0,h.position().top),g>=0&&e.$filters&&e.$filters.eq(g).find("a, select, input").filter(":visible").focus())}),c.filter.bindSearch(h,g.find("."+c.css.filter)),f.filter_hideFilters&&c.filter.hideFilters(t,e)),h.trigger("stickyHeadersInit")}},remove:function(d,e,f){var g=e.namespace+"stickyheaders ";e.$table.removeClass("hasStickyHeaders").unbind("pagerComplete filterEnd ".split(" ").join(g).replace(/\s+/g," ")).next("."+c.css.stickyWrap).remove(),f.$sticky&&f.$sticky.length&&f.$sticky.remove(),a(b).add(f.stickyHeaders_xScroll).add(f.stickyHeaders_yScroll).add(f.stickyHeaders_attachTo).unbind("scroll resize ".split(" ").join(g).replace(/\s+/g," ")),c.addHeaderResizeEvent(d,!1)}})}(jQuery,window),function(a,b){"use strict";var c=a.tablesorter=a.tablesorter||{};a.extend(c.css,{resizer:"tablesorter-resizer"}),c.addWidget({id:"resizable",priority:40,options:{resizable:!0,resizable_addLastColumn:!1,resizable_widths:[],resizable_throttle:!1},format:function(d,e,f){if(!e.$table.hasClass("hasResizable")){e.$table.addClass("hasResizable"),c.resizableReset(d,!0);var g,h,i,j,k,l={},m=e.$table,n=m.parent(),o="auto"===m.parent().css("overflow"),p=0,q=null,r=null,s=Math.abs(m.parent().width()-m.width())<20,t=function(a){if(0!==p&&q){var b=a.pageX-p,c=q.width();q.width(c+b),q.width()!==c&&s?r.width(r.width()-b):o&&(m.width(function(a,c){return c+b}),r.length||(n[0].scrollLeft=m.width())),p=a.pageX}},u=function(){c.storage&&q&&r&&(l={},l[q.index()]=q.width(),l[r.index()]=r.width(),q.width(l[q.index()]),r.width(l[r.index()]),f.resizable!==!1&&c.storage(d,"tablesorter-resizable",e.$headers.map(function(){return a(this).width()}).get())),p=0,q=r=null,a(b).trigger("resize")};if(l=c.storage&&f.resizable!==!1?c.storage(d,"tablesorter-resizable"):{})for(j in l)!isNaN(j)&&j<e.$headers.length&&e.$headers.eq(j).width(l[j]);g=m.children("thead:first").children("tr"),g.children().each(function(){var b,f=a(this);j=f.attr("dat