tablesorter/dist/js/widgets/widget-output.min.js

2 lines
6.2 KiB
JavaScript
Raw Normal View History

2017-09-28 02:07:28 +00:00
/*! Widget: output - updated 9/27/2017 (v2.29.0) */
2018-05-28 20:18:32 +00:00
!function(t){"use strict";var e=t.tablesorter,o=e.output={event:"outputTable",noDblClick:600,lastEvent:0,busy:!1,regexQuote:/([\n\t\x09\x0d\x0a]|<[^<]+>)/,regexBR:/(<br([\s\/])?>|\n)/g,regexIMG:/<img[^>]+alt\s*=\s*['"]([^'"]+)['"][^>]*>/i,regexHTML:/<[^<]+>/g,replaceCR:"\r\n",replaceTab:"\t",popupTitle:"Output",popupStyle:"width:100%;height:100%;margin:0;resize:none;",message:"Your device does not support downloading. Please try again in desktop browser.",init:function(t){t.$table.off(o.event).on(o.event,function(e){e.stopPropagation(),!o.busy&&e.timeStamp-o.lastEvent>o.noDblClick&&(o.lastEvent=e.timeStamp,o.busy=!0,o.process(t,t.widgetOptions))})},processRow:function(u,n,r,a){var p,i,l,s,c,d,f,_,w,m,g=u.widgetOptions,h=[],v=g.output_duplicateSpans,b=r&&a&&g.output_headerRows&&t.isFunction(g.output_callbackJSON),y=0,S=n.length;for(s=0;s<S;s++)for(h[s]||(h[s]=[]),y=0,l=(i=n.eq(s).children()).length,f=0;f<l;f++){if((p=i.eq(f)).filter("[rowspan]").length)for(_=parseInt(p.attr("rowspan"),10)-1,m=o.formatData(u,g,p,r,f),c=1;c<=_;c++)h[s+c]||(h[s+c]=[]),h[s+c][y]=r?m:v?m:"";if(p.filter("[colspan]").length)for(w=parseInt(p.attr("colspan"),10)-1,m=o.formatData(u,g,p,r,f),d=0;d<w;d++)if(p.filter("[rowspan]").length)for(_=parseInt(p.attr("rowspan"),10),c=0;c<_;c++)h[s+c]||(h[s+c]=[]),h[s+c][y+d]=b?g.output_callbackJSON(p,m,y+d)||m+"("+(y+d)+")":r?m:v?m:"";else h[s][y+d]=b?g.output_callbackJSON(p,m,y+d)||m+"("+(y+d)+")":r?m:v?m:"";for(;void 0!==h[s][y];)y++;h[s][y]=h[s][y]||o.formatData(u,g,p,r,y),y++}return e.output.removeColumns(u,g,h)},removeColumns:function(t,e,o){var u,n,r,a=[],p=o.length;for(u=0;u<p;u++)for(n=o[u],a[u]=[],r=0;r<t.columns;r++)e.output_hiddenColumnArray[r]||a[u].push(n[r]);return a},process:function(u,n,r,a){var p,i,l,s,c,d,f,_=window.JSON&&JSON.hasOwnProperty("stringify"),w=0,m=(n.output_separator||",").toLowerCase(),g="json"===m,h="array"===m,v=g||h?",":n.output_separator,b=n.output_saveRows,y=u.$table;for(n.output_regex=new RegExp("("+(/\\/.test(v)?"\\":"")+v+")"),n.output_hiddenColumnArray=[],w=0;w<u.columns;w++)n.output_hiddenColumnArray[w]=t.inArray(w,n.output_ignoreColumns)>-1||!n.output_hiddenColumns&&"none"===u.$headerIndexed[w].css("display")&&!u.$headerIndexed[w].hasClass("tablesorter-scroller-hidden-column");if(i=y.children("thead").children("tr").not("."+(e.css.filterRow||"tablesorter-filter-row")).filter(function(){return n.output_hiddenColumns||"none"!==t(this).css("display")}),l=o.processRow(u,i,!0,g),r||(r=y.children("tbody").children("tr").not(u.selectorRemove)),r="function"==typeof b?r.filter(b):/^f/.test(b)?r.not("."+(n.filter_filteredRow||"filtered")):/^v/.test(b)?r.filter(":visible"):/^[.#:\[]/.test(b)?r.filter(b):r,s=o.processRow(u,r),n.output_includeFooter&&(s=s.concat(o.processRow(u,y.children("tfoot").children("tr:visible")))),c=l.length,g){for(m=[],d=s.length,w=0;w<d;w++)f=l[c>1&&n.output_headerRows?w%c:c-1],m.push(o.row2Hash(f,s[w]));p=_?JSON.stringify(m):m}else n.output_includeHeader?(f=[l[c>1&&n.output_headerRows?w%c:c-1]],m=o.row2CSV(n,n.output_headerRows?l:f,h).concat(o.row2CSV(n,s,h))):m=o.row2CSV(n,s,h),p=h&&_?JSON.stringify(m):m.join("\n");if(a)return p;if(t.isFunction(n.output_callback)){if(!1===(f=n.output_callback(u,p,u.pager&&u.pager.ajaxObject.url||null)))return void(o.busy=!1);"string"==typeof f&&(p=f)}/p/i.test(n.output_delivery||"")?o.popup(p,n.output_popupStyle,g||h):o.download(u,n,p),o.busy=!1},row2CSV:function(t,e,o){var u,n,r=[],a=e.length;for(n=0;n<a;n++)u=(e[n]||[]).join("").replace(/\"/g,""),(e[n]||[]).length>0&&""!==u&&(r[r.length]=o?e[n]:e[n].join(t.output_separator));return r},row2Hash:function(t,e){var o,u={},n=e.length;for(o=0;o<n;o++)o<t.length&&(u[t[o]]=e[o]);return u},formatData:function(e,u,n,r,a){var p=n.attr(u.output_dataAttrib),i=void 0!==p?p:n.html(),l=(u.output_separator||",").toLowerCase(),s="json"===l||"array"===l,c=i.replace(/\"/g,u.output_replaceQuote||"“");return c=u.output_trimSpaces?c.replace(o.regexBR,""):c.replace(o.regexBR,o.replaceCR).replace(/\t/g,o.replaceTab),i=c.match(o.regexIMG),u.output_includeHTML||null===i||(c=i[1]),c=u.output