Skip to content

Commit faef51e

Browse files
committed
Merge branch 'master' of https://github.com/angular-ui/ui-scroll
2 parents 34167e8 + 4984fcb commit faef51e

File tree

4 files changed

+88
-80
lines changed

4 files changed

+88
-80
lines changed

dist/ui-scroll-grid.js

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-ui-scroll
33
* https://github.com/angular-ui/ui-scroll.git
4-
* Version: 1.4.1 -- 2016-05-25T16:35:15.970Z
4+
* Version: 1.4.1 -- 2016-05-25T17:20:36.922Z
55
* License: MIT
66
*/
77

@@ -43,7 +43,7 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
4343
column.cells.forEach(function (cell) {
4444
return cell.css(attr, value);
4545
});
46-
column.layout.css[attr] = value;
46+
column.css[attr] = value;
4747
}
4848
};
4949

@@ -64,32 +64,18 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
6464

6565
this.header = header;
6666
this.cells = [];
67-
this.layout = { css: {} };
67+
this.css = {};
6868
this.mapTo = columns.length;
6969
this.id = columns.length;
7070

71-
this.reset = function () {
72-
this.header.removeAttr('style');
73-
this.cells.forEach(function (cell) {
74-
return cell.removeAttr('style');
75-
});
76-
};
71+
// controller api methods
7772

7873
this.applyLayout = function (layout) {
79-
this.layout.css = angular.extend({}, layout.css);
74+
this.css = angular.extend({}, layout.css);
75+
this.mapTo = layout.mapTo;
76+
applyCss(this.header, this.css);
8077
};
8178

82-
function moveBefore(element, target) {
83-
element.detach();
84-
target.before(element);
85-
}
86-
87-
function moveLast(element, target) {
88-
var parent = element.parent();
89-
element.detach();
90-
parent.append(element);
91-
}
92-
9379
this.moveBefore = function (target) {
9480
if (target) {
9581
moveBefore(header, target.header);
@@ -104,17 +90,41 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
10490
}
10591
};
10692

93+
this.columnFromPoint = function (x, y) {
94+
if (insidePoint(header, x, y)) return this;
95+
for (var i = 0; i < this.cells.length; i++) {
96+
if (insidePoint(this.cells[i], x, y)) return this;
97+
}
98+
};
99+
100+
this.applyCss = function (target) {
101+
applyCss(target, this.css);
102+
};
103+
104+
// function definitions
105+
107106
function insidePoint(element, x, y) {
108107
var offset = element.offset();
109108
if (x < offset.left || offset.left + element.outerWidth(true) < x) return false;
110109
if (y < offset.top || offset.top + element.outerHeight(true) < y) return false;
111110
return true;
112111
}
113112

114-
this.columnFromPoint = function (x, y) {
115-
if (insidePoint(header, x, y)) return this;
116-
for (var i = 0; i < this.cells.length; i++) {
117-
if (insidePoint(this.cells[i], x, y)) return this;
113+
function moveBefore(element, target) {
114+
element.detach();
115+
target.before(element);
116+
}
117+
118+
function moveLast(element, target) {
119+
var parent = element.parent();
120+
element.detach();
121+
parent.append(element);
122+
}
123+
124+
function applyCss(target, css) {
125+
target.removeAttr('style');
126+
for (var attr in css) {
127+
if (css.hasOwnProperty(attr)) target.css(attr, css[attr]);
118128
}
119129
};
120130
}
@@ -130,23 +140,17 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
130140
$timeout(function () {
131141
scrollViewport.adapter.gridAdapter = new GridAdapter(_this);
132142
scrollViewport.adapter.transform = function (scope, item) {
133-
return _this.transform(rowMap.get(scope), item);
143+
return transform(rowMap.get(scope), item);
134144
};
135145
});
136146

137-
this.transform = function (row) {
147+
function transform(row) {
138148
var parent = row[0].parent();
139149
var last = row[row.length - 1].next();
140150
var visible = [];
141151

142-
function applyCss(target, css) {
143-
for (var attr in css) {
144-
if (css.hasOwnProperty(attr)) target.css(attr, css[attr]);
145-
}
146-
};
147-
148-
columns.forEach(function (column, index) {
149-
applyCss(row[index], column.layout.css);
152+
row.forEach(function (cell, index) {
153+
columns[index].applyCss(cell);
150154
visible[columns[index].mapTo] = row[index];
151155
});
152156

@@ -159,7 +163,7 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
159163
current.after(cell);
160164
current = cell;
161165
});
162-
};
166+
}
163167

164168
this.registerColumn = function (header) {
165169
columns.push(new ColumnController(columns, header));
@@ -212,24 +216,22 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
212216
columns.forEach(function (column, index) {
213217
return result.push({
214218
index: index,
215-
css: angular.extend({}, column.layout.css),
219+
css: angular.extend({}, column.css),
216220
mapTo: column.mapTo
217221
});
218222
});
219223
return result;
220224
};
221225

222226
this.applyLayout = function (layouts) {
223-
var _this3 = this;
224-
225227
if (!layouts || layouts.length != columns.length) {
226228
throw new Error('Failed to apply layout - number of layouts should match number of columns');
227229
}
228230
layouts.forEach(function (layout, index) {
229231
columns[index].applyLayout(layout);
230232
});
231233
rowMap.forEach(function (row) {
232-
_this3.transform(row);
234+
transform(row);
233235
});
234236
};
235237

dist/ui-scroll-jqlite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-ui-scroll
33
* https://github.com/angular-ui/ui-scroll.git
4-
* Version: 1.4.1 -- 2016-05-25T16:35:15.970Z
4+
* Version: 1.4.1 -- 2016-05-25T17:20:36.922Z
55
* License: MIT
66
*/
77

dist/ui-scroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* angular-ui-scroll
33
* https://github.com/angular-ui/ui-scroll.git
4-
* Version: 1.4.1 -- 2016-05-25T16:35:15.970Z
4+
* Version: 1.4.1 -- 2016-05-25T17:20:36.922Z
55
* License: MIT
66
*/
77

src/ui-scroll-grid.js

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('ui.scroll.grid', [])
2323
if (arguments.length == 2) {
2424
column.header.css(attr, value);
2525
column.cells.forEach((cell) => cell.css(attr, value));
26-
column.layout.css[attr] = value;
26+
column.css[attr] = value;
2727
}
2828
};
2929

@@ -42,30 +42,18 @@ angular.module('ui.scroll.grid', [])
4242

4343
this.header = header;
4444
this.cells = [];
45-
this.layout = {css: {}};
45+
this.css = {};
4646
this.mapTo = columns.length;
4747
this.id = columns.length;
4848

49-
this.reset = function () {
50-
this.header.removeAttr('style');
51-
this.cells.forEach((cell) => cell.removeAttr('style'));
52-
};
49+
// controller api methods
5350

5451
this.applyLayout = function(layout) {
55-
this.layout.css = angular.extend({}, layout.css);
52+
this.css = angular.extend({}, layout.css);
53+
this.mapTo = layout.mapTo;
54+
applyCss(this.header, this.css);
5655
};
5756

58-
function moveBefore(element, target) {
59-
element.detach();
60-
target.before(element);
61-
}
62-
63-
function moveLast(element, target) {
64-
let parent = element.parent();
65-
element.detach();
66-
parent.append(element);
67-
}
68-
6957
this.moveBefore = function(target) {
7058
if (target) {
7159
moveBefore(header, target.header);
@@ -76,6 +64,20 @@ angular.module('ui.scroll.grid', [])
7664
}
7765
};
7866

67+
this.columnFromPoint = function (x,y) {
68+
if (insidePoint(header, x,y))
69+
return this;
70+
for (let i=0; i<this.cells.length; i++)
71+
if (insidePoint(this.cells[i], x,y))
72+
return this;
73+
};
74+
75+
this.applyCss = function(target) {
76+
applyCss(target, this.css);
77+
}
78+
79+
// function definitions
80+
7981
function insidePoint(element, x,y) {
8082
let offset = element.offset();
8183
if (x < offset.left || offset.left + element.outerWidth(true) < x )
@@ -85,13 +87,24 @@ angular.module('ui.scroll.grid', [])
8587
return true;
8688
}
8789

88-
this.columnFromPoint = function (x,y) {
89-
if (insidePoint(header, x,y))
90-
return this;
91-
for (let i=0; i<this.cells.length; i++)
92-
if (insidePoint(this.cells[i], x,y))
93-
return this;
94-
};
90+
function moveBefore(element, target) {
91+
element.detach();
92+
target.before(element);
93+
}
94+
95+
function moveLast(element, target) {
96+
let parent = element.parent();
97+
element.detach();
98+
parent.append(element);
99+
}
100+
101+
function applyCss (target, css) {
102+
target.removeAttr('style');
103+
for (let attr in css)
104+
if (css.hasOwnProperty(attr))
105+
target.css(attr, css[attr]);
106+
};
107+
95108
}
96109

97110
function GridController(scope, scrollViewport) {
@@ -102,22 +115,16 @@ angular.module('ui.scroll.grid', [])
102115

103116
$timeout(() => {
104117
scrollViewport.adapter.gridAdapter = new GridAdapter(this);
105-
scrollViewport.adapter.transform = (scope, item) => this.transform(rowMap.get(scope), item);
118+
scrollViewport.adapter.transform = (scope, item) => transform(rowMap.get(scope), item);
106119
});
107120

108-
this.transform = function (row) {
121+
function transform (row) {
109122
let parent = row[0].parent();
110123
let last = row[row.length-1].next();
111124
let visible = [];
112125

113-
function applyCss (target, css) {
114-
for (let attr in css)
115-
if (css.hasOwnProperty(attr))
116-
target.css(attr, css[attr]);
117-
};
118-
119-
columns.forEach((column, index) => {
120-
applyCss(row[index], column.layout.css);
126+
row.forEach((cell, index) => {
127+
columns[index].applyCss(cell);
121128
visible[columns[index].mapTo] = row[index];
122129
});
123130

@@ -168,7 +175,6 @@ angular.module('ui.scroll.grid', [])
168175
row.splice(i, 1);
169176
if (!row.length)
170177
rowMap.delete(scope);
171-
172178
};
173179

174180
this.getColumns = function () {
@@ -182,7 +188,7 @@ angular.module('ui.scroll.grid', [])
182188
let result = [];
183189
columns.forEach((column, index) => result.push({
184190
index: index,
185-
css: angular.extend({}, column.layout.css),
191+
css: angular.extend({}, column.css),
186192
mapTo: column.mapTo
187193
})
188194
);
@@ -194,7 +200,7 @@ angular.module('ui.scroll.grid', [])
194200
throw new Error('Failed to apply layout - number of layouts should match number of columns');
195201
}
196202
layouts.forEach((layout, index) => { columns[index].applyLayout(layout); });
197-
rowMap.forEach((row) => { this.transform(row); });
203+
rowMap.forEach((row) => { transform(row); });
198204
};
199205

200206
this.moveBefore = function (selected, target) {

0 commit comments

Comments
 (0)