1
1
/*!
2
- * ui-grid - v4.0.1 - 2016-12-15
2
+ * ui-grid - v4.0.2 - 2016-12-30
3
3
* Copyright (c) 2016 ; License: MIT
4
4
*/
5
5
@@ -2120,8 +2120,15 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
2120
2120
templateUrl: 'ui-grid/uiGridMenu',
2121
2121
replace: false,
2122
2122
link: function ($scope, $elm, $attrs, uiGridCtrl) {
2123
-
2124
2123
$scope.dynamicStyles = '';
2124
+ if (uiGridCtrl && uiGridCtrl.grid && uiGridCtrl.grid.options && uiGridCtrl.grid.options.gridMenuTemplate) {
2125
+ var gridMenuTemplate = uiGridCtrl.grid.options.gridMenuTemplate;
2126
+ gridUtil.getTemplate(gridMenuTemplate).then(function (contents) {
2127
+ var template = angular.element(contents);
2128
+ var newElm = $compile(template)($scope);
2129
+ $elm.replaceWith(newElm);
2130
+ });
2131
+ }
2125
2132
2126
2133
var setupHeightStyle = function(gridHeight) {
2127
2134
//menu appears under header row, so substract that height from it's total
@@ -2138,7 +2145,7 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
2138
2145
setupHeightStyle(uiGridCtrl.grid.gridHeight);
2139
2146
uiGridCtrl.grid.api.core.on.gridDimensionChanged($scope, function(oldGridHeight, oldGridWidth, newGridHeight, newGridWidth) {
2140
2147
setupHeightStyle(newGridHeight);
2141
- });
2148
+ });
2142
2149
}
2143
2150
2144
2151
$scope.i18n = {
@@ -2273,13 +2280,11 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
2273
2280
angular.element($window).on('resize', applyHideMenu);
2274
2281
}
2275
2282
2276
- $scope.$on('$destroy', function () {
2277
- angular.element(document).off('click touchstart', applyHideMenu);
2278
- });
2279
-
2280
-
2281
- $scope.$on('$destroy', function() {
2283
+ $scope.$on('$destroy', function unbindEvents() {
2282
2284
angular.element($window).off('resize', applyHideMenu);
2285
+ angular.element(document).off('click touchstart', applyHideMenu);
2286
+ $elm.off('keyup', checkKeyUp);
2287
+ $elm.off('keydown', checkKeyDown);
2283
2288
});
2284
2289
2285
2290
if (uiGridCtrl) {
@@ -3214,7 +3219,9 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
3214
3219
}
3215
3220
}
3216
3221
3217
-
3222
+ $scope.$on('$destroy', function unbindEvents() {
3223
+ $elm.off();
3224
+ });
3218
3225
},
3219
3226
controller: ['$scope', function ($scope) {
3220
3227
this.rowStyle = function (index) {
@@ -4784,7 +4791,7 @@ angular.module('ui.grid')
4784
4791
* @methodOf ui.grid.class:Grid
4785
4792
* @description returns the GridRow that contains the rowEntity
4786
4793
* @param {object} rowEntity the gridOptions.data array element instance
4787
- * @param {array} rows [optional] the rows to look in - if not provided then
4794
+ * @param {array} lookInRows [optional] the rows to look in - if not provided then
4788
4795
* looks in grid.rows
4789
4796
*/
4790
4797
Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
@@ -4849,13 +4856,20 @@ angular.module('ui.grid')
4849
4856
self.rows.length = 0;
4850
4857
4851
4858
newRawData.forEach( function( newEntity, i ) {
4852
- var newRow;
4859
+ var newRow, oldRow;
4860
+
4853
4861
if ( self.options.enableRowHashing ){
4854
4862
// if hashing is enabled, then this row will be in the hash if we already know about it
4855
- newRow = oldRowHash.get( newEntity );
4863
+ oldRow = oldRowHash.get( newEntity );
4856
4864
} else {
4857
4865
// otherwise, manually search the oldRows to see if we can find this row
4858
- newRow = self.getRow(newEntity, oldRows);
4866
+ oldRow = self.getRow(newEntity, oldRows);
4867
+ }
4868
+
4869
+ // update newRow to have an entity
4870
+ if ( oldRow ) {
4871
+ newRow = oldRow;
4872
+ newRow.entity = newEntity;
4859
4873
}
4860
4874
4861
4875
// if we didn't find the row, it must be new, so create it
@@ -8143,6 +8157,15 @@ angular.module('ui.grid')
8143
8157
*/
8144
8158
baseOptions.rowTemplate = baseOptions.rowTemplate || 'ui-grid/ui-grid-row';
8145
8159
8160
+ /**
8161
+ * @ngdoc string
8162
+ * @name gridMenuTemplate
8163
+ * @propertyOf ui.grid.class:GridOptions
8164
+ * @description 'ui-grid/uiGridMenu' by default. When provided, this setting uses a
8165
+ * custom grid menu template.
8166
+ */
8167
+ baseOptions.gridMenuTemplate = baseOptions.gridMenuTemplate || 'ui-grid/uiGridMenu';
8168
+
8146
8169
/**
8147
8170
* @ngdoc object
8148
8171
* @name appScopeProvider
@@ -11786,6 +11809,11 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
11786
11809
for ( var i = mouseWheeltoBind.length; i; ) {
11787
11810
$elm.on(mouseWheeltoBind[--i], cbs[fn]);
11788
11811
}
11812
+ $elm.on('$destroy', function unbindEvents() {
11813
+ for ( var i = mouseWheeltoBind.length; i; ) {
11814
+ $elm.off(mouseWheeltoBind[--i], cbs[fn]);
11815
+ }
11816
+ });
11789
11817
};
11790
11818
s.off.mousewheel = function (elm, fn) {
11791
11819
var $elm = angular.element(elm);
@@ -16436,7 +16464,11 @@ module.filter('px', function() {
16436
16464
});
16437
16465
16438
16466
16439
- $scope.$on( '$destroy', rowWatchDereg );
16467
+ $scope.$on('$destroy', function destroyEvents() {
16468
+ rowWatchDereg();
16469
+ // unbind all jquery events in order to avoid memory leaks
16470
+ $elm.off();
16471
+ });
16440
16472
16441
16473
function registerBeginEditEvents() {
16442
16474
$elm.on('dblclick', beginEdit);
@@ -16971,6 +17003,11 @@ module.filter('px', function() {
16971
17003
16972
17004
return true;
16973
17005
});
17006
+
17007
+ $scope.$on('$destroy', function unbindEvents() {
17008
+ // unbind all jquery events in order to avoid memory leaks
17009
+ $elm.off();
17010
+ });
16974
17011
}
16975
17012
};
16976
17013
}
@@ -17114,6 +17151,11 @@ module.filter('px', function() {
17114
17151
}
17115
17152
return true;
17116
17153
});
17154
+
17155
+ $scope.$on('$destroy', function unbindEvents() {
17156
+ // unbind jquery events to prevent memory leaks
17157
+ $elm.off();
17158
+ });
17117
17159
}
17118
17160
};
17119
17161
}
@@ -17206,7 +17248,7 @@ module.filter('px', function() {
17206
17248
}
17207
17249
};
17208
17250
17209
- $elm[0].addEventListener('change', handleFileSelect, false); // TODO: why the false on the end? Google
17251
+ $elm[0].addEventListener('change', handleFileSelect, false);
17210
17252
17211
17253
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
17212
17254
$elm[0].focus();
@@ -17216,13 +17258,17 @@ module.filter('px', function() {
17216
17258
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
17217
17259
});
17218
17260
});
17261
+
17262
+ $scope.$on('$destroy', function unbindEvents() {
17263
+ // unbind jquery events to prevent memory leaks
17264
+ $elm.off();
17265
+ $elm[0].removeEventListener('change', handleFileSelect, false);
17266
+ });
17219
17267
}
17220
17268
};
17221
17269
}
17222
17270
};
17223
17271
}]);
17224
-
17225
-
17226
17272
})();
17227
17273
17228
17274
(function () {
@@ -22385,6 +22431,8 @@ module.filter('px', function() {
22385
22431
movingElm.css({'width': reducedWidth + 'px'});
22386
22432
}
22387
22433
};
22434
+
22435
+ $scope.$on('$destroy', offAllEvents);
22388
22436
}
22389
22437
}
22390
22438
};
@@ -25966,6 +26014,10 @@ module.filter('px', function() {
25966
26014
window.setTimeout(function () { evt.target.onselectstart = null; }, 0);
25967
26015
}
25968
26016
}
26017
+
26018
+ $scope.$on('$destroy', function unbindEvents() {
26019
+ $elm.off();
26020
+ });
25969
26021
}
25970
26022
};
25971
26023
}]);
0 commit comments