chore(*): switch from JSHint/JSCS to ESLint
Partially cherry-picked from c3220325a0
Ref #14952
Closes #14993
This commit is contained in:
committed by
Georgios Kalpakas
parent
9f10428651
commit
b1bc25169e
@@ -0,0 +1,11 @@
|
||||
bower_components/**
|
||||
build/**
|
||||
docs/bower_components/**
|
||||
docs/app/assets/js/angular-bootstrap/**
|
||||
docs/config/templates/**
|
||||
node_modules/**
|
||||
lib/htmlparser/**
|
||||
src/angular.bind.js
|
||||
src/ngParseExt/ucd.js
|
||||
i18n/closure/**
|
||||
tmp/**
|
||||
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"rules": {
|
||||
// Rules are divided into sections from http://eslint.org/docs/rules/
|
||||
|
||||
// Possible errors
|
||||
"comma-dangle": ["error", "never"],
|
||||
"no-cond-assign": ["error", "except-parens"],
|
||||
"no-constant-condition": ["error", {"checkLoops": false}],
|
||||
"no-control-regex": "error",
|
||||
"no-debugger": "error",
|
||||
"no-dupe-args": "error",
|
||||
"no-dupe-keys": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-empty-character-class": "error",
|
||||
"no-empty": "error",
|
||||
"no-ex-assign": "error",
|
||||
"no-extra-boolean-cast": "error",
|
||||
"no-extra-semi": "error",
|
||||
"no-func-assign": "error",
|
||||
"no-inner-declarations": "error",
|
||||
"no-invalid-regexp": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-negated-in-lhs": "error",
|
||||
"no-obj-calls": "error",
|
||||
"no-regex-spaces": "error",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-unreachable": "error",
|
||||
"use-isnan": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"valid-typeof": "error",
|
||||
"no-unexpected-multiline": "error",
|
||||
|
||||
// Best practices
|
||||
"accessor-pairs": "error",
|
||||
"array-callback-return": "error",
|
||||
"eqeqeq": ["error", "allow-null"],
|
||||
"no-alert": "error",
|
||||
"no-caller": "error",
|
||||
"no-case-declarations": "error",
|
||||
"no-eval": "error",
|
||||
"no-extend-native": "error",
|
||||
"no-extra-bind": "error",
|
||||
"no-extra-label": "error",
|
||||
"no-fallthrough": "error",
|
||||
"no-floating-decimal": "error",
|
||||
"no-implied-eval": "error",
|
||||
"no-invalid-this": "error",
|
||||
"no-iterator": "error",
|
||||
"no-multi-str": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-new": "error",
|
||||
"no-octal-escape": "error",
|
||||
"no-octal": "error",
|
||||
"no-proto": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-return-assign": "error",
|
||||
"no-script-url": "error",
|
||||
"no-self-assign": "error",
|
||||
"no-self-compare": "error",
|
||||
"no-sequences": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-unmodified-loop-condition": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-concat": "error",
|
||||
"no-useless-escape": "error",
|
||||
"no-void": "error",
|
||||
"no-with": "error",
|
||||
"radix": "error",
|
||||
"wrap-iife": ["error", "inside"],
|
||||
|
||||
// Strict mode
|
||||
"strict": ["error", "global"],
|
||||
|
||||
// Variables
|
||||
"no-delete-var": "error",
|
||||
"no-label-var": "error",
|
||||
"no-restricted-globals": ["error", "event"],
|
||||
"no-shadow-restricted-names": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-undef": "error",
|
||||
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
|
||||
|
||||
// Node.js
|
||||
"handle-callback-err": "error",
|
||||
|
||||
// Stylistic issues
|
||||
"array-bracket-spacing": ["error", "never"],
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||
"comma-style": ["error", "last"],
|
||||
"eol-last": "error",
|
||||
"keyword-spacing": "error",
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"max-len": ["error", { "code": 200, "ignoreComments": true, "ignoreUrls": true }],
|
||||
"new-cap": "error",
|
||||
"new-parens": "error",
|
||||
"no-array-constructor": "error",
|
||||
"no-bitwise": "error",
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
"no-multiple-empty-lines": ["error", { "max": 3, "maxEOF": 1 }],
|
||||
"no-whitespace-before-property": "error",
|
||||
"no-spaced-func": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"no-unneeded-ternary": "error",
|
||||
"semi-spacing": "error",
|
||||
"semi": "error",
|
||||
"space-before-blocks": ["error", "always"],
|
||||
"space-before-function-paren": ["error", "never"],
|
||||
"space-in-parens": ["error", "never"],
|
||||
"space-infix-ops": "error",
|
||||
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
|
||||
"unicode-bom": ["error", "never"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./.eslintrc-base.json",
|
||||
|
||||
"env": {
|
||||
// Note: don't set `"browser": true`; code in "src/" should be compatible with
|
||||
// non-browser environments like Node.js with a custom window implementation
|
||||
// like jsdom. All browser globals should be taken from window.
|
||||
"browser": false,
|
||||
"node": false
|
||||
},
|
||||
|
||||
"globals": {
|
||||
"window": false,
|
||||
|
||||
"angular": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./.eslintrc-base.json",
|
||||
|
||||
"env": {
|
||||
"browser": false,
|
||||
"node": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
// This config contains proposed rules that we'd like to have enabled but haven't
|
||||
// converted the code to adhere yet. If a decision comes to not enable one of these
|
||||
// rules, it should be removed from the file. Every rule that got enabled in the
|
||||
// end should be moved from here to a respective section in .eslintrc.json
|
||||
|
||||
"rules": {
|
||||
// Rules are divided into sections from http://eslint.org/docs/rules/
|
||||
|
||||
// Best practices
|
||||
"complexity": ["error", 10],
|
||||
"dot-notation": "error",
|
||||
"dot-location": ["error", "property"],
|
||||
|
||||
// Stylistic issues
|
||||
"block-spacing": ["error", "always"],
|
||||
"comma-spacing": "error",
|
||||
"id-blacklist": ["error", "event"],
|
||||
"indent": ["error", 2],
|
||||
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
|
||||
"object-curly-spacing": ["error", "never"],
|
||||
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
|
||||
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" }}],
|
||||
"quotes": ["error", "single"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "./.eslintrc-node.json"
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"excludeFiles": ["src/ngLocale/**"],
|
||||
"disallowKeywords": ["with"],
|
||||
"disallowKeywordsOnNewLine": ["else"],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
|
||||
"disallowSpaceBeforeBinaryOperators": [","],
|
||||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
|
||||
"disallowSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInCallExpression": true,
|
||||
"disallowSpacesInFunctionDeclaration": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInNamedFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true
|
||||
},
|
||||
"disallowSpacesInsideArrayBrackets": true,
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"else",
|
||||
"while",
|
||||
"catch"
|
||||
],
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireSpaceAfterBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
|
||||
"requireSpaceBeforeBinaryOperators": ["?", ":", "+", "-", "/", "*", "%", "==", "===", "!=", "!==", ">", ">=", "<", "<=", "&&", "||"],
|
||||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpacesInConditionalExpression": {
|
||||
"afterTest": true,
|
||||
"beforeConsequent": true,
|
||||
"afterConsequent": true,
|
||||
"beforeAlternate": true
|
||||
},
|
||||
"requireSpacesInForStatement": true,
|
||||
"requireSpacesInFunction": {
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"validateLineBreaks": "LF"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
node_modules/**
|
||||
lib/htmlparser/**
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"bitwise": true,
|
||||
"esversion": 6,
|
||||
"immed": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"maxlen": 200,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"expr": true,
|
||||
"laxbreak": true,
|
||||
"loopfunc": true,
|
||||
"strict": "global",
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"indent": 2,
|
||||
|
||||
"globals": {
|
||||
"ArrayBuffer": false,
|
||||
"Uint8Array": false
|
||||
}
|
||||
}
|
||||
+24
-68
@@ -18,7 +18,7 @@ module.exports = function(grunt) {
|
||||
|
||||
var NG_VERSION = versionInfo.currentVersion;
|
||||
NG_VERSION.cdn = versionInfo.cdnVersion;
|
||||
var dist = 'angular-'+ NG_VERSION.full;
|
||||
var dist = 'angular-' + NG_VERSION.full;
|
||||
|
||||
if (versionInfo.cdnVersion == null) {
|
||||
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?');
|
||||
@@ -41,7 +41,7 @@ module.exports = function(grunt) {
|
||||
hostname: '0.0.0.0',
|
||||
base: '.',
|
||||
keepalive: true,
|
||||
middleware: function(connect, options){
|
||||
middleware: function(connect, options) {
|
||||
var base = Array.isArray(options.base) ? options.base[options.base.length - 1] : options.base;
|
||||
return [
|
||||
util.conditionalCsp(),
|
||||
@@ -61,7 +61,7 @@ module.exports = function(grunt) {
|
||||
// to avoid https://github.com/joyent/libuv/issues/826
|
||||
port: 8000,
|
||||
hostname: '0.0.0.0',
|
||||
middleware: function(connect, options){
|
||||
middleware: function(connect, options) {
|
||||
var base = Array.isArray(options.base) ? options.base[options.base.length - 1] : options.base;
|
||||
return [
|
||||
function(req, resp, next) {
|
||||
@@ -115,68 +115,24 @@ module.exports = function(grunt) {
|
||||
tmp: ['tmp']
|
||||
},
|
||||
|
||||
jshint: {
|
||||
options: {
|
||||
jshintrc: true,
|
||||
},
|
||||
node: {
|
||||
files: { src: ['*.js', 'lib/**/*.js'] },
|
||||
},
|
||||
tests: {
|
||||
files: { src: 'test/**/*.js' },
|
||||
},
|
||||
ng: {
|
||||
files: { src: files['angularSrc'].concat('!src/angular.bind.js') },
|
||||
},
|
||||
ngAnimate: {
|
||||
files: { src: 'src/ngAnimate/**/*.js' },
|
||||
},
|
||||
ngCookies: {
|
||||
files: { src: 'src/ngCookies/**/*.js' },
|
||||
},
|
||||
ngLocale: {
|
||||
files: { src: 'src/ngLocale/**/*.js' },
|
||||
},
|
||||
ngMessageFormat: {
|
||||
files: { src: 'src/ngMessageFormat/**/*.js' },
|
||||
},
|
||||
ngMessages: {
|
||||
files: { src: 'src/ngMessages/**/*.js' },
|
||||
},
|
||||
ngMock: {
|
||||
files: { src: 'src/ngMock/**/*.js' },
|
||||
},
|
||||
ngParseExt: {
|
||||
files: { src: 'src/ngParseExt/**/*.js' },
|
||||
},
|
||||
ngResource: {
|
||||
files: { src: 'src/ngResource/**/*.js' },
|
||||
},
|
||||
ngRoute: {
|
||||
files: { src: 'src/ngRoute/**/*.js' },
|
||||
},
|
||||
ngSanitize: {
|
||||
files: { src: 'src/ngSanitize/**/*.js' },
|
||||
},
|
||||
ngScenario: {
|
||||
files: { src: 'src/ngScenario/**/*.js' },
|
||||
},
|
||||
ngTouch: {
|
||||
files: { src: 'src/ngTouch/**/*.js' },
|
||||
},
|
||||
ngAria: {
|
||||
files: {src: 'src/ngAria/**/*.js'},
|
||||
}
|
||||
},
|
||||
|
||||
jscs: {
|
||||
src: [
|
||||
'src/**/*.js',
|
||||
'test/**/*.js',
|
||||
'!src/angular.bind.js' // we ignore this file since contains an early return statement
|
||||
],
|
||||
options: {
|
||||
config: '.jscsrc'
|
||||
eslint: {
|
||||
all: {
|
||||
src: [
|
||||
'*.js',
|
||||
'benchmarks/**/*.js',
|
||||
'docs/**/*.js',
|
||||
'lib/**/*.js',
|
||||
'scripts/**/*.js',
|
||||
'src/**/*.js',
|
||||
'test/**/*.js',
|
||||
'i18n/**/*.js',
|
||||
'!docs/app/assets/js/angular-bootstrap/**',
|
||||
'!docs/bower_components/**',
|
||||
'!docs/config/templates/**',
|
||||
'!src/angular.bind.js',
|
||||
'!i18n/closure/**',
|
||||
'!src/ngParseExt/ucd.js'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -318,7 +274,7 @@ module.exports = function(grunt) {
|
||||
|
||||
compress: {
|
||||
build: {
|
||||
options: {archive: 'build/' + dist +'.zip', mode: 'zip'},
|
||||
options: {archive: 'build/' + dist + '.zip', mode: 'zip'},
|
||||
src: ['**'],
|
||||
cwd: 'build',
|
||||
expand: true,
|
||||
@@ -366,7 +322,7 @@ module.exports = function(grunt) {
|
||||
|
||||
|
||||
//alias tasks
|
||||
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
|
||||
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['eslint', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']);
|
||||
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
|
||||
grunt.registerTask('test:jquery', 'Run the jQuery (latest) unit tests with Karma', ['tests:jquery']);
|
||||
grunt.registerTask('test:jquery-2.2', 'Run the jQuery 2.2 unit tests with Karma', ['tests:jquery-2.2']);
|
||||
@@ -383,6 +339,6 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('minify', ['bower', 'clean', 'build', 'minall']);
|
||||
grunt.registerTask('webserver', ['connect:devserver']);
|
||||
grunt.registerTask('package', ['bower', 'validate-angular-files', 'clean', 'buildall', 'minall', 'collect-errors', 'docs', 'copy', 'write', 'compress']);
|
||||
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'jshint', 'jscs']);
|
||||
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'eslint']);
|
||||
grunt.registerTask('default', ['package']);
|
||||
};
|
||||
|
||||
Vendored
+3
-3
@@ -245,10 +245,10 @@ var angularFiles = {
|
||||
]
|
||||
};
|
||||
|
||||
['2.1', '2.2'].forEach(function (jQueryVersion) {
|
||||
['2.1', '2.2'].forEach(function(jQueryVersion) {
|
||||
angularFiles['karmaJquery' + jQueryVersion] = []
|
||||
.concat(angularFiles.karmaJquery)
|
||||
.map(function (path) {
|
||||
.map(function(path) {
|
||||
if (path.startsWith('bower_components/jquery')) {
|
||||
return path.replace(/^bower_components\/jquery/, 'bower_components/jquery-' + jQueryVersion);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ if (exports) {
|
||||
Array.prototype.slice.call(arguments, 0).forEach(function(filegroup) {
|
||||
angularFiles[filegroup].forEach(function(file) {
|
||||
// replace @ref
|
||||
var match = file.match(/^\@(.*)/);
|
||||
var match = file.match(/^@(.*)/);
|
||||
if (match) {
|
||||
files = files.concat(angularFiles[match[1]]);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../.eslintrc-browser.json",
|
||||
|
||||
"globals": {
|
||||
"benchmarkSteps": false,
|
||||
|
||||
// Benchmarks are not run in IE 9 so we're fine.
|
||||
"console": false
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('eventDelegationBenchmark', []);
|
||||
|
||||
app.directive('noopDir', function() {
|
||||
@@ -5,7 +7,7 @@ app.directive('noopDir', function() {
|
||||
compile: function($element, $attrs) {
|
||||
return function($scope, $element) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -13,12 +15,12 @@ app.directive('noopDir', function() {
|
||||
app.directive('nativeClick', ['$parse', function($parse) {
|
||||
return {
|
||||
compile: function($element, $attrs) {
|
||||
var expr = $parse($attrs.tstEvent);
|
||||
$parse($attrs.tstEvent);
|
||||
return function($scope, $element) {
|
||||
$element[0].addEventListener('click', function() {
|
||||
console.log('clicked');
|
||||
}, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}]);
|
||||
@@ -26,13 +28,12 @@ app.directive('nativeClick', ['$parse', function($parse) {
|
||||
app.directive('dlgtClick', function() {
|
||||
return {
|
||||
compile: function($element, $attrs) {
|
||||
var evt = $attrs.dlgtClick;
|
||||
// We don't setup the global event listeners as the costs are small and one time only...
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('DataController', function($rootScope) {
|
||||
app.controller('DataController', function DataController($rootScope) {
|
||||
this.ngRepeatCount = 1000;
|
||||
this.rows = [];
|
||||
var self = this;
|
||||
@@ -47,8 +48,8 @@ app.controller('DataController', function($rootScope) {
|
||||
self.rows = oldRows;
|
||||
if (self.rows.length !== self.ngRepeatCount) {
|
||||
self.rows = [];
|
||||
for (var i=0; i<self.ngRepeatCount; i++) {
|
||||
self.rows.push('row'+i);
|
||||
for (var i = 0; i < self.ngRepeatCount; i++) {
|
||||
self.rows.push('row' + i);
|
||||
}
|
||||
}
|
||||
$rootScope.$apply();
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
/* eslint-env node */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [{
|
||||
id: 'angular',
|
||||
src: '/build/angular.js'
|
||||
},{
|
||||
src: 'app.js',
|
||||
}, {
|
||||
src: 'app.js'
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('largetableBenchmark', []);
|
||||
|
||||
app.config(function($compileProvider) {
|
||||
@@ -12,21 +14,23 @@ app.filter('noop', function() {
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('DataController', function($scope, $rootScope) {
|
||||
app.controller('DataController', function DataController($scope, $rootScope) {
|
||||
var totalRows = 1000;
|
||||
var totalColumns = 20;
|
||||
|
||||
var data = $scope.data = [];
|
||||
$scope.digestDuration = '?';
|
||||
$scope.numberOfBindings = totalRows*totalColumns*2 + totalRows + 1;
|
||||
$scope.numberOfBindings = totalRows * totalColumns * 2 + totalRows + 1;
|
||||
$scope.numberOfWatches = '?';
|
||||
|
||||
/* @this */
|
||||
function iGetter() { return this.i; }
|
||||
/* @this */
|
||||
function jGetter() { return this.j; }
|
||||
|
||||
for (var i=0; i<totalRows; i++) {
|
||||
for (var i = 0; i < totalRows; i++) {
|
||||
data[i] = [];
|
||||
for (var j=0; j<totalColumns; j++) {
|
||||
for (var j = 0; j < totalColumns; j++) {
|
||||
data[i][j] = {
|
||||
i: i, j: j,
|
||||
iFn: iGetter,
|
||||
@@ -64,14 +68,13 @@ app.controller('DataController', function($scope, $rootScope) {
|
||||
});
|
||||
});
|
||||
|
||||
var fn = function() { return 'x'};
|
||||
|
||||
|
||||
app.directive('baselineBindingTable', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
link: function ($scope, $element) {
|
||||
link: function($scope, $element) {
|
||||
var i, j, row, cell, comment;
|
||||
var document = window.document;
|
||||
var template = document.createElement('span');
|
||||
template.setAttribute('ng-repeat', 'foo in foos');
|
||||
template.classList.add('ng-scope');
|
||||
@@ -104,8 +107,9 @@ app.directive('baselineBindingTable', function() {
|
||||
app.directive('baselineInterpolationTable', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
link: function ($scope, $element) {
|
||||
link: function($scope, $element) {
|
||||
var i, j, row, cell, comment;
|
||||
var document = window.document;
|
||||
var template = document.createElement('span');
|
||||
template.setAttribute('ng-repeat', 'foo in foos');
|
||||
template.classList.add('ng-scope');
|
||||
@@ -180,4 +184,4 @@ app.directive('baselineTable', function() {
|
||||
};
|
||||
});
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
/* eslint-env node */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [{
|
||||
@@ -9,7 +13,7 @@ module.exports = function(config) {
|
||||
src: '/build/angular.js'
|
||||
},
|
||||
{
|
||||
src: 'app.js',
|
||||
src: 'app.js'
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
//Override me with ?jquery=/bower_components/jquery/dist/jquery.js
|
||||
// Override me with ?jquery=/bower_components/jquery/dist/jquery.js
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
/* eslint-env node */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [ {
|
||||
scripts: [{
|
||||
id: 'angular',
|
||||
src: '/build/angular.js'
|
||||
},
|
||||
{
|
||||
src: 'app.js',
|
||||
src: 'app.js'
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('orderByBenchmark', []);
|
||||
|
||||
app.controller('DataController', function($rootScope, $scope) {
|
||||
app.controller('DataController', function DataController($rootScope, $scope) {
|
||||
this.ngRepeatCount = 5000;
|
||||
this.rows = [];
|
||||
var self = this;
|
||||
@@ -37,7 +39,7 @@ app.controller('DataController', function($rootScope, $scope) {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
benchmarkSteps.push({
|
||||
name: '$apply',
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/* eslint-env node */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [
|
||||
{
|
||||
"id": "jquery",
|
||||
"src": "jquery-noop.js"
|
||||
},{
|
||||
}, {
|
||||
id: 'angular',
|
||||
src: '/build/angular.js'
|
||||
},{
|
||||
src: 'app.js',
|
||||
}, {
|
||||
src: 'app.js'
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var app = angular.module('parsedExpressionBenchmark', []);
|
||||
|
||||
app.config(function($compileProvider) {
|
||||
@@ -17,7 +19,7 @@ app.directive('bmPeWatch', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
compile: function($element, $attrs) {
|
||||
$element.text( $attrs.bmPeWatch );
|
||||
$element.text($attrs.bmPeWatch);
|
||||
return function($scope, $element, $attrs) {
|
||||
$scope.$watch($attrs.bmPeWatch, function(val) {
|
||||
$element.text(val);
|
||||
@@ -38,9 +40,9 @@ app.directive('bmPeWatchLiteral', function($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
compile: function($element, $attrs) {
|
||||
$element.text( $attrs.bmPeWatchLiteral );
|
||||
$element.text($attrs.bmPeWatchLiteral);
|
||||
return function($scope, $element, $attrs) {
|
||||
$scope.$watch( $parse($attrs.bmPeWatchLiteral, retZero) );
|
||||
$scope.$watch($parse($attrs.bmPeWatchLiteral, retZero));
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -55,31 +57,31 @@ app.controller('DataController', function($scope, $rootScope) {
|
||||
|
||||
$scope.func = function() { return star;};
|
||||
|
||||
for (var i=0; i<totalRows; i++) {
|
||||
for (var i = 0; i < totalRows; i++) {
|
||||
data.push({
|
||||
index: i,
|
||||
odd: i%2 === 0,
|
||||
even: i%2 === 1,
|
||||
str0: "foo-" + Math.random()*Date.now(),
|
||||
str1: "bar-" + Math.random()*Date.now(),
|
||||
str2: "baz-" + Math.random()*Date.now(),
|
||||
num0: Math.random()*Date.now(),
|
||||
num1: Math.random()*Date.now(),
|
||||
num2: Math.random()*Date.now(),
|
||||
date0: new Date(Math.random()*Date.now()),
|
||||
date1: new Date(Math.random()*Date.now()),
|
||||
date2: new Date(Math.random()*Date.now()),
|
||||
func: function(){ return star; },
|
||||
obj: data[i-1],
|
||||
keys: data[i-1] && (data[i-1].keys || Object.keys(data[i-1])),
|
||||
constructor: data[i-1]
|
||||
odd: i % 2 === 0,
|
||||
even: i % 2 === 1,
|
||||
str0: "foo-" + Math.random() * Date.now(),
|
||||
str1: "bar-" + Math.random() * Date.now(),
|
||||
str2: "baz-" + Math.random() * Date.now(),
|
||||
num0: Math.random() * Date.now(),
|
||||
num1: Math.random() * Date.now(),
|
||||
num2: Math.random() * Date.now(),
|
||||
date0: new Date(Math.random() * Date.now()),
|
||||
date1: new Date(Math.random() * Date.now()),
|
||||
date2: new Date(Math.random() * Date.now()),
|
||||
func: function() { return star; },
|
||||
obj: data[i - 1],
|
||||
keys: data[i - 1] && (data[i - 1].keys || Object.keys(data[i - 1])),
|
||||
constructor: data[i - 1]
|
||||
});
|
||||
}
|
||||
|
||||
benchmarkSteps.push({
|
||||
name: '$apply',
|
||||
fn: function() {
|
||||
for (var i=0; i<50; i++) {
|
||||
for (var i = 0; i < 50; i++) {
|
||||
$rootScope.$digest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
/* eslint-env node */
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
scripts: [ {
|
||||
scripts: [{
|
||||
id: 'angular',
|
||||
src: '/build/angular.js'
|
||||
},
|
||||
{
|
||||
src: 'app.js',
|
||||
src: 'app.js'
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ var parseRawCommit = function(raw) {
|
||||
|
||||
lines.forEach(function(line) {
|
||||
match = line.match(/(?:Closes|Fixes)\s#(\d+)/);
|
||||
if (match) msg.closes.push(parseInt(match[1]));
|
||||
if (match) msg.closes.push(parseInt(match[1], 10));
|
||||
});
|
||||
|
||||
match = raw.match(/BREAKING CHANGE:([\s\S]*)/);
|
||||
@@ -48,7 +48,7 @@ var parseRawCommit = function(raw) {
|
||||
|
||||
|
||||
msg.body = lines.join('\n');
|
||||
match = msg.subject.match(/^(.*)\((.*)\)\:\s(.*)$/);
|
||||
match = msg.subject.match(/^(.*)\((.*)\):\s(.*)$/);
|
||||
|
||||
if (!match || !match[1] || !match[3]) {
|
||||
warn('Incorrect message: %s %s', msg.hash, msg.subject);
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@ describe('changelog.js', function() {
|
||||
module2: [{subject: 'breaking change 2'}]
|
||||
};
|
||||
var expectedOutput =
|
||||
'\n' + '## test\n\n' +
|
||||
'\n## test\n\n' +
|
||||
'- **module1:** breaking change 1\n' +
|
||||
'- **module2:** breaking change 2\n' +
|
||||
'\n';
|
||||
@@ -92,7 +92,7 @@ describe('changelog.js', function() {
|
||||
]
|
||||
};
|
||||
var expectedOutput =
|
||||
'\n' + '## test\n\n' +
|
||||
'\n## test\n\n' +
|
||||
'- **module1:**\n' +
|
||||
' - breaking change 1.1\n' +
|
||||
' - breaking change 1.2\n' +
|
||||
|
||||
+40
-41
@@ -9,72 +9,72 @@ var Q = require('q');
|
||||
var _ = require('lodash');
|
||||
var semver = require('semver');
|
||||
|
||||
var exec = function (cmd) {
|
||||
return function () {
|
||||
var exec = function(cmd) {
|
||||
return function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
args.unshift(cmd);
|
||||
var fullCmd = util.format.apply(util, args);
|
||||
return Q.nfcall(cp.exec, fullCmd).then(function (out) {
|
||||
return Q.nfcall(cp.exec, fullCmd).then(function(out) {
|
||||
return out[0].split('\n');
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var andThen = function (fn, after) {
|
||||
return function () {
|
||||
var andThen = function(fn, after) {
|
||||
return /* @this */ function() {
|
||||
return fn.apply(this, arguments).then(after);
|
||||
};
|
||||
};
|
||||
|
||||
var oneArg = function (fn) {
|
||||
return function (arg) {
|
||||
var oneArg = function(fn) {
|
||||
return function(arg) {
|
||||
return fn(arg);
|
||||
};
|
||||
};
|
||||
|
||||
var oneLine = function (lines) {
|
||||
var oneLine = function(lines) {
|
||||
return lines[0].trim();
|
||||
};
|
||||
|
||||
var noArgs = function (fn) {
|
||||
return function () {
|
||||
var noArgs = function(fn) {
|
||||
return function() {
|
||||
return fn();
|
||||
};
|
||||
};
|
||||
|
||||
var identity = function (i) { return i; };
|
||||
var identity = function(i) { return i; };
|
||||
|
||||
// like Q.all, but runs the commands in series
|
||||
// useful for ensuring env state (like which branch is checked out)
|
||||
var allInSeries = function (fn) {
|
||||
return function (args) {
|
||||
var allInSeries = function(fn) {
|
||||
return function(args) {
|
||||
var results = [];
|
||||
var def;
|
||||
while (args.length > 0) {
|
||||
(function (arg) {
|
||||
(function(arg) {
|
||||
if (def) {
|
||||
def = def.then(function () {
|
||||
def = def.then(function() {
|
||||
return fn(arg);
|
||||
});
|
||||
} else {
|
||||
def = fn(arg);
|
||||
}
|
||||
def = def.then(function (res) {
|
||||
def = def.then(function(res) {
|
||||
results.push(res);
|
||||
});
|
||||
}(args.pop()));
|
||||
})(args.pop());
|
||||
}
|
||||
return def.then(function () {
|
||||
return def.then(function() {
|
||||
return results;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var compareBranches = function (left, right) {
|
||||
var compareBranches = function(left, right) {
|
||||
console.log('# These commits are in ' + left.name + ' but not in ' + right.name + '\n');
|
||||
console.log(_(left.log).
|
||||
difference(right.log).
|
||||
map(function (line) {
|
||||
map(function(line) {
|
||||
return left.full[left.log.indexOf(line)]; // lol O(n^2)
|
||||
}).
|
||||
value().
|
||||
@@ -85,44 +85,43 @@ var checkout = oneArg(exec('git checkout %s'));
|
||||
|
||||
var getCurrentBranch = andThen(noArgs(exec('git rev-parse --abbrev-ref HEAD')), oneLine);
|
||||
var getTags = noArgs(exec('git tag'));
|
||||
var getShaOfTag = oneArg(exec('git rev-list %s | head -n 1'));
|
||||
var getTheLog = oneArg(exec('git log --pretty=oneline %s..HEAD | cat'));
|
||||
|
||||
// remember this so we can restore state
|
||||
var currentBranch;
|
||||
|
||||
getCurrentBranch().
|
||||
then(function (branch) {
|
||||
then(function(branch) {
|
||||
currentBranch = branch;
|
||||
}).
|
||||
then(getTags).
|
||||
then(function (tags) {
|
||||
then(function(tags) {
|
||||
return tags.
|
||||
filter(semver.valid).
|
||||
map(semver.clean).
|
||||
sort(semver.rcompare);
|
||||
}).
|
||||
then(function (tags) {
|
||||
var major = tags[0].split('.')[0];
|
||||
then(function(tags) {
|
||||
var major = semver(tags[0]).major;
|
||||
return tags.
|
||||
filter(function (ver) {
|
||||
return semver(ver).major == major;
|
||||
filter(function(ver) {
|
||||
return semver(ver).major === major;
|
||||
});
|
||||
}).
|
||||
then(function (tags) {
|
||||
then(function(tags) {
|
||||
return _(tags).
|
||||
groupBy(function (tag) {
|
||||
groupBy(function(tag) {
|
||||
return tag.split('.')[1];
|
||||
}).
|
||||
map(function (group) {
|
||||
map(function(group) {
|
||||
return _.first(group);
|
||||
}).
|
||||
map(function (tag) {
|
||||
map(function(tag) {
|
||||
return 'v' + tag;
|
||||
}).
|
||||
value();
|
||||
}).
|
||||
then(function (tags) {
|
||||
then(function(tags) {
|
||||
var master = tags.pop();
|
||||
var stable = tags.pop();
|
||||
|
||||
@@ -131,38 +130,38 @@ then(function (tags) {
|
||||
{ name: 'master', tag: master}
|
||||
];
|
||||
}).
|
||||
then(allInSeries(function (branch) {
|
||||
then(allInSeries(function(branch) {
|
||||
return checkout(branch.name).
|
||||
then(function () {
|
||||
then(function() {
|
||||
return getTheLog(branch.tag);
|
||||
}).
|
||||
then(function (log) {
|
||||
then(function(log) {
|
||||
return log.
|
||||
filter(identity);
|
||||
}).
|
||||
then(function (log) {
|
||||
branch.full = log.map(function (line) {
|
||||
then(function(log) {
|
||||
branch.full = log.map(function(line) {
|
||||
line = line.split(' ');
|
||||
var sha = line.shift();
|
||||
var msg = line.join(' ');
|
||||
return sha + ((/fix\([^\)]+\):/i.test(msg)) ? ' * ' : ' ') + msg;
|
||||
});
|
||||
branch.log = log.map(function (line) {
|
||||
branch.log = log.map(function(line) {
|
||||
return line.substr(41);
|
||||
});
|
||||
return branch;
|
||||
});
|
||||
})).
|
||||
then(function (pairs) {
|
||||
then(function(pairs) {
|
||||
compareBranches(pairs[0], pairs[1]);
|
||||
console.log('\n');
|
||||
compareBranches(pairs[1], pairs[0]);
|
||||
return pairs;
|
||||
}).
|
||||
then(function () {
|
||||
then(function() {
|
||||
return checkout(currentBranch);
|
||||
}).
|
||||
catch(function (e) {
|
||||
catch(function(e) {
|
||||
console.log(e.stack);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
"use strict";
|
||||
/* jshint browser: true */
|
||||
/* global importScripts, onmessage: true, postMessage, lunr */
|
||||
'use strict';
|
||||
|
||||
/* eslint-env worker */
|
||||
/* global importScripts, lunr */
|
||||
|
||||
// Load up the lunr library
|
||||
importScripts('../components/lunr.js-0.5.12/lunr.min.js');
|
||||
|
||||
// Create the lunr index - the docs should be an array of object, each object containing
|
||||
// the path and search terms for a page
|
||||
var index = lunr(function() {
|
||||
var index = lunr(/* @this */function() {
|
||||
this.ref('path');
|
||||
this.field('titleWords', {boost: 50});
|
||||
this.field('members', { boost: 40});
|
||||
this.field('keywords', { boost : 20 });
|
||||
this.field('members', {boost: 40});
|
||||
this.field('keywords', {boost: 20});
|
||||
});
|
||||
|
||||
// Retrieve the searchData which contains the information about each page to be indexed
|
||||
@@ -25,13 +26,13 @@ searchDataRequest.onload = function() {
|
||||
searchData.forEach(function(page) {
|
||||
index.add(page);
|
||||
});
|
||||
postMessage({ e: 'index-ready' });
|
||||
postMessage({e: 'index-ready'});
|
||||
};
|
||||
searchDataRequest.open('GET', 'search-data.json');
|
||||
searchDataRequest.send();
|
||||
|
||||
// The worker receives a message everytime the web app wants to query the index
|
||||
onmessage = function(oEvent) {
|
||||
self.onmessage = function(oEvent) {
|
||||
var q = oEvent.data.q;
|
||||
var hits = index.search(q);
|
||||
var results = [];
|
||||
@@ -40,5 +41,5 @@ onmessage = function(oEvent) {
|
||||
results.push(hit.ref);
|
||||
});
|
||||
// The results of the query are sent back to the web app via a new message
|
||||
postMessage({ e: 'query-ready', q: q, d: results });
|
||||
};
|
||||
self.postMessage({e: 'query-ready', q: q, d: results});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../../.eslintrc-node.json",
|
||||
|
||||
|
||||
"env": {
|
||||
"jasmine": true,
|
||||
"protractor": true
|
||||
},
|
||||
|
||||
"globals": {
|
||||
/* testabilityPatch / matchers */
|
||||
"inject": false,
|
||||
"module": false,
|
||||
"dealoc": false,
|
||||
"_jQuery": false,
|
||||
"_jqLiteMode": false,
|
||||
"sortedHtml": false,
|
||||
"childrenTagsOf": false,
|
||||
"assertHidden": false,
|
||||
"assertVisible": false,
|
||||
"provideLog": false,
|
||||
"spyOnlyCallsWithArgs": false,
|
||||
"createMockStyleSheet": false,
|
||||
"browserTrigger": false,
|
||||
"jqLiteCacheSize": false
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"extends": "../../../.jshintrc-base",
|
||||
|
||||
"globals": {
|
||||
|
||||
/* jasmine / karma */
|
||||
"it": false,
|
||||
"iit": false,
|
||||
"describe": false,
|
||||
"ddescribe": false,
|
||||
"beforeEach": false,
|
||||
"afterEach": false,
|
||||
"expect": false,
|
||||
"jasmine": false,
|
||||
"spyOn": false,
|
||||
"waits": false,
|
||||
"waitsFor": false,
|
||||
"runs": false,
|
||||
"dump": false,
|
||||
|
||||
/* e2e */
|
||||
"protractor": false,
|
||||
"browser": false,
|
||||
"element": false,
|
||||
"by": false,
|
||||
"$": false,
|
||||
"$$": false,
|
||||
|
||||
/* testabilityPatch / matchers */
|
||||
"inject": false,
|
||||
"module": false,
|
||||
"dealoc": false,
|
||||
"_jQuery": false,
|
||||
"_jqLiteMode": false,
|
||||
"sortedHtml": false,
|
||||
"childrenTagsOf": false,
|
||||
"assertHidden": false,
|
||||
"assertVisible": false,
|
||||
"provideLog": false,
|
||||
"spyOnlyCallsWithArgs": false,
|
||||
"createMockStyleSheet": false,
|
||||
"browserTrigger": false,
|
||||
"jqLiteCacheSize": false
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ describe("doc.angularjs.org", function() {
|
||||
expect(element(by.css('.view-source')).getAttribute('href')).toMatch(/https?:\/\/github\.com\/angular\/angular\.js\/tree\/.+\/src\/ng\/http\.js#L\d+/);
|
||||
});
|
||||
|
||||
it('should change the page content when clicking a link to a service', function () {
|
||||
it('should change the page content when clicking a link to a service', function() {
|
||||
browser.get('build/docs/index.html');
|
||||
|
||||
var ngBindLink = element(by.css('.definition-table td a[href="api/ng/directive/ngClick"]'));
|
||||
@@ -23,7 +23,7 @@ describe("doc.angularjs.org", function() {
|
||||
});
|
||||
|
||||
|
||||
it('should show the functioning input directive example', function () {
|
||||
it('should show the functioning input directive example', function() {
|
||||
browser.get('build/docs/index.html#!/api/ng/directive/input');
|
||||
|
||||
// Ensure that the page is loaded before trying to switch frames.
|
||||
@@ -48,4 +48,4 @@ describe("doc.angularjs.org", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,4 +9,4 @@ describe("provider pages", function() {
|
||||
expect(serviceLink.getAttribute('href')).toMatch(/api\/ng\/service\/\$compile/);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,4 +19,4 @@ describe("service pages", function() {
|
||||
expect(element.all(by.css('.input-arguments p em')).first().getText()).toContain('(default: 0)');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var webdriver = require('protractor/node_modules/selenium-webdriver');
|
||||
|
||||
describe('docs.angularjs.org', function () {
|
||||
describe('docs.angularjs.org', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
// read and clear logs from previous tests
|
||||
@@ -24,7 +24,7 @@ describe('docs.angularjs.org', function () {
|
||||
});
|
||||
|
||||
|
||||
describe('App', function () {
|
||||
describe('App', function() {
|
||||
// it('should filter the module list when searching', function () {
|
||||
// browser.get();
|
||||
// browser.waitForAngular();
|
||||
@@ -38,7 +38,7 @@ describe('docs.angularjs.org', function () {
|
||||
// });
|
||||
|
||||
|
||||
it('should change the page content when clicking a link to a service', function () {
|
||||
it('should change the page content when clicking a link to a service', function() {
|
||||
browser.get('build/docs/index-production.html');
|
||||
|
||||
var ngBindLink = element(by.css('.definition-table td a[href="api/ng/directive/ngClick"]'));
|
||||
@@ -83,4 +83,4 @@ describe('docs.angularjs.org', function () {
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../../.eslintrc-browser.json",
|
||||
|
||||
"globals": {
|
||||
// ngMocks
|
||||
"module": false,
|
||||
"inject": true,
|
||||
|
||||
"lunr": false
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('docsApp', [
|
||||
'ngRoute',
|
||||
'ngCookies',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('directives', [])
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('DocsController', [])
|
||||
|
||||
.controller('DocsController', [
|
||||
@@ -27,9 +29,9 @@ angular.module('DocsController', [])
|
||||
|
||||
path = path.replace(/^\/?(.+?)(\/index)?\/?$/, '$1');
|
||||
|
||||
currentPage = $scope.currentPage = NG_PAGES[path];
|
||||
var currentPage = $scope.currentPage = NG_PAGES[path];
|
||||
|
||||
if ( currentPage ) {
|
||||
if (currentPage) {
|
||||
$scope.partialPath = 'partials/' + path + '.html';
|
||||
$scope.currentArea = NG_NAVIGATION[currentPage.area];
|
||||
var pathParts = currentPage.path.split('/');
|
||||
@@ -37,7 +39,7 @@ angular.module('DocsController', [])
|
||||
var breadcrumbPath = '';
|
||||
angular.forEach(pathParts, function(part) {
|
||||
breadcrumbPath += part;
|
||||
breadcrumb.push({ name: (NG_PAGES[breadcrumbPath]&&NG_PAGES[breadcrumbPath].name) || part, url: breadcrumbPath });
|
||||
breadcrumb.push({ name: (NG_PAGES[breadcrumbPath] && NG_PAGES[breadcrumbPath].name) || part, url: breadcrumbPath });
|
||||
breadcrumbPath += '/';
|
||||
});
|
||||
} else {
|
||||
|
||||
+16
-14
@@ -1,23 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('errors', ['ngSanitize'])
|
||||
|
||||
.filter('errorLink', ['$sanitize', function ($sanitize) {
|
||||
var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s\.\;\,\(\)\{\}<>]/g,
|
||||
.filter('errorLink', ['$sanitize', function($sanitize) {
|
||||
var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s\.;,\(\)\{\}<>]/g,
|
||||
MAILTO_REGEXP = /^mailto:/,
|
||||
STACK_TRACE_REGEXP = /:\d+:\d+$/;
|
||||
|
||||
var truncate = function (text, nchars) {
|
||||
var truncate = function(text, nchars) {
|
||||
if (text.length > nchars) {
|
||||
return text.substr(0, nchars - 3) + '...';
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
return function (text, target) {
|
||||
return function(text, target) {
|
||||
if (!text) return text;
|
||||
|
||||
var targetHtml = target ? ' target="' + target + '"' : '';
|
||||
|
||||
return $sanitize(text.replace(LINKY_URL_REGEXP, function (url) {
|
||||
return $sanitize(text.replace(LINKY_URL_REGEXP, function(url) {
|
||||
if (STACK_TRACE_REGEXP.test(url)) {
|
||||
return url;
|
||||
}
|
||||
@@ -25,7 +27,7 @@ angular.module('errors', ['ngSanitize'])
|
||||
// if we did not match ftp/http/mailto then assume mailto
|
||||
if (!/^((ftp|https?):\/\/|mailto:)/.test(url)) url = 'mailto:' + url;
|
||||
|
||||
return '<a' + targetHtml + ' href="' + url +'">' +
|
||||
return '<a' + targetHtml + ' href="' + url + '">' +
|
||||
truncate(url.replace(MAILTO_REGEXP, ''), 60) +
|
||||
'</a>';
|
||||
}));
|
||||
@@ -33,33 +35,33 @@ angular.module('errors', ['ngSanitize'])
|
||||
}])
|
||||
|
||||
|
||||
.directive('errorDisplay', ['$location', 'errorLinkFilter', function ($location, errorLinkFilter) {
|
||||
var encodeAngleBrackets = function (text) {
|
||||
.directive('errorDisplay', ['$location', 'errorLinkFilter', function($location, errorLinkFilter) {
|
||||
var encodeAngleBrackets = function(text) {
|
||||
return text.replace(/</g, '<').replace(/>/g, '>');
|
||||
};
|
||||
|
||||
var interpolate = function (formatString) {
|
||||
var interpolate = function(formatString) {
|
||||
var formatArgs = arguments;
|
||||
return formatString.replace(/\{\d+\}/g, function (match) {
|
||||
return formatString.replace(/\{\d+\}/g, function(match) {
|
||||
// Drop the braces and use the unary plus to convert to an integer.
|
||||
// The index will be off by one because of the formatString.
|
||||
var index = +match.slice(1, -1);
|
||||
if (index + 1 >= formatArgs.length) {
|
||||
return match;
|
||||
}
|
||||
return formatArgs[index+1];
|
||||
return formatArgs[index + 1];
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
link: function (scope, element, attrs) {
|
||||
link: function(scope, element, attrs) {
|
||||
var search = $location.search(),
|
||||
formatArgs = [attrs.errorDisplay],
|
||||
formattedText,
|
||||
i;
|
||||
|
||||
for (i = 0; angular.isDefined(search['p'+i]); i++) {
|
||||
formatArgs.push(search['p'+i]);
|
||||
for (i = 0; angular.isDefined(search['p' + i]); i++) {
|
||||
formatArgs.push(search['p' + i]);
|
||||
}
|
||||
|
||||
formattedText = encodeAngleBrackets(interpolate.apply(null, formatArgs));
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('examples', [])
|
||||
|
||||
.directive('runnableExample', ['$templateCache', '$document', function($templateCache, $document) {
|
||||
.directive('runnableExample', [function() {
|
||||
var exampleClassNameSelector = '.runnable-example-file';
|
||||
var doc = $document[0];
|
||||
var tpl =
|
||||
'<nav class="runnable-example-tabs" ng-if="tabs">' +
|
||||
' <a ng-class="{active:$index==activeTabIndex}"' +
|
||||
@@ -29,12 +30,12 @@ angular.module('examples', [])
|
||||
return function(scope, element) {
|
||||
var node = element[0];
|
||||
var examples = node.querySelectorAll(exampleClassNameSelector);
|
||||
var tabs = [], now = Date.now();
|
||||
var tabs = [];
|
||||
angular.forEach(examples, function(child, index) {
|
||||
tabs.push(child.getAttribute('name'));
|
||||
});
|
||||
|
||||
if(tabs.length > 0) {
|
||||
if (tabs.length > 0) {
|
||||
scope.tabs = tabs;
|
||||
scope.$on('tabChange', function(e, index, title) {
|
||||
angular.forEach(examples, function(child) {
|
||||
@@ -101,7 +102,7 @@ angular.module('examples', [])
|
||||
},
|
||||
controllerAs: 'plnkr',
|
||||
template: '<button ng-click="plnkr.open($event)" class="btn pull-right"> <i class="glyphicon glyphicon-edit"> </i> Edit in Plunker</button> ',
|
||||
controller: [function() {
|
||||
controller: [function PlnkrOpenerCtrl() {
|
||||
var ctrl = this;
|
||||
|
||||
ctrl.example = {
|
||||
@@ -167,7 +168,7 @@ angular.module('examples', [])
|
||||
}])
|
||||
|
||||
.factory('getExampleData', ['$http', '$q', function($http, $q) {
|
||||
return function(exampleFolder){
|
||||
return function(exampleFolder) {
|
||||
// Load the manifest for the example
|
||||
return $http.get(exampleFolder + '/manifest.json')
|
||||
.then(function(response) {
|
||||
@@ -199,4 +200,4 @@ angular.module('examples', [])
|
||||
});
|
||||
});
|
||||
};
|
||||
}]);
|
||||
}]);
|
||||
|
||||
+23
-21
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('search', [])
|
||||
|
||||
.controller('DocsSearchCtrl', ['$scope', '$location', 'docsSearch', function($scope, $location, docsSearch) {
|
||||
@@ -9,7 +11,7 @@ angular.module('search', [])
|
||||
|
||||
$scope.search = function(q) {
|
||||
var MIN_SEARCH_LENGTH = 2;
|
||||
if(q.length >= MIN_SEARCH_LENGTH) {
|
||||
if (q.length >= MIN_SEARCH_LENGTH) {
|
||||
docsSearch(q).then(function(hits) {
|
||||
// Make sure the areas are always in the same order
|
||||
var results = {
|
||||
@@ -23,28 +25,24 @@ angular.module('search', [])
|
||||
angular.forEach(hits, function(hit) {
|
||||
var area = hit.area;
|
||||
|
||||
var limit = (area == 'api') ? 40 : 14;
|
||||
var limit = (area === 'api') ? 40 : 14;
|
||||
results[area] = results[area] || [];
|
||||
if(results[area].length < limit) {
|
||||
if (results[area].length < limit) {
|
||||
results[area].push(hit);
|
||||
}
|
||||
});
|
||||
|
||||
var totalAreas = 0;
|
||||
for(var i in results) {
|
||||
++totalAreas;
|
||||
}
|
||||
if(totalAreas > 0) {
|
||||
var totalAreas = Object.keys(results).length;
|
||||
if (totalAreas > 0) {
|
||||
$scope.colClassName = 'cols-' + totalAreas;
|
||||
}
|
||||
$scope.hasResults = totalAreas > 0;
|
||||
$scope.results = results;
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
clearResults();
|
||||
}
|
||||
if(!$scope.$$phase) $scope.$apply();
|
||||
if (!$scope.$$phase) $scope.$apply();
|
||||
};
|
||||
|
||||
$scope.submit = function() {
|
||||
@@ -52,14 +50,14 @@ angular.module('search', [])
|
||||
if ($scope.results.api) {
|
||||
result = $scope.results.api[0];
|
||||
} else {
|
||||
for(var i in $scope.results) {
|
||||
for (var i in $scope.results) {
|
||||
result = $scope.results[i][0];
|
||||
if(result) {
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(result) {
|
||||
if (result) {
|
||||
$location.path(result.path);
|
||||
$scope.hideResults();
|
||||
}
|
||||
@@ -92,10 +90,12 @@ angular.module('search', [])
|
||||
// It should only be used where the browser does not support WebWorkers
|
||||
function localSearchFactory($http, $timeout, NG_PAGES) {
|
||||
|
||||
console.log('Using Local Search Index');
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log('Using Local Search Index');
|
||||
}
|
||||
|
||||
// Create the lunr index
|
||||
var index = lunr(function() {
|
||||
var index = lunr(/* @this */ function() {
|
||||
this.ref('path');
|
||||
this.field('titleWords', {boost: 50});
|
||||
this.field('members', { boost: 40});
|
||||
@@ -136,12 +136,14 @@ angular.module('search', [])
|
||||
// It should only be used where the browser does support WebWorkers
|
||||
function webWorkerSearchFactory($q, $rootScope, NG_PAGES) {
|
||||
|
||||
console.log('Using WebWorker Search Index')
|
||||
if (window.console && window.console.log) {
|
||||
window.console.log('Using WebWorker Search Index');
|
||||
}
|
||||
|
||||
var searchIndex = $q.defer();
|
||||
var results;
|
||||
|
||||
var worker = new Worker('js/search-worker.js');
|
||||
var worker = new window.Worker('js/search-worker.js');
|
||||
|
||||
// The worker will send us a message in two situations:
|
||||
// - when the index has been built, ready to run a query
|
||||
@@ -149,7 +151,7 @@ angular.module('search', [])
|
||||
worker.onmessage = function(oEvent) {
|
||||
$rootScope.$apply(function() {
|
||||
|
||||
switch(oEvent.data.e) {
|
||||
switch (oEvent.data.e) {
|
||||
case 'index-ready':
|
||||
searchIndex.resolve();
|
||||
break;
|
||||
@@ -206,7 +208,7 @@ angular.module('search', [])
|
||||
FORWARD_SLASH_KEYCODE = 191;
|
||||
angular.element($document[0].body).on('keydown', function(event) {
|
||||
var input = element[0];
|
||||
if(event.keyCode == FORWARD_SLASH_KEYCODE && document.activeElement != input) {
|
||||
if (event.keyCode === FORWARD_SLASH_KEYCODE && window.document.activeElement !== input) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
input.focus();
|
||||
@@ -214,7 +216,7 @@ angular.module('search', [])
|
||||
});
|
||||
|
||||
element.on('keydown', function(event) {
|
||||
if(event.keyCode == ESCAPE_KEY_KEYCODE) {
|
||||
if (event.keyCode === ESCAPE_KEY_KEYCODE) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
scope.$apply(function() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('tutorials', [])
|
||||
|
||||
.directive('docTutorialNav', function() {
|
||||
@@ -20,7 +22,7 @@ angular.module('tutorials', [])
|
||||
scope.seq = seq;
|
||||
scope.prev = pages[seq];
|
||||
scope.next = pages[2 + seq];
|
||||
scope.diffLo = seq ? (seq - 1): '0~1';
|
||||
scope.diffLo = seq ? (seq - 1) : '0~1';
|
||||
scope.diffHi = seq;
|
||||
|
||||
element.addClass('btn-group');
|
||||
@@ -40,7 +42,7 @@ angular.module('tutorials', [])
|
||||
'<div class="alert alert-info" ng-show="show">\n' +
|
||||
' <p>Reset the workspace to step {{step}}.</p>' +
|
||||
' <p><pre>git checkout -f step-{{step}}</pre></p>\n' +
|
||||
' <p>Refresh your browser or check out this step online: '+
|
||||
' <p>Refresh your browser or check out this step online: ' +
|
||||
'<a href="http://angular.github.io/angular-phonecat/step-{{step}}/app">Step {{step}} Live Demo</a>.</p>\n' +
|
||||
'</div>\n' +
|
||||
'<p>The most important changes are listed below. You can see the full diff on ' +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
angular.module('versions', [])
|
||||
|
||||
@@ -6,7 +6,7 @@ angular.module('versions', [])
|
||||
$scope.docs_version = NG_VERSIONS[0];
|
||||
$scope.docs_versions = NG_VERSIONS;
|
||||
|
||||
for(var i=0, minor = NaN; i < NG_VERSIONS.length; i++) {
|
||||
for (var i = 0, minor = NaN; i < NG_VERSIONS.length; i++) {
|
||||
var version = NG_VERSIONS[i];
|
||||
// NaN will give false here
|
||||
if (minor <= version.minor) {
|
||||
@@ -25,7 +25,7 @@ angular.module('versions', [])
|
||||
url = '';
|
||||
if (version.isOldDocsUrl) {
|
||||
url = version.docsUrl;
|
||||
}else{
|
||||
} else {
|
||||
url = version.docsUrl + currentPagePath;
|
||||
}
|
||||
$window.location = url;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../../.eslintrc-browser.json",
|
||||
|
||||
"env": {
|
||||
"jasmine": true
|
||||
},
|
||||
|
||||
"rules": {
|
||||
// Some rules are not that important in tests and conflict with
|
||||
// Jasmine or would make it easier to write some tests; we disable
|
||||
// those ones here.
|
||||
"no-invalid-this": "off",
|
||||
"no-throw-literal": "off",
|
||||
"no-unused-vars": "off"
|
||||
},
|
||||
|
||||
"globals": {
|
||||
// ngMocks
|
||||
"module": false,
|
||||
"inject": true
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"extends": "../../../.jshintrc-base",
|
||||
"browser": true,
|
||||
"globals": {
|
||||
// AngularJS
|
||||
"angular": false,
|
||||
|
||||
// ngMocks
|
||||
"module": false,
|
||||
"inject": true,
|
||||
|
||||
// Jasmine
|
||||
"jasmine": false,
|
||||
"describe": false,
|
||||
"ddescribe": false,
|
||||
"xdescribe": false,
|
||||
"it": false,
|
||||
"iit": false,
|
||||
"xit": false,
|
||||
"beforeEach": false,
|
||||
"afterEach": false,
|
||||
"spyOn": false,
|
||||
"expect": false
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe("code", function() {
|
||||
var prettyPrintOne, oldPP;
|
||||
var compile, scope;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe("DocsController", function() {
|
||||
var $scope;
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ describe('errors', function() {
|
||||
}));
|
||||
|
||||
|
||||
it('should set the element\s HTML', function() {
|
||||
it('should set the element\'s HTML', function() {
|
||||
var elem = $compile('<span error-display="bar">foo</span>')($rootScope);
|
||||
expect(elem.html()).toBe('bar');
|
||||
});
|
||||
@@ -152,7 +152,7 @@ describe('errors', function() {
|
||||
it('should pass the interpolated text through `errorLinkFilter`', function() {
|
||||
$location.search = jasmine.createSpy('search').and.returnValue({p0: 'foo'});
|
||||
|
||||
var elem = $compile('<span error-display="foo = {0}"></span>')($rootScope);
|
||||
$compile('<span error-display="foo = {0}"></span>')($rootScope);
|
||||
expect(errorLinkFilter).toHaveBeenCalledTimes(1);
|
||||
expect(errorLinkFilter).toHaveBeenCalledWith('foo = foo', '_blank');
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ module.exports = new Package('angularjs', [
|
||||
docTypes: ['overview', 'tutorial'],
|
||||
getPath: function(doc) {
|
||||
var docPath = path.dirname(doc.fileInfo.relativePath);
|
||||
if ( doc.fileInfo.baseName !== 'index' ) {
|
||||
if (doc.fileInfo.baseName !== 'index') {
|
||||
docPath = path.join(docPath, doc.fileInfo.baseName);
|
||||
}
|
||||
return docPath;
|
||||
@@ -108,12 +108,12 @@ module.exports = new Package('angularjs', [
|
||||
});
|
||||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['module' ],
|
||||
docTypes: ['module'],
|
||||
pathTemplate: '${area}/${name}',
|
||||
outputPathTemplate: 'partials/${area}/${name}.html'
|
||||
});
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['componentGroup' ],
|
||||
docTypes: ['componentGroup'],
|
||||
pathTemplate: '${area}/${moduleName}/${groupType}',
|
||||
outputPathTemplate: 'partials/${area}/${moduleName}/${groupType}.html'
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
// eslint-disable-next-line new-cap
|
||||
var encoder = new require('node-html-encoder').Encoder();
|
||||
|
||||
/**
|
||||
@@ -11,7 +12,7 @@ module.exports = function typeInlineTagDef(getTypeClass) {
|
||||
return {
|
||||
name: 'type',
|
||||
handler: function(doc, tagName, tagDescription) {
|
||||
return '<a href="" class="' + getTypeClass(tagDescription) + '">'+encoder.htmlEncode(tagDescription) + '</a>';
|
||||
return '<a href="" class="' + getTypeClass(tagDescription) + '">' + encoder.htmlEncode(tagDescription) + '</a>';
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @dgProcessor errorDocsProcessor
|
||||
@@ -18,7 +15,7 @@ module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
|
||||
docs.forEach(function(doc) {
|
||||
var parts, namespaceDoc;
|
||||
|
||||
if ( doc.docType === 'error' ) {
|
||||
if (doc.docType === 'error') {
|
||||
|
||||
// Parse out the error info from the id
|
||||
parts = doc.name.split(':');
|
||||
@@ -27,7 +24,7 @@ module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
|
||||
|
||||
// Get or create the relevant errorNamespace doc
|
||||
namespaceDoc = errorNamespaceMap.get(doc.namespace);
|
||||
if ( !namespaceDoc ) {
|
||||
if (!namespaceDoc) {
|
||||
namespaceDoc = {
|
||||
area: 'error',
|
||||
name: doc.namespace,
|
||||
@@ -49,4 +46,4 @@ module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
|
||||
/**
|
||||
* @dgProcessor generateIndexPagesProcessor
|
||||
@@ -21,7 +20,7 @@ module.exports = function generateIndexPagesProcessor() {
|
||||
// Collect up all the areas in the docs
|
||||
var areas = {};
|
||||
docs.forEach(function(doc) {
|
||||
if ( doc.area ) {
|
||||
if (doc.area) {
|
||||
areas[doc.area] = doc.area;
|
||||
}
|
||||
});
|
||||
@@ -40,4 +39,4 @@ module.exports = function generateIndexPagesProcessor() {
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
|
||||
var KEYWORD_REGEX = /^((ng:|[\$_a-z])[\w\-_]+)/;
|
||||
|
||||
// Load up the keywords to ignore, if specified in the config
|
||||
if ( this.ignoreWordsFile ) {
|
||||
if (this.ignoreWordsFile) {
|
||||
|
||||
var ignoreWordsPath = path.resolve(readFilesProcessor.basePath, this.ignoreWordsFile);
|
||||
wordsToIgnore = fs.readFileSync(ignoreWordsPath, 'utf8').toString().split(/[,\s\n\r]+/gm);
|
||||
@@ -59,7 +59,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
|
||||
// without the ng to the title text, e.g. "controller".
|
||||
function extractTitleWords(title) {
|
||||
var match = /ng([A-Z]\w*)/.exec(title);
|
||||
if ( match ) {
|
||||
if (match) {
|
||||
title = title + ' ' + match[1].toLowerCase();
|
||||
}
|
||||
return title;
|
||||
@@ -68,11 +68,11 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
|
||||
function extractWords(text, words, keywordMap) {
|
||||
|
||||
var tokens = text.toLowerCase().split(/[\.\s,`'"#]+/mg);
|
||||
_.forEach(tokens, function(token){
|
||||
_.forEach(tokens, function(token) {
|
||||
var match = token.match(KEYWORD_REGEX);
|
||||
if (match){
|
||||
if (match) {
|
||||
var key = match[1];
|
||||
if ( !keywordMap[key]) {
|
||||
if (!keywordMap[key]) {
|
||||
keywordMap[key] = true;
|
||||
words.push(key);
|
||||
}
|
||||
@@ -96,11 +96,11 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
|
||||
// Search each top level property of the document for search terms
|
||||
_.forEach(doc, function(value, key) {
|
||||
|
||||
if ( _.isString(value) && !propertiesToIgnore[key] ) {
|
||||
if (_.isString(value) && !propertiesToIgnore[key]) {
|
||||
extractWords(value, words, keywordMap);
|
||||
}
|
||||
|
||||
if ( key === 'methods' || key === 'properties' || key === 'events' ) {
|
||||
if (key === 'methods' || key === 'properties' || key === 'events') {
|
||||
_.forEach(value, function(member) {
|
||||
extractWords(member.name, members, membersMap);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
@@ -67,7 +67,7 @@ module.exports = function generatePagesDataProcessor(log) {
|
||||
})
|
||||
|
||||
.tap(function(docTypes) {
|
||||
if ( docTypes.input ) {
|
||||
if (docTypes.input) {
|
||||
docTypes.directive = docTypes.directive || [];
|
||||
// Combine input docTypes into directive docTypes
|
||||
docTypes.directive = docTypes.directive.concat(docTypes.input);
|
||||
@@ -79,7 +79,7 @@ module.exports = function generatePagesDataProcessor(log) {
|
||||
|
||||
sectionPages = _.sortBy(sectionPages, 'name');
|
||||
|
||||
if ( sectionPages.length > 0 ) {
|
||||
if (sectionPages.length > 0) {
|
||||
// Push a navItem for this section
|
||||
navItems.push({
|
||||
name: sectionName,
|
||||
@@ -158,7 +158,7 @@ module.exports = function generatePagesDataProcessor(log) {
|
||||
|
||||
// We are only interested in pages that are not landing pages
|
||||
var navPages = _.filter(pages, function(page) {
|
||||
return page.docType != 'componentGroup';
|
||||
return page.docType !== 'componentGroup';
|
||||
});
|
||||
|
||||
// Generate an object collection of pages that is grouped by area e.g.
|
||||
|
||||
@@ -31,4 +31,4 @@ module.exports = function generateVersionDocProcessor(gitData) {
|
||||
docs.push(versionDoc);
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = function debugDeployment(getVersion) {
|
||||
name: 'debug',
|
||||
examples: {
|
||||
commonFiles: {
|
||||
scripts: [ '../../../angular.js' ]
|
||||
scripts: ['../../../angular.js']
|
||||
},
|
||||
dependencyPath: '../../../'
|
||||
},
|
||||
@@ -35,4 +35,4 @@ module.exports = function debugDeployment(getVersion) {
|
||||
'css/animations.css'
|
||||
]
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = function defaultDeployment(getVersion) {
|
||||
name: 'default',
|
||||
examples: {
|
||||
commonFiles: {
|
||||
scripts: [ '../../../angular.min.js' ]
|
||||
scripts: ['../../../angular.min.js']
|
||||
},
|
||||
dependencyPath: '../../../'
|
||||
},
|
||||
@@ -35,4 +35,4 @@ module.exports = function defaultDeployment(getVersion) {
|
||||
'css/animations.css'
|
||||
]
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
+1
-1
@@ -39,4 +39,4 @@ module.exports = function jqueryDeployment(getVersion) {
|
||||
'css/animations.css'
|
||||
]
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = function productionDeployment(getVersion) {
|
||||
name: 'production',
|
||||
examples: {
|
||||
commonFiles: {
|
||||
scripts: [ cdnUrl + '/angular.min.js' ]
|
||||
scripts: [cdnUrl + '/angular.min.js']
|
||||
},
|
||||
dependencyPath: cdnUrl + '/'
|
||||
},
|
||||
@@ -38,4 +38,4 @@ module.exports = function productionDeployment(getVersion) {
|
||||
'css/animations.css'
|
||||
]
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -7,4 +7,4 @@ var StringMap = require('stringmap');
|
||||
*/
|
||||
module.exports = function errorNamespaceMap() {
|
||||
return new StringMap();
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,4 @@ module.exports = function getVersion(readFilesProcessor) {
|
||||
packageFile = packageFile || 'bower.json';
|
||||
return require(path.join(sourceFolder,component,packageFile)).version;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
name: 'installation'
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
name: 'sortOrder',
|
||||
transforms: function(doc, tag, value) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
name: 'step',
|
||||
transforms: function(doc, tag, value) {
|
||||
if ( doc.docType !== 'tutorial' ) {
|
||||
if (doc.docType !== 'tutorial') {
|
||||
throw new Error('Invalid tag, step. You should only use this tag on tutorial docs');
|
||||
}
|
||||
return parseInt(value,10);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// Meta data used by the AngularJS docs app
|
||||
angular.module('navData', [])
|
||||
.value('NG_NAVIGATION', {$ doc.areas | json $});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// Meta data used by the AngularJS docs app
|
||||
angular.module('pagesData', [])
|
||||
.value('NG_PAGES', {$ doc.pages | json $});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// Meta data used by the AngularJS docs app
|
||||
angular.module('versionsData', [])
|
||||
.value('NG_VERSION', {$ doc.currentVersion | json $})
|
||||
|
||||
@@ -222,7 +222,7 @@ value of its attribute becomes true.
|
||||
angular.module('app', []).directive('setFocusIf', function() {
|
||||
return function link($scope, $element, $attr) {
|
||||
$scope.$watch($attr.setFocusIf, function(value) {
|
||||
if ( value ) { $element[0].focus(); }
|
||||
if (value) { $element[0].focus(); }
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -227,18 +227,18 @@ it('should show example', inject(
|
||||
},
|
||||
function($location) {
|
||||
// open http://example.com/base/index.html#!/a
|
||||
$location.absUrl() == 'http://example.com/base/index.html#!/a'
|
||||
$location.path() == '/a'
|
||||
$location.absUrl() === 'http://example.com/base/index.html#!/a'
|
||||
$location.path() === '/a'
|
||||
|
||||
$location.path('/foo')
|
||||
$location.absUrl() == 'http://example.com/base/index.html#!/foo'
|
||||
$location.absUrl() === 'http://example.com/base/index.html#!/foo'
|
||||
|
||||
$location.search() == {}
|
||||
$location.search() === {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://example.com/base/index.html#!/foo?a=b&c'
|
||||
$location.absUrl() === 'http://example.com/base/index.html#!/foo?a=b&c'
|
||||
|
||||
$location.path('/new').search('x=y');
|
||||
$location.absUrl() == 'http://example.com/base/index.html#!/new?x=y'
|
||||
$location.absUrl() === 'http://example.com/base/index.html#!/new?x=y'
|
||||
}
|
||||
));
|
||||
```
|
||||
@@ -271,29 +271,29 @@ it('should show example', inject(
|
||||
// in browser with HTML5 history support:
|
||||
// open http://example.com/#!/a -> rewrite to http://example.com/a
|
||||
// (replacing the http://example.com/#!/a history record)
|
||||
$location.path() == '/a'
|
||||
$location.path() === '/a'
|
||||
|
||||
$location.path('/foo');
|
||||
$location.absUrl() == 'http://example.com/foo'
|
||||
$location.absUrl() === 'http://example.com/foo'
|
||||
|
||||
$location.search() == {}
|
||||
$location.search() === {}
|
||||
$location.search({a: 'b', c: true});
|
||||
$location.absUrl() == 'http://example.com/foo?a=b&c'
|
||||
$location.absUrl() === 'http://example.com/foo?a=b&c'
|
||||
|
||||
$location.path('/new').search('x=y');
|
||||
$location.url() == 'new?x=y'
|
||||
$location.absUrl() == 'http://example.com/new?x=y'
|
||||
$location.url() === 'new?x=y'
|
||||
$location.absUrl() === 'http://example.com/new?x=y'
|
||||
|
||||
// in browser without html5 history support:
|
||||
// open http://example.com/new?x=y -> redirect to http://example.com/#!/new?x=y
|
||||
// (again replacing the http://example.com/new?x=y history item)
|
||||
$location.path() == '/new'
|
||||
$location.search() == {x: 'y'}
|
||||
$location.path() === '/new'
|
||||
$location.search() === {x: 'y'}
|
||||
|
||||
$location.path('/foo/bar');
|
||||
$location.path() == '/foo/bar'
|
||||
$location.url() == '/foo/bar?x=y'
|
||||
$location.absUrl() == 'http://example.com/#!/foo/bar?x=y'
|
||||
$location.path() === '/foo/bar'
|
||||
$location.url() === '/foo/bar?x=y'
|
||||
$location.absUrl() === 'http://example.com/#!/foo/bar?x=y'
|
||||
}
|
||||
));
|
||||
```
|
||||
@@ -411,9 +411,9 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
|
||||
.controller("LocationController", function($scope, $location) {
|
||||
$scope.$location = {};
|
||||
angular.forEach("protocol host port path search hash".split(" "), function(method){
|
||||
$scope.$location[method] = function(){
|
||||
var result = $location[method].call($location);
|
||||
angular.forEach("protocol host port path search hash".split(" "), function(method) {
|
||||
$scope.$location[method] = function() {
|
||||
var result = $location[method]();
|
||||
return angular.isObject(result) ? angular.toJson(result) : result;
|
||||
};
|
||||
});
|
||||
@@ -460,7 +460,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
.directive('ngAddressBar', function($browser, $timeout) {
|
||||
return {
|
||||
template: 'Address: <input id="addressBar" type="text" style="width: 400px" >',
|
||||
link: function(scope, element, attrs){
|
||||
link: function(scope, element, attrs) {
|
||||
var input = element.children("input"), delay;
|
||||
|
||||
input.on('keypress keyup keydown', function(event) {
|
||||
@@ -488,7 +488,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
url = 'http://www.example.com/base/path?a=b#h';
|
||||
|
||||
|
||||
it("should show fake browser info on load", function(){
|
||||
it("should show fake browser info on load", function() {
|
||||
expect(addressBar.getAttribute('value')).toBe(url);
|
||||
|
||||
expect(element(by.binding('$location.protocol()')).getText()).toBe('http');
|
||||
@@ -500,7 +500,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
|
||||
});
|
||||
|
||||
it("should change $location accordingly", function(){
|
||||
it("should change $location accordingly", function() {
|
||||
var navigation = element.all(by.css("#navigation a"));
|
||||
|
||||
navigation.get(0).click();
|
||||
@@ -565,9 +565,9 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
|
||||
.controller("LocationController", function($scope, $location) {
|
||||
$scope.$location = {};
|
||||
angular.forEach("protocol host port path search hash".split(" "), function(method){
|
||||
$scope.$location[method] = function(){
|
||||
var result = $location[method].call($location);
|
||||
angular.forEach("protocol host port path search hash".split(" "), function(method) {
|
||||
$scope.$location[method] = function() {
|
||||
var result = $location[method]();
|
||||
return angular.isObject(result) ? angular.toJson(result) : result;
|
||||
};
|
||||
});
|
||||
@@ -614,7 +614,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
.directive('ngAddressBar', function($browser, $timeout) {
|
||||
return {
|
||||
template: 'Address: <input id="addressBar" type="text" style="width: 400px" >',
|
||||
link: function(scope, element, attrs){
|
||||
link: function(scope, element, attrs) {
|
||||
var input = element.children("input"), delay;
|
||||
|
||||
input.on('keypress keyup keydown', function(event) {
|
||||
@@ -641,7 +641,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
var addressBar = element(by.css("#addressBar")),
|
||||
url = 'http://www.example.com/base/index.html#!/path?a=b#h';
|
||||
|
||||
it("should show fake browser info on load", function(){
|
||||
it("should show fake browser info on load", function() {
|
||||
expect(addressBar.getAttribute('value')).toBe(url);
|
||||
|
||||
expect(element(by.binding('$location.protocol()')).getText()).toBe('http');
|
||||
@@ -653,7 +653,7 @@ In these examples we use `<base href="/base/index.html" />`. The inputs represen
|
||||
|
||||
});
|
||||
|
||||
it("should change $location accordingly", function(){
|
||||
it("should change $location accordingly", function() {
|
||||
var navigation = element.all(by.css("#navigation a"));
|
||||
|
||||
navigation.get(0).click();
|
||||
@@ -735,7 +735,7 @@ ng.$rootScope.Scope scope} life-cycle. This means it's your responsibility to ca
|
||||
```js
|
||||
describe('serviceUnderTest', function() {
|
||||
beforeEach(module(function($provide) {
|
||||
$provide.factory('serviceUnderTest', function($location){
|
||||
$provide.factory('serviceUnderTest', function($location) {
|
||||
// whatever it does...
|
||||
});
|
||||
});
|
||||
@@ -843,7 +843,7 @@ to bind it to `ngModel`:
|
||||
<file name="script.js">
|
||||
angular.module('locationExample', [])
|
||||
.controller('LocationController', ['$scope', '$location', function($scope, $location) {
|
||||
$scope.locationPath = function (newLocation) {
|
||||
$scope.locationPath = function(newLocation) {
|
||||
return $location.path(newLocation);
|
||||
};
|
||||
}]);
|
||||
|
||||
@@ -74,20 +74,20 @@ attributes (if they have not been explicitly specified by the developer):
|
||||
</form>
|
||||
</file>
|
||||
<file name="script.js">
|
||||
var app = angular.module('ngAria_ngModelExample', ['ngAria'])
|
||||
.controller('formsController', function($scope){
|
||||
angular.module('ngAria_ngModelExample', ['ngAria'])
|
||||
.controller('formsController', function($scope) {
|
||||
$scope.checked = false;
|
||||
$scope.toggleCheckbox = function(){
|
||||
$scope.toggleCheckbox = function() {
|
||||
$scope.checked = !$scope.checked;
|
||||
};
|
||||
})
|
||||
.directive('someCheckbox', function(){
|
||||
.directive('someCheckbox', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
link: function($scope, $el, $attrs) {
|
||||
$el.on('keypress', function(event){
|
||||
$el.on('keypress', function(event) {
|
||||
event.preventDefault();
|
||||
if(event.keyCode === 32 || event.keyCode === 13){
|
||||
if (event.keyCode === 32 || event.keyCode === 13) {
|
||||
$scope.toggleCheckbox();
|
||||
$scope.$apply();
|
||||
}
|
||||
|
||||
@@ -230,8 +230,8 @@ You can see the complete application running below.
|
||||
|
||||
this.getHero = function(id) {
|
||||
return heroesPromise.then(function(heroes) {
|
||||
for(var i=0; i<heroes.length; i++) {
|
||||
if ( heroes[i].id == id) return heroes[i];
|
||||
for (var i = 0; i < heroes.length; i++) {
|
||||
if (heroes[i].id === id) return heroes[i];
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -250,7 +250,7 @@ You can see the complete application running below.
|
||||
};
|
||||
|
||||
this.isSelected = function(hero) {
|
||||
return (hero.id == selectedId);
|
||||
return (hero.id === selectedId);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -321,8 +321,8 @@ You can see the complete application running below.
|
||||
|
||||
this.getCrisis = function(id) {
|
||||
return crisesPromise.then(function(crises) {
|
||||
for(var i=0; i<crises.length; i++) {
|
||||
if ( crises[i].id == id) return crises[i];
|
||||
for (var i = 0; i < crises.length; i++) {
|
||||
if (crises[i].id === id) return crises[i];
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -342,7 +342,7 @@ You can see the complete application running below.
|
||||
};
|
||||
|
||||
this.isSelected = function(crisis) {
|
||||
return (crisis.id == selectedId);
|
||||
return (crisis.id === selectedId);
|
||||
};
|
||||
|
||||
this.onSelect = function(crisis) {
|
||||
@@ -725,8 +725,8 @@ function HeroService($q) {
|
||||
|
||||
this.getHero = function(id) {
|
||||
return heroesPromise.then(function(heroes) {
|
||||
for(var i=0; i<heroes.length; i++) {
|
||||
if ( heroes[i].id == id) return heroes[i];
|
||||
for (var i = 0; i < heroes.length; i++) {
|
||||
if (heroes[i].id === id) return heroes[i];
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -924,7 +924,7 @@ function HeroListComponent(heroService) {
|
||||
};
|
||||
|
||||
this.isSelected = function(hero) {
|
||||
return (hero.id == selectedId);
|
||||
return (hero.id === selectedId);
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ Components can be registered using the `.component()` method of an Angular modul
|
||||
|
||||
<example name="heroComponentSimple" module="heroApp">
|
||||
<file name="index.js">
|
||||
angular.module('heroApp', []).controller('mainCtrl', function() {
|
||||
angular.module('heroApp', []).controller('MainCtrl', function MainCtrl() {
|
||||
this.hero = {
|
||||
name: 'Spawn'
|
||||
};
|
||||
@@ -55,7 +55,7 @@ Components can be registered using the `.component()` method of an Angular modul
|
||||
</file>
|
||||
<file name="index.html">
|
||||
<!-- components match only elements -->
|
||||
<div ng-controller="mainCtrl as ctrl">
|
||||
<div ng-controller="MainCtrl as ctrl">
|
||||
<b>Hero</b><br>
|
||||
<hero-detail hero="ctrl.hero"></hero-detail>
|
||||
</div>
|
||||
@@ -200,7 +200,7 @@ it upwards to the heroList component, which updates the original data.
|
||||
|
||||
<example name="heroComponentTree" module="heroApp">
|
||||
<file name="index.js">
|
||||
var mode = angular.module('heroApp', []);
|
||||
angular.module('heroApp', []);
|
||||
</file>
|
||||
|
||||
<file name="heroList.js">
|
||||
@@ -388,7 +388,7 @@ Here is a tab pane example built from components:
|
||||
angular.module('docsTabsExample', [])
|
||||
.component('myTabs', {
|
||||
transclude: true,
|
||||
controller: function() {
|
||||
controller: function MyTabsController() {
|
||||
var panes = this.panes = [];
|
||||
this.select = function(pane) {
|
||||
angular.forEach(panes, function(pane) {
|
||||
|
||||
@@ -103,7 +103,7 @@ different currencies and also pay the invoice.
|
||||
<example name="guide-concepts-2" ng-app-included="true" >
|
||||
<file name="invoice1.js">
|
||||
angular.module('invoice1', [])
|
||||
.controller('InvoiceController', function() {
|
||||
.controller('InvoiceController', function InvoiceController() {
|
||||
this.qty = 1;
|
||||
this.cost = 2;
|
||||
this.inCurr = 'EUR';
|
||||
@@ -199,7 +199,7 @@ Let's refactor our example and move the currency conversion into a service in an
|
||||
EUR: 0.74,
|
||||
CNY: 6.09
|
||||
};
|
||||
var convert = function (amount, inCurr, outCurr) {
|
||||
var convert = function(amount, inCurr, outCurr) {
|
||||
return amount * usdToForeignRates[outCurr] / usdToForeignRates[inCurr];
|
||||
};
|
||||
|
||||
@@ -211,7 +211,7 @@ Let's refactor our example and move the currency conversion into a service in an
|
||||
</file>
|
||||
<file name="invoice2.js">
|
||||
angular.module('invoice2', ['finance2'])
|
||||
.controller('InvoiceController', ['currencyConverter', function(currencyConverter) {
|
||||
.controller('InvoiceController', ['currencyConverter', function InvoiceController(currencyConverter) {
|
||||
this.qty = 1;
|
||||
this.cost = 2;
|
||||
this.inCurr = 'EUR';
|
||||
@@ -277,7 +277,7 @@ Now that Angular knows of all the parts of the application, it needs to create t
|
||||
In the previous section we saw that controllers are created using a factory function.
|
||||
For services there are multiple ways to define their factory
|
||||
(see the {@link services service guide}).
|
||||
In the example above, we are using an anonymous function as the factory function for `currencyConverter` service.
|
||||
In the example above, we are using an anonymous function as the factory function for `currencyConverter` service.
|
||||
This function should return the `currencyConverter` service instance.
|
||||
|
||||
Back to the initial question: How does the `InvoiceController` get a reference to the `currencyConverter` function?
|
||||
@@ -303,7 +303,7 @@ The following example shows how this is done with Angular:
|
||||
<example name="guide-concepts-3" ng-app-included="true">
|
||||
<file name="invoice3.js">
|
||||
angular.module('invoice3', ['finance3'])
|
||||
.controller('InvoiceController', ['currencyConverter', function(currencyConverter) {
|
||||
.controller('InvoiceController', ['currencyConverter', function InvoiceController(currencyConverter) {
|
||||
this.qty = 1;
|
||||
this.cost = 2;
|
||||
this.inCurr = 'EUR';
|
||||
@@ -321,13 +321,13 @@ The following example shows how this is done with Angular:
|
||||
angular.module('finance3', [])
|
||||
.factory('currencyConverter', ['$http', function($http) {
|
||||
var YAHOO_FINANCE_URL_PATTERN =
|
||||
'//query.yahooapis.com/v1/public/yql?q=select * from '+
|
||||
'yahoo.finance.xchange where pair in ("PAIRS")&format=json&'+
|
||||
'//query.yahooapis.com/v1/public/yql?q=select * from ' +
|
||||
'yahoo.finance.xchange where pair in ("PAIRS")&format=json&' +
|
||||
'env=store://datatables.org/alltableswithkeys&callback=JSON_CALLBACK';
|
||||
var currencies = ['USD', 'EUR', 'CNY'];
|
||||
var usdToForeignRates = {};
|
||||
|
||||
var convert = function (amount, inCurr, outCurr) {
|
||||
var convert = function(amount, inCurr, outCurr) {
|
||||
return amount * usdToForeignRates[outCurr] / usdToForeignRates[inCurr];
|
||||
};
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ those conditions.
|
||||
<file name="script.js">
|
||||
angular.module('urlDecorator', []).
|
||||
|
||||
controller('Ctrl', ['$scope', function ($scope) {
|
||||
controller('Ctrl', ['$scope', function($scope) {
|
||||
$scope.id = 3;
|
||||
$scope.warnCount = 0; // for testing
|
||||
}]).
|
||||
@@ -336,8 +336,8 @@ those conditions.
|
||||
var exps = matchExpressions(originalExp);
|
||||
|
||||
// create and store the getters using $parse
|
||||
var getters = exps.map(function(el) {
|
||||
if (el) return $parse(el);
|
||||
var getters = exps.map(function(exp) {
|
||||
return exp && $parse(exp);
|
||||
});
|
||||
|
||||
return function newLinkFn(scope, elem, attr) {
|
||||
@@ -388,13 +388,13 @@ those conditions.
|
||||
<file name="index.html">
|
||||
<div ng-controller="Ctrl">
|
||||
<a ng-href="/products/{{ id }}/view" id="id3">View Product {{ id }}</a>
|
||||
- <strong>id == 3</strong>, so no warning<br>
|
||||
- <strong>id === 3</strong>, so no warning<br>
|
||||
<a ng-href="/products/{{ id + 5 }}/view" id="id8">View Product {{ id + 5 }}</a>
|
||||
- <strong>id + 5 == 8</strong>, so no warning<br>
|
||||
- <strong>id + 5 === 8</strong>, so no warning<br>
|
||||
<a ng-href="/products/{{ someOtherId }}/view" id="someOtherId">View Product {{ someOtherId }}</a>
|
||||
- <strong style="background-color: #ffff00;">someOtherId == undefined</strong>, so warn<br>
|
||||
- <strong style="background-color: #ffff00;">someOtherId === undefined</strong>, so warn<br>
|
||||
<a ng-href="/products/{{ someOtherId + 5 }}/view" id="someOtherId5">View Product {{ someOtherId + 5 }}</a>
|
||||
- <strong>someOtherId + 5 == 5</strong>, so no warning<br>
|
||||
- <strong>someOtherId + 5 === 5</strong>, so no warning<br>
|
||||
<div>Warn Count: {{ warnCount }}</div>
|
||||
</div>
|
||||
</file>
|
||||
@@ -432,7 +432,7 @@ changed (that never happens) and we need all of our default dates to be `'shortD
|
||||
<file name="script.js">
|
||||
angular.module('filterDecorator', []).
|
||||
|
||||
controller('Ctrl', ['$scope', function ($scope) {
|
||||
controller('Ctrl', ['$scope', function($scope) {
|
||||
$scope.genesis = new Date(2010, 0, 5);
|
||||
$scope.ngConf = new Date(2016, 4, 4);
|
||||
}]).
|
||||
@@ -480,7 +480,7 @@ changed (that never happens) and we need all of our default dates to be `'shortD
|
||||
|
||||
it('should still allow dates to be formatted', function() {
|
||||
expect(element(by.id('ngConf')).getText())
|
||||
.toMatch(/ng-conf 2016 with full date format\: [A-Za-z]+, [A-Za-z]+ \d{1,2}, \d{4}/);
|
||||
.toMatch(/ng-conf 2016 with full date format: [A-Za-z]+, [A-Za-z]+ \d{1,2}, \d{4}/);
|
||||
});
|
||||
</file>
|
||||
</example>
|
||||
|
||||
@@ -269,8 +269,8 @@ function, since the template is requested before the scope is initialized.
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
templateUrl: function(elem, attr){
|
||||
return 'customer-'+attr.type+'.html';
|
||||
templateUrl: function(elem, attr) {
|
||||
return 'customer-' + attr.type + '.html';
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -676,7 +676,7 @@ that redefines `name` as `Jeff`. What do you think the `{{name}}` binding will r
|
||||
transclude: true,
|
||||
scope: {},
|
||||
templateUrl: 'my-dialog.html',
|
||||
link: function (scope) {
|
||||
link: function(scope) {
|
||||
scope.name = 'Jeff';
|
||||
}
|
||||
};
|
||||
@@ -720,10 +720,10 @@ own behavior to it.
|
||||
.controller('Controller', ['$scope', '$timeout', function($scope, $timeout) {
|
||||
$scope.name = 'Tobias';
|
||||
$scope.message = '';
|
||||
$scope.hideDialog = function (message) {
|
||||
$scope.hideDialog = function(message) {
|
||||
$scope.message = message;
|
||||
$scope.dialogIsHidden = true;
|
||||
$timeout(function () {
|
||||
$timeout(function() {
|
||||
$scope.message = '';
|
||||
$scope.dialogIsHidden = false;
|
||||
}, 2000);
|
||||
@@ -856,7 +856,7 @@ to which tab is active.
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {},
|
||||
controller: ['$scope', function($scope) {
|
||||
controller: ['$scope', function MyTabsController($scope) {
|
||||
var panes = $scope.panes = [];
|
||||
|
||||
$scope.select = function(pane) {
|
||||
|
||||
@@ -144,7 +144,7 @@ identifier `$locals`.
|
||||
|
||||
<file name="protractor.js" type="protractor">
|
||||
it('should calculate expression in binding', function() {
|
||||
if (browser.params.browser == 'safari') {
|
||||
if (browser.params.browser === 'safari') {
|
||||
// Safari can't handle dialogs.
|
||||
return;
|
||||
}
|
||||
@@ -221,8 +221,8 @@ similar jqLite object.
|
||||
* return a copy of an object with only non-object keys
|
||||
* we need this to avoid circular references
|
||||
*/
|
||||
function simpleKeys (original) {
|
||||
return Object.keys(original).reduce(function (obj, key) {
|
||||
function simpleKeys(original) {
|
||||
return Object.keys(original).reduce(function(obj, key) {
|
||||
obj[key] = typeof original[key] === 'object' ? '{ ... }' : original[key];
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
@@ -85,7 +85,7 @@ or the filter expression is changed).
|
||||
|
||||
<file name="script.js">
|
||||
angular.module('FilterInControllerModule', []).
|
||||
controller('FilterController', ['filterFilter', function(filterFilter) {
|
||||
controller('FilterController', ['filterFilter', function FilterController(filterFilter) {
|
||||
this.array = [
|
||||
{name: 'Tobias'},
|
||||
{name: 'Jeff'},
|
||||
|
||||
@@ -225,10 +225,10 @@ You may find it helpful to play with the following example as you read the expla
|
||||
}
|
||||
|
||||
angular.module('messageFormatExample', ['ngMessageFormat'])
|
||||
.controller('ckCtrl', function ($scope, $injector, $parse) {
|
||||
var people = [ new Person("Alice", "female"),
|
||||
new Person("Bob", "male"),
|
||||
new Person("Charlie", "male") ];
|
||||
.controller('ckCtrl', function($scope, $injector, $parse) {
|
||||
var people = [new Person("Alice", "female"),
|
||||
new Person("Bob", "male"),
|
||||
new Person("Charlie", "male")];
|
||||
|
||||
$scope.sender = new Person("Harry Potter", "male");
|
||||
$scope.recipients = people.slice();
|
||||
|
||||
@@ -965,7 +965,7 @@ Before:
|
||||
|
||||
```js
|
||||
$scope.resetWithCancel = function (e) {
|
||||
if (e.keyCode == 27) {
|
||||
if (e.keyCode === 27) {
|
||||
$scope.myForm.myInput1.$cancelUpdate();
|
||||
$scope.myValue = '';
|
||||
}
|
||||
@@ -976,7 +976,7 @@ After:
|
||||
|
||||
```js
|
||||
$scope.resetWithCancel = function (e) {
|
||||
if (e.keyCode == 27) {
|
||||
if (e.keyCode === 27) {
|
||||
$scope.myForm.myInput1.$rollbackViewValue();
|
||||
$scope.myValue = '';
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ The above is a suggestion. Tailor it to your needs.
|
||||
user.load('World');
|
||||
})
|
||||
|
||||
.controller('XmplController', function($scope, greeter, user){
|
||||
.controller('XmplController', function($scope, greeter, user) {
|
||||
$scope.greeting = greeter.greet(user.name);
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ subsystem takes care of the rest.
|
||||
<file name="script.js">
|
||||
angular.
|
||||
module('myServiceModule', []).
|
||||
controller('MyController', ['$scope', 'notify', function ($scope, notify) {
|
||||
controller('MyController', ['$scope', 'notify', function($scope, notify) {
|
||||
$scope.callNotify = function(msg) {
|
||||
notify(msg);
|
||||
};
|
||||
@@ -52,7 +52,7 @@ subsystem takes care of the rest.
|
||||
var msgs = [];
|
||||
return function(msg) {
|
||||
msgs.push(msg);
|
||||
if (msgs.length == 3) {
|
||||
if (msgs.length === 3) {
|
||||
win.alert(msgs.join("\n"));
|
||||
msgs = [];
|
||||
}
|
||||
|
||||
+54
-39
@@ -1,13 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var fs = require('fs');
|
||||
var _ = require('lodash');
|
||||
var stripJsonComments = require('strip-json-comments');
|
||||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
var log = require('gulp-util').log;
|
||||
var concat = require('gulp-concat');
|
||||
var jshint = require('gulp-jshint');
|
||||
var eslint = require('gulp-eslint');
|
||||
var bower = require('bower');
|
||||
var Dgeni = require('dgeni');
|
||||
var merge = require('event-stream').merge;
|
||||
@@ -29,28 +25,31 @@ var ignoredFiles = '!src/angular.bind.js';
|
||||
var assets = 'app/assets/**/*';
|
||||
|
||||
|
||||
var getJshintConfig = function(filepath) {
|
||||
return JSON.parse(stripJsonComments(fs.readFileSync(filepath, {encoding: 'utf-8'})));
|
||||
};
|
||||
|
||||
var getMergedJshintConfig = function(filepath) {
|
||||
// "extends" doesn't work in configuration passed by an object, we need to do the extending ourselves.
|
||||
var config = getJshintConfig(filepath);
|
||||
var baseConfig = getJshintConfig('../.jshintrc-base');
|
||||
_.merge(config, baseConfig);
|
||||
delete config.extends;
|
||||
|
||||
// Examples don't run in strict mode; accept that for now.
|
||||
config.strict = false;
|
||||
|
||||
return config;
|
||||
var getMergedEslintConfig = function(filepath) {
|
||||
return {
|
||||
configFile: filepath,
|
||||
baseConfig: '../.eslintrc.json',
|
||||
rules: {
|
||||
// Examples don't run in strict mode; accept that for now.
|
||||
strict: 'off',
|
||||
// Generated examples may miss the final EOL; ignore that.
|
||||
'eol-last': 'off',
|
||||
// While alerts would be bad to have in the library or test code,
|
||||
// they're perfectly fine in examples.
|
||||
'no-alert': 'off',
|
||||
// some dgeni-packages templates generate whitespace-only lines
|
||||
'no-trailing-spaces': ['error', { 'skipBlankLines': true }]
|
||||
},
|
||||
ignore: false,
|
||||
useEslintrc: false
|
||||
};
|
||||
};
|
||||
|
||||
var copyComponent = function(component, pattern, sourceFolder, packageFile) {
|
||||
pattern = pattern || '/**/*';
|
||||
sourceFolder = sourceFolder || bowerFolder;
|
||||
packageFile = packageFile || 'bower.json';
|
||||
var version = require(path.resolve(sourceFolder,component,packageFile)).version;
|
||||
var version = require(path.resolve(sourceFolder, component, packageFile)).version;
|
||||
return gulp
|
||||
.src(sourceFolder + '/' + component + pattern)
|
||||
.pipe(gulp.dest(outputFolder + '/components/' + component + '-' + version));
|
||||
@@ -58,7 +57,7 @@ var copyComponent = function(component, pattern, sourceFolder, packageFile) {
|
||||
|
||||
gulp.task('bower', function() {
|
||||
var bowerTask = bower.commands.install();
|
||||
bowerTask.on('log', function (result) {
|
||||
bowerTask.on('log', function(result) {
|
||||
log('bower:', result.id, result.data.endpoint.name);
|
||||
});
|
||||
bowerTask.on('error', function(error) {
|
||||
@@ -101,7 +100,7 @@ gulp.task('assets', ['bower'], function() {
|
||||
})),
|
||||
copyComponent('bootstrap', '/dist/**/*'),
|
||||
copyComponent('open-sans-fontface'),
|
||||
copyComponent('lunr.js','/*.js'),
|
||||
copyComponent('lunr.js', '/*.js'),
|
||||
copyComponent('google-code-prettify'),
|
||||
copyComponent('jquery', '/dist/*.js'),
|
||||
copyComponent('marked', '/**/*.js', '../node_modules', 'package.json')
|
||||
@@ -116,35 +115,51 @@ gulp.task('doc-gen', ['bower'], function() {
|
||||
});
|
||||
});
|
||||
|
||||
// JSHint the example and protractor test files
|
||||
gulp.task('jshint', ['doc-gen'], function() {
|
||||
var examplesConfig = getMergedJshintConfig('../docs/app/test/.jshintrc');
|
||||
// Some tests use `alert` which is not assumed to be available even with `"browser": true`.
|
||||
examplesConfig.globals.alert = false;
|
||||
|
||||
var protractorConfig = getMergedJshintConfig('../docs/app/e2e/.jshintrc');
|
||||
// Lint the example and protractor test files
|
||||
gulp.task('eslint', ['doc-gen'], function() {
|
||||
var examplesConfig = getMergedEslintConfig('../docs/app/test/.eslintrc.json');
|
||||
// While in source we don't want to assume the browser environment so that we're
|
||||
// compatible with non-browser window implementations like jsdom, it's not necessary
|
||||
// in examples and may look weird to casual readers.
|
||||
examplesConfig.envs = ['browser'];
|
||||
|
||||
var protractorConfig = getMergedEslintConfig('../docs/app/e2e/.eslintrc.json');
|
||||
protractorConfig.rules['no-unused-vars'] = ['error', {
|
||||
vars: 'local',
|
||||
args: 'none',
|
||||
// This variable is declared in code generated by dgeni-packages
|
||||
// and not always used.
|
||||
varsIgnorePattern: '^rootEl$'
|
||||
}];
|
||||
|
||||
return merge(
|
||||
gulp.src([
|
||||
outputFolder + '/examples/**/*.js',
|
||||
'!' + outputFolder + '/examples/**/protractor.js',
|
||||
'!' + outputFolder + '/examples/**/protractor.js'
|
||||
])
|
||||
.pipe(jshint(examplesConfig))
|
||||
.pipe(jshint.reporter('jshint-stylish'))
|
||||
.pipe(jshint.reporter('fail')),
|
||||
// eslint() attaches the lint output to the "eslint" property
|
||||
// of the file object so it can be used by other modules.
|
||||
.pipe(eslint(examplesConfig))
|
||||
// eslint.format() outputs the lint results to the console.
|
||||
// Alternatively use eslint.formatEach() (see Docs).
|
||||
.pipe(eslint.format())
|
||||
// To have the process exit with an error code (1) on
|
||||
// lint error, return the stream and pipe to failAfterError last.
|
||||
.pipe(eslint.failAfterError()),
|
||||
gulp.src([
|
||||
outputFolder + '/ptore2e/**/*.js',
|
||||
outputFolder + '/examples/**/protractor.js',
|
||||
outputFolder + '/examples/**/protractor.js'
|
||||
])
|
||||
.pipe(jshint(protractorConfig))
|
||||
.pipe(jshint.reporter('jshint-stylish'))
|
||||
.pipe(jshint.reporter('fail'))
|
||||
.pipe(eslint(protractorConfig))
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError())
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// The default task that will be run if no task is supplied
|
||||
gulp.task('default', ['assets', 'doc-gen', 'build-app', 'jshint']);
|
||||
gulp.task('default', ['assets', 'doc-gen', 'build-app', 'eslint']);
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch([src, ignoredFiles, assets], ['assets', 'build-app']);
|
||||
|
||||
@@ -17,16 +17,16 @@ var collections = {
|
||||
console.log('Google Docs...');
|
||||
|
||||
var flag = process && process.argv[2];
|
||||
if (flag == '--login') {
|
||||
if (flag === '--login') {
|
||||
var username = process.argv[3];
|
||||
if (username) {
|
||||
askPassword(function(password){
|
||||
askPassword(function(password) {
|
||||
login(username, password);
|
||||
});
|
||||
} else {
|
||||
console.log('Missing username!');
|
||||
}
|
||||
} else if (flag == '--fetch') {
|
||||
} else if (flag === '--fetch') {
|
||||
var collection = process.argv[3];
|
||||
if (collection) {
|
||||
fetch(collection, collections[collection]);
|
||||
@@ -46,7 +46,7 @@ function help() {
|
||||
}
|
||||
|
||||
|
||||
function fetch(collection, url){
|
||||
function fetch(collection, url) {
|
||||
console.log('fetching a list of docs in collection ' + collection + '...');
|
||||
request('GET', url, {
|
||||
headers: {
|
||||
@@ -54,10 +54,10 @@ function fetch(collection, url){
|
||||
'Authorization': 'GoogleLogin auth=' + getAuthToken()
|
||||
}
|
||||
},
|
||||
function(chunk){
|
||||
function(chunk) {
|
||||
var entries = chunk.split('<entry');
|
||||
entries.shift();
|
||||
entries.forEach(function(entry){
|
||||
entries.forEach(function(entry) {
|
||||
var title = entry.match(/<title>(.*?)<\/title>/)[1];
|
||||
if (title.match(/\.ngdoc$/)) {
|
||||
var exportUrl = entry.match(/<content type='text\/html' src='(.*?)'\/>/)[1];
|
||||
@@ -77,7 +77,7 @@ function download(collection, name, url) {
|
||||
'Authorization': 'GoogleLogin auth=' + getAuthToken()
|
||||
}
|
||||
},
|
||||
function(data){
|
||||
function(data) {
|
||||
data = data.replace('\ufeff', '');
|
||||
data = data.replace(/\r\n/mg, '\n');
|
||||
|
||||
@@ -111,7 +111,7 @@ function download(collection, name, url) {
|
||||
* -d service=writely
|
||||
* -d Gdata-version=3.0 | cut -d "=" -f 2)
|
||||
*/
|
||||
function login(username, password){
|
||||
function login(username, password) {
|
||||
request('POST', 'https://www.google.com/accounts/ClientLogin',
|
||||
{
|
||||
data: {
|
||||
@@ -125,11 +125,11 @@ function login(username, password){
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
},
|
||||
function(chunk){
|
||||
function(chunk) {
|
||||
var token;
|
||||
chunk.split('\n').forEach(function(line){
|
||||
chunk.split('\n').forEach(function(line) {
|
||||
var parts = line.split('=');
|
||||
if (parts[0] == 'Auth') {
|
||||
if (parts[0] === 'Auth') {
|
||||
token = parts[1];
|
||||
}
|
||||
});
|
||||
@@ -161,16 +161,16 @@ function request(method, url, options, response) {
|
||||
port: (url[1] ? 443 : 80),
|
||||
path: url[3],
|
||||
method: method
|
||||
}, function(res){
|
||||
}, function(res) {
|
||||
var data;
|
||||
switch (res.statusCode) {
|
||||
case 200:
|
||||
data = [];
|
||||
res.setEncoding('utf8');
|
||||
res.on('end', function () { response(data.join('')); });
|
||||
res.on('close', function () { response(data.join('')); }); // https
|
||||
res.on('data', function (chunk) { data.push(chunk); });
|
||||
res.on('error', function (e) { console.log(e); });
|
||||
res.on('end', function() { response(data.join('')); });
|
||||
res.on('close', function() { response(data.join('')); }); // https
|
||||
res.on('data', function(chunk) { data.push(chunk); });
|
||||
res.on('error', function(e) { console.log(e); });
|
||||
break;
|
||||
case 401:
|
||||
console.log('Error: Login credentials expired! Please login.');
|
||||
@@ -182,13 +182,13 @@ function request(method, url, options, response) {
|
||||
console.log('REQUEST POST: ', options.data);
|
||||
console.log('REQUEST HEADERS: ', options.headers);
|
||||
console.log('RESPONSE HEADERS: ', res.headers);
|
||||
res.on('end', function (){ console.log('BODY: ', data.join('')); });
|
||||
res.on('close', function (){ console.log('BODY: ', data.join('')); }); // https
|
||||
res.on('data', function (chunk) { data.push(chunk); });
|
||||
res.on('error', function (e){ console.log(e); });
|
||||
res.on('end', function() { console.log('BODY: ', data.join('')); });
|
||||
res.on('close', function() { console.log('BODY: ', data.join('')); }); // https
|
||||
res.on('data', function(chunk) { data.push(chunk); });
|
||||
res.on('error', function(e) { console.log(e); });
|
||||
}
|
||||
});
|
||||
for(var header in options.headers) {
|
||||
for (var header in options.headers) {
|
||||
req.setHeader(header, options.headers[header]);
|
||||
}
|
||||
if (options.data)
|
||||
@@ -201,7 +201,7 @@ function request(method, url, options, response) {
|
||||
|
||||
function encodeData(obj) {
|
||||
var pairs = [];
|
||||
for(var key in obj) {
|
||||
for (var key in obj) {
|
||||
pairs.push(key + '=' + obj[key]);
|
||||
}
|
||||
return pairs.join('&') + '\n';
|
||||
@@ -247,7 +247,7 @@ function reflow(text, margin) {
|
||||
reflowLine = '';
|
||||
col = 0;
|
||||
}
|
||||
line.replace(/\s*\S*\s*/g, function(chunk){
|
||||
line.replace(/\s*\S*\s*/g, function(chunk) {
|
||||
if (col + chunk.length > margin) flush();
|
||||
reflowLine += chunk;
|
||||
col += chunk.length;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../.eslintrc-node.json",
|
||||
|
||||
"env": {
|
||||
"jasmine": true,
|
||||
"protractor": true
|
||||
},
|
||||
|
||||
"globals": {
|
||||
"binding": false,
|
||||
"input": false
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe("localized filters", function() {
|
||||
describe("es locale", function() {
|
||||
beforeEach(function() {
|
||||
@@ -90,7 +92,7 @@ describe("localized filters", function() {
|
||||
input('person2').enter('Vojta');
|
||||
expect(element('ng-pluralize:last').html()).toBe('Igor and Vojta are viewing!');
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("sk locale", function() {
|
||||
@@ -129,7 +131,7 @@ describe("localized filters", function() {
|
||||
|
||||
it('should show pluralized strings with correct data-binding', function() {
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("zh locale", function() {
|
||||
@@ -180,6 +182,6 @@ describe("localized filters", function() {
|
||||
input('person2').enter('一哥');
|
||||
expect(element('ng-pluralize:last').html()).toBe('彭迪 和 一哥 在浏览该文件!');
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../.eslintrc-node.json",
|
||||
|
||||
"env": {
|
||||
"jasmine": true
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var closureI18nExtractor = require('../src/closureI18nExtractor.js');
|
||||
var converter = require('../src/converter.js');
|
||||
findLocaleId = closureI18nExtractor.findLocaleId;
|
||||
extractNumberSymbols = closureI18nExtractor.extractNumberSymbols;
|
||||
extractCurrencySymbols = closureI18nExtractor.extractCurrencySymbols;
|
||||
extractDateTimeSymbols = closureI18nExtractor.extractDateTimeSymbols;
|
||||
outputLocale = closureI18nExtractor.outputLocale;
|
||||
var findLocaleId = closureI18nExtractor.findLocaleId;
|
||||
var extractNumberSymbols = closureI18nExtractor.extractNumberSymbols;
|
||||
var extractCurrencySymbols = closureI18nExtractor.extractCurrencySymbols;
|
||||
var extractDateTimeSymbols = closureI18nExtractor.extractDateTimeSymbols;
|
||||
var outputLocale = closureI18nExtractor.outputLocale;
|
||||
|
||||
|
||||
function newTestLocaleInfo() {
|
||||
@@ -59,21 +61,29 @@ function newTestLocaleInfo() {
|
||||
}
|
||||
|
||||
|
||||
describe("findLocaleId", function() {
|
||||
it("should find the id from numbers", function() {
|
||||
expect(findLocaleId("NumberFormatSymbols_en_GB", "num")).toEqual("en_GB");
|
||||
describe('findLocaleId', function() {
|
||||
it('should find the id from numbers', function() {
|
||||
expect(findLocaleId('NumberFormatSymbols_en_GB', 'num')).toEqual('en_GB');
|
||||
});
|
||||
|
||||
|
||||
it("should find the id from datetime", function() {
|
||||
expect(findLocaleId("DateTimeSymbols_en_ISO", "datetime")).toEqual("en_ISO");
|
||||
it('should find the id from datetime', function() {
|
||||
expect(findLocaleId('DateTimeSymbols_en', 'datetime')).toBe('en');
|
||||
expect(findLocaleId('DateTimeSymbols_en_ISO', 'datetime')).toEqual('en_ISO');
|
||||
});
|
||||
|
||||
it('should not find localeId if data is missing', function() {
|
||||
expect(findLocaleId('', 'num')).toBeUndefined();
|
||||
expect(findLocaleId('aa', 'datetime')).toBeUndefined();
|
||||
expect(findLocaleId('aa', 'randomType')).toBeUndefined();
|
||||
expect(findLocaleId('NumberFormatSymbols_en', 'datetime')).toBeUndefined();
|
||||
expect(findLocaleId('DateTimeSymbols_en', 'num')).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should throw an error otherwise", function() {
|
||||
it('should throw an error otherwise', function() {
|
||||
expect(function() {
|
||||
findLocaleId("str", "otherwise")
|
||||
}).toThrowError("unknown type in findLocaleId: otherwise");
|
||||
findLocaleId('str', 'otherwise');
|
||||
}).toThrowError('unknown type in findLocaleId: otherwise');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,7 +127,7 @@ describe("extractNumberSymbols", function() {
|
||||
expect(localeInfo).toEqual({
|
||||
'en_GB': { NUMBER_FORMATS: expectedNumberFormats }
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("extractCurrencySymbols", function() {
|
||||
@@ -131,7 +141,6 @@ describe("extractCurrencySymbols", function() {
|
||||
"};"
|
||||
].join('\n');
|
||||
|
||||
var localeInfo = {};
|
||||
var currencySymbols = extractCurrencySymbols(CONTENT);
|
||||
expect(currencySymbols.GBP).toEqual([2, '£', 'GB£']);
|
||||
expect(currencySymbols.AOA).toEqual([2, 'Kz', 'Kz']);
|
||||
@@ -215,7 +224,6 @@ describe("extractDateTimeSymbols", function() {
|
||||
|
||||
describe("pluralExtractor", function() {
|
||||
it("should output PLURAL_CAT in the output string code", function() {
|
||||
var localeIds = ["fr_CA"];
|
||||
var content = (
|
||||
"goog.provide('goog.i18n.pluralRules');\n" +
|
||||
"\n" +
|
||||
@@ -248,21 +256,24 @@ describe("pluralExtractor", function() {
|
||||
// Ref: closureI18nExtractor.pluralExtractor.
|
||||
pluralCat = pluralCat.replace(/^@@|@@$/g, '');
|
||||
// pluralCat requires these constants to exist.
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
var PLURAL_CATEGORY = {
|
||||
ZERO: "zero", ONE: "one", TWO: "two",
|
||||
FEW: "few", MANY: "many", OTHER: "other"
|
||||
};
|
||||
// Obtain the function by evaluating the source text.
|
||||
// eslint-disable-next-line no-eval
|
||||
pluralCat = eval("(" + pluralCat + ")");
|
||||
// Confirm some expectations for pluralCat in fr_CA.
|
||||
expect(pluralCat(0)).toEqual("one");
|
||||
expect(pluralCat(3)).toEqual("other");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("serializeContent", function() {
|
||||
it("should not make any modifications to the content of the locale", function() {
|
||||
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo());
|
||||
// eslint-disable-next-line no-eval
|
||||
expect(eval("(" + serializedContent + ")")).toEqual(newTestLocaleInfo());
|
||||
});
|
||||
it("should only have ascii characters", function() {
|
||||
@@ -271,6 +282,7 @@ describe("serializeContent", function() {
|
||||
});
|
||||
it("should not transform arrays into objects", function() {
|
||||
var serializedContent = closureI18nExtractor.serializeContent(newTestLocaleInfo().fr_CA);
|
||||
// eslint-disable-next-line no-eval
|
||||
var deserializedLocale = eval("(" + serializedContent + ")");
|
||||
expect(deserializedLocale.DATETIME_FORMATS.MONTH.length).not.toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var converter = require('../src/converter.js');
|
||||
|
||||
describe("convertNumberData", function() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var parsePattern = require('../src/parser.js').parsePattern;
|
||||
|
||||
describe('parsePattern', function() {
|
||||
@@ -22,7 +24,7 @@ describe('parsePattern', function() {
|
||||
parseAndExpect('#,##0.###', '', '-', '', '', 1, 0, 3, 3, 3);
|
||||
parseAndExpect('#,##0.###;#,##0.###-', '', '', '', '-', 1, 0, 3, 3, 3);
|
||||
parseAndExpect('#,##,##0.###', '', '-', '', '', 1, 0, 3, 2, 3);
|
||||
parseAndExpect("#,##0.###;\'\u202A\'-#,##0.###\'\u202C\'",
|
||||
parseAndExpect("#,##0.###;'\u202A'-#,##0.###'\u202C'",
|
||||
'', '\u202A-', '', '\u202C', 1, 0, 3, 3, 3);
|
||||
parseAndExpect('#0.###;#0.###-', '', '', '', '-', 1, 0, 3, 0, 0);
|
||||
|
||||
@@ -31,7 +33,7 @@ describe('parsePattern', function() {
|
||||
it('should parse CURRENCY patterns', function() {
|
||||
// all CURRENCY patterns from closure
|
||||
parseAndExpect('#,##0.00 \u00A4', '', '-', ' \u00A4', ' \u00A4', 1, 2, 2, 3, 3);
|
||||
parseAndExpect("#,##0.00\u00A0\u00A4;\'\u202A\'-#,##0.00\'\u202C\'\u00A0\u00A4",
|
||||
parseAndExpect("#,##0.00\u00A0\u00A4;'\u202A'-#,##0.00'\u202C'\u00A0\u00A4",
|
||||
'', '\u202A-', '\u00A0\u00A4', '\u202C\u00A0\u00A4', 1, 2, 2, 3, 3);
|
||||
parseAndExpect('#,##0.00 \u00A4;(#,##0.00 \u00A4)',
|
||||
'', '(', ' \u00A4', ' \u00A4)', 1, 2, 2, 3, 3);
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
var util = require('../src/util.js');
|
||||
|
||||
describe('findLocaleId', function() {
|
||||
it('should find localeId', function() {
|
||||
expect(util.findLocaleId('', 'num')).toBeUndefined();
|
||||
expect(util.findLocaleId('aa', 'datetime')).toBeUndefined();
|
||||
expect(util.findLocaleId('aa', 'randomType')).toBeUndefined();
|
||||
expect(util.findLocaleId('NumberFormatSymbols_en', 'datetime')).toBeUndefined();
|
||||
expect(util.findLocaleId('DateTimeSymbols_en', 'num')).toBeUndefined();
|
||||
|
||||
expect(util.findLocaleId('DateTimeSymbols_en', 'datetime')).toBe('en');
|
||||
expect(util.findLocaleId('NumberFormatSymbols_en_US', 'num')).toBe('en_US');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../.eslintrc-node.json"
|
||||
}
|
||||
@@ -20,7 +20,7 @@ function findLocaleId(str, type) {
|
||||
return (str.match(/^NumberFormatSymbols_(.+)$/) || [])[1];
|
||||
}
|
||||
|
||||
if (type != 'datetime') { throw new Error('unknown type in findLocaleId: ' + type); }
|
||||
if (type !== 'datetime') { throw new Error('unknown type in findLocaleId: ' + type); }
|
||||
|
||||
return (str.match(/^DateTimeSymbols_(.+)$/) || [])[1];
|
||||
}
|
||||
@@ -36,6 +36,7 @@ function getInfoForLocale(localeInfo, localeID) {
|
||||
|
||||
function extractNumberSymbols(content, localeInfo, currencySymbols) {
|
||||
//eval script in the current context so that we get access to all the symbols
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(content.toString());
|
||||
for (var propName in goog.i18n) {
|
||||
var localeID = findLocaleId(propName, 'num');
|
||||
@@ -49,6 +50,7 @@ function extractNumberSymbols(content, localeInfo, currencySymbols) {
|
||||
|
||||
function extractCurrencySymbols(content) {
|
||||
//eval script in the current context so that we get access to all the symbols
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(content.toString());
|
||||
// var currencySymbols = goog.i18n.currency.CurrencyInfo;
|
||||
// currencySymbols.__proto__ = goog.i18n.currency.CurrencyInfoTier2;
|
||||
@@ -58,12 +60,13 @@ function extractCurrencySymbols(content) {
|
||||
|
||||
function extractDateTimeSymbols(content, localeInfo) {
|
||||
//eval script in the current context so that we get access to all the symbols
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(content.toString());
|
||||
for (var propName in goog.i18n) {
|
||||
var localeID = findLocaleId(propName, 'datetime');
|
||||
if (localeID) {
|
||||
var info = getInfoForLocale(localeInfo, localeID);
|
||||
localeInfo[localeID].DATETIME_FORMATS =
|
||||
info.DATETIME_FORMATS =
|
||||
converter.convertDatetimeData(goog.i18n[propName]);
|
||||
}
|
||||
}
|
||||
@@ -78,6 +81,7 @@ function pluralExtractor(content, localeInfo) {
|
||||
// e.g. plural rules for en_SG is the same as those for en.
|
||||
goog.LOCALE = localeIds[i].match(/[^_]+/)[0];
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
eval(contentText);
|
||||
} catch (e) {
|
||||
console.log("Error in eval(contentText): " + e.stack);
|
||||
@@ -121,7 +125,7 @@ function canonicalizeForJsonStringify(unused_key, object) {
|
||||
// 2. https://code.google.com/p/v8/issues/detail?id=164
|
||||
// ECMA-262 does not specify enumeration order. The de facto standard
|
||||
// is to match insertion order, which V8 also does ...
|
||||
if (typeof object != "object" || Object.prototype.toString.apply(object) === '[object Array]') {
|
||||
if (typeof object !== "object" || Object.prototype.toString.apply(object) === '[object Array]') {
|
||||
return object;
|
||||
}
|
||||
var result = {};
|
||||
|
||||
@@ -3,14 +3,8 @@
|
||||
|
||||
var Q = require('q'),
|
||||
qfs = require('q-io/fs'),
|
||||
converter = require('./converter.js'),
|
||||
util = require('./util.js'),
|
||||
closureI18nExtractor = require('./closureI18nExtractor.js'),
|
||||
localeInfo = {},
|
||||
currencySymbols,
|
||||
goog = { provide: function() {},
|
||||
require: function() {},
|
||||
i18n: {currency: {}, pluralRules: {}} };
|
||||
localeInfo = {};
|
||||
|
||||
|
||||
var NG_LOCALE_DIR = '../src/ngLocale/';
|
||||
@@ -77,7 +71,7 @@ function writeLocaleFiles() {
|
||||
var content = closureI18nExtractor.outputLocale(localeInfo, localeID);
|
||||
if (!content) return;
|
||||
var correctedLocaleId = closureI18nExtractor.correctedLocaleId(localeID);
|
||||
var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js'
|
||||
var filename = NG_LOCALE_DIR + 'angular-locale_' + correctedLocaleId + '.js';
|
||||
console.log('Writing ' + filename);
|
||||
return qfs.write(filename, content)
|
||||
.then(function() {
|
||||
@@ -95,7 +89,8 @@ function writeLocaleFiles() {
|
||||
function createFolder(folder) {
|
||||
return qfs.isDirectory(folder).then(function(isDir) {
|
||||
if (!isDir) return qfs.makeDirectory(folder).then(function() {
|
||||
console.log('Created directory %j', folder); });
|
||||
console.log('Created directory %j', folder);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* after obtaining data from closure files, use converter to massage the data into the formats
|
||||
* we want
|
||||
@@ -10,24 +12,22 @@ var parsePattern = require('./parser').parsePattern;
|
||||
|
||||
|
||||
function convertNumberData(dataObj, currencySymbols) {
|
||||
var numberFormats = {},
|
||||
|
||||
numberFormats = {
|
||||
var numberFormats = {
|
||||
DECIMAL_SEP: dataObj.DECIMAL_SEP,
|
||||
GROUP_SEP: dataObj.GROUP_SEP,
|
||||
PATTERNS: [parsePattern(dataObj.DECIMAL_PATTERN),
|
||||
parsePattern(dataObj.CURRENCY_PATTERN)]
|
||||
}
|
||||
};
|
||||
|
||||
if (currencySymbols[dataObj.DEF_CURRENCY_CODE]) {
|
||||
numberFormats.CURRENCY_SYM = currencySymbols[dataObj.DEF_CURRENCY_CODE][1];
|
||||
} else {
|
||||
if (dataObj.DEF_CURRENCY_CODE == 'MTL') {
|
||||
if (dataObj.DEF_CURRENCY_CODE === 'MTL') {
|
||||
numberFormats.CURRENCY_SYM = '₤'; //for some reason this is missing in closure
|
||||
} else {
|
||||
// if there is no corresponding currency symbol, just use currency code.
|
||||
var code = numberFormats.CURRENCY_SYM = dataObj.DEF_CURRENCY_CODE;
|
||||
console.log(code +' has no currency symbol in closure, used ' + code + ' instead!');
|
||||
console.log(code + ' has no currency symbol in closure, used ' + code + ' instead!');
|
||||
}
|
||||
}
|
||||
return numberFormats;
|
||||
|
||||
+12
-10
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A simple parser to parse a number format into a pattern object
|
||||
*/
|
||||
@@ -27,20 +29,20 @@ function parsePattern(pattern) {
|
||||
lgSize: 0
|
||||
};
|
||||
|
||||
var parts = pattern.split(PATTERN_SEP),
|
||||
positive = parts[0],
|
||||
negative = parts[1];
|
||||
var patternParts = pattern.split(PATTERN_SEP),
|
||||
positive = patternParts[0],
|
||||
negative = patternParts[1];
|
||||
|
||||
var parts = positive.split(DECIMAL_SEP),
|
||||
integer = parts[0],
|
||||
fraction = parts[1];
|
||||
var positiveParts = positive.split(DECIMAL_SEP),
|
||||
integer = positiveParts[0],
|
||||
fraction = positiveParts[1];
|
||||
|
||||
p.posPre = integer.substr(0, integer.indexOf(DIGIT));
|
||||
|
||||
for (var i = 0; i < fraction.length; i++) {
|
||||
var ch = fraction.charAt(i);
|
||||
if (ch == ZERO) p.minFrac = p.maxFrac = i + 1;
|
||||
else if (ch == DIGIT) p.maxFrac = i + 1;
|
||||
if (ch === ZERO) p.minFrac = p.maxFrac = i + 1;
|
||||
else if (ch === DIGIT) p.maxFrac = i + 1;
|
||||
else p.posSuf += ch;
|
||||
}
|
||||
|
||||
@@ -52,8 +54,8 @@ function parsePattern(pattern) {
|
||||
var trunkLen = positive.length - p.posPre.length - p.posSuf.length,
|
||||
pos = negative.indexOf(DIGIT);
|
||||
|
||||
p.negPre = negative.substr(0, pos).replace(/\'/g, '');
|
||||
p.negSuf = negative.substr(pos + trunkLen).replace(/\'/g, '');
|
||||
p.negPre = negative.substr(0, pos).replace(/'/g, '');
|
||||
p.negSuf = negative.substr(pos + trunkLen).replace(/'/g, '');
|
||||
} else {
|
||||
// hardcoded '-' sign is fine as all locale use '-' as MINUS_SIGN. (\u2212 is the same as '-')
|
||||
p.negPre = '-' + p.posPre;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
exports.findLocaleId = function findLocaleId(str, type) {
|
||||
if (type === 'num') {
|
||||
return (str.match(/^NumberFormatSymbols_(.+)$/) || [])[1];
|
||||
} else if (type == 'datetime') {
|
||||
return (str.match(/^DateTimeSymbols_(.+)$/) || [])[1];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "../../.eslintrc-node.json"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"env": {
|
||||
"jasmine": true
|
||||
},
|
||||
"rules": {
|
||||
"no-multi-str": "off"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var extractValues = require('../src/extractValues.js').extractValues;
|
||||
var stream = require('stream');
|
||||
|
||||
function StringStream(str) {
|
||||
function stringStream(str) {
|
||||
return new stream.Readable({
|
||||
read: function(n) {
|
||||
this.push(str);
|
||||
@@ -12,41 +14,46 @@ function StringStream(str) {
|
||||
|
||||
describe('extractValues', function() {
|
||||
it('should extract the values from the xml', function(done) {
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char><char cp="0002" IDS="Y"></char><char cp="0003" IDS="N"></char></repertoire></ucd>';
|
||||
extractValues(StringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [ [ '0001', '0002' ] ] });
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char>' +
|
||||
'<char cp="0002" IDS="Y"></char><char cp="0003" IDS="N"></char></repertoire></ucd>';
|
||||
extractValues(stringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [['0001', '0002']] });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract the values from the xml if the last element matches', function(done) {
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char><char cp="0002" IDS="Y"></char><char cp="0003" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(StringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [ [ '0001', '0003' ] ] });
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char>' +
|
||||
'<char cp="0002" IDS="Y"></char><char cp="0003" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(stringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [['0001', '0003']] });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support `reserved`', function(done) {
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char><reserved first-cp="0002" last-cp="0005" IDS="N"></reserved><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(StringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [ [ '0001', '0001' ], [ '0006', '0006' ] ] });
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char>' +
|
||||
'<reserved first-cp="0002" last-cp="0005" IDS="N"></reserved><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(stringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [['0001', '0001'], ['0006', '0006']] });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support `surrogate`', function(done) {
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char><surrogate first-cp="0002" last-cp="0005" IDS="N"></surrogate><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(StringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [ [ '0001', '0001' ], [ '0006', '0006' ] ] });
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char>' +
|
||||
'<surrogate first-cp="0002" last-cp="0005" IDS="N"></surrogate><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(stringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [['0001', '0001'], ['0006', '0006']] });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support `noncharactere`', function(done) {
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char><noncharacter first-cp="0002" last-cp="0005" IDS="N"></noncharacter><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(StringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [ [ '0001', '0001' ], [ '0006', '0006' ] ] });
|
||||
var str = '<ucd><repertoire><char cp="0000" IDS="N"></char><char cp="0001" IDS="Y"></char>' +
|
||||
'<noncharacter first-cp="0002" last-cp="0005" IDS="N"></noncharacter><char cp="0006" IDS="Y"></char></repertoire></ucd>';
|
||||
extractValues(stringStream(str), {'IDS': 'Y'}, function(values) {
|
||||
expect(values).toEqual({ IDS_Y : [['0001', '0001'], ['0006', '0006']] });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var generateCodeModule = require('../src/generateCode.js');
|
||||
var generateCode = generateCodeModule.generateCode;
|
||||
@@ -5,7 +6,7 @@ var generateFunction = generateCodeModule.generateFunction;
|
||||
|
||||
describe('generateFunction', function() {
|
||||
it('should generate function with ranges', function() {
|
||||
expect(generateFunction([ [ '0001', '0003' ] ], 'IDS_Y')).toEqual('\
|
||||
expect(generateFunction([['0001', '0003']], 'IDS_Y')).toEqual('\
|
||||
function IDS_Y(cp) {\n\
|
||||
if (0x0001 <= cp && cp <= 0x0003) return true;\n\
|
||||
return false;\n\
|
||||
@@ -13,7 +14,7 @@ function IDS_Y(cp) {\n\
|
||||
});
|
||||
|
||||
it('should generate function with multiple ranges', function() {
|
||||
expect(generateFunction([ [ '0001', '0003' ], [ '0005', '0009'] ], 'IDS_Y')).toEqual('\
|
||||
expect(generateFunction([['0001', '0003'], ['0005', '0009']], 'IDS_Y')).toEqual('\
|
||||
function IDS_Y(cp) {\n\
|
||||
if (0x0001 <= cp && cp <= 0x0003) return true;\n\
|
||||
if (0x0005 <= cp && cp <= 0x0009) return true;\n\
|
||||
@@ -22,7 +23,7 @@ function IDS_Y(cp) {\n\
|
||||
});
|
||||
|
||||
it('should generate function with unique values', function() {
|
||||
expect(generateFunction([ [ '0001', '0001' ], [ '0005', '0009'] ], 'IDS_Y')).toEqual('\
|
||||
expect(generateFunction([['0001', '0001'], ['0005', '0009']], 'IDS_Y')).toEqual('\
|
||||
function IDS_Y(cp) {\n\
|
||||
if (cp === 0x0001) return true;\n\
|
||||
if (0x0005 <= cp && cp <= 0x0009) return true;\n\
|
||||
@@ -33,7 +34,7 @@ function IDS_Y(cp) {\n\
|
||||
|
||||
describe('generateCode', function() {
|
||||
it('should generate the function for all the values', function() {
|
||||
expect(generateCode({ IDS_Y : [ [ '0001', '0001' ], [ '0006', '0006' ] ], IDC_Y : [ [ '0002', '0002' ], [ '0007', '0007' ] ] })).toEqual('\
|
||||
expect(generateCode({ IDS_Y : [['0001', '0001'], ['0006', '0006']], IDC_Y : [['0002', '0002'], ['0007', '0007']] })).toEqual('\
|
||||
/******************************************************\n\
|
||||
* Generated file, do not modify *\n\
|
||||
* *\n\
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var zlib = require('zlib');
|
||||
var extractValues = require('./extractValues').extractValues;
|
||||
var generateCode = require('./generateCode').generateCode;
|
||||
var generateextractValues = require('./extractValues').extractValues;
|
||||
// ID_Start and ID_Continue
|
||||
var propertiesToExtract = {'IDS': 'Y', 'IDC': 'Y'};
|
||||
|
||||
@@ -17,7 +16,7 @@ function main() {
|
||||
function writeFile(validRanges) {
|
||||
var code = generateCode(validRanges);
|
||||
try {
|
||||
var stats = fs.lstatSync('../src/ngParseExt');
|
||||
fs.lstatSync('../src/ngParseExt');
|
||||
} catch (e) {
|
||||
fs.mkdirSync('../src/ngParseExt');
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user