Skip to content

Commit 1775c71

Browse files
committed
release v0.3.0
1 parent 579494e commit 1775c71

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

release/angular-responsive-tables.js

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
controller: function($element) {
2222
return {
2323
getHeader: function(td) {
24+
var firstHeader = td.parentElement.querySelector("th");
25+
if (firstHeader) return firstHeader;
2426
var headers = getHeaders($element[0]);
2527
if (headers.length) {
2628
var row = td.parentElement;
@@ -37,47 +39,36 @@
3739
};
3840
},
3941
compile: function(element, attrs) {
40-
function apply() {
41-
var headers = getHeaders(element[0]);
42-
if (headers.length) {
43-
var rows = element[0].querySelectorAll("tbody > tr");
44-
Array.prototype.forEach.call(rows, function(row) {
45-
var headerIndex = 0;
46-
Array.prototype.forEach.call(row.querySelectorAll("td"), function(value, index) {
47-
if (!value.getAttributeNode("responsive-dynamic")) {
48-
var th = value.parentElement.querySelector("th") || headers.item(headerIndex);
49-
updateTitle(value, th);
50-
}
51-
headerIndex += colspan(value);
52-
});
53-
});
54-
}
55-
}
5642
attrs.$addClass("responsive");
57-
if (Array.prototype.some.call(element.find("th"), function(it) {
58-
return it.getAttributeNode("ng-repeat") || it.getAttributeNode("data-ng-repeat");
59-
})) {
60-
setTimeout(function() {
61-
apply();
62-
}, 0);
63-
} else {
64-
apply();
43+
var headers = getHeaders(element[0]);
44+
if (headers.length) {
45+
var rows = element[0].querySelectorAll("tbody > tr");
46+
Array.prototype.forEach.call(rows, function(row) {
47+
var headerIndex = 0;
48+
Array.prototype.forEach.call(row.querySelectorAll("td"), function(value, index) {
49+
var th = value.parentElement.querySelector("th") || headers.item(headerIndex);
50+
updateTitle(value, th);
51+
headerIndex += colspan(value);
52+
});
53+
});
6554
}
6655
}
6756
};
6857
}
6958
function wtResponsiveDynamic() {
7059
return {
71-
restrict: "A",
60+
restrict: "E",
7261
require: "^^wtResponsiveTable",
7362
link: function(scope, element, attrs, tableCtrl) {
74-
Array.prototype.forEach.call(element[0].parentElement.querySelectorAll("td"), function(td) {
75-
var th = tableCtrl.getHeader(td);
76-
updateTitle(td, th);
77-
});
63+
setTimeout(function() {
64+
Array.prototype.forEach.call(element[0].parentElement.querySelectorAll("td"), function(td) {
65+
var th = tableCtrl.getHeader(td);
66+
updateTitle(td, th);
67+
});
68+
}, 0);
7869
}
7970
};
8071
}
8172
"use strict";
82-
angular.module("wt.responsive", []).directive("wtResponsiveTable", [ wtResponsiveTable ]).directive("responsiveDynamic", [ wtResponsiveDynamic ]);
73+
angular.module("wt.responsive", []).directive("wtResponsiveTable", [ wtResponsiveTable ]).directive("td", [ wtResponsiveDynamic ]);
8374
})();

release/angular-responsive-tables.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)