Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.5 #358

Merged
merged 19 commits into from
Apr 29, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ There is a task for CI testing with PhantomJS


## Change Log
* __2013-03-29__ - Version 2.0.3 - fixing some more minor bugs.
* __2013-04-23__ - Version 2.0.5 - Moving to $http for external template fetching. Should fix issues with grid rendering before templates are retrieved, as well as fetching the same template multiple times. Also fixed bug that prevented the grid from maintaining row selections post-sort thanks to [sum4me](https://github.com/sum4me).
* __2013-04-08__ - Version 2.0.4 - fixing some more minor bugs.
* __2013-03-29__ - Version 2.0.3 - changed default multiSelect behavior, updating some plugins and making some more minor bugfixes.
* __2013-03-08__ - Version 2.0.2 - minor bugfixes, updating some plugins.
* __2013-03-05__ - Version 2.0.1 - Moved to grunt build system. No more international version; all languages are included by default. Fixed minor grouping display issue. Using $templateCache for templates instead of global namespace.
Expand Down
360 changes: 190 additions & 170 deletions build/ng-grid.debug.js

Large diffs are not rendered by default.

314 changes: 166 additions & 148 deletions build/ng-grid.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/ng-grid.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ng-grid-2.0.4.min.js

This file was deleted.

360 changes: 190 additions & 170 deletions ng-grid-2.0.4.debug.js → ng-grid-2.0.5.debug.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ng-grid-2.0.5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-grid",
"version": "2.0.4",
"version": "2.0.5",
"description": "__Contributors:__",
"main": "ng-grid.min.js",
"directories": {
Expand Down
108 changes: 63 additions & 45 deletions src/classes/grid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="footer.js" />
/// <reference path="../services/SortService.js" />
/// <reference path="../../lib/jquery-1.8.2.min" />
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse) {
var ngGrid = function ($scope, options, sortService, domUtilityService, $filter, $templateCache, $utils, $timeout, $parse, $http, $q) {
var defaults = {
//Define an aggregate template to customize the rows when grouped. See github wiki for more details.
aggregateTemplate: undefined,
Expand Down Expand Up @@ -215,32 +215,46 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
self.data = [];
self.lateBindColumns = false;
self.filteredRows = [];

self.initTemplates = function() {
var templates = ['rowTemplate', 'aggregateTemplate', 'headerRowTemplate', 'checkboxCellTemplate', 'checkboxHeaderTemplate', 'menuTemplate', 'footerTemplate'];

var promises = [];
templates.forEach(function(template) {
promises.push( self.getTemplate(template) );
});

return $q.all(promises);
};

//Templates
// test templates for urls and get the tempaltes via synchronous ajax calls
var getTemplate = function (key) {
self.getTemplate = function (key) {
var t = self.config[key];
var uKey = self.gridId + key + ".html";
var p = $q.defer();
if (t && !TEMPLATE_REGEXP.test(t)) {
$templateCache.put(uKey, $.ajax({
type: "GET",
url: t,
async: false
}).responseText);
$http.get(t, {
cache: $templateCache
})
.success(function(data){
$templateCache.put(uKey, data);
p.resolve();
})
.error(function(err){
p.reject("Could not load template: " + t);
});
} else if (t) {
$templateCache.put(uKey, t);
p.resolve();
} else {
var dKey = key + ".html";
$templateCache.put(uKey, $templateCache.get(dKey));
p.resolve();
}

return p.promise;
};
getTemplate('rowTemplate');
getTemplate('aggregateTemplate');
getTemplate('headerRowTemplate');
getTemplate('checkboxCellTemplate');
getTemplate('checkboxHeaderTemplate');
getTemplate('menuTemplate');
getTemplate('footerTemplate');

if (typeof self.config.data == "object") {
self.data = self.config.data; // we cannot watch for updates if you don't pass the string name
Expand Down Expand Up @@ -442,35 +456,41 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
}
};
self.init = function() {
//factories and services
$scope.selectionProvider = new ngSelectionProvider(self, $scope, $parse);
$scope.domAccessProvider = new ngDomAccessProvider(self);
self.rowFactory = new ngRowFactory(self, $scope, domUtilityService, $templateCache, $utils);
self.searchProvider = new ngSearchProvider($scope, self, $filter);
self.styleProvider = new ngStyleProvider($scope, self);
$scope.$watch('configGroups', function(a) {
var tempArr = [];
angular.forEach(a, function(item) {
tempArr.push(item.field || item);
});
self.config.groups = tempArr;
self.rowFactory.filteredRowsChanged();
$scope.$emit('ngGridEventGroups', a);
}, true);
$scope.$watch('columns', function (a) {
domUtilityService.BuildStyles($scope, self, true);
$scope.$emit('ngGridEventColumns', a);
}, true);
$scope.$watch(function() {
return options.i18n;
}, function(newLang) {
$utils.seti18n($scope, newLang);
return self.initTemplates().then(function(){
//factories and services
$scope.selectionProvider = new ngSelectionProvider(self, $scope, $parse);
$scope.domAccessProvider = new ngDomAccessProvider(self);
self.rowFactory = new ngRowFactory(self, $scope, domUtilityService, $templateCache, $utils);
self.searchProvider = new ngSearchProvider($scope, self, $filter);
self.styleProvider = new ngStyleProvider($scope, self);
$scope.$watch('configGroups', function(a) {
var tempArr = [];
angular.forEach(a, function(item) {
tempArr.push(item.field || item);
});
self.config.groups = tempArr;
self.rowFactory.filteredRowsChanged();
$scope.$emit('ngGridEventGroups', a);
}, true);
$scope.$watch('columns', function (a) {
domUtilityService.BuildStyles($scope, self, true);
$scope.$emit('ngGridEventColumns', a);
}, true);
$scope.$watch(function() {
return options.i18n;
}, function(newLang) {
$utils.seti18n($scope, newLang);
});
self.maxCanvasHt = self.calcMaxCanvasHeight();
if (self.config.sortInfo.fields && self.config.sortInfo.fields.length > 0) {
self.getColsFromFields();
self.sortActual();
}
});
self.maxCanvasHt = self.calcMaxCanvasHeight();
if (self.config.sortInfo.fields && self.config.sortInfo.fields.length > 0) {
self.getColsFromFields();
self.sortActual();
}

// var p = $q.defer();
// p.resolve();
// return p.promise;
};

self.resizeOnData = function(col) {
Expand Down Expand Up @@ -565,7 +585,7 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
angular.forEach(tempData, function(item, i) {
var e = self.rowMap[i];
if (e != undefined) {
var v = self.rowCache[v];
var v = self.rowCache[i];
if(v != undefined) {
item.preSortSelected = v.selected;
item.preSortIndex = i;
Expand Down Expand Up @@ -813,6 +833,4 @@ var ngGrid = function ($scope, options, sortService, domUtilityService, $filter,
}
return newDim;
};
//call init
self.init();
};
Loading