| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
;(function($) { |
| 53 |
'use strict'; |
| 54 |
|
| 55 |
var ts = $.tablesorter, |
| 56 |
|
| 57 |
tablereflow = { |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
init : function(table, c, wo) { |
| 62 |
var $this, |
| 63 |
title = wo.reflow_dataAttrib, |
| 64 |
header = wo.reflow_headerAttrib, |
| 65 |
headers = []; |
| 66 |
c.$table |
| 67 |
.addClass(wo.reflow_className) |
| 68 |
.off('refresh.tsreflow updateComplete.tsreflow2') |
| 69 |
|
| 70 |
|
| 71 |
.on('refresh.tsreflow updateComplete.tsreflow2', function() { |
| 72 |
tablereflow.init(table, c, wo); |
| 73 |
}); |
| 74 |
c.$headers.each(function() { |
| 75 |
$this = $(this); |
| 76 |
headers.push( $.trim( $this.attr(header) || $this.text() ) ); |
| 77 |
}); |
| 78 |
c.$tbodies.children().each(function() { |
| 79 |
$(this).children().each(function(i) { |
| 80 |
$(this).attr(title, headers[i]); |
| 81 |
}); |
| 82 |
}); |
| 83 |
}, |
| 84 |
init2: function(table, c, wo) { |
| 85 |
var $this, $tbody, i, $hdr, txt, len, |
| 86 |
cols = c.columns, |
| 87 |
header = wo.reflow2_headerAttrib, |
| 88 |
headers = []; |
| 89 |
c.$table |
| 90 |
.addClass(wo.reflow2_className) |
| 91 |
.off('refresh.tsreflow2 updateComplete.tsreflow2') |
| 92 |
|
| 93 |
|
| 94 |
.on('refresh.tsreflow2 updateComplete.tsreflow2', function() { |
| 95 |
tablereflow.init2(table, c, wo); |
| 96 |
}); |
| 97 |
|
| 98 |
|
| 99 |
for (i = 0; i < cols; i++) { |
| 100 |
$hdr = c.$headers.filter('[data-column="' + i + '"]'); |
| 101 |
if ($hdr.length > 1) { |
| 102 |
txt = []; |
| 103 |
|
| 104 |
$hdr.each(function() { |
| 105 |
$this = $(this); |
| 106 |
if (!$this.hasClass(wo.reflow2_classIgnore)) { |
| 107 |
txt.push( $this.attr(header) || $this.text() ); |
| 108 |
} |
| 109 |
}); |
| 110 |
} else { |
| 111 |
txt = [ $hdr.attr(header) || $hdr.text() ]; |
| 112 |
} |
| 113 |
headers.push( txt ); |
| 114 |
} |
| 115 |
|
| 116 |
txt = '<b class="' + c.selectorRemove.slice(1) + ' ' + wo.reflow2_labelClass; |
| 117 |
c.$tbodies.children().each(function() { |
| 118 |
$tbody = ts.processTbody(table, $(this), true); |
| 119 |
$tbody.children().each(function(j) { |
| 120 |
$this = $(this); |
| 121 |
len = headers[j].length; |
| 122 |
i = len - 1; |
| 123 |
while (i >= 0) { |
| 124 |
$this.prepend(txt + (i === 0 && len > 1 ? ' ' + wo.reflow2_labelTop : '') + '">' + headers[j][i] + '</b>'); |
| 125 |
i--; |
| 126 |
} |
| 127 |
}); |
| 128 |
ts.processTbody(table, $tbody, false); |
| 129 |
}); |
| 130 |
}, |
| 131 |
remove : function(table, c, wo) { |
| 132 |
c.$table.removeClass(wo.reflow_className); |
| 133 |
}, |
| 134 |
remove2 : function(table, c, wo) { |
| 135 |
c.$table.removeClass(wo.reflow2_className); |
| 136 |
} |
| 137 |
}; |
| 138 |
|
| 139 |
ts.addWidget({ |
| 140 |
id: 'reflow', |
| 141 |
options: { |
| 142 |
|
| 143 |
reflow_className : 'ui-table-reflow', |
| 144 |
|
| 145 |
reflow_headerAttrib : 'data-name', |
| 146 |
|
| 147 |
reflow_dataAttrib : 'data-title' |
| 148 |
}, |
| 149 |
init: function(table, thisWidget, c, wo) { |
| 150 |
tablereflow.init(table, c, wo); |
| 151 |
}, |
| 152 |
remove: function(table, c, wo) { |
| 153 |
tablereflow.remove(table, c, wo); |
| 154 |
} |
| 155 |
}); |
| 156 |
|
| 157 |
ts.addWidget({ |
| 158 |
id: 'reflow2', |
| 159 |
options: { |
| 160 |
|
| 161 |
reflow2_className : 'ui-table-reflow', |
| 162 |
|
| 163 |
reflow2_classIgnore : 'ui-table-reflow-ignore', |
| 164 |
|
| 165 |
reflow2_headerAttrib : 'data-name', |
| 166 |
|
| 167 |
reflow2_labelClass : 'ui-table-cell-label', |
| 168 |
|
| 169 |
reflow2_labelTop : 'ui-table-cell-label-top' |
| 170 |
}, |
| 171 |
init: function(table, thisWidget, c, wo) { |
| 172 |
tablereflow.init2(table, c, wo); |
| 173 |
}, |
| 174 |
remove: function(table, c, wo) { |
| 175 |
tablereflow.remove2(table, c, wo); |
| 176 |
} |
| 177 |
}); |
| 178 |
|
| 179 |
})(jQuery); |