!function(e){"use strict";var t,i,a,o=e.tablesorter,n=!1,l=o.view={copyCaption:function(t,i){l.removeCaption(t,i),t.$table.find("caption").length>0&&e(i.view_caption).text(t.$table.find("caption").text())},removeCaption:function(t,i){e(i.view_caption).empty()},buildToolBar:function(t,i){l.removeToolBar(t,i),l.copyCaption(t,i);var a=e(i.view_toolbar);e.each(i.view_layouts,function(t,o){var n=i.view_switcher_class;t===i.view_layout&&(n+=" active");var l=e("",{href:"#","class":n,"data-view-type":t,title:o.title});l.append(e("",{"class":o.icon})),a.append(l)}),a.find("."+i.view_switcher_class).on("click",function(o){if(o.preventDefault(),e(this).hasClass("active"))return!1;a.find("."+i.view_switcher_class).removeClass("active"),e(this).addClass("active"),i.view_layout=e(this).attr("data-view-type"),!0===i.view_layouts[i.view_layout].raw?(l.remove(t,i),l.buildToolBar(t,i)):(!1===n&&l.hideTable(t,i),l.buildView(t,i))})},removeToolBar:function(t,i){e(i.view_toolbar).empty(),l.removeCaption(t,i)},buildView:function(t,i){l.removeView(t,i);var a=i.view_layouts[i.view_layout],n=e(a.container,{"class":i.view_layout});o.getColumnText(t.$table,0,function(t){var i=a.tmpl;e.each(e(t.$row).find("td"),function(t,a){var o={},n="{col"+t+"}";e.each(a.attributes,function(e,t){o[t.nodeName]=t.nodeValue});var l=e(a).html(),r=e("").append(e("",o).append(l));i=i.replace(new RegExp(n,"g"),r.html()),n="{col"+t+":raw}",i=i.replace(new RegExp(n,"g"),e(a).text())});var o=e(i);e.each(t.$row[0].attributes,function(e,t){"class"===t.nodeName?o.attr(t.nodeName,o.attr(t.nodeName)+" "+t.nodeValue):o.attr(t.nodeName,t.nodeValue)}),n.append(o)}),e(i.view_container).append(n),t.$table.triggerHandler("viewComplete")},removeView:function(t,i){e(i.view_container).empty()},hideTable:function(e){t=e.$table.css("position"),i=e.$table.css("bottom"),a=e.$table.css("left"),e.$table.css({position:"absolute",top:"-10000px",left:"-10000px"}),n=!0},init:function(e,t){!1!==t.view_layout&&void 0!==t.view_layouts[t.view_layout]&&(!1===n&&l.hideTable(e,t),e.$table.on("tablesorter-ready",function(){l.buildToolBar(e,t),l.buildView(e,t)}))},remove:function(e,o){l.removeToolBar(e,o),l.removeView(e,o),e.$table.css({position:t,top:i,left:a}),n=!1}};o.addWidget({id:"view",options:{view_toolbar:"#ts-view-toolbar",view_container:"#ts-view",view_caption:"#ts-view-caption",view_switcher_class:"ts-view-switcher",view_layout:!1,view_layouts:{}},init:function(e,t,i,a){l.init(i,a)},remove:function(e,t,i){l.remove(t,i)}})}(jQuery);