Skip to content

Commit 9a3f55a

Browse files
committed
Merge branch 'master' into smart-hide-sort-priority
2 parents 7725eac + 6032ac0 commit 9a3f55a

File tree

7 files changed

+267
-17
lines changed

7 files changed

+267
-17
lines changed

lib/grunt/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var cachedAngularFiles = grunt.file.readJSON('lib/test/angular/files.json');
1010
var util = module.exports = {
1111

1212
testDependencies: {
13-
unit: ['bower_components/jquery/jquery.min.js', 'lib/test/jquery.simulate.js', 'dist/release/ui-grid.css', 'bower_components/lodash/dist/lodash.min.js', 'bower_components/csv-js/csv.js']
13+
unit: ['bower_components/jquery/jquery.min.js', 'lib/test/jquery.simulate.js','lib/test/classList.polyFill.js', 'dist/release/ui-grid.css', 'bower_components/lodash/dist/lodash.min.js', 'bower_components/csv-js/csv.js']
1414
},
1515

1616
testFiles: {

lib/test/classList.polyFill.js

+240
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
/*
2+
* classList.js: Cross-browser full element.classList implementation.
3+
* 1.1.20150312
4+
*
5+
* By Eli Grey, http://eligrey.com
6+
* License: Dedicated to the public domain.
7+
* See https://github.com/eligrey/classList.js/blob/master/LICENSE.md
8+
*/
9+
10+
/*global self, document, DOMException */
11+
12+
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
13+
14+
if ("document" in self) {
15+
16+
// Full polyfill for browsers with no classList support
17+
// Including IE < Edge missing SVGElement.classList
18+
if (!("classList" in document.createElement("_"))
19+
|| document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg","g"))) {
20+
21+
(function (view) {
22+
23+
"use strict";
24+
25+
if (!('Element' in view)) return;
26+
27+
var
28+
classListProp = "classList"
29+
, protoProp = "prototype"
30+
, elemCtrProto = view.Element[protoProp]
31+
, objCtr = Object
32+
, strTrim = String[protoProp].trim || function () {
33+
return this.replace(/^\s+|\s+$/g, "");
34+
}
35+
, arrIndexOf = Array[protoProp].indexOf || function (item) {
36+
var
37+
i = 0
38+
, len = this.length
39+
;
40+
for (; i < len; i++) {
41+
if (i in this && this[i] === item) {
42+
return i;
43+
}
44+
}
45+
return -1;
46+
}
47+
// Vendors: please allow content code to instantiate DOMExceptions
48+
, DOMEx = function (type, message) {
49+
this.name = type;
50+
this.code = DOMException[type];
51+
this.message = message;
52+
}
53+
, checkTokenAndGetIndex = function (classList, token) {
54+
if (token === "") {
55+
throw new DOMEx(
56+
"SYNTAX_ERR"
57+
, "An invalid or illegal string was specified"
58+
);
59+
}
60+
if (/\s/.test(token)) {
61+
throw new DOMEx(
62+
"INVALID_CHARACTER_ERR"
63+
, "String contains an invalid character"
64+
);
65+
}
66+
return arrIndexOf.call(classList, token);
67+
}
68+
, ClassList = function (elem) {
69+
var
70+
trimmedClasses = strTrim.call(elem.getAttribute("class") || "")
71+
, classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
72+
, i = 0
73+
, len = classes.length
74+
;
75+
for (; i < len; i++) {
76+
this.push(classes[i]);
77+
}
78+
this._updateClassName = function () {
79+
elem.setAttribute("class", this.toString());
80+
};
81+
}
82+
, classListProto = ClassList[protoProp] = []
83+
, classListGetter = function () {
84+
return new ClassList(this);
85+
}
86+
;
87+
// Most DOMException implementations don't allow calling DOMException's toString()
88+
// on non-DOMExceptions. Error's toString() is sufficient here.
89+
DOMEx[protoProp] = Error[protoProp];
90+
classListProto.item = function (i) {
91+
return this[i] || null;
92+
};
93+
classListProto.contains = function (token) {
94+
token += "";
95+
return checkTokenAndGetIndex(this, token) !== -1;
96+
};
97+
classListProto.add = function () {
98+
var
99+
tokens = arguments
100+
, i = 0
101+
, l = tokens.length
102+
, token
103+
, updated = false
104+
;
105+
do {
106+
token = tokens[i] + "";
107+
if (checkTokenAndGetIndex(this, token) === -1) {
108+
this.push(token);
109+
updated = true;
110+
}
111+
}
112+
while (++i < l);
113+
114+
if (updated) {
115+
this._updateClassName();
116+
}
117+
};
118+
classListProto.remove = function () {
119+
var
120+
tokens = arguments
121+
, i = 0
122+
, l = tokens.length
123+
, token
124+
, updated = false
125+
, index
126+
;
127+
do {
128+
token = tokens[i] + "";
129+
index = checkTokenAndGetIndex(this, token);
130+
while (index !== -1) {
131+
this.splice(index, 1);
132+
updated = true;
133+
index = checkTokenAndGetIndex(this, token);
134+
}
135+
}
136+
while (++i < l);
137+
138+
if (updated) {
139+
this._updateClassName();
140+
}
141+
};
142+
classListProto.toggle = function (token, force) {
143+
token += "";
144+
145+
var
146+
result = this.contains(token)
147+
, method = result ?
148+
force !== true && "remove"
149+
:
150+
force !== false && "add"
151+
;
152+
153+
if (method) {
154+
this[method](token);
155+
}
156+
157+
if (force === true || force === false) {
158+
return force;
159+
} else {
160+
return !result;
161+
}
162+
};
163+
classListProto.toString = function () {
164+
return this.join(" ");
165+
};
166+
167+
if (objCtr.defineProperty) {
168+
var classListPropDesc = {
169+
get: classListGetter
170+
, enumerable: true
171+
, configurable: true
172+
};
173+
try {
174+
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
175+
} catch (ex) { // IE 8 doesn't support enumerable:true
176+
if (ex.number === -0x7FF5EC54) {
177+
classListPropDesc.enumerable = false;
178+
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
179+
}
180+
}
181+
} else if (objCtr[protoProp].__defineGetter__) {
182+
elemCtrProto.__defineGetter__(classListProp, classListGetter);
183+
}
184+
185+
}(self));
186+
187+
} else {
188+
// There is full or partial native classList support, so just check if we need
189+
// to normalize the add/remove and toggle APIs.
190+
191+
(function () {
192+
"use strict";
193+
194+
var testElement = document.createElement("_");
195+
196+
testElement.classList.add("c1", "c2");
197+
198+
// Polyfill for IE 10/11 and Firefox <26, where classList.add and
199+
// classList.remove exist but support only one argument at a time.
200+
if (!testElement.classList.contains("c2")) {
201+
var createMethod = function(method) {
202+
var original = DOMTokenList.prototype[method];
203+
204+
DOMTokenList.prototype[method] = function(token) {
205+
var i, len = arguments.length;
206+
207+
for (i = 0; i < len; i++) {
208+
token = arguments[i];
209+
original.call(this, token);
210+
}
211+
};
212+
};
213+
createMethod('add');
214+
createMethod('remove');
215+
}
216+
217+
testElement.classList.toggle("c3", false);
218+
219+
// Polyfill for IE 10 and Firefox <24, where classList.toggle does not
220+
// support the second argument.
221+
if (testElement.classList.contains("c3")) {
222+
var _toggle = DOMTokenList.prototype.toggle;
223+
224+
DOMTokenList.prototype.toggle = function(token, force) {
225+
if (1 in arguments && !this.contains(token) === !force) {
226+
return force;
227+
} else {
228+
return _toggle.call(this, token);
229+
}
230+
};
231+
232+
}
233+
234+
testElement = null;
235+
}());
236+
237+
}
238+
239+
}
240+

src/features/exporter/js/exporter.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,9 @@
751751
* @param {string} colTypes which columns to export, valid values are
752752
* uiGridExporterConstants.ALL, uiGridExporterConstants.VISIBLE,
753753
* uiGridExporterConstants.SELECTED
754+
* @param {boolean} applyCellFilters whether or not to get the display value or the raw value of the data
754755
*/
755-
getData: function (grid, rowTypes, colTypes) {
756+
getData: function (grid, rowTypes, colTypes, applyCellFilters) {
756757
var data = [];
757758
var rows;
758759
var columns;
@@ -793,7 +794,8 @@
793794
if ( (gridCol.visible || colTypes === uiGridExporterConstants.ALL ) &&
794795
gridCol.colDef.exporterSuppressExport !== true &&
795796
grid.options.exporterSuppressColumns.indexOf( gridCol.name ) === -1 ){
796-
var extractedField = { value: grid.options.exporterFieldCallback( grid, row, gridCol, grid.getCellValue( row, gridCol ) ) };
797+
var cellValue = applyCellFilters ? grid.getCellDisplayValue( row, gridCol ) : grid.getCellValue( row, gridCol );
798+
var extractedField = { value: grid.options.exporterFieldCallback( grid, row, gridCol, cellValue ) };
797799
if ( gridCol.colDef.exporterPdfAlign ) {
798800
extractedField.alignment = gridCol.colDef.exporterPdfAlign;
799801
}
@@ -993,7 +995,7 @@
993995
var exportData = self.getData(grid, rowTypes, colTypes);
994996
var docDefinition = self.prepareAsPdf(grid, exportColumnHeaders, exportData);
995997

996-
if (self.isIE()) {
998+
if (self.isIE() || navigator.appVersion.indexOf("Edge") !== -1) {
997999
self.downloadPDF(grid.options.exporterPdfFilename, docDefinition);
9981000
} else {
9991001
pdfMake.createPdf(docDefinition).open();

src/features/exporter/test/exporter.spec.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('ui.grid.exporter uiGridExporterService', function () {
2727
grid = gridClassFactory.createGrid({});
2828
grid.options.columnDefs = [
2929
{field: 'col1', name: 'col1', displayName: 'Col1', width: 50, pinnedLeft: true},
30-
{field: 'col2', name: 'col2', displayName: 'Col2', width: '*', type: 'number'},
30+
{field: 'col2', name: 'col2', displayName: 'Col2', width: '*', type: 'number', cellFilter: 'uppercase'},
3131
{field: 'col3', name: 'col3', displayName: 'Col3', width: 100},
3232
{field: 'col4', name: 'col4', displayName: 'Col4', width: 200}
3333
];
@@ -265,6 +265,14 @@ describe('ui.grid.exporter uiGridExporterService', function () {
265265
]);
266266
});
267267

268+
it('gets the rows display values', function() {
269+
expect(uiGridExporterService.getData(grid, uiGridExporterConstants.ALL, uiGridExporterConstants.ALL, true)).toEqual([
270+
[ {value: 'a_0'}, {value: 'B_0'}, {value: 'c_0'}, {value: 'd_0'} ],
271+
[ {value: 'a_1'}, {value: 'B_1'}, {value: 'c_1'}, {value: 'd_1'} ],
272+
[ {value: 'a_2'}, {value: 'B_2'}, {value: 'c_2'}, {value: 'd_2'} ]
273+
]);
274+
});
275+
268276
it('maps data using objectCallback', function() {
269277
grid.options.exporterFieldCallback = function( grid, row, col, value ){
270278
if ( col.name === 'col2' ){

src/js/core/directives/ui-grid-column-menu.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $documen
336336
templateUrl: 'ui-grid/uiGridColumnMenu',
337337
replace: true,
338338
link: function ($scope, $elm, $attrs, uiGridCtrl) {
339-
var self = this;
340-
341339
uiGridColumnMenuService.initialize( $scope, uiGridCtrl );
342340

343341
$scope.defaultMenuItems = uiGridColumnMenuService.getDefaultMenuItems( $scope );
@@ -375,7 +373,7 @@ function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $documen
375373

376374
$scope.$broadcast('hide-menu', { originalEvent: event });
377375
} else {
378-
self.shown = $scope.menuShown = true;
376+
$scope.menuShown = true;
379377
uiGridColumnMenuService.repositionMenu( $scope, column, colElementPosition, $elm, $columnElement );
380378

381379
$scope.colElement = $columnElement;

test/karma.conf.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ module.exports = function(config) {
1414

1515
// list of files / patterns to load in the browser
1616
// note that the karmangular setup from util.createKarmangularConfig seems
17-
// to take precedence over this, but we can't remove this because then
17+
// to take precedence over this, but we can't remove this because then
1818
// the karmangular task doesn't appear to run. So includes the features/**/test, but
1919
// they don't get run if you've used the --fast or --core options
2020
files: [
2121
'bower_components/jquery/jquery.min.js',
2222
'lib/test/jquery.simulate.js',
23+
'lib/test/classList.polyFill.js',
2324
'bower_components/lodash/dist/lodash.min.js',
24-
25+
2526
'src/js/core/bootstrap.js',
2627
'src/js/**/*.js',
2728
'src/features/**/js/**/*.js',
@@ -105,7 +106,7 @@ module.exports = function(config) {
105106
customLaunchers: util.customLaunchers()
106107

107108
});
108-
109+
109110
// TODO(c0bra): remove once SauceLabs supports websockets.
110111
// This speeds up the capturing a bit, as browsers don't even try to use websocket. -- (thanks vojta)
111112
if (process.env.TRAVIS) {
@@ -114,7 +115,7 @@ module.exports = function(config) {
114115
config.reporters = ['dots', 'coverage'];
115116

116117
var buildLabel = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
117-
118+
118119
// config.transports = ['websocket', 'xhr-polling'];
119120

120121
config.sauceLabs.build = buildLabel;
@@ -141,4 +142,4 @@ module.exports = function(config) {
141142
var bs = grunt.option('browsers').split(/,/).map(function(b) { return b.trim(); });
142143
config.browsers = bs;
143144
}
144-
};
145+
};

0 commit comments

Comments
 (0)