Skip to content

Commit

Permalink
feat(ng-table.js): support the CommonJS module format
Browse files Browse the repository at this point in the history
ng-table.js is now output in UMD format and thus supports the following module formats:
* global script tag
* AMD (eg RequireJS)
* CommonJS

BREAKING CHANGE:

1) The AMD (RequireJS) module returned by ng-table.js is now an object that references
the angular module.

Previously, the module returned *was* the angular module.

Note: this will only affect apps that are using RequireJS to load ng-table.js.

Those apps that are loading ng-table.js as a script tag will be unaffected.

2) Replaced LESS with SASS

This will only affect the minority of apps that are using the ng-table.less file in the
dist folder.

Those apps that are using the ng-table.css will be unaffected.
  • Loading branch information
christianacca committed Jul 31, 2016
1 parent 78be04b commit 7261ff4
Show file tree
Hide file tree
Showing 27 changed files with 356 additions and 74 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ out
typings
npm-debug.log
test/*.js
# redundant webpack build artifacts produced by ExtractTextPlugin
dist/styles.*
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ before_install:
install:
- npm prune && npm install
- npm run setup
- grunt
- npm run build

script:
- npm test
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- npm install -g karma-cli
- npm prune && npm install
- npm run setup
- grunt
- npm run build
cache_directories:
- node_modules
- bower_components
Expand Down
41 changes: 41 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import angular from 'angular';
import { ngTable } from './src/scripts/ngTable.directive';
import { ngTableColumn } from './src/scripts/ngTableColumn';
import { ngTableColumnsBinding } from './src/scripts/ngTableColumnsBinding.directive';
import { ngTableController } from './src/scripts/ngTableController';
import { ngTableDefaultGetDataProvider } from './src/scripts/ngTableDefaultGetData';
import { ngTableDefaults } from './src/scripts/ngTableDefaults';
import { ngTableDynamic } from './src/scripts/ngTableDynamic.directive';
import { ngTableEventsChannel } from './src/scripts/ngTableEventsChannel';
import { ngTableFilterConfigProvider } from './src/scripts/ngTableFilterConfig';
import { ngTableFilterRow } from './src/scripts/ngTableFilterRow.directive';
import { ngTableFilterRowController } from './src/scripts/ngTableFilterRowController';
import { ngTableGroupRow } from './src/scripts/ngTableGroupRow.directive';
import { ngTableGroupRowController } from './src/scripts/ngTableGroupRowController';
import { ngTablePagination } from './src/scripts/ngTablePagination.directive';
import { ngTableParamsFactory } from './src/scripts/ngTableParams';
import { ngTableSelectFilterDs } from './src/scripts/ngTableSelectFilterDs.directive';
import { ngTableSorterRow } from './src/scripts/ngTableSorterRow.directive';
import { ngTableSorterRowController } from './src/scripts/ngTableSorterRowController';

var module = angular.module('ngTable', [])
.directive('ngTable', ngTable)
.factory('ngTableColumn', ngTableColumn)
.directive('ngTableColumnsBinding', ngTableColumnsBinding)
.controller('ngTableController', ngTableController)
.provider('ngTableDefaultGetData', ngTableDefaultGetDataProvider)
.value('ngTableDefaults',ngTableDefaults)
.directive('ngTableDynamic', ngTableDynamic)
.factory('ngTableEventsChannel', ngTableEventsChannel)
.provider('ngTableFilterConfig', ngTableFilterConfigProvider)
.directive('ngTableFilterRow', ngTableFilterRow)
.controller('ngTableFilterRowController', ngTableFilterRowController)
.directive('ngTableGroupRow', ngTableGroupRow)
.controller('ngTableGroupRowController', ngTableGroupRowController)
.directive('ngTablePagination', ngTablePagination)
.factory('NgTableParams', ngTableParamsFactory)
.directive('ngTableSelectFilterDs', ngTableSelectFilterDs)
.directive('ngTableSorterRow', ngTableSorterRow)
.controller('ngTableSorterRowController', ngTableSorterRowController);

export { module as default };
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
},
"main": "dist/ng-table.js",
"devDependencies": {
"angular": "^1.5.8",
"coveralls": "~2.11.0",
"css-loader": "^0.23.1",
"extract-text-webpack-plugin": "^2.0.0-beta.3",
"grunt": "~0.4.2",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.3.0",
Expand All @@ -20,6 +23,7 @@
"grunt-contrib-uglify": "0.8.x",
"grunt-contrib-watch": "~0.6.x",
"grunt-hustler": "0.11.2",
"html-loader": "^0.4.3",
"jasmine-core": "^2.3.4",
"karma": "0.13.22",
"karma-chrome-launcher": "1.0.1",
Expand All @@ -30,16 +34,29 @@
"karma-phantomjs-launcher": "1.0.0",
"load-grunt-tasks": "~0.2.0",
"lodash": "~3.7.0",
"ngtemplate-loader": "github:wearymonkey/ngtemplate-loader#63e3461d8b1298de913e3528766068260915ae1f",
"node-sass": "^3.8.0",
"phantomjs-prebuilt": "2.1.7",
"sass-loader": "^4.0.0",
"style-loader": "^0.13.1",
"typescript": "1.8.10",
"typings": "^1.2.0"
"typings": "^1.2.0",
"webpack": "^2.1.0-beta.20",
"webpack-dev-server": "^2.1.0-beta.0",
"webpack-merge": "^0.14.1"
},
"scripts": {
"build": "webpack --env.debug",
"build:prod": "webpack --env.prod",
"build:full": "webpack --env.prod --env.debug",
"setup": "bower prune && bower install && npm run typings",
"test": "npm run tsc && karma start --single-run --no-auto-watch",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings install"
"typings": "typings install",
"watch:debug": "webpack --watch --env.debug",
"watch": "webpack --watch",
"webpack": "webpack"
},
"dependencies": {},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/ngTable.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @url https://github.com/esvit/ng-table/
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

import angular from 'angular';

/**
* @ngdoc directive
Expand All @@ -16,8 +16,6 @@
* @description
* Directive that instantiates {@link ngTableController ngTableController}.
*/
angular.module('ngTable').directive('ngTable', ngTable);

ngTable.$inject = ['$q', '$parse'];

function ngTable($q, $parse) {
Expand Down Expand Up @@ -129,3 +127,5 @@ function ngTable($q, $parse) {
}
}
}

export { ngTable };
7 changes: 4 additions & 3 deletions src/scripts/ngTableColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

import angular from 'angular';

/**
* @ngdoc service
Expand All @@ -14,8 +15,6 @@
* @description
* Service to construct a $column definition used by {@link ngTable ngTable} directive
*/
angular.module('ngTable').factory('ngTableColumn', ngTableColumn);

ngTableColumn.$inject = [];

function ngTableColumn() {
Expand Down Expand Up @@ -121,4 +120,6 @@ function ngTableColumn() {
function isScopeLike(object){
return object != null && angular.isFunction(object.$new);
}
}
}

export { ngTableColumn };
7 changes: 3 additions & 4 deletions src/scripts/ngTableColumnsBinding.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.directive('ngTableColumnsBinding', ngTableColumnsBinding);

ngTableColumnsBinding.$inject = ["$parse"];

/**
Expand Down Expand Up @@ -36,4 +33,6 @@ function ngTableColumnsBinding($parse){
});
}
}
}
}

export { ngTableColumnsBinding };
8 changes: 5 additions & 3 deletions src/scripts/ngTableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

import angular from 'angular';

/**
* @ngdoc object
* @name ngTableController
*
* @description
* Each {@link ngTable ngTable} directive creates an instance of `ngTableController`
*/
angular.module('ngTable').controller('ngTableController', ngTableController);

ngTableController.$inject = [
'$scope', 'NgTableParams', '$timeout', '$parse', '$compile', '$attrs', '$element', 'ngTableColumn', 'ngTableEventsChannel'
];
Expand Down Expand Up @@ -270,4 +270,6 @@ function ngTableController($scope, NgTableParams, $timeout, $parse, $compile, $a
}

commonInit();
}
}

export { ngTableController };
8 changes: 4 additions & 4 deletions src/scripts/ngTableDefaultGetData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/


angular.module('ngTable')
.provider('ngTableDefaultGetData', ngTableDefaultGetDataProvider);
import angular from 'angular';

ngTableDefaultGetDataProvider.$inject = [];

Expand Down Expand Up @@ -127,4 +125,6 @@ function ngTableDefaultGetDataProvider(){
return ret;
}
}
}
}

export { ngTableDefaultGetDataProvider };
6 changes: 4 additions & 2 deletions src/scripts/ngTableDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
* @module ngTable
* @description Default Parameters for ngTable
*/
angular.module('ngTable').value('ngTableDefaults',{
var ngTableDefaults = {
params: {},
settings: {}
});
};

export { ngTableDefaults };
8 changes: 5 additions & 3 deletions src/scripts/ngTableDynamic.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

import angular from 'angular';

/**
* @ngdoc directive
* @name ngTableDynamic
Expand All @@ -16,8 +18,6 @@
* A dynamic version of the {@link ngTable ngTable} directive that accepts a dynamic list of columns
* definitions to render
*/
angular.module('ngTable').directive('ngTableDynamic', ngTableDynamic);

ngTableDynamic.$inject = [];

function ngTableDynamic(){
Expand Down Expand Up @@ -70,4 +70,6 @@ function ngTableDynamic(){
};
}
};
}
}

export { ngTableDynamic };
7 changes: 4 additions & 3 deletions src/scripts/ngTableEventsChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.factory('ngTableEventsChannel', ngTableEventsChannel);
import angular from 'angular';

ngTableEventsChannel.$inject = ['$rootScope'];

Expand Down Expand Up @@ -90,4 +89,6 @@ function ngTableEventsChannel($rootScope){
function rest(array, n) {
return Array.prototype.slice.call(array, n == null ? 1 : n);
}
}
}

export { ngTableEventsChannel };
7 changes: 4 additions & 3 deletions src/scripts/ngTableFilterConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.provider('ngTableFilterConfig', ngTableFilterConfigProvider);
import angular from 'angular';

ngTableFilterConfigProvider.$inject = [];

Expand Down Expand Up @@ -80,4 +79,6 @@ function ngTableFilterConfigProvider(){
return config.aliasUrls[aliasName] || config.defaultBaseUrl + aliasName + config.defaultExt;
}
}
}
}

export { ngTableFilterConfigProvider };
9 changes: 5 additions & 4 deletions src/scripts/ngTableFilterRow.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.directive('ngTableFilterRow', ngTableFilterRow);
import templateUrl from '../ng-table/filterRow.html';

ngTableFilterRow.$inject = [];

function ngTableFilterRow(){
var directive = {
restrict: 'E',
replace: true,
templateUrl: 'ng-table/filterRow.html',
templateUrl: templateUrl,
scope: true,
controller: 'ngTableFilterRowController'
};
return directive;
}
}

export { ngTableFilterRow };
7 changes: 4 additions & 3 deletions src/scripts/ngTableFilterRowController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.controller('ngTableFilterRowController', ngTableFilterRowController);
import angular from 'angular';

ngTableFilterRowController.$inject = ['$scope', 'ngTableFilterConfig'];

Expand All @@ -32,4 +31,6 @@ function ngTableFilterRowController($scope, ngTableFilterConfig){
return '';
}
};
}
}

export { ngTableFilterRowController };
9 changes: 5 additions & 4 deletions src/scripts/ngTableGroupRow.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/

angular.module('ngTable')
.directive('ngTableGroupRow', ngTableGroupRow);
import templateUrl from '../ng-table/groupRow.html';

ngTableGroupRow.$inject = [];

function ngTableGroupRow(){
var directive = {
restrict: 'E',
replace: true,
templateUrl: 'ng-table/groupRow.html',
templateUrl: templateUrl,
scope: true,
controller: 'ngTableGroupRowController',
controllerAs: 'dctrl'
};
return directive;
}
}

export { ngTableGroupRow };
Loading

0 comments on commit 7261ff4

Please sign in to comment.