angular-table 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29059fb4c1ab0f15e5184bd0fb56ea8b6980c8dc
4
- data.tar.gz: f2a9eb4d42f5cf334b4cd0495698ac62c31ea0c7
3
+ metadata.gz: 0056250ac2ecf0d968e85775a1c188529e3dca47
4
+ data.tar.gz: 03760cba5691dad52e585ffd06aa08995cc2782b
5
5
  SHA512:
6
- metadata.gz: 42104469a3dab66925ecd6d32d9841e3756f9abfb5b993b615fd8bf62194366525be90b0ac66fb8edf11aba25ec86690017ab6b987692adb066f1d7cda54b2d5
7
- data.tar.gz: 806949061dbd0980f3a144564d86153e61fed8778de85162a452446356e613c4c5983c730fa0fb01eb65f0ba0d4f04549fd0c9ab20a2ebb3eafb3a31c4f6d09a
6
+ metadata.gz: e8ffa9daed80724576f5ef6cfaf785541e533158a1a62f3068c051c31ec25c849c895cc2dd6acfb9c2fcafe4f32082d16786f392452653ac2357ac3962fbb4cf
7
+ data.tar.gz: 58eacc1b3022a94e6ca91c7116f3e14ca95e4f97876c5552fd9ec69b7aa8743dfb671f9248d9899bfd7452de8f18c3b370e52a333b063b5e8471ce2a01f01cd1
@@ -1,5 +1,5 @@
1
1
  // author: Samuel Mueller
2
- // version: 0.0.6
2
+ // version: 0.0.7
3
3
  // license: MIT
4
4
  // homepage: http://github.com/ssmm/angular-table
5
5
  (function() {
@@ -10,13 +10,22 @@
10
10
  var constructHeader, normalizeInput, validateInput;
11
11
 
12
12
  constructHeader = function(customHeaderMarkup, bodyDefinitions) {
13
- var icon, td, th, title, tr, _i, _len;
13
+ var attribute, icon, td, th, title, tr, _i, _j, _len, _len1, _ref;
14
14
 
15
15
  tr = angular.element("<tr></tr>");
16
16
  for (_i = 0, _len = bodyDefinitions.length; _i < _len; _i++) {
17
17
  td = bodyDefinitions[_i];
18
18
  th = angular.element("<th style='cursor: pointer;'></th>");
19
- title = customHeaderMarkup[td.attribute] || td.title;
19
+ if (customHeaderMarkup[td.attribute]) {
20
+ _ref = customHeaderMarkup[td.attribute].attributes;
21
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
22
+ attribute = _ref[_j];
23
+ th.attr("" + attribute.name, "" + attribute.value);
24
+ }
25
+ title = customHeaderMarkup[td.attribute].content;
26
+ } else {
27
+ title = td.title;
28
+ }
20
29
  th.html("" + title);
21
30
  if (td.sortable) {
22
31
  th.attr("ng-click", "predicate = '" + td.attribute + "'; descending = !descending;");
@@ -115,16 +124,23 @@
115
124
  list: "="
116
125
  },
117
126
  link: function($scope, $element, $attributes) {
127
+ var normalizePage, update;
128
+
118
129
  $scope.instance = $scope;
119
130
  $scope.currentPage = 0;
120
- $scope.update = function() {
131
+ normalizePage = function(page) {
132
+ page = Math.max(0, page);
133
+ page = Math.min($scope.numberOfPages - 1, page);
134
+ return page;
135
+ };
136
+ update = function(reset) {
121
137
  var x;
122
138
 
123
139
  $scope.currentPage = 0;
124
140
  if ($scope.list) {
125
141
  if ($scope.list.length > 0) {
126
142
  $scope.numberOfPages = Math.ceil($scope.list.length / $scope.itemsPerPage);
127
- $scope.pages = (function() {
143
+ return $scope.pages = (function() {
128
144
  var _i, _ref, _results;
129
145
 
130
146
  _results = [];
@@ -135,9 +151,8 @@
135
151
  })();
136
152
  } else {
137
153
  $scope.numberOfPages = 1;
138
- $scope.pages = [0];
154
+ return $scope.pages = [0];
139
155
  }
140
- return $scope.list = $scope.list;
141
156
  }
142
157
  };
143
158
  $scope.fromPage = function() {
@@ -163,13 +178,14 @@
163
178
  }
164
179
  };
165
180
  $scope.goToPage = function(page) {
166
- page = Math.max(0, page);
167
- page = Math.min($scope.numberOfPages - 1, page);
168
- return $scope.currentPage = page;
181
+ return $scope.currentPage = normalizePage(page);
169
182
  };
170
- $scope.update();
183
+ update();
184
+ $scope.$watch("itemsPerPage", function() {
185
+ return update();
186
+ });
171
187
  return $scope.$watch("list", function() {
172
- return $scope.update();
188
+ return update();
173
189
  });
174
190
  }
175
191
  };
@@ -221,17 +237,19 @@
221
237
  };
222
238
  return {
223
239
  collectCustomHeaderMarkup: function(thead) {
224
- var customHeaderMarkup, th, tr, _i, _len, _ref;
240
+ var customHeaderMarkup, customHeaderMarkups, th, tr, _i, _len, _ref;
225
241
 
226
- customHeaderMarkup = {};
242
+ customHeaderMarkups = {};
227
243
  tr = thead.find("tr");
228
244
  _ref = tr.find("th");
229
245
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
230
246
  th = _ref[_i];
231
247
  th = angular.element(th);
232
- customHeaderMarkup[th.attr("attribute")] = th.html();
248
+ customHeaderMarkup = customHeaderMarkups[th.attr("attribute")] = {};
249
+ customHeaderMarkup.content = th.html();
250
+ customHeaderMarkup.attributes = th[0].attributes;
233
251
  }
234
- return customHeaderMarkup;
252
+ return customHeaderMarkups;
235
253
  },
236
254
  collectBodyDefinition: function(tbody) {
237
255
  var attribute, bodyDefinition, initialSortDirection, sortable, td, title, width, _i, _len, _ref;
@@ -1,3 +1,3 @@
1
1
  module AngularTable
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-23 00:00:00.000000000 Z
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,8 +38,7 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Angular directive for easy HTML table declaration. Makes them sortable
42
- and adds pagination.
41
+ description: Html tables with sorting and pagination.
43
42
  email:
44
43
  - mueller.samu@gmail.com
45
44
  executables: []
@@ -72,6 +71,5 @@ rubyforge_project:
72
71
  rubygems_version: 2.0.3
73
72
  signing_key:
74
73
  specification_version: 4
75
- summary: Angular directive for easy HTML table declaration. Makes them sortable and
76
- adds pagination.
74
+ summary: Html tables with sorting and pagination.
77
75
  test_files: []