Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit d5470d4

Browse files
rschmuklerrobertmesserle
authored andcommitted
refactor(): use strict, consolidate material.core, interimElement chaining
Closes #643. Closes #650. Closes #597. Closes #596. Closes #525.
1 parent b549713 commit d5470d4

File tree

13 files changed

+172
-357
lines changed

13 files changed

+172
-357
lines changed

config/karma.conf.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,24 @@
11

22
module.exports = function(config) {
3-
4-
var UNCOMPILED_SRC = [
5-
'config/test-utils.js',
6-
'src/core/**/*.js',
7-
8-
// Test utilities, source, and specifications.
9-
// We are explicit like this because we don't want to put
10-
// demos in the tests, and Karma doesn't support advanced
11-
// globbing.
12-
'src/components/*/*.js',
13-
'src/components/tabs/js/*.js'
14-
];
15-
16-
var COMPILED_SRC = [
17-
// Minified source
18-
'dist/angular-material.min.js',
19-
20-
// Test utilties and specifications
21-
'config/test-utils.js',
22-
'src/**/*.spec.js'
23-
];
24-
25-
// releaseMode is a custom configuration option.
26-
var testSrc = config.releaseMode ? COMPILED_SRC : UNCOMPILED_SRC;
27-
283
config.set({
294

305
basePath: __dirname + '/..',
316
frameworks: ['jasmine'],
327
files: [
33-
// Dependencies
348
'bower_components/angular/angular.js',
359
'bower_components/angular-animate/angular-animate.js',
3610
'bower_components/angular-aria/angular-aria.js',
3711
'bower_components/angular-mocks/angular-mocks.js',
38-
'bower_components/hammerjs/hammer.js'
39-
].concat(testSrc),
12+
'bower_components/hammerjs/hammer.js',
13+
'config/test-utils.js',
14+
'src/core/**/*.js',
15+
16+
// We are explicit like this because we don't want to put
17+
// demos in the tests, and Karma doesn't support advanced
18+
// globbing.
19+
'src/components/*/*.js',
20+
'src/components/tabs/js/*.js',
21+
],
4022

4123
port: 9876,
4224
reporters: ['progress'],

gulpfile.js

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var glob = require('glob').sync;
77
var gulp = require('gulp');
88
var karma = require('karma').server;
99
var pkg = require('./package.json');
10+
var exec = require('child_process').exec;
1011
var mergeStream = require('merge-stream');
1112

1213
var argv = require('minimist')(process.argv.slice(2));
@@ -24,7 +25,7 @@ var ngAnnotate = require('gulp-ng-annotate');
2425
var rename = require('gulp-rename');
2526
var sass = require('gulp-sass');
2627
var through2 = require('through2');
27-
var closureCompiler = require('gulp-closure-compiler');
28+
var uglify = require('gulp-uglify');
2829
var webserver = require('gulp-webserver');
2930

3031
var karma = require('karma').server;
@@ -44,24 +45,11 @@ var config = {
4445
' * Angular Material Design\n' +
4546
' * https://github.com/angular/material\n' +
4647
' * @license MIT\n' +
47-
' * v' + VERSION + '\n' +
48+
' * v' + pkg.version + '\n' +
4849
' */\n',
49-
jsBaseFiles: [
50-
'src/core/**/*.js',
51-
'!src/core/**/*.spec.js'
52-
],
53-
themeBaseFiles: [
54-
'src/core/style/color-palette.scss',
55-
'src/core/style/variables.scss',
56-
'src/core/style/mixins.scss'
57-
],
58-
scssBaseFiles: [
59-
'src/core/style/color-palette.scss',
60-
'src/core/style/variables.scss',
61-
'src/core/style/mixins.scss',
62-
'src/core/style/structure.scss',
63-
'src/core/style/layout.scss'
64-
],
50+
jsBaseFiles: ['src/core/**/*.js', '!src/core/**/*.spec.js'],
51+
themeBaseFiles: ['src/core/style/color-palette.scss', 'src/core/style/variables.scss', 'src/core/style/mixins.scss'],
52+
scssBaseFiles: ['src/core/style/color-palette.scss', 'src/core/style/variables.scss', 'src/core/style/mixins.scss', 'src/core/style/{structure,layout}.scss'],
6553
paths: 'src/{components,services}/**',
6654
outputDir: 'dist/'
6755
};
@@ -89,33 +77,31 @@ var buildModes = {
8977
IS_DEMO_BUILD && (BUILD_MODE="demos");
9078
BUILD_MODE = buildModes[BUILD_MODE] || buildModes['default'];
9179

92-
9380
if (IS_RELEASE_BUILD) {
9481
console.log(
9582
gutil.colors.red('--release:'),
96-
'Building release version (minified)...'
83+
'Building release version (minified, debugs stripped)...'
9784
);
9885
}
9986

10087
require('./docs/gulpfile')(gulp, IS_RELEASE_BUILD);
10188

102-
103-
10489
gulp.task('default', ['build']);
90+
//gulp.task('build', ['scripts', 'sass', 'sass-src']);
10591
gulp.task('validate', ['jshint', 'karma']);
10692
gulp.task('changelog', function(done) {
10793
changelog({
10894
repository: 'https://github.com/angular/material',
109-
version: VERSION,
95+
version: pkg.version,
11096
file: 'CHANGELOG.md'
11197
}, function(err, log) {
11298
fs.writeFileSync(__dirname + '/CHANGELOG.md', log);
11399
});
114100
});
115101
gulp.task('jshint', function() {
116102
return gulp.src(
117-
buildConfig.paths.js.concat(buildConfig.paths.test)
118-
)
103+
buildConfig.paths.js.concat(buildConfig.paths.test)
104+
)
119105
.pipe(jshint('.jshintrc'))
120106
.pipe(jshint.reporter(require('jshint-summary')({
121107
fileColCol: ',bold',
@@ -126,30 +112,19 @@ gulp.task('jshint', function() {
126112
.pipe(jshint.reporter('fail'));
127113
});
128114

129-
130115
/** *****************************************
131116
*
132117
* Tasks for Karma Test
133118
*
134119
** ***************************************** */
135120

136121
gulp.task('karma', function(done) {
137-
var karmaConfig = {
138-
singleRun: true,
139-
autoWatch: false,
122+
karma.start({
123+
singleRun:true,
124+
autoWatch:false,
140125
browsers : argv.browsers ? argv.browsers.trim().split(',') : ['Chrome'],
141126
configFile: __dirname + '/config/karma.conf.js'
142-
};
143-
144-
gutil.log('Running unit tests on unminified source.');
145-
karma.start(karmaConfig, testMinified);
146-
147-
function testMinified() {
148-
gutil.log('Running unit tests on minified source.');
149-
buildJs(true);
150-
karmaConfig.releaseMode = true;
151-
karma.start(karmaConfig, done);
152-
}
127+
},done);
153128
});
154129

155130
gulp.task('karma-watch', function(done) {
@@ -189,10 +164,7 @@ gulp.task('build-all-modules', function() {
189164
stream = buildModule(moduleId, false);
190165
}
191166

192-
stream.on('end', function() {
193-
next();
194-
});
195-
}));
167+
gulp.task('build', ['build-themes', 'build-scss', 'build-js'], function() {
196168
});
197169

198170
function buildModule(module, isRelease) {
@@ -289,7 +261,6 @@ gulp.task('server', function() {
289261
}));
290262
});
291263

292-
293264
/** *****************************************
294265
*
295266
* Tasks and functions for module Javascript
@@ -343,12 +314,14 @@ function buildJs(isRelease) {
343314
return gulp.src(config.jsBaseFiles.concat([jsGlob]))
344315
.pipe(filterNonCodeFiles())
345316
.pipe(utils.buildNgMaterialDefinition())
317+
.pipe(insert.wrap('(function() {\n', '})();\n'))
346318
.pipe(concat('angular-material.js'))
347319
.pipe(insert.prepend(config.banner))
348320
.pipe(ngAnnotate())
349321
.pipe(gulp.dest(config.outputDir))
350-
.pipe(gulpif(isRelease, lazypipe()
351-
.pipe(minifyJs, 'angular-material.min.js')
322+
.pipe(gulpif(IS_RELEASE_BUILD, lazypipe()
323+
.pipe(uglify)
324+
.pipe(rename, {extname: '.min.js'})
352325
.pipe(gulp.dest, config.outputDir)
353326
()
354327
));
@@ -388,7 +361,7 @@ gulp.task('build-module-demo', function() {
388361
var demoIndexTemplate = fs.readFileSync(
389362
__dirname + '/docs/demos/demo-index.template.html', 'utf8'
390363
).toString();
391-
364+
392365
gutil.log('Building demos for', mod, '...');
393366

394367
return utils.readModuleDemos(mod, function() {

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
"dgeni": "^0.4.1",
1111
"dgeni-packages": "^0.10.3",
1212
"esprima": "^1.2.2",
13-
"event-stream": "^3.1.5",
1413
"glob": "~4.0.2",
1514
"gulp": "^3.6.2",
1615
"gulp-autoprefixer": "^1.0.1",
17-
"gulp-closure-compiler": "^0.2.7",
1816
"gulp-concat": "^2.2.0",
1917
"gulp-filter": "^1.0.2",
2018
"gulp-if": "^1.2.0",
2119
"gulp-insert": "^0.4.0",
2220
"gulp-jshint": "^1.5.5",
2321
"gulp-minify-css": "^0.3.4",
24-
"gulp-ng-annotate": "^0.3.5",
22+
"gulp-ng-annotate": "^0.3.4",
2523
"gulp-ng-html2js": "^0.1.8",
2624
"gulp-rename": "^1.2.0",
25+
"gulp-replace": "^0.3.0",
2726
"gulp-sass": "ajoslin/gulp-sass#master",
2827
"gulp-uglify": "^0.3.0",
2928
"gulp-util": "^3.0.1",

src/components/dialog/dialog.js

Lines changed: 11 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -43,114 +43,24 @@ function MdDialogDirective($$rAF, $mdTheming) {
4343
* an element with class `md-actions` for the dialog's actions.
4444
*
4545
* @usage
46-
* ##### HTML
47-
*
4846
* <hljs lang="html">
49-
* <div ng-app="demoApp" ng-controller="EmployeeController">
50-
* <md-button ng-click="showAlert()" class="md-raised md-warn">
51-
* Employee Alert!
52-
* </md-button>
53-
* <md-button ng-click="closeAlert()" ng-disabled="!hasAlert()" class="md-raised">
54-
* Close Alert
55-
* </md-button>
56-
* <md-button ng-click="showGreeting($event)" class="md-raised md-primary" >
57-
* Greet Employee
47+
* <div ng-controller="MyController">
48+
* <md-button ng-click="openDialog($event)">
49+
* Open a Dialog from this button!
5850
* </md-button>
5951
* </div>
6052
* </hljs>
6153
*
62-
* ##### JavaScript
63-
*
6454
* <hljs lang="js">
65-
* (function(angular, undefined){
66-
* "use strict";
67-
*
68-
* angular
69-
* .module('demoApp', ['ngMaterial'])
70-
* .controller('EmployeeController', EmployeeEditor)
71-
* .controller('GreetingController', GreetingController);
72-
*
73-
* // Fictitious Employee Editor to show how to use simple and complex dialogs.
74-
*
75-
* function EmployeeEditor($scope, $mdDialog) {
76-
* var alert;
77-
*
78-
* $scope.showAlert = showAlert;
79-
* $scope.closeAlert = closeAlert;
80-
* $scope.showGreeting = showCustomGreeting;
81-
*
82-
* $scope.hasAlert = function() { return !!alert };
83-
* $scope.userName = $scope.userName || 'Bobby';
84-
*
85-
* // Dialog #1 - Show simple alert dialog and cache
86-
* // reference to dialog instance
87-
*
88-
* function showAlert() {
89-
* alert = $mdDialog.alert()
90-
* .title('Attention, ' + $scope.userName)
55+
* var app = angular.module('app', ['ngMaterial']);
56+
* app.controller('MyController', function($scope, $mdDialog) {
57+
* $scope.openDialog = function($event) {
58+
* $mdDialog.show(
59+
* $mdDialog.alert()
60+
* .title('Hello, ' + $scope.userName)
9161
* .content('This is an example of how easy dialogs can be!')
92-
* .ok('Close');
93-
*
94-
* $mdDialog
95-
* .show( alert )
96-
* .finally(function() {
97-
* alert = undefined;
98-
* });
99-
* }
100-
*
101-
* // Close the specified dialog instance and resolve with 'finished' flag
102-
* // Normally this is not needed, just use '$mdDialog.hide()' to close
103-
* // the most recent dialog popup.
104-
*
105-
* function closeAlert() {
106-
* $mdDialog.hide( alert, "finished" );
107-
* alert = undefined;
108-
* }
109-
*
110-
* // Dialog #2 - Demonstrate more complex dialogs construction and popup.
111-
*
112-
* function showCustomGreeting($event) {
113-
* $mdDialog.show({
114-
* targetEvent: $event,
115-
* template:
116-
* '<md-dialog>' +
117-
*
118-
* ' <md-content>Hello {{ employee }}!</md-content>' +
119-
*
120-
* ' <div class="md-actions">' +
121-
* ' <md-button ng-click="closeDialog()">' +
122-
* ' Close Greeting' +
123-
*
124-
* ' </md-button>' +
125-
* ' </div>' +
126-
* '</md-dialog>',
127-
* controller: 'GreetingController',
128-
* onComplete: afterShowAnimation,
129-
* locals: { employee: $scope.userName }
130-
* });
131-
*
132-
* // When the 'enter' animation finishes...
133-
*
134-
* function afterShowAnimation(scope, element, options) {
135-
* // post-show code here: DOM element focus, etc.
136-
* }
137-
* }
138-
* }
139-
*
140-
* // Greeting controller used with the more complex 'showCustomGreeting()' custom dialog
141-
*
142-
* function GreetingController($scope, $mdDialog, employee) {
143-
* // Assigned from construction <code>locals</code> options...
144-
* $scope.employee = employee;
145-
*
146-
* $scope.closeDialog = function() {
147-
* // Easily hides most recent dialog shown...
148-
* // no specific instance reference is needed.
149-
* $mdDialog.hide();
150-
* };
151-
* }
152-
*
153-
* })(angular);
62+
* );
63+
* });
15464
* </hljs>
15565
*/
15666

0 commit comments

Comments
 (0)