Skip to content

Commit

Permalink
Fix angular-datatables for angular 1.6.1 #921
Browse files Browse the repository at this point in the history
  • Loading branch information
l-lin committed Dec 27, 2016
1 parent ecde916 commit eb70a13
Show file tree
Hide file tree
Showing 30 changed files with 93 additions and 87 deletions.
49 changes: 26 additions & 23 deletions dist/angular-datatables.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand All @@ -14,7 +14,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
.directive('datatable', dataTable);

/* @ngInject */
function dataTable($q, $http, DTRendererFactory, DTRendererService, DTPropertyUtil) {
function dataTable($q, $http, $log, DTRendererFactory, DTRendererService, DTPropertyUtil) {
compileDirective.$inject = ['tElm'];
ControllerDirective.$inject = ['$scope'];
return {
Expand Down Expand Up @@ -93,8 +93,11 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
// See https://github.com/l-lin/angular-datatables/issues/181
if (options.language && options.language.url) {
var languageDefer = $q.defer();
$http.get(options.language.url).success(function(language) {
var languageUrl = options.language.url;
$http.get(options.language.url).then(function(language) {
languageDefer.resolve(language);
}, function() {
$log.error('Could not fetch the content of the language from ' + languageUrl);
});
options.language = languageDefer.promise;
}
Expand Down Expand Up @@ -138,7 +141,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
}
}
}
dataTable.$inject = ['$q', '$http', 'DTRendererFactory', 'DTRendererService', 'DTPropertyUtil'];
dataTable.$inject = ['$q', '$http', '$log', 'DTRendererFactory', 'DTRendererService', 'DTPropertyUtil'];

'use strict';
angular.module('datatables.factory', [])
Expand Down Expand Up @@ -1161,27 +1164,27 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
}

function _doRender(options, $elem) {
var defer = $q.defer();
// Destroy the table if it exists in order to be able to redraw the dataTable
options.bDestroy = true;
if (_oTable) {
_oTable.destroy();
DTRendererService.showLoading(_$elem, _$scope);
// Empty in case of columns change
$elem.empty();
}
DTRendererService.hideLoading($elem);
// Condition to refresh the dataTable
if (_shouldDeferRender(options)) {
$timeout(function() {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}, 0, false);
} else {
var defer = $q.defer();
// Destroy the table if it exists in order to be able to redraw the dataTable
options.bDestroy = true;
if (_oTable) {
_oTable.destroy();
DTRendererService.showLoading(_$elem, _$scope);
// Empty in case of columns change
$elem.empty();
}
DTRendererService.hideLoading($elem);
// Condition to refresh the dataTable
if (_shouldDeferRender(options)) {
$timeout(function() {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}
return defer.promise;
}, 0, false);
} else {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}
// See https://github.com/l-lin/angular-datatables/issues/147
return defer.promise;
}
// See https://github.com/l-lin/angular-datatables/issues/147
function _shouldDeferRender(options) {
if (angular.isDefined(options) && angular.isDefined(options.dom)) {
// S for scroller plugin
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-datatables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/css/angular-datatables.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/css/angular-datatables.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions dist/plugins/bootstrap/angular-datatables.bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down Expand Up @@ -357,15 +357,15 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
}

function _setDom(options) {
if (!options.dom || options.dom === $.fn.dataTable.defaults.sDom) {
return DTBootstrapDefaultOptions.getOptions().dom;
}
return options.dom;
if (!options.dom || options.dom === $.fn.dataTable.defaults.sDom) {
return DTBootstrapDefaultOptions.getOptions().dom;
}
/**
* Integrate Bootstrap
* @param options the datatables options
*/
return options.dom;
}
/**
* Integrate Bootstrap
* @param options the datatables options
*/
function integrate(options) {
_init(options.bootstrap);
DTBootstrapTableTools.integrate(options.bootstrap);
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/bootstrap/angular-datatables.bootstrap.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/bootstrap/datatables.bootstrap.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/buttons/angular-datatables.buttons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/buttons/angular-datatables.buttons.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/colreorder/angular-datatables.colreorder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/colvis/angular-datatables.colvis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/colvis/angular-datatables.colvis.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/fixedheader/angular-datatables.fixedheader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/scroller/angular-datatables.scroller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/scroller/angular-datatables.scroller.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/select/angular-datatables.select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/plugins/select/angular-datatables.select.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/plugins/tabletools/angular-datatables.tabletools.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-datatables - v0.5.6
* angular-datatables - v0.6.0
* https://github.com/l-lin/angular-datatables
* License: MIT
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/angular-datatables.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('datatables.directive', ['datatables.instances', 'datatables.rend
.directive('datatable', dataTable);

/* @ngInject */
function dataTable($q, $http, DTRendererFactory, DTRendererService, DTPropertyUtil) {
function dataTable($q, $http, $log, DTRendererFactory, DTRendererService, DTPropertyUtil) {
return {
restrict: 'A',
scope: {
Expand Down Expand Up @@ -81,8 +81,11 @@ function dataTable($q, $http, DTRendererFactory, DTRendererService, DTPropertyUt
// See https://github.com/l-lin/angular-datatables/issues/181
if (options.language && options.language.url) {
var languageDefer = $q.defer();
$http.get(options.language.url).success(function(language) {
var languageUrl = options.language.url;
$http.get(options.language.url).then(function(language) {
languageDefer.resolve(language);
}, function() {
$log.error('Could not fetch the content of the language from ' + languageUrl);
});
options.language = languageDefer.promise;
}
Expand Down
38 changes: 19 additions & 19 deletions src/angular-datatables.renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,27 +446,27 @@ function dtAjaxRenderer($q, $timeout, DTRenderer, DTRendererService, DT_DEFAULT_
}

function _doRender(options, $elem) {
var defer = $q.defer();
// Destroy the table if it exists in order to be able to redraw the dataTable
options.bDestroy = true;
if (_oTable) {
_oTable.destroy();
DTRendererService.showLoading(_$elem, _$scope);
// Empty in case of columns change
$elem.empty();
}
DTRendererService.hideLoading($elem);
// Condition to refresh the dataTable
if (_shouldDeferRender(options)) {
$timeout(function() {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}, 0, false);
} else {
var defer = $q.defer();
// Destroy the table if it exists in order to be able to redraw the dataTable
options.bDestroy = true;
if (_oTable) {
_oTable.destroy();
DTRendererService.showLoading(_$elem, _$scope);
// Empty in case of columns change
$elem.empty();
}
DTRendererService.hideLoading($elem);
// Condition to refresh the dataTable
if (_shouldDeferRender(options)) {
$timeout(function() {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}
return defer.promise;
}, 0, false);
} else {
defer.resolve(DTRendererService.renderDataTable($elem, options));
}
// See https://github.com/l-lin/angular-datatables/issues/147
return defer.promise;
}
// See https://github.com/l-lin/angular-datatables/issues/147
function _shouldDeferRender(options) {
if (angular.isDefined(options) && angular.isDefined(options.dom)) {
// S for scroller plugin
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/bootstrap/angular-datatables.bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,15 @@ function dtBootstrap(DTBootstrapTableTools, DTBootstrapColVis, DTBootstrapDefaul
}

function _setDom(options) {
if (!options.dom || options.dom === $.fn.dataTable.defaults.sDom) {
return DTBootstrapDefaultOptions.getOptions().dom;
}
return options.dom;
if (!options.dom || options.dom === $.fn.dataTable.defaults.sDom) {
return DTBootstrapDefaultOptions.getOptions().dom;
}
/**
* Integrate Bootstrap
* @param options the datatables options
*/
return options.dom;
}
/**
* Integrate Bootstrap
* @param options the datatables options
*/
function integrate(options) {
_init(options.bootstrap);
DTBootstrapTableTools.integrate(options.bootstrap);
Expand Down

0 comments on commit eb70a13

Please sign in to comment.